summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorOrcan Ogetbil <oget.fedora@gmail.com>2010-11-27 22:16:34 +0000
committerOrcan Ogetbil <oget.fedora@gmail.com>2010-11-27 22:16:34 +0000
commit6a06e5877875d05dcc6ece1a33cf1f7d7762f197 (patch)
tree5a22f4d7a6c5625942f1eb4c157e7d106d08bda2 /muse2
parent59e3c2271cb4e23cbb1021b2a0136e6bd90ea4f1 (diff)
ported popu menus of the canvas
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog1
-rw-r--r--muse2/muse/arranger/pcanvas.cpp101
-rw-r--r--muse2/muse/arranger/pcanvas.h5
-rw-r--r--muse2/muse/widgets/canvas.cpp19
-rw-r--r--muse2/muse/widgets/canvas.h11
5 files changed, 89 insertions, 48 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 5b8e0a9b..46688805 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -4,6 +4,7 @@
routedialogbase. (Orcan)
- Fixed the whatsthis and tooltip bits of tho Midi Ports dialog. (Orcan)
- Ported Quant Config dialog. (Orcan)
+ - Ported the popup menus in the canvas. This should restore the color selection of tracks. (Orcan)
26.11.2010
- Fixed midi trackinfo growing size - set output device list box and instrument button
h-size policy to 'Ignore'. (Tim)
diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp
index 0569f03d..6fbc32af 100644
--- a/muse2/muse/arranger/pcanvas.cpp
+++ b/muse2/muse/arranger/pcanvas.cpp
@@ -67,7 +67,7 @@ const char* partColorNames[] = {
"Piano",
"Saxophon",
};
-
+/*
//---------------------------------------------------------
// ColorListItem
//---------------------------------------------------------
@@ -78,7 +78,7 @@ class ColorListItem { //: public QCustomMenuItem { ddskrjo
int fontheight;
QString label;
virtual QSize sizeHint() { return QSize(80, h); }
- virtual void paint(QPainter* p, const QColorGroup&, bool /*act*/, bool /*enabled*/, int x, int y, int /*w*/, int h)
+ virtual void paint(QPainter* p, const QColorGroup&, bool act, bool enabled, int x, int y, int w, int h)
{
p->fillRect(x+5, y+2, h-4, h-4, QBrush(color));
p->drawText(x+5 + h - 4 + 3, y+(fontheight * 3) / 4, label);
@@ -90,6 +90,26 @@ class ColorListItem { //: public QCustomMenuItem { ddskrjo
}
QString text() const { return QString("PartColor"); }
};
+*/
+// ORCAN : colorRect does the same job as the above class.
+// Shall we get rid of the class?
+
+//---------------------------------------------------------
+// colorRect
+// paints a rectangular icon with a given color
+//---------------------------------------------------------
+
+QIcon colorRect(const QColor& color, int width, int height) {
+ QPainter painter;
+ QPixmap image(width, height);
+ painter.begin(&image);
+ painter.setBrush(color);
+ QRect rectangle(0, 0, width, height);
+ painter.drawRect(rectangle);
+ painter.end();
+ QIcon icon(image);
+ return icon;
+}
//---------------------------------------------------------
// NPart
@@ -702,18 +722,20 @@ void PartCanvas::glueItem(CItem* item)
// genItemPopup
//---------------------------------------------------------
-Q3PopupMenu* PartCanvas::genItemPopup(CItem* item)
+QMenu* PartCanvas::genItemPopup(CItem* item)
{
NPart* npart = (NPart*) item;
Track::TrackType trackType = npart->track()->type();
- Q3PopupMenu* partPopup = new Q3PopupMenu(this);
+ QMenu* partPopup = new QMenu(this);
- partPopup->insertItem(*editcutIconSet, tr("C&ut"), 4);
- partPopup->setAccel(Qt::CTRL+Qt::Key_X, 4);
+ QAction *act_cut = partPopup->addAction(*editcutIconSet, tr("C&ut"));
+ act_cut->setData(4);
+ act_cut->setShortcut(Qt::CTRL+Qt::Key_X);
- partPopup->insertItem(*editcopyIconSet, tr("&Copy"), 5);
- partPopup->setAccel(Qt::CTRL+Qt::Key_C, 5);
+ QAction *act_copy = partPopup->addAction(*editcopyIconSet, tr("&Copy"));
+ act_copy->setData(5);
+ act_copy->setShortcut(Qt::CTRL+Qt::Key_C);
partPopup->insertSeparator();
int rc = npart->part()->events()->arefCount();
@@ -721,43 +743,62 @@ Q3PopupMenu* PartCanvas::genItemPopup(CItem* item)
if(rc > 1)
st += (QString().setNum(rc) + QString(" "));
st += QString(tr("clones"));
- partPopup->insertItem(st, 18);
+ QAction *act_select = partPopup->addAction(st);
+ act_select->setData(18);
partPopup->insertSeparator();
- partPopup->insertItem(tr("rename"), 0);
- Q3PopupMenu* colorPopup = new Q3PopupMenu(this);
- partPopup->insertItem(tr("color"), colorPopup);
+ QAction *act_rename = partPopup->addAction(tr("rename"));
+ act_rename->setData(0);
+ QMenu* colorPopup = new QMenu(tr("color"));
+ partPopup->addMenu(colorPopup);
// part color selection
const QFontMetrics& fm = colorPopup->fontMetrics();
int h = fm.lineSpacing();
for (int i = 0; i < NUM_PARTCOLORS; ++i) {
- ColorListItem* item = new ColorListItem(config.partColors[i], h, fontMetrics().height(), partColorNames[i]);
- //colorPopup->insertItem(item, 20+i); ddskrjo
+ //ColorListItem* item = new ColorListItem(config.partColors[i], h, fontMetrics().height(), partColorNames[i]); //ddskrjo
+ QAction *act_color = colorPopup->addAction(colorRect(config.partColors[i], 80, 80), partColorNames[i]);
+ act_color->setData(20+i);
}
- partPopup->insertItem(QIcon(*deleteIcon), tr("delete"), 1); // ddskrjo added QIcon to all
- partPopup->insertItem(QIcon(*cutIcon), tr("split"), 2);
- partPopup->insertItem(QIcon(*glueIcon), tr("glue"), 3);
- partPopup->insertItem(tr("de-clone"), 15);
+ QAction *act_delete = partPopup->addAction(QIcon(*deleteIcon), tr("delete")); // ddskrjo added QIcon to all
+ act_delete->setData(1);
+ QAction *act_split = partPopup->addAction(QIcon(*cutIcon), tr("split"));
+ act_split->setData(2);
+ QAction *act_glue = partPopup->addAction(QIcon(*glueIcon), tr("glue"));
+ act_glue->setData(3);
+ QAction *act_declone = partPopup->addAction(tr("de-clone"));
+ act_declone->setData(15);
partPopup->insertSeparator();
switch(trackType) {
- case Track::MIDI:
- partPopup->insertItem(QIcon(*pianoIconSet), tr("pianoroll"), 10);
- partPopup->insertItem(QIcon(*edit_listIcon), tr("list"), 12);
- partPopup->insertItem(tr("export"), 16);
+ case Track::MIDI: {
+ QAction *act_pianoroll = partPopup->addAction(QIcon(*pianoIconSet), tr("pianoroll"));
+ act_pianoroll->setData(10);
+ QAction *act_mlist = partPopup->addAction(QIcon(*edit_listIcon), tr("list"));
+ act_mlist->setData(12);
+ QAction *act_mexport = partPopup->addAction(tr("export"));
+ act_mexport->setData(16);
+ }
break;
- case Track::DRUM:
- partPopup->insertItem(QIcon(*edit_listIcon), tr("list"), 12);
- partPopup->insertItem(QIcon(*edit_drummsIcon), tr("drums"), 13);
- partPopup->insertItem(tr("export"), 16);
+ case Track::DRUM: {
+ QAction *act_dlist = partPopup->addAction(QIcon(*edit_listIcon), tr("list"));
+ act_dlist->setData(12);
+ QAction *act_drums = partPopup->addAction(QIcon(*edit_drummsIcon), tr("drums"));
+ act_drums->setData(13);
+ QAction *act_dexport = partPopup->addAction(tr("export"));
+ act_dexport->setData(16);
+ }
break;
- case Track::WAVE:
- partPopup->insertItem(QIcon(*edit_waveIcon), tr("wave edit"), 14);
- partPopup->insertItem(tr("export"), 16);
- partPopup->insertItem(tr("file info"), 17);
+ case Track::WAVE: {
+ QAction *act_wedit = partPopup->addAction(QIcon(*edit_waveIcon), tr("wave edit"));
+ act_wedit->setData(14);
+ QAction *act_wexport = partPopup->addAction(tr("export"));
+ act_wexport->setData(16);
+ QAction *act_wfinfo = partPopup->addAction(tr("file info"));
+ act_wfinfo->setData(17);
+ }
break;
case Track::AUDIO_OUTPUT:
case Track::AUDIO_INPUT:
diff --git a/muse2/muse/arranger/pcanvas.h b/muse2/muse/arranger/pcanvas.h
index b8f133fe..8ce464a5 100644
--- a/muse2/muse/arranger/pcanvas.h
+++ b/muse2/muse/arranger/pcanvas.h
@@ -16,7 +16,6 @@
#include <QDropEvent>
#include <QDragLeaveEvent>
#include <QMouseEvent>
-#include <Q3PopupMenu>
#include <QKeyEvent>
#include <QEvent>
#include <QDragEnterEvent>
@@ -39,7 +38,7 @@ class NPart : public CItem {
class QLineEdit;
class MidiEditor;
-class Q3PopupMenu;
+class QMenu;
class Xml;
//---------------------------------------------------------
@@ -88,7 +87,7 @@ class PartCanvas : public Canvas {
virtual void dragLeaveEvent(QDragLeaveEvent*);
virtual void viewDropEvent(QDropEvent*);
- virtual Q3PopupMenu* genItemPopup(CItem*);
+ virtual QMenu* genItemPopup(CItem*);
virtual void itemPopup(CItem*, int, const QPoint&);
void glueItem(CItem* item);
diff --git a/muse2/muse/widgets/canvas.cpp b/muse2/muse/widgets/canvas.cpp
index ef5ee0de..58187304 100644
--- a/muse2/muse/widgets/canvas.cpp
+++ b/muse2/muse/widgets/canvas.cpp
@@ -539,9 +539,9 @@ void Canvas::viewMousePressEvent(QMouseEvent* event)
else {
itemPopupMenu = genItemPopup(curItem);
if (itemPopupMenu) {
- int n = itemPopupMenu->exec(QCursor::pos());
- if (n != -1)
- itemPopup(curItem, n, start);
+ QAction *act = itemPopupMenu->exec(QCursor::pos());
+ if (act)
+ itemPopup(curItem, act->data().toInt(), start);
delete itemPopupMenu;
}
}
@@ -549,9 +549,9 @@ void Canvas::viewMousePressEvent(QMouseEvent* event)
else {
canvasPopupMenu = genCanvasPopup();
if (canvasPopupMenu) {
- int n = canvasPopupMenu->exec(QCursor::pos(), 0);
- if (n != -1)
- canvasPopup(n);
+ QAction *act = canvasPopupMenu->exec(QCursor::pos(), 0);
+ if (act)
+ canvasPopup(act->data().toInt());
delete canvasPopupMenu;
}
}
@@ -1370,16 +1370,17 @@ int Canvas::selectionSize()
// genCanvasPopup
//---------------------------------------------------------
-Q3PopupMenu* Canvas::genCanvasPopup()
+QMenu* Canvas::genCanvasPopup()
{
if (canvasTools == 0)
return 0;
- Q3PopupMenu* canvasPopup = new Q3PopupMenu(this);
+ QMenu* canvasPopup = new QMenu(this);
for (unsigned i = 0; i < 9; ++i) {
if ((canvasTools & (1 << i))==0)
continue;
- canvasPopup->insertItem(QIcon(**toolList[i].icon), tr(toolList[i].tip), 1<<i); // ddskrjo
+ QAction* act = canvasPopup->addAction(QIcon(**toolList[i].icon), tr(toolList[i].tip));
+ act->setData(1<<i); // ddskrjo
}
canvasPopup->setActiveItem(0);
return canvasPopup;
diff --git a/muse2/muse/widgets/canvas.h b/muse2/muse/widgets/canvas.h
index f25d1b2f..d4476df8 100644
--- a/muse2/muse/widgets/canvas.h
+++ b/muse2/muse/widgets/canvas.h
@@ -14,10 +14,9 @@
//Added by qt3to4:
#include <QWheelEvent>
#include <QMouseEvent>
-#include <Q3PopupMenu>
#include <QKeyEvent>
-class Q3PopupMenu;
+class QMenu;
//---------------------------------------------------------
// Canvas
@@ -75,8 +74,8 @@ class Canvas : public View {
HScrollDir hscrollDir;
VScrollDir vscrollDir;
int keyState;
- Q3PopupMenu* itemPopupMenu;
- Q3PopupMenu* canvasPopupMenu;
+ QMenu* itemPopupMenu;
+ QMenu* canvasPopupMenu;
void setCursor();
virtual void viewKeyPressEvent(QKeyEvent* event);
@@ -118,7 +117,7 @@ class Canvas : public View {
\param item The canvas item that is rightclicked
\return A QPopupMenu*
*/
- virtual Q3PopupMenu* genItemPopup(CItem* /*item*/) { return 0; }
+ virtual QMenu* genItemPopup(CItem* /*item*/) { return 0; }
/*!
\brief Pure virtual member
@@ -126,7 +125,7 @@ class Canvas : public View {
Implementing class is responsible for creating a popup to be shown when the user rightclicks an empty region of the canvas
\return A QPopupMenu*
*/
- Q3PopupMenu* genCanvasPopup();
+ QMenu* genCanvasPopup();
/*!
\brief Virtual member