|
From: Tapio V. <aa...@us...> - 2011-01-06 18:04:08
|
Module: editor
Branch: master
Commit: 8251bb986bd3ace10bb3ae75ad5a4ee680e401bd
Author: Tapio Vierros <tap...@gm...>
Date: Thu Jan 6 19:13:37 2011 +0200
Notegraph can now be scrolled horizontally (+some tweaks).
---
editor.ui | 35 +++++++++++++++++++++++++++++++----
editorapp.cc | 2 ++
editorapp.hh | 2 +-
notegraphwidget.cc | 6 ++++++
notegraphwidget.hh | 5 +++++
5 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/editor.ui b/editor.ui
index ca93edc..22cc419 100644
--- a/editor.ui
+++ b/editor.ui
@@ -19,14 +19,20 @@
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QVBoxLayout" name="mainLayout" stretch="7,3">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAsNeeded</enum>
+ <enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
@@ -37,18 +43,24 @@
<x>0</x>
<y>0</y>
<width>778</width>
- <height>261</height>
+ <height>353</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="NoteGraphWidget" name="noteGraph" native="true">
<property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
</widget>
</item>
</layout>
@@ -125,16 +137,25 @@
<property name="text">
<string>&New</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+N</string>
+ </property>
</action>
<action name="actionOpen">
<property name="text">
<string>&Open</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+O</string>
+ </property>
</action>
<action name="actionSave">
<property name="text">
<string>&Save</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+S</string>
+ </property>
</action>
<action name="actionSaveAs">
<property name="text">
@@ -145,11 +166,17 @@
<property name="text">
<string>E&xit</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+Q</string>
+ </property>
</action>
<action name="actionUndo">
<property name="text">
<string>&Undo</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+Z</string>
+ </property>
</action>
<action name="actionRedo">
<property name="text">
diff --git a/editorapp.cc b/editorapp.cc
index 0e1972f..b72876a 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -6,6 +6,8 @@
EditorApp::EditorApp(QWidget *parent): QMainWindow(parent)
{
ui.setupUi(this);
+ // Now adjust the NoteGraph's width according to the content
+ ui.noteGraph->updateWidth();
}
void EditorApp::on_actionAbout_triggered()
diff --git a/editorapp.hh b/editorapp.hh
index 2258e27..81bf334 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -14,5 +14,5 @@ public slots:
void on_actionExit_triggered();
private:
- Ui_EditorApp ui;
+ Ui::EditorApp ui;
};
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 4c78bd8..b1e8a91 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -26,9 +26,15 @@ NoteGraphWidget::NoteGraphWidget(QWidget *parent)
}
}
+ requiredWidth = x + 3;
setAcceptDrops(true);
}
+void NoteGraphWidget::updateWidth()
+{
+ setFixedWidth(requiredWidth);
+}
+
void NoteGraphWidget::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasFormat("application/x-notelabel")) {
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index f8a6556..1f52420 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -7,6 +7,8 @@ class NoteGraphWidget: public QWidget
public:
NoteGraphWidget(QWidget *parent = 0);
+ void updateWidth();
+
protected:
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
@@ -14,4 +16,7 @@ protected:
void mousePressEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void mouseDoubleClickEvent(QMouseEvent * event);
+
+private:
+ int requiredWidth;
};
|