aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-09-16 00:53:06 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-09-16 00:53:06 +0800
commitc944d7279bd3745f3391c56dc1dbc5e02f26c425 (patch)
treed96db563d7afb263faad5579286b025a5b4f0318
parent9fecb429a37bcaa577aaa972139f6db3ce17ac50 (diff)
downloadQMidiPlayer-c944d7279bd3745f3391c56dc1dbc5e02f26c425.tar.xz
Use QCommandLineParser to parse arguments.
New argument for loading plugins from given files. Use functor whenever possible in QObject::connect. A little bit of code cleanups.
-rw-r--r--.gitignore1
-rw-r--r--ChangeLog7
-rw-r--r--qmidiplayer-desktop/main.cpp16
-rw-r--r--qmidiplayer-desktop/qmpchanneleditor.cpp158
-rw-r--r--qmidiplayer-desktop/qmpchanneleditor.hpp1
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.hpp31
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp54
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.hpp18
-rw-r--r--qmidiplayer-desktop/qmpplistwindow.cpp2
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp4
-rw-r--r--qmidiplayer-desktop/qmpplugin.hpp2
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.cpp4
12 files changed, 138 insertions, 160 deletions
diff --git a/.gitignore b/.gitignore
index a46a9f0..faa25d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
# User configuration
+*.txt.user
*.pro.user
build/
diff --git a/ChangeLog b/ChangeLog
index 988aea6..bab77a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-09-16 0.8.7 indev
+Use QCommandLineParser to parse arguments.
+
+New argument for loading plugins from given files.
+Use functor whenever possible in QObject::connect.
+A little bit of code cleanups.
+
2019-09-13 0.8.7 indev
CMake. It's happening.
diff --git a/qmidiplayer-desktop/main.cpp b/qmidiplayer-desktop/main.cpp
index f62429c..602aedc 100644
--- a/qmidiplayer-desktop/main.cpp
+++ b/qmidiplayer-desktop/main.cpp
@@ -20,13 +20,17 @@
#include <QStyle>
#include <QTranslator>
#include <QLibraryInfo>
+#include <QCommandLineParser>
int main(int argc,char **argv)
{
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+ QCoreApplication::setApplicationName("qmidiplayer");
+ QCoreApplication::setApplicationVersion(APP_VERSION);
if(!qgetenv("QT_SCALE_FACTOR").length()&&!qgetenv("QT_SCREEN_SCALE_FACTORS").length())
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc,argv);
+
QTranslator qtTranslator;
qtTranslator.load("qt_"+QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
@@ -34,7 +38,17 @@ int main(int argc,char **argv)
QTranslator qmpTranslator;
qmpTranslator.load("qmp_"+QLocale::system().name());
a.installTranslator(&qmpTranslator);
- qmpMainWindow w;
+
+ QCommandLineParser clp;
+ clp.setApplicationDescription("A cross-platform MIDI player.");
+ clp.addHelpOption();
+ clp.addVersionOption();
+ clp.addPositionalArgument("file",QCoreApplication::translate("main","midi files to play (optional)."),"[files...]");
+ clp.addOption(QCommandLineOption("plugin",QCoreApplication::translate("main","Load a plugin from <plugin library>."),"plugin library"));
+ clp.addOption(QCommandLineOption({"l","load-all-files"},QCoreApplication::translate("main","Load all files from the same folder.")));
+ clp.process(a);
+
+ qmpMainWindow w(&clp);
if(w.parseArgs()==1)return 0;
w.init();
diff --git a/qmidiplayer-desktop/qmpchanneleditor.cpp b/qmidiplayer-desktop/qmpchanneleditor.cpp
index fbe3d50..103d612 100644
--- a/qmidiplayer-desktop/qmpchanneleditor.cpp
+++ b/qmidiplayer-desktop/qmpchanneleditor.cpp
@@ -81,13 +81,13 @@ void qmpChannelEditor::showEvent(QShowEvent *e)
knobpressed=0;
setupWindow();
connectSlots();
- connect(qmpMainWindow::getInstance()->getTimer(),SIGNAL(timeout()),this,SLOT(setupWindow()));
+ updconn=connect(qmpMainWindow::getInstance()->getTimer(),&QTimer::timeout,std::bind(&qmpChannelEditor::setupWindow,this,-1));
e->accept();
}
void qmpChannelEditor::closeEvent(QCloseEvent *e)
{
disconnectSlots();
- disconnect(qmpMainWindow::getInstance()->getTimer(),SIGNAL(timeout()),this,SLOT(setupWindow()));
+ disconnect(updconn);
e->accept();
}
@@ -106,92 +106,98 @@ void qmpChannelEditor::on_pbChRight_clicked()
}
void qmpChannelEditor::commonPressed()
-{disconnect(qmpMainWindow::getInstance()->getTimer(),SIGNAL(timeout()),this,SLOT(setupWindow()));knobpressed=1;}
+{
+ disconnect(updconn);
+ knobpressed=1;
+}
void qmpChannelEditor::commonReleased()
-{connect(qmpMainWindow::getInstance()->getTimer(),SIGNAL(timeout()),this,SLOT(setupWindow()));sendCC();knobpressed=0;}
+{
+ updconn=connect(qmpMainWindow::getInstance()->getTimer(),&QTimer::timeout,std::bind(&qmpChannelEditor::setupWindow,this,-1));
+ sendCC();knobpressed=0;
+}
void qmpChannelEditor::commonChanged()
{if(knobpressed){sendCC();setupWindow();}}
void qmpChannelEditor::connectSlots()
{
- connect(ui->dCut,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dReso,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dReverb,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dChorus,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dVol,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dPan,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dAttack,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dDecay,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dRelease,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dRate,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dDepth,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- connect(ui->dDelay,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
+ connect(ui->dCut,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dReso,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dReverb,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dChorus,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dVol,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dPan,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dAttack,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dDecay,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dRelease,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dRate,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dDepth,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ connect(ui->dDelay,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
- connect(ui->dCut,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dReso,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dReverb,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dChorus,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dVol,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dPan,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dAttack,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dDecay,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dRelease,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dRate,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dDepth,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- connect(ui->dDelay,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
+ connect(ui->dCut,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dReso,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dReverb,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dChorus,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dVol,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dPan,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dAttack,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dDecay,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dRelease,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dRate,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dDepth,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ connect(ui->dDelay,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
- connect(ui->dCut,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dReso,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dReverb,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dChorus,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dVol,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dPan,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dAttack,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dDecay,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dRelease,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dRate,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dDepth,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- connect(ui->dDelay,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
+ connect(ui->dCut,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dReso,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dReverb,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dChorus,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dVol,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dPan,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dAttack,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dDecay,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dRelease,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dRate,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dDepth,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ connect(ui->dDelay,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
}
void qmpChannelEditor::disconnectSlots()
{
- disconnect(ui->dCut,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dReso,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dReverb,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dChorus,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dVol,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dPan,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dAttack,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dDecay,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dRelease,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dRate,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dDepth,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
- disconnect(ui->dDelay,SIGNAL(sliderPressed()),this,SLOT(commonPressed()));
+ disconnect(ui->dCut,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dReso,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dReverb,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dChorus,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dVol,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dPan,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dAttack,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dDecay,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dRelease,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dRate,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dDepth,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
+ disconnect(ui->dDelay,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
- disconnect(ui->dCut,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dReso,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dReverb,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dChorus,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dVol,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dPan,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dAttack,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dDecay,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dRelease,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dRate,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dDepth,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
- disconnect(ui->dDelay,SIGNAL(sliderReleased()),this,SLOT(commonReleased()));
+ disconnect(ui->dCut,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dReso,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dReverb,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dChorus,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dVol,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dPan,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dAttack,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dDecay,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dRelease,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dRate,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dDepth,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
+ disconnect(ui->dDelay,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
- disconnect(ui->dCut,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dReso,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dReverb,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dChorus,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dVol,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dPan,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dAttack,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dDecay,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dRelease,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dRate,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dDepth,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
- disconnect(ui->dDelay,SIGNAL(valueChanged(int)),this,SLOT(commonChanged()));
+ disconnect(ui->dCut,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dReso,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dReverb,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dChorus,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dVol,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dPan,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dAttack,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dDecay,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dRelease,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dRate,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dDepth,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
+ disconnect(ui->dDelay,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
}
diff --git a/qmidiplayer-desktop/qmpchanneleditor.hpp b/qmidiplayer-desktop/qmpchanneleditor.hpp
index 0653af5..350db1e 100644
--- a/qmidiplayer-desktop/qmpchanneleditor.hpp
+++ b/qmidiplayer-desktop/qmpchanneleditor.hpp
@@ -36,6 +36,7 @@ class qmpChannelEditor:public QDialog
void sendCC();
void connectSlots();
void disconnectSlots();
+ QMetaObject::Connection updconn;
QCommonStyle* styl;
};
diff --git a/qmidiplayer-desktop/qmpchannelswindow.hpp b/qmidiplayer-desktop/qmpchannelswindow.hpp
index ab3227f..93742a2 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.hpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.hpp
@@ -19,37 +19,6 @@ namespace Ui {
class qmpChannelsWindow;
}
-class QDCPushButton:public QPushButton
-{
- Q_OBJECT
- private:
- int id;
- protected:
- void mousePressEvent(QMouseEvent *event){QPushButton::mousePressEvent(event);emit onClick(id);}
- public:
- QDCPushButton(QString s):QPushButton(s){id=-1;}
- void setID(int _id){id=_id;}
- QSize sizeHint()const{return QSize();}
- signals:
- void onClick(int id);
-};
-
-class QDCComboBox:public QComboBox
-{
- Q_OBJECT
- private:
- int id;
- public:
- QDCComboBox():QComboBox(){id=-1;connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(indexChangedSlot(int)));}
- void setID(int _id){id=_id;}
- QSize sizeHint()const{return QSize();}
- QSize minimumSizeHint()const{return QSize();}
- signals:
- void onChange(int id,int idx);
- public slots:
- void indexChangedSlot(int idx){emit(onChange(id,idx));}
-};
-
class qmpChannelsWindow;
class qmpChannelFunc:public qmpFuncBaseIntf
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index e097c62..76cd221 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -28,9 +28,10 @@ char* wcsto8bit(const wchar_t* s)
qmpMainWindow* qmpMainWindow::ref=nullptr;
-qmpMainWindow::qmpMainWindow(QWidget *parent) :
+qmpMainWindow::qmpMainWindow(QCommandLineParser *_clp,QWidget *parent):
QMainWindow(parent),
- ui(new Ui::qmpMainWindow)
+ ui(new Ui::qmpMainWindow),
+ clp(_clp)
{
ui->setupUi(this);
ui->lbCurPoly->setText("00000");ui->lbMaxPoly->setText("00000");
@@ -38,7 +39,7 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) :
setButtonHeight(ui->pbNext,36);setButtonHeight(ui->pbPlayPause,36);setButtonHeight(ui->pbAdd,36);
setButtonHeight(ui->pbPrev,36);setButtonHeight(ui->pbSettings,36);setButtonHeight(ui->pbStop,36);
playing=false;stopped=true;dragging=false;fin=false;
- settingsw=new qmpSettingsWindow(this);pmgr=new qmpPluginManager();
+ settingsw=new qmpSettingsWindow(this);
player=nullptr;timer=nullptr;fluidrenderer=nullptr;
}
@@ -107,7 +108,7 @@ void qmpMainWindow::init()
timer=new QTimer(this);
renderf=new qmpRenderFunc(this);
panicf=new qmpPanicFunc(this);
- if(havemidi)
+ if(argfiles.size())
{
plistw->emptyList();
for(auto&i:argfiles)plistw->insertItem(i);
@@ -115,49 +116,34 @@ void qmpMainWindow::init()
registerFunctionality(renderf,"Render",tr("Render to wave").toStdString(),getThemedIconc(":/img/render.svg"),0,false);
registerFunctionality(panicf,"Panic",tr("Panic").toStdString(),getThemedIconc(":/img/panic.svg"),0,false);
registerFunctionality(reloadsynf,"ReloadSynth",tr("Restart fluidsynth").toStdString(),getThemedIconc(":/img/repeat-base.svg"),0,false);
- pmgr->scanPlugins();settingsw->updatePluginList(pmgr);pmgr->initPlugins();
+ pmgr=new qmpPluginManager();
+ const QStringList &qpp=clp->values("plugin");
+ std::vector<std::string> pp;
+ for(auto s:qpp)
+ pp.push_back(s.toStdString());
+ pmgr->scanPlugins(pp);
+ settingsw->updatePluginList(pmgr);pmgr->initPlugins();
ui->vsMasterVol->setValue(qmpSettingsWindow::getSettingsIntf()->value("Audio/Gain",50).toInt());
- connect(timer,SIGNAL(timeout()),this,SLOT(updateWidgets()));
- connect(timer,SIGNAL(timeout()),infow,SLOT(updateInfo()));
+ connect(timer,&QTimer::timeout,this,&qmpMainWindow::updateWidgets);
+ connect(timer,&QTimer::timeout,infow,&qmpInfoWindow::updateInfo);
ui->pbNext->setIcon(QIcon(getThemedIcon(":/img/next.svg")));
ui->pbPrev->setIcon(QIcon(getThemedIcon(":/img/prev.svg")));
ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/play.svg")));
ui->pbStop->setIcon(QIcon(getThemedIcon(":/img/stop.svg")));
ui->pbSettings->setIcon(QIcon(getThemedIcon(":/img/settings.svg")));
ui->pbAdd->setIcon(QIcon(getThemedIcon(":/img/open.svg")));
- if(havemidi)on_pbPlayPause_clicked();
+ if(argfiles.size())on_pbPlayPause_clicked();
setupWidget();settingsw->verifySF();
}
int qmpMainWindow::parseArgs()
{
- bool loadfolder=false;havemidi=false;
- QStringList args=QApplication::arguments();
- for(int i=1;i<args.size();++i)
+ bool loadfolder=clp->isSet("load-all-files");
+ const QStringList &args=clp->positionalArguments();
+ for(int i=0;i<args.size();++i)
{
- if(args.at(i).at(0)=='-')
- {
- if(args.at(i)==QString("--help"))
- {
- printf("Usage: %s [Options] [Midi Files]\n",args.at(0).toStdString().c_str());
- printf("Possible options are: \n");
- printf(" -l, --load-all-files Load all files from the same folder.\n");
- printf(" --help Show this help and exit.\n");
- printf(" --version Show this version information and exit.\n");
- return 1;
- }
- if(args.at(i)==QString("--version"))
- {
- printf("QMidiPlayer %s\n",APP_VERSION);
- return 1;
- }
- if(args.at(i)==QString("-l")||args.at(i)==QString("--load-all-files"))
- loadfolder=true;
- }
- else
if(QFileInfo(args.at(i)).exists())
{
- if(!havemidi)havemidi=true;
if(loadfolder||qmpSettingsWindow::getSettingsIntf()->value("Behavior/LoadFolder",0).toInt())
{
QDirIterator di(QFileInfo(args.at(i)).absolutePath());
@@ -665,7 +651,7 @@ void qmpMainWindow::setupWidget()
pb->setIconSize(QSize(16,16));
ui->buttonwidget->layout()->addWidget(pb);
mfunc[enabled_buttons[i]].setAssignedControl(pb);
- connect(pb,SIGNAL(onClick(std::string)),this,SLOT(funcReflector(std::string)));
+ connect(pb,&QReflectivePushButton::onClick,this,&qmpMainWindow::funcReflector);
}
for(unsigned i=0;i<enabled_actions.size();++i)
{
@@ -677,7 +663,7 @@ void qmpMainWindow::setupWidget()
);
ui->lbFileName->addAction(a);
mfunc[enabled_actions[i]].setAssignedControl(a);
- connect(a,SIGNAL(onClick(std::string)),this,SLOT(funcReflector(std::string)));
+ connect(a,&QReflectiveAction::onClick,this,&qmpMainWindow::funcReflector);
}
ui->buttonwidget->layout()->setAlignment(Qt::AlignLeft);
}
diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp
index 262bc2e..a95d1fe 100644
--- a/qmidiplayer-desktop/qmpmainwindow.hpp
+++ b/qmidiplayer-desktop/qmpmainwindow.hpp
@@ -14,6 +14,7 @@
#include <QSlider>
#include <QPointer>
#include <QApplication>
+#include <QCommandLineParser>
#include <thread>
#include <chrono>
#include <future>
@@ -60,14 +61,10 @@ class QReflectiveAction:public QAction
std::string reflt;
signals:
void onClick(std::string s);
- private slots:
- void triggerslot(){
- emit(onClick(reflt));
- }
public:
explicit QReflectiveAction(const QIcon& icon,const QString& text,const std::string& ref):
QAction(icon,text,nullptr),reflt(ref){
- connect(this,SIGNAL(triggered(bool)),this,SLOT(triggerslot()));
+ connect(this,&QAction::triggered,std::bind(&QReflectiveAction::onClick,this,reflt));
}
};
@@ -78,14 +75,10 @@ class QReflectivePushButton:public QPushButton
std::string reflt;
signals:
void onClick(std::string s);
- private slots:
- void clickslot(){
- emit(onClick(reflt));
- }
public:
explicit QReflectivePushButton(const QIcon& icon,const QString& text,const std::string& ref):
QPushButton(icon,""),reflt(ref){
- connect(this,SIGNAL(clicked(bool)),this,SLOT(clickslot()));
+ connect(this,&QPushButton::clicked,std::bind(&QReflectivePushButton::onClick,this,reflt));
setToolTip(text);
}
};
@@ -141,7 +134,7 @@ class qmpMainWindow:public QMainWindow
Q_OBJECT
public:
- explicit qmpMainWindow(QWidget *parent = 0);
+ explicit qmpMainWindow(QCommandLineParser *clp,QWidget *parent=nullptr);
void init();
void closeEvent(QCloseEvent *event);
void dropEvent(QDropEvent *event);
@@ -195,7 +188,7 @@ class qmpMainWindow:public QMainWindow
private:
Ui::qmpMainWindow *ui;
QTimer *timer;
- bool playing,stopped,dragging,fin,havemidi;
+ bool playing,stopped,dragging,fin;
std::thread *playerTh=nullptr;
std::thread *renderTh=nullptr;
std::chrono::steady_clock::time_point st;
@@ -217,6 +210,7 @@ class qmpMainWindow:public QMainWindow
qmpReloadSynthFunc* reloadsynf;
std::vector<std::string> enabled_buttons,enabled_actions;
std::vector<QString> argfiles;
+ QCommandLineParser *clp;
void onfnChanged();
void playerSetup(IFluidSettings *fs);
diff --git a/qmidiplayer-desktop/qmpplistwindow.cpp b/qmidiplayer-desktop/qmpplistwindow.cpp
index ca6e8fc..667682e 100644
--- a/qmidiplayer-desktop/qmpplistwindow.cpp
+++ b/qmidiplayer-desktop/qmpplistwindow.cpp
@@ -20,7 +20,7 @@ qmpPlistWindow::qmpPlistWindow(QWidget *parent) :
setButtonHeight(ui->pbClear,36);setButtonHeight(ui->pbLoad,36);
setButtonHeight(ui->pbRemove,36);setButtonHeight(ui->pbRepeat,36);
setButtonHeight(ui->pbSave,36);setButtonHeight(ui->pbShuffle,36);
- connect(this,SIGNAL(selectionChanging()),parent,SLOT(selectionChanged()));
+ connect(this,&qmpPlistWindow::selectionChanging,(qmpMainWindow*)parent,&qmpMainWindow::selectionChanged);
repeat=0;shuffle=0;
if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/RestorePlaylist","").toInt())
{
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp
index 2339625..1c83524 100644
--- a/qmidiplayer-desktop/qmpplugin.cpp
+++ b/qmidiplayer-desktop/qmpplugin.cpp
@@ -49,10 +49,10 @@ void qmpPluginManager::scanPlugins()
}
}
#else
-void qmpPluginManager::scanPlugins()
+void qmpPluginManager::scanPlugins(const std::vector<std::string> &pp)
{
QDirIterator *dir;
- std::vector<std::string> cpluginpaths;
+ std::vector<std::string> cpluginpaths(pp);
#ifdef QMP_BUILD_UNIX_PACKAGE
dir=new QDirIterator("/usr/lib/qmidiplayer/");
while(dir->hasNext())
diff --git a/qmidiplayer-desktop/qmpplugin.hpp b/qmidiplayer-desktop/qmpplugin.hpp
index 512fc35..be10b12 100644
--- a/qmidiplayer-desktop/qmpplugin.hpp
+++ b/qmidiplayer-desktop/qmpplugin.hpp
@@ -21,7 +21,7 @@ class qmpPluginManager
qmpPluginManager();
~qmpPluginManager();
std::vector<qmpPlugin> *getPlugins();
- void scanPlugins();
+ void scanPlugins(const std::vector<std::string> &pp);
void initPlugins();
void deinitPlugins();
};
diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp
index 08a76fd..5c5c7b0 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.cpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.cpp
@@ -22,7 +22,7 @@ qmpSettingsWindow::qmpSettingsWindow(QWidget *parent) :
ui(new Ui::qmpSettingsWindow)
{
ui->setupUi(this);customOptions.clear();customOptPages.clear();
- connect(this,SIGNAL(dialogClosing()),parent,SLOT(dialogClosed()));
+ connect(this,&qmpSettingsWindow::dialogClosing,(qmpMainWindow*)parent,&qmpMainWindow::dialogClosed);
settings=new QSettings(QDir::homePath()+QString("/.config/qmprc"),QSettings::IniFormat);
settingsInit();outwidget=ui->cbOutputDevice;
ui->pbAdd->setIcon(QIcon(getThemedIcon(":/img/add.svg")));
@@ -732,7 +732,7 @@ QFileEdit::QFileEdit(QWidget *par):QWidget(par)
tb=new QToolButton(this);
tb->setText("...");
layout->addWidget(tb);
- connect(tb,SIGNAL(clicked()),this,SLOT(chooseFile()));
+ connect(tb,&QToolButton::clicked,this,&QFileEdit::chooseFile);
}
QString QFileEdit::text(){return le->text();}
void QFileEdit::setText(const QString& s){le->setText(s);}