summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muse2/ChangeLog4
-rw-r--r--muse2/muse/mixer/astrip.cpp40
-rw-r--r--muse2/muse/mixer/mstrip.cpp23
-rw-r--r--muse2/muse/mixer/strip.cpp2
-rw-r--r--muse2/muse/mixer/strip.h2
-rw-r--r--muse2/muse/widgets/combobox.cpp64
-rw-r--r--muse2/muse/widgets/combobox.h24
7 files changed, 78 insertions, 81 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 32d65061..d5dd93ce 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,7 @@
+17.08.2011:
+ - Convert some Qt3 style coding in ComboBox to Qt4 in terms of menu entry handling. (Orcan)
+ - Add mouse wheel support to ComboBox. (Orcan)
+ - Fix AutoType indicator coloring. (Orcan)
16.08.2011:
- More drawing fixes, improved accuracy (grids, timescales, edges, markers guaranteed to align now). (Tim p4.0.30)
Much drawing changed to device (pixel) space instead of virtual space, for accuracy.
diff --git a/muse2/muse/mixer/astrip.cpp b/muse2/muse/mixer/astrip.cpp
index 5644e6eb..658a4970 100644
--- a/muse2/muse/mixer/astrip.cpp
+++ b/muse2/muse/mixer/astrip.cpp
@@ -211,16 +211,14 @@ void AudioStrip::songChanged(int val)
autoType->setCurrentItem(track->automationType());
if(track->automationType() == AUTO_TOUCH || track->automationType() == AUTO_WRITE)
{
- //autoType->setPaletteBackgroundColor(Qt::red);
QPalette palette;
- palette.setColor(autoType->backgroundRole(), QColor(Qt::red));
+ palette.setColor(QPalette::Button, QColor(Qt::red));
autoType->setPalette(palette);
}
else
{
- //autoType->setPaletteBackgroundColor(qApp->palette().active().background());
QPalette palette;
- palette.setColor(autoType->backgroundRole(), qApp->palette().color(QPalette::Active, QPalette::Background));
+ palette.setColor(QPalette::Button, qApp->palette().color(QPalette::Active, QPalette::Background));
autoType->setPalette(palette);
}
@@ -927,41 +925,31 @@ AudioStrip::AudioStrip(QWidget* parent, AudioTrack* at)
// automation type
//---------------------------------------------------
- autoType = new ComboBox(this);
+ autoType = new ComboBox();
autoType->setFont(config.fonts[1]);
autoType->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
- autoType->setAlignment(Qt::AlignCenter);
- autoType->insertItem(tr("Off"), AUTO_OFF);
- autoType->insertItem(tr("Read"), AUTO_READ);
- autoType->insertItem(tr("Touch"), AUTO_TOUCH);
- autoType->insertItem(tr("Write"), AUTO_WRITE);
+ autoType->addAction(tr("Off"), AUTO_OFF);
+ autoType->addAction(tr("Read"), AUTO_READ);
+ autoType->addAction(tr("Touch"), AUTO_TOUCH);
+ autoType->addAction(tr("Write"), AUTO_WRITE);
autoType->setCurrentItem(t->automationType());
- // FIXME: TODO: Convert ComboBox to QT4
- //autoType->insertItem(AUTO_OFF, tr("Off"));
- //autoType->insertItem(AUTO_READ, tr("Read"));
- //autoType->insertItem(AUTO_TOUCH, tr("Touch"));
- //autoType->insertItem(AUTO_WRITE, tr("Write"));
- //autoType->setCurrentIndex(t->automationType());
-
+
if(t->automationType() == AUTO_TOUCH || t->automationType() == AUTO_WRITE)
{
- // FIXME:
- //autoType->setPaletteBackgroundColor(Qt::red);
- QPalette palette;
- palette.setColor(autoType->backgroundRole(), QColor(Qt::red));
- autoType->setPalette(palette);
+ QPalette palette;
+ palette.setColor(QPalette::Button, QColor(Qt::red));
+ autoType->setPalette(palette);
}
else
{
- // FIXME:
- //autoType->setPaletteBackgroundColor(qApp->palette().active().background());
QPalette palette;
- palette.setColor(autoType->backgroundRole(), qApp->palette().color(QPalette::Active, QPalette::Background));
+ palette.setColor(QPalette::Button, qApp->palette().color(QPalette::Active, QPalette::Background));
autoType->setPalette(palette);
}
+
autoType->setToolTip(tr("automation type"));
- connect(autoType, SIGNAL(activated(int,int)), SLOT(setAutomationType(int,int)));
+ connect(autoType, SIGNAL(activated(int)), SLOT(setAutomationType(int)));
grid->addWidget(autoType, _curGridRow++, 0, 1, 2);
if (off) {
diff --git a/muse2/muse/mixer/mstrip.cpp b/muse2/muse/mixer/mstrip.cpp
index d773708a..ad21916d 100644
--- a/muse2/muse/mixer/mstrip.cpp
+++ b/muse2/muse/mixer/mstrip.cpp
@@ -405,28 +405,21 @@ MidiStrip::MidiStrip(QWidget* parent, MidiTrack* t)
// automation mode
//---------------------------------------------------
- autoType = new ComboBox(this);
+ autoType = new ComboBox();
autoType->setFont(config.fonts[1]);
autoType->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
- autoType->setAlignment(Qt::AlignCenter);
autoType->setEnabled(false);
// Removed by T356.
// Disabled for now. There is no midi automation mechanism yet...
- //autoType->insertItem(tr("Off"), AUTO_OFF);
- //autoType->insertItem(tr("Read"), AUTO_READ);
- //autoType->insertItem(tr("Touch"), AUTO_TOUCH);
- //autoType->insertItem(tr("Write"), AUTO_WRITE);
+ //autoType->addAction(tr("Off"), AUTO_OFF);
+ //autoType->addAction(tr("Read"), AUTO_READ);
+ //autoType->addAction(tr("Touch"), AUTO_TOUCH);
+ //autoType->addAction(tr("Write"), AUTO_WRITE);
//autoType->setCurrentItem(t->automationType());
- // TODO: Convert ComboBox to QT4
- //autoType->insertItem(AUTO_OFF, tr("Off"));
- //autoType->insertItem(AUTO_READ, tr("Read"));
- //autoType->insertItem(AUTO_TOUCH, tr("Touch"));
- //autoType->insertItem(AUTO_WRITE, tr("Write"));
- //autoType->setCurrentIndex(t->automationType());
- //autoType->setToolTip(tr("automation type"));
-
- //connect(autoType, SIGNAL(activated(int,int)), SLOT(setAutomationType(int,int)));
+ //autoType->setToolTip(tr("automation type"));
+ //connect(autoType, SIGNAL(activated(int)), SLOT(setAutomationType(int)));
+
grid->addWidget(autoType, _curGridRow++, 0, 1, 2);
connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat()));
inHeartBeat = false;
diff --git a/muse2/muse/mixer/strip.cpp b/muse2/muse/mixer/strip.cpp
index 0c4059d8..3cf9765d 100644
--- a/muse2/muse/mixer/strip.cpp
+++ b/muse2/muse/mixer/strip.cpp
@@ -257,7 +257,7 @@ Strip::~Strip()
// setAutomationType
//---------------------------------------------------------
-void Strip::setAutomationType(int t,int)
+void Strip::setAutomationType(int t)
{
track->setAutomationType(AutomationType(t));
song->update(SC_AUTOMATION);
diff --git a/muse2/muse/mixer/strip.h b/muse2/muse/mixer/strip.h
index b138992e..cf3babe8 100644
--- a/muse2/muse/mixer/strip.h
+++ b/muse2/muse/mixer/strip.h
@@ -60,7 +60,7 @@ class Strip : public QFrame {
protected slots:
virtual void heartBeat();
- void setAutomationType(int t,int);
+ void setAutomationType(int t);
public slots:
void resetPeaks();
diff --git a/muse2/muse/widgets/combobox.cpp b/muse2/muse/widgets/combobox.cpp
index 9e278376..bd78d6f2 100644
--- a/muse2/muse/widgets/combobox.cpp
+++ b/muse2/muse/widgets/combobox.cpp
@@ -6,6 +6,8 @@
//=========================================================
#include <QMenu>
+#include <QSignalMapper>
+#include <QWheelEvent>
#include "combobox.h"
@@ -14,67 +16,75 @@
//---------------------------------------------------------
ComboBox::ComboBox(QWidget* parent, const char* name)
- : QLabel(parent)
+ : QToolButton(parent)
{
setObjectName(name);
_currentItem = 0;
- _id = -1;
- list = new QMenu(0);
- connect(list, SIGNAL(triggered(QAction*)), SLOT(activatedIntern(QAction*)));
- setFrameStyle(QFrame::Panel | QFrame::Raised);
- setLineWidth(2);
+
+ menu = new QMenu(this);
+
+ autoTypeSignalMapper = new QSignalMapper(this);
+ connect(autoTypeSignalMapper, SIGNAL(mapped(int)), this, SLOT(activatedIntern(int)));
}
ComboBox::~ComboBox()
{
- delete list;
+ delete menu;
}
//---------------------------------------------------------
// mousePressEvent
//---------------------------------------------------------
-void ComboBox::mousePressEvent(QMouseEvent*)
+void ComboBox::mousePressEvent(QMouseEvent* /*ev*/)
+ {
+ menu->exec(QCursor::pos());
+ }
+
+//---------------------------------------------------------
+// wheelEvent
+//---------------------------------------------------------
+
+void ComboBox::wheelEvent(QWheelEvent* ev)
{
- list->exec(QCursor::pos());
+ int i = itemlist.indexOf(_currentItem);
+ int len = itemlist.count();
+ if (ev->delta() > 0 && i > 0)
+ activatedIntern(_currentItem-1);
+ else if (ev->delta() < 0 && -1 < i && i < len - 1)
+ activatedIntern(_currentItem+1);
}
//---------------------------------------------------------
// activated
//---------------------------------------------------------
-void ComboBox::activatedIntern(QAction* act)
+void ComboBox::activatedIntern(int id)
{
- _currentItem = act->data().toInt();
- emit activated(_currentItem, _id);
- setText(act->text());
+ setCurrentItem(id);
+ emit activated(id);
}
//---------------------------------------------------------
// setCurrentItem
//---------------------------------------------------------
-void ComboBox::setCurrentItem(int i)
+void ComboBox::setCurrentItem(int id)
{
- _currentItem = i;
- // ORCAN - CHECK
- QList<QAction *> actions = list->actions();
- for (QList<QAction *>::iterator it = actions.begin(); it != actions.end(); ++it) {
- QAction* act = *it;
- if (act->data().toInt() == i) {
- setText(act->text());
- break;
- }
- }
+ QAction* act = (QAction*) autoTypeSignalMapper->mapping(id);
+ _currentItem = id;
+ setText(act->text());
}
//---------------------------------------------------------
// insertItem
//---------------------------------------------------------
-void ComboBox::insertItem(const QString& s, int id)
+void ComboBox::addAction(const QString& s, int id)
{
- QAction *act = list->addAction(s);
- act->setData(id);
+ QAction *act = menu->addAction(s);
+ connect(act, SIGNAL(triggered()), autoTypeSignalMapper, SLOT(map()));
+ autoTypeSignalMapper->setMapping(act, id);
+ itemlist << id;
}
diff --git a/muse2/muse/widgets/combobox.h b/muse2/muse/widgets/combobox.h
index 305ad0b3..c099b3ce 100644
--- a/muse2/muse/widgets/combobox.h
+++ b/muse2/muse/widgets/combobox.h
@@ -8,36 +8,38 @@
#ifndef __COMBOBOX_H__
#define __COMBOBOX_H__
-#include <QLabel>
+#include <QToolButton>
class QMenu;
+class QSignalMapper;
//---------------------------------------------------------
// ComboBox
//---------------------------------------------------------
-class ComboBox : public QLabel {
+class ComboBox : public QToolButton {
Q_OBJECT
- Q_PROPERTY( int id READ id WRITE setId )
- int _id;
int _currentItem;
- QMenu* list;
+ QList<int> itemlist;
+
+ QMenu* menu;
virtual void mousePressEvent(QMouseEvent*);
+ virtual void wheelEvent(QWheelEvent*);
+
+ QSignalMapper* autoTypeSignalMapper;
private slots:
- void activatedIntern(QAction*);
+ void activatedIntern(int id);
signals:
- void activated(int val, int id);
+ void activated(int id);
public:
- ComboBox(QWidget* parent, const char* name = 0);
+ ComboBox(QWidget* parent = 0, const char* name = 0);
~ComboBox();
void setCurrentItem(int);
- void insertItem(const QString& s, int id = -1);
- int id() const { return _id; }
- void setId(int i) { _id = i; }
+ void addAction(const QString& s, int id = -1);
};
#endif