|
From: Tapio V. <aa...@us...> - 2011-02-07 10:48:09
|
Module: editor
Branch: master
Commit: bfa091e416d8c0ac3133bd0638ea7e4162fb0efb
Author: Tapio Vierros <tap...@gm...>
Date: Mon Feb 7 12:36:59 2011 +0200
Dummy context menu for NoteGraphWidget.
---
notegraphwidget.cc | 31 +++++++++++++++++++++++++++++++
notegraphwidget.hh | 1 +
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 4c4eec4..2aa12a9 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -3,6 +3,7 @@
#include <QScrollArea>
#include <QScrollBar>
#include <QPainter>
+#include <QMenu>
#include <iostream>
#include <algorithm>
#include <cmath>
@@ -35,6 +36,10 @@ NoteGraphWidget::NoteGraphWidget(QWidget *parent)
setFocusPolicy(Qt::StrongFocus);
setWhatsThis(tr("Note graph that displays the song notes and allows you to manipulate them."));
+ // Context menu
+ setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&)));
+
updateNotes();
}
@@ -406,6 +411,32 @@ void NoteGraphWidget::keyPressEvent(QKeyEvent *event)
}
+void NoteGraphWidget::showContextMenu(const QPoint &pos)
+{
+ QAction actionNew(NULL);
+ QAction actionSelectAll(NULL);
+ QAction actionDeselect(NULL);
+ QMenu menuContext(NULL);
+
+ menuContext.addAction(&actionNew);
+ menuContext.addSeparator();
+ menuContext.addAction(&actionSelectAll);
+ menuContext.addAction(&actionDeselect);
+
+ actionNew.setText(tr("New note"));
+ actionSelectAll.setText(tr("Select all"));
+ actionDeselect.setText(tr("Deselect"));
+
+ QPoint globalPos = mapToGlobal(pos);
+ QAction *sel = menuContext.exec(globalPos);
+ if (sel) {
+ if (sel == &actionNew) ;
+ else if (sel == &actionSelectAll) ;
+ else if (sel == &actionDeselect) ;
+ }
+}
+
+
VocalTrack NoteGraphWidget::getVocalTrack() const
{
VocalTrack track(TrackName::LEAD_VOCAL);
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index e53d1a3..72b8d29 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -98,6 +98,7 @@ public:
QString dumpLyrics() const;
public slots:
+ void showContextMenu(const QPoint &pos);
void timeSyllable();
void timeSentence();
void setSeekHandleWrapToViewport(bool state) { m_seekHandle.wrapToViewport = state; }
|