|
From: Tapio V. <aa...@us...> - 2011-01-10 21:05:20
|
Module: editor
Branch: master
Commit: 4052167e63f6ceaa7b387300e3c9bd9ce1f7899d
Author: Tapio Vierros <tap...@gm...>
Date: Mon Jan 10 22:31:27 2011 +0200
Note floating status can be changed with checkbox.
---
editorapp.cc | 5 +++++
editorapp.hh | 4 ++++
notegraphwidget.cc | 15 +++++++++------
notegraphwidget.hh | 1 +
notelabel.hh | 2 +-
5 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index caa1a3e..24e6ffb 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -154,3 +154,8 @@ void EditorApp::on_actionAbout_triggered()
);
}
+void EditorApp::on_chkFloating_stateChanged(int state)
+{
+ if (ui.noteGraph->selectedNote())
+ ui.noteGraph->selectedNote()->setFloating(state != 0);
+}
diff --git a/editorapp.hh b/editorapp.hh
index a43fd9f..7992b31 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -14,6 +14,8 @@ public:
public slots:
void updateNoteInfo(NoteLabel* note);
+ // Automatic slots
+
// File menu
void on_actionNew_triggered();
void on_actionExit_triggered();
@@ -27,6 +29,8 @@ public slots:
void on_actionWhatsThis_triggered();
void on_actionAbout_triggered();
+ // Note properties tab
+ void on_chkFloating_stateChanged(int);
private:
Ui::EditorApp ui;
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 53178c1..d817b87 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -31,11 +31,14 @@ void NoteGraphWidget::selectNote(NoteLabel* note)
{
if (m_selectedNote) // Reset old pixmap
m_selectedNote->setSelected(false);
+
// Assign new selection
m_selectedNote = note;
- if (m_selectedNote)
+ if (m_selectedNote) {
m_selectedNote->setSelected();
- else m_selectedAction = NONE;
+ m_selectedNote->setFloating(false);
+ } else m_selectedAction = NONE;
+
// Signal UI about the change
emit updateNoteInfo(m_selectedNote);
}
@@ -72,8 +75,8 @@ void NoteGraphWidget::setLyrics(QString lyrics)
}
// Set first and last to non-floating
- if (first) first->disableFloating();
- if (last) last->disableFloating();
+ if (first) first->setFloating(false);
+ if (last) last->setFloating(false);
rebuildNoteList();
m_requiredWidth = x + gap;
@@ -178,13 +181,13 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
// Start a resize
m_selectedAction = RESIZE;
child->startResizing( (hotSpot.x() < NoteLabel::resize_margin) ? -1 : 1 );
- child->disableFloating();
+ child->setFloating(false);
} else {
// Start a drag
m_selectedAction = MOVE;
child->startDragging(hotSpot);
- child->disableFloating();
+ child->setFloating(false);
}
child->createPixmap(child->size());
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index 4da3ac7..042b531 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -24,6 +24,7 @@ public:
void rebuildNoteList();
void selectNote(NoteLabel* note);
+ NoteLabel* selectedNote() const { return m_selectedNote; }
signals:
void updateNoteInfo(NoteLabel*);
diff --git a/notelabel.hh b/notelabel.hh
index 98ae85a..43e5e48 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -18,7 +18,7 @@ public:
void setSelected(bool state = true) { m_selected = state; createPixmap(size()); }
bool isFloating() const { return m_floating; }
- void disableFloating() { m_floating = false; createPixmap(size()); }
+ void setFloating(bool state) { m_floating = state; createPixmap(size()); }
void startResizing(int dir);
void startDragging(const QPoint& point);
|