summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muse2/CMakeLists.txt3
-rw-r--r--muse2/ChangeLog3
-rw-r--r--muse2/muse/plugin.cpp164
-rw-r--r--muse2/muse/plugin.h39
-rw-r--r--muse2/muse/widgets/knob.cpp2
-rw-r--r--muse2/muse/widgets/knob.h6
-rw-r--r--muse2/muse/widgets/mlabel.h4
-rw-r--r--muse2/muse/widgets/slider.cpp2
-rw-r--r--muse2/muse/widgets/slider.h2
-rw-r--r--muse2/muse/widgets/sliderbase.cpp2
-rw-r--r--muse2/muse/widgets/sliderbase.h2
-rw-r--r--muse2/muse/widgets/ttoolbutton.h2
12 files changed, 115 insertions, 116 deletions
diff --git a/muse2/CMakeLists.txt b/muse2/CMakeLists.txt
index 047cdc3e..094f5ec3 100644
--- a/muse2/CMakeLists.txt
+++ b/muse2/CMakeLists.txt
@@ -140,6 +140,9 @@ if (NOT QT4_FOUND)
)
endif (NOT QT4_FOUND)
+# Needed for plugins factory:
+SET(QT_USE_QTUITOOLS TRUE)
+
include(${QT_USE_FILE})
# set (MUSE_QT_WRAP_CPP QT4_WRAP_CPP)
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 3d45cb37..89791bfe 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -3,6 +3,9 @@
- Ported sigedit and posedit. Used SpinBox in place of Q3SpinWidget. TODO: Needs some work on
locating the arrows of the SpinBox accurately. Maybe we need to implement another SpinBox
from scratch? (Orcan)
+ - Ported plugin.cpp. Both internal and LADSPA plugins tested okay. (Orcan)
+ - Trivial conversion of Qt3 support methods to Qt4 in some widgets: slider, sliderbase, knob,
+ ttoolbutton, mlabel. (Orcan)
04.12.2010
- Fix: Escape button does not exit track renaming editor. (Orcan)
- Fix: Midi ports config table items are editable when they are not supposed to. (Orcan)
diff --git a/muse2/muse/plugin.cpp b/muse2/muse/plugin.cpp
index 4b215277..8d2d3752 100644
--- a/muse2/muse/plugin.cpp
+++ b/muse2/muse/plugin.cpp
@@ -6,41 +6,31 @@
// (C) Copyright 2000 Werner Schweer (ws@seh.de)
//=========================================================
-#include <qdir.h>
-//Added by qt3to4:
-#include <QBoxLayout>
-#include <QGridLayout>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-#include <Qt3Support>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <cmath>
#include <math.h>
-#include <qwidget.h>
-#include <QLayout>
-#include <qlabel.h>
-#include <qsignalmapper.h>
-#include <qpushbutton.h>
-#include <q3scrollview.h>
-#include <q3listview.h>
-//#include <q3toolbar.h>
-#include <QToolBar>
-#include <qtoolbutton.h>
-#include <q3whatsthis.h>
-#include <qcheckbox.h>
-#include <qtooltip.h>
-//#include <qwidgetfactory.h>
-#include <qfile.h>
-#include <qobject.h>
-#include <qcombobox.h>
#include <QButtonGroup>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDir>
+#include <QFile>
+#include <QGridLayout>
#include <QGroupBox>
-#include <qradiobutton.h>
-#include <qmessagebox.h>
-#include <qtimer.h>
+#include <QHBoxLayout>
+#include <QMainWindow>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QSignalMapper>
+#include <QSizePolicy>
+#include <QScrollArea>
+#include <QToolBar>
+#include <QToolButton>
+#include <QVBoxLayout>
+#include <QWhatsThis>
#include "globals.h"
#include "gconfig.h"
@@ -257,8 +247,9 @@ bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, int port, int ctl
*min = ctlmn;
*max = ctlmx;
- float fbias = (fmin + fmax) / 2.0;
- float normbias = fbias / frng;
+ // Orcan: commented out next 2 lines to suppress compiler warning:
+ //float fbias = (fmin + fmax) / 2.0;
+ //float normbias = fbias / frng;
float normdef = fdef / frng;
fdef = normdef * fctlrng;
@@ -2801,8 +2792,11 @@ Plugin* PluginDialog::getPlugin(QWidget* parent)
return 0;
}
-const char* presetOpenText = "<img source=\"fileopen\"> "
- "Click this button to load a saved <em>preset</em>.";
+// TODO: We need to use .qrc files to use icons in WhatsThis bubbles. See Qt
+// Resource System in Qt documentation - ORCAN
+//const char* presetOpenText = "<img source=\"fileopen\"> "
+// "Click this button to load a saved <em>preset</em>.";
+const char* presetOpenText = "Click this button to load a saved <em>preset</em>.";
const char* presetSaveText = "Click this button to save curent parameter "
"settings as a <em>preset</em>. You will be prompted for a file name.";
const char* presetBypassText = "Click this button to bypass effect unit";
@@ -2814,40 +2808,38 @@ const char* presetBypassText = "Click this button to bypass effect unit";
//PluginGui::PluginGui(PluginI* p)
// p3.3.43
PluginGui::PluginGui(PluginIBase* p)
- : Q3MainWindow(0)
+ : QMainWindow(0)
{
gw = 0;
params = 0;
plugin = p;
setCaption(plugin->name());
- QToolBar* tools = new QToolBar(tr("File Buttons"), this);
- QToolButton* fileOpen = new QToolButton(
- QIcon(*openIconS), // ddskrjo
- tr("Load Preset"),
- QString::null, this, SLOT(load()),
- tools, "load preset" );
-
- QToolButton* fileSave = new QToolButton(
- QIcon(*saveIconS), // ddskrjo
- tr("Save Preset"),
- QString::null,
- this, SLOT(save()),
- tools, "save preset");
-
- Q3WhatsThis::whatsThisButton(tools);
-
- onOff = new QToolButton(tools, "bypass");
- onOff->setIconSet(*exitIconS);
- onOff->setToggleButton(true);
- onOff->setOn(plugin->on());
- QToolTip::add(onOff, tr("bypass plugin"));
+ QToolBar* tools = addToolBar(tr("File Buttons"));
+
+ QAction* fileOpen = new QAction(QIcon(*openIconS), tr("Load Preset"), this);
+ connect(fileOpen, SIGNAL(triggered()), this, SLOT(load()));
+ tools->addAction(fileOpen);
+
+ QAction* fileSave = new QAction(QIcon(*saveIconS), tr("Save Preset"), this);
+ connect(fileSave, SIGNAL(triggered()), this, SLOT(save()));
+ tools->addAction(fileSave);
+
+ tools->addAction(QWhatsThis::createAction(this));
+
+ onOff = new QAction(QIcon(*exitIconS), tr("bypass plugin"), this);
+ onOff->setCheckable(true);
+ onOff->setChecked(plugin->on());
+ onOff->setToolTip(tr("bypass plugin"));
connect(onOff, SIGNAL(toggled(bool)), SLOT(bypassToggled(bool)));
+ tools->addAction(onOff);
- Q3WhatsThis::add(fileOpen, tr(presetOpenText));
- Q3WhatsThis::add(onOff, tr(presetBypassText));
- Q3MimeSourceFactory::defaultFactory()->setPixmap(QString("fileopen"), *openIcon );
- Q3WhatsThis::add(fileSave, tr(presetSaveText));
+ // TODO: We need to use .qrc files to use icons in WhatsThis bubbles. See Qt
+ // Resource System in Qt documentation - ORCAN
+ //Q3MimeSourceFactory::defaultFactory()->setPixmap(QString("fileopen"), *openIcon );
+ fileOpen->setWhatsThis(tr(presetOpenText));
+ onOff->setWhatsThis(tr(presetBypassText));
+ fileSave->setWhatsThis(tr(presetSaveText));
QString id;
//id.setNum(plugin->plugin()->id());
@@ -2858,17 +2850,20 @@ PluginGui::PluginGui(PluginIBase* p)
//
// construct GUI from *.ui file
//
-#if 0 // ddskrjo
- mw = QWidgetFactory::create(uifile.name(), 0, this);
+ PluginLoader loader;
+ QFile file(uifile.name());
+ file.open(QFile::ReadOnly);
+ mw = loader.load(&file, this);
+ file.close();
setCentralWidget(mw);
- const QObjectList* l = mw->children();
+ QObjectList l = mw->children();
QObject *obj;
nobj = 0;
- QObjectListIt it(*l);
- while ((obj = it.current()) != 0) {
- ++it;
+ QList<QObject*>::iterator it;
+ for (it = l.begin(); it != l.end(); ++it) {
+ obj = *it;
const char* name = obj->name();
if (*name !='P')
continue;
@@ -2878,7 +2873,7 @@ PluginGui::PluginGui(PluginIBase* p)
continue;
++nobj;
}
- it.toFirst();
+ it = l.begin();
gw = new GuiWidgets[nobj];
nobj = 0;
QSignalMapper* mapper = new QSignalMapper(this, "pluginGuiMapper");
@@ -2889,8 +2884,8 @@ PluginGui::PluginGui(PluginIBase* p)
connect(mapperPressed, SIGNAL(mapped(int)), SLOT(guiParamPressed(int)));
connect(mapperReleased, SIGNAL(mapped(int)), SLOT(guiParamReleased(int)));
- while ((obj = it.current()) != 0) {
- ++it;
+ for (it = l.begin(); it != l.end(); ++it) {
+ obj = *it;
const char* name = obj->name();
if (*name !='P')
continue;
@@ -2951,22 +2946,22 @@ PluginGui::PluginGui(PluginIBase* p)
++nobj;
}
updateValues(); // otherwise the GUI won't have valid data
-#endif
}
else {
//mw = new QWidget(this);
//setCentralWidget(mw);
// p3.4.43
- view = new Q3ScrollView(this);
+ view = new QScrollArea;
+ view->setWidgetResizable(true);
setCentralWidget(view);
- mw = new QWidget(view);
- view->setResizePolicy(Q3ScrollView::AutoOneFit);
//view->setVScrollBarMode(QScrollView::AlwaysOff);
- view->addChild(mw);
- QGridLayout* grid = new QGridLayout(mw);
+ mw = new QWidget;
+ QGridLayout* grid = new QGridLayout;
grid->setSpacing(2);
+ mw->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
+
int n = plugin->parameters();
params = new GuiParam[n];
@@ -3021,9 +3016,9 @@ PluginGui::PluginGui(PluginIBase* p)
params[i].actuator = cb;
}
else {
- label = new QLabel(QString(plugin->paramName(i)), mw);
+ label = new QLabel(QString(plugin->paramName(i)), 0);
params[i].type = GuiParam::GUI_SLIDER;
- params[i].label = new DoubleLabel(val, lower, upper, mw);
+ params[i].label = new DoubleLabel(val, lower, upper, 0);
params[i].label->setFrame(true);
params[i].label->setPrecision(2);
params[i].label->setId(i);
@@ -3031,7 +3026,7 @@ PluginGui::PluginGui(PluginIBase* p)
//params[i].label->setContentsMargins(2, 2, 2, 2);
//params[i].label->setFixedHeight(h);
- Slider* s = new Slider(mw, "param", Qt::Horizontal,
+ Slider* s = new Slider(0, "param", Qt::Horizontal,
Slider::None); //, style);
s->setCursorHoming(true);
@@ -3074,8 +3069,10 @@ PluginGui::PluginGui(PluginIBase* p)
}
// p3.3.43
resize(280, height());
-
+
grid->setColStretch(2, 10);
+ mw->setLayout(grid);
+ view->setWidget(mw);
}
connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat()));
}
@@ -3853,15 +3850,14 @@ void PluginGui::guiSliderRightClicked(const QPoint &p, int idx)
}
//---------------------------------------------------------
-// PluginWidgetFactory
+// PluginLoader
//---------------------------------------------------------
-#if 0 // ddskrjo
-QWidget* PluginWidgetFactory::createWidget(const QString& className, QWidget* parent, const char* name) const
+QWidget* PluginLoader::createWidget(const QString & className, QWidget * parent, const QString & name)
{
- if(className == "DoubleLabel")
+ if(className == QString("DoubleLabel"))
return new DoubleLabel(parent, name);
- if(className == "Slider")
- return new Slider(parent, name);
- return 0;
+ if(className == QString("Slider"))
+ return new Slider(parent, name, Qt::Horizontal);
+
+ return QUiLoader::createWidget(className, parent, name);
};
-#endif
diff --git a/muse2/muse/plugin.h b/muse2/muse/plugin.h
index 8c69058e..f5ac9031 100644
--- a/muse2/muse/plugin.h
+++ b/muse2/muse/plugin.h
@@ -12,13 +12,9 @@
#include <list>
#include <vector>
-#include <q3mainwindow.h>
-#include <qstring.h>
-#include <qwidget.h>
-//#include <qwidgetfactory.h>
-#include <qdialog.h>
-#include <qfileinfo.h>
-#include <qcombobox.h>
+#include <QDialog>
+#include <QUiLoader>
+
#include "ladspa.h"
#include "globals.h"
@@ -38,27 +34,28 @@
#include <dssi.h>
#endif
+class QComboBox;
+class QFileInfo;
+class QScrollArea;
+class QToolButton;
+
class Xml;
-class QWidget;
-// class QLabel;
class Slider;
-class Q3ListView;
-class Q3ScrollView;
-class QToolButton;
class DoubleLabel;
class AudioTrack;
class MidiController;
//---------------------------------------------------------
-// PluginWidgetFactory
+// PluginLoader
//---------------------------------------------------------
-#if 0
-class PluginWidgetFactory : public QWidgetFactory
+
+class PluginLoader : public QUiLoader
{
- public:
- virtual QWidget* createWidget(const QString& className, QWidget* parent, const char* name) const;
+ public:
+ virtual QWidget* createWidget(const QString & className, QWidget * parent = 0, const QString & name = QString());
+ PluginLoader(QObject * parent = 0) : QUiLoader(parent) {}
};
-#endif
+
//---------------------------------------------------------
// Plugin
//---------------------------------------------------------
@@ -308,7 +305,7 @@ class PluginIBase
// PluginGui
//---------------------------------------------------------
-class PluginGui : public Q3MainWindow {
+class PluginGui : public QMainWindow {
Q_OBJECT
//PluginI* plugin; // plugin instance
@@ -318,9 +315,9 @@ class PluginGui : public Q3MainWindow {
int nobj; // number of widgets in gw
GuiWidgets* gw;
- QToolButton* onOff;
+ QAction* onOff;
QWidget* mw; // main widget
- Q3ScrollView* view;
+ QScrollArea* view;
void updateControls();
diff --git a/muse2/muse/widgets/knob.cpp b/muse2/muse/widgets/knob.cpp
index 9d94e54c..2f462835 100644
--- a/muse2/muse/widgets/knob.cpp
+++ b/muse2/muse/widgets/knob.cpp
@@ -216,7 +216,7 @@ double Knob::getValue(const QPoint &p)
//.u Description
// Called by QwtSliderBase
//------------------------------------------------------------
-void Knob::getScrollMode( QPoint &p, const Qt::ButtonState &/*button*/, int &scrollMode, int &direction)// prevent compiler warning : unsused parameter
+void Knob::getScrollMode( QPoint &p, const Qt::MouseButton &/*button*/, int &scrollMode, int &direction)// prevent compiler warning : unsused parameter
{
int dx, dy, r;
double arc;
diff --git a/muse2/muse/widgets/knob.h b/muse2/muse/widgets/knob.h
index 0e412d1e..4da733ee 100644
--- a/muse2/muse/widgets/knob.h
+++ b/muse2/muse/widgets/knob.h
@@ -52,9 +52,9 @@ class Knob : public SliderBase, public ScaleIf
void paintEvent(QPaintEvent *);
void resizeEvent(QResizeEvent *e);
double getValue(const QPoint &p);
- void getScrollMode( QPoint &p, const Qt::ButtonState &button, int &scrollMode, int &direction );
- void scaleChange() { repaint(false); }
- void fontChange(const QFont &) { repaint(false); }
+ void getScrollMode( QPoint &p, const Qt::MouseButton &button, int &scrollMode, int &direction );
+ void scaleChange() { repaint(); }
+ void fontChange(const QFont &) { repaint(); }
public:
Knob(QWidget* parent = 0, const char *name = 0);
diff --git a/muse2/muse/widgets/mlabel.h b/muse2/muse/widgets/mlabel.h
index 490e8686..04604041 100644
--- a/muse2/muse/widgets/mlabel.h
+++ b/muse2/muse/widgets/mlabel.h
@@ -30,10 +30,10 @@ class MLabel : public QLabel {
public:
MLabel(const QString& txt, QWidget* parent, const char* name = 0)
- : QLabel(txt, parent, name) {};
+ : QLabel(txt, parent) {setObjectName(name);};
MLabel(QWidget* parent, const char* name = 0)
- : QLabel(parent, name) {};
+ : QLabel(parent) {setObjectName(name);};
};
#endif
diff --git a/muse2/muse/widgets/slider.cpp b/muse2/muse/widgets/slider.cpp
index a1a9890a..ca42741c 100644
--- a/muse2/muse/widgets/slider.cpp
+++ b/muse2/muse/widgets/slider.cpp
@@ -567,7 +567,7 @@ double Slider::getValue( const QPoint &p)
// Called by SliderBase
//
//------------------------------------------------------------
-void Slider::getScrollMode( QPoint &p, const Qt::ButtonState &button, int &scrollMode, int &direction )
+void Slider::getScrollMode( QPoint &p, const Qt::MouseButton &button, int &scrollMode, int &direction )
{
if(cursorHoming() && button == Qt::LeftButton)
{
diff --git a/muse2/muse/widgets/slider.h b/muse2/muse/widgets/slider.h
index 79969807..51c819f5 100644
--- a/muse2/muse/widgets/slider.h
+++ b/muse2/muse/widgets/slider.h
@@ -63,7 +63,7 @@ class Slider : public SliderBase, public ScaleIf
protected:
virtual void drawSlider (QPainter *p, const QRect &r);
double getValue(const QPoint &p);
- void getScrollMode( QPoint &p, const Qt::ButtonState &button, int &scrollMode, int &direction);
+ void getScrollMode( QPoint &p, const Qt::MouseButton &button, int &scrollMode, int &direction);
void resizeEvent(QResizeEvent *e);
void paintEvent (QPaintEvent *e);
void valueChange();
diff --git a/muse2/muse/widgets/sliderbase.cpp b/muse2/muse/widgets/sliderbase.cpp
index 3ce15c1e..eeed13c5 100644
--- a/muse2/muse/widgets/sliderbase.cpp
+++ b/muse2/muse/widgets/sliderbase.cpp
@@ -158,7 +158,7 @@ void SliderBase::setUpdateTime(int t)
void SliderBase::mousePressEvent(QMouseEvent *e)
{
QPoint p = e->pos();
- const Qt::ButtonState button = e->button();
+ const Qt::MouseButton button = e->button();
d_timerTick = 0;
getScrollMode(p, button, d_scrollMode, d_direction);
diff --git a/muse2/muse/widgets/sliderbase.h b/muse2/muse/widgets/sliderbase.h
index 0dd39659..b7c758a8 100644
--- a/muse2/muse/widgets/sliderbase.h
+++ b/muse2/muse/widgets/sliderbase.h
@@ -65,7 +65,7 @@ class SliderBase : public QWidget, public DoubleRange
void mouseReleaseEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
virtual double getValue(const QPoint & p) = 0;
- virtual void getScrollMode( QPoint &p, const Qt::ButtonState &button,
+ virtual void getScrollMode( QPoint &p, const Qt::MouseButton &button,
int &scrollMode, int &direction) = 0;
public slots:
diff --git a/muse2/muse/widgets/ttoolbutton.h b/muse2/muse/widgets/ttoolbutton.h
index 381f3f18..0f1f8af2 100644
--- a/muse2/muse/widgets/ttoolbutton.h
+++ b/muse2/muse/widgets/ttoolbutton.h
@@ -21,7 +21,7 @@ class TransparentToolButton : public QToolButton {
public:
TransparentToolButton(QWidget* parent, const char* name = 0)
- : QToolButton(parent, name) {}
+ : QToolButton(parent) {setObjectName(name);}
};
#endif