|
From: Tapio V. <aa...@us...> - 2011-01-12 13:35:09
|
Module: editor
Branch: master
Commit: b0bd2cd414e489a6b06d6264703b28bdbf10b8db
Author: Tapio Vierros <tap...@gm...>
Date: Wed Jan 12 14:30:06 2011 +0200
NoteGraphWidget is now spawned outside of ui generator.
This allows greater control over the widget in constructor
and also makes it easy to delete&reconstruct.
---
editor.ui | 31 +++----------------------------
editorapp.cc | 25 +++++++++++++++----------
editorapp.hh | 2 ++
notegraphwidget.cc | 3 ++-
4 files changed, 22 insertions(+), 39 deletions(-)
diff --git a/editor.ui b/editor.ui
index 9fe5094..52f041d 100644
--- a/editor.ui
+++ b/editor.ui
@@ -20,7 +20,7 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <widget class="QScrollArea" name="scrollArea">
+ <widget class="QScrollArea" name="noteGraphScroller">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -30,7 +30,7 @@
<property name="widgetResizable">
<bool>true</bool>
</property>
- <widget class="QWidget" name="scrollAreaWidgetContents">
+ <widget class="QWidget" name="noteGraphScrollerContents">
<property name="geometry">
<rect>
<x>0</x>
@@ -39,24 +39,7 @@
<height>227</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="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>
+ <layout class="QGridLayout" name="gridLayout_2"/>
</widget>
</widget>
<widget class="QFrame" name="frame">
@@ -460,14 +443,6 @@
</property>
</action>
</widget>
- <customwidgets>
- <customwidget>
- <class>NoteGraphWidget</class>
- <extends>QWidget</extends>
- <header>notegraphwidget.hh</header>
- <container>1</container>
- </customwidget>
- </customwidgets>
<resources/>
<connections/>
</ui>
diff --git a/editorapp.cc b/editorapp.cc
index bd4c393..bcdc9d1 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -1,18 +1,23 @@
-#include <QtGui>
+#include <QtGui>
#include <cstdlib>
#include "editorapp.hh"
#include "notelabel.hh"
+#include "notegraphwidget.hh"
EditorApp::EditorApp(QWidget *parent): QMainWindow(parent)
{
ui.setupUi(this);
+
+ noteGraph = new NoteGraphWidget(NULL);
+ ui.noteGraphScroller->setWidget(noteGraph);
+
// Splitter sizes cannot be set through designer :(
QList<int> ss; ss.push_back(700); ss.push_back(300); // Proportions, not pixels
ui.splitter->setSizes(ss);
// Custom signals/slots
- connect(ui.noteGraph, SIGNAL(updateNoteInfo(NoteLabel*)), this, SLOT(updateNoteInfo(NoteLabel*)));
+ connect(noteGraph, SIGNAL(updateNoteInfo(NoteLabel*)), this, SLOT(updateNoteInfo(NoteLabel*)));
updateNoteInfo(NULL);
// Some icons to menus to make them prettier
@@ -63,11 +68,11 @@ void EditorApp::on_actionNew_triggered()
case QMessageBox::Yes:
// TODO: Save
case QMessageBox::No:
- ui.noteGraph->clear(); break;
+ noteGraph->clear(); break;
default: break;
}
} else {
- ui.noteGraph->clear();
+ noteGraph->clear();
}
}
@@ -139,7 +144,7 @@ void EditorApp::on_actionLyricsFromFile_triggered()
}
if (text != "")
- ui.noteGraph->setLyrics(text);
+ noteGraph->setLyrics(text);
}
}
@@ -154,7 +159,7 @@ void EditorApp::on_actionLyricsFromClipboard_triggered()
tr("Pasting lyrics from clipboard will replace the existing ones. Continue?"),
QMessageBox::Ok | QMessageBox::Cancel);
if (b == QMessageBox::Ok) {
- ui.noteGraph->setLyrics(text);
+ noteGraph->setLyrics(text);
}
} else {
QMessageBox::warning(this, tr("No text to paste"), tr("No suitable data on the clipboard."));
@@ -176,12 +181,12 @@ void EditorApp::on_actionAbout_triggered()
void EditorApp::on_cmbNoteType_currentIndexChanged(int index)
{
- if (ui.noteGraph->selectedNote())
- ui.noteGraph->selectedNote()->setType(index);
+ if (noteGraph->selectedNote())
+ noteGraph->selectedNote()->setType(index);
}
void EditorApp::on_chkFloating_stateChanged(int state)
{
- if (ui.noteGraph->selectedNote())
- ui.noteGraph->selectedNote()->setFloating(state != 0);
+ if (noteGraph->selectedNote())
+ noteGraph->selectedNote()->setFloating(state != 0);
}
diff --git a/editorapp.hh b/editorapp.hh
index 6e357f8..eaa9fa2 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -3,6 +3,7 @@
#include "ui_editor.h"
class NoteLabel;
+class NoteGraphWidget;
class EditorApp: public QMainWindow
{
@@ -36,4 +37,5 @@ public slots:
private:
Ui::EditorApp ui;
+ NoteGraphWidget* noteGraph;
};
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index ff06eb7..8ddd97e 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -21,7 +21,8 @@ NoteGraphWidget::NoteGraphWidget(QWidget *parent)
}
setPixmap(QPixmap::fromImage(image));
- setFixedWidth(std::max(width, (unsigned)1024)); // FIXME: Width should come from song length * pixPerSec
+ // FIXME: Width should come from song length * pixPerSec
+ setFixedSize(std::max(width, (unsigned)1024), height);
setFocusPolicy(Qt::StrongFocus);
setWhatsThis(tr("Note graph that displays the song notes and allows you to manipulate them."));
|