diff options
author | Chris Xiong <chirs241097@gmail.com> | 2016-05-03 23:20:16 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2016-05-03 23:20:16 +0800 |
commit | 015a45c276caf34be3ce9175a1bcce644d736a0b (patch) | |
tree | 05ebec5acd744170981e5569c1e0aed4f78ed68f /qmidiplayer-desktop | |
parent | bb82e7dfe2c6f3ee40a79f949db68cdd2c28456b (diff) | |
download | QMidiPlayer-015a45c276caf34be3ce9175a1bcce644d736a0b.tar.xz |
Finish option proxying for all types.
Add more options for the visualization plugin.
Bump version to 0.8.0.
Package the visualization plugin for debian.
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r-- | qmidiplayer-desktop/qmidiplayer-desktop.pro | 8 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmphelpwindow.hpp | 2 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpplugin.cpp | 32 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpsettingswindow.cpp | 203 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpsettingswindow.hpp | 18 |
5 files changed, 237 insertions, 26 deletions
diff --git a/qmidiplayer-desktop/qmidiplayer-desktop.pro b/qmidiplayer-desktop/qmidiplayer-desktop.pro index 9e169e6..e3d6492 100644 --- a/qmidiplayer-desktop/qmidiplayer-desktop.pro +++ b/qmidiplayer-desktop/qmidiplayer-desktop.pro @@ -60,6 +60,14 @@ unix{ isEmpty(PREFIX) { PREFIX = /usr/local } + BUILDM = $$(QMP_BUILD_MODE) + isEmpty(BUILDM) { + message(Building in normal(debugging) mode...) + } + else { + message(Building in packaging mode...) + DEFINES += QMP_BUILD_UNIX_PACKAGE + } BINDIR = $$PREFIX/bin target.path = $$BINDIR DATADIR = $$PREFIX/share diff --git a/qmidiplayer-desktop/qmphelpwindow.hpp b/qmidiplayer-desktop/qmphelpwindow.hpp index 209a753..053a738 100644 --- a/qmidiplayer-desktop/qmphelpwindow.hpp +++ b/qmidiplayer-desktop/qmphelpwindow.hpp @@ -2,7 +2,7 @@ #define QMPHELPWINDOW_H #include <QDialog> -#define APP_VERSION "0.7.8" +#define APP_VERSION "0.8.0" namespace Ui { class qmpHelpWindow; diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp index 7b089d7..f014902 100644 --- a/qmidiplayer-desktop/qmpplugin.cpp +++ b/qmidiplayer-desktop/qmpplugin.cpp @@ -25,6 +25,7 @@ void qmpPluginManager::scanPlugins() DIR *dir; struct dirent *file; std::vector<std::string> cpluginpaths; +#ifdef QMP_BUILD_UNIX_PACKAGE if((dir=opendir("/usr/lib/qmidiplayer/"))) { while((file=readdir(dir))) @@ -32,6 +33,7 @@ void qmpPluginManager::scanPlugins() cpluginpaths.push_back(std::string("/usr/lib/qmidiplayer/")+std::string(file->d_name)); closedir(dir); } +#endif if((dir=opendir("./"))) { while((file=readdir(dir))) @@ -121,16 +123,20 @@ void qmpPluginAPI::unregisterVisualizationIntf(int intfhandle) void qmpPluginAPI::registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval) {qsw->registerOptionInt(tab,desc,key,min,max,defaultval);} int qmpPluginAPI::getOptionInt(std::string key){return qsw->getOptionInt(key);} -void qmpPluginAPI::setOptionInt(std::string key,int val){qsw->SetOptionInt(key,val);} -void qmpPluginAPI::registerOptionUint(std::string,std::string,std::string,unsigned,unsigned,unsigned){} -unsigned qmpPluginAPI::getOptionUint(std::string){return 0;} -void qmpPluginAPI::setOptionUint(std::string,unsigned){} -void qmpPluginAPI::registerOptionBool(std::string,std::string,std::string,bool){} -bool qmpPluginAPI::getOptionBool(std::string){return false;} -void qmpPluginAPI::setOptionBool(std::string,bool){} -void qmpPluginAPI::registerOptionDouble(std::string,std::string,std::string,double,double,double){} -double qmpPluginAPI::getOptionDouble(std::string){return 0;} -void qmpPluginAPI::setOptionDouble(std::string,double){} -void qmpPluginAPI::registerOptionString(std::string,std::string,std::string,std::string){} -std::string qmpPluginAPI::getOptionString(std::string){return "";} -void qmpPluginAPI::setOptionString(std::string,std::string){} +void qmpPluginAPI::setOptionInt(std::string key,int val){qsw->setOptionInt(key,val);} +void qmpPluginAPI::registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval) +{qsw->registerOptionUint(tab,desc,key,min,max,defaultval);} +unsigned qmpPluginAPI::getOptionUint(std::string key){return qsw->getOptionUint(key);} +void qmpPluginAPI::setOptionUint(std::string key,unsigned val){qsw->setOptionUint(key,val);} +void qmpPluginAPI::registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval) +{qsw->registerOptionBool(tab,desc,key,defaultval);} +bool qmpPluginAPI::getOptionBool(std::string key){return qsw->getOptionBool(key);} +void qmpPluginAPI::setOptionBool(std::string key,bool val){qsw->setOptionBool(key,val);} +void qmpPluginAPI::registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval) +{qsw->registerOptionDouble(tab,desc,key,min,max,defaultval);} +double qmpPluginAPI::getOptionDouble(std::string key){return qsw->getOptionDouble(key);} +void qmpPluginAPI::setOptionDouble(std::string key,double val){qsw->setOptionDouble(key,val);} +void qmpPluginAPI::registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval) +{qsw->registerOptionString(tab,desc,key,defaultval);} +std::string qmpPluginAPI::getOptionString(std::string key){return qsw->getOptionString(key);} +void qmpPluginAPI::setOptionString(std::string key,std::string val){return qsw->setOptionString(key,val);} diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp index 011aaeb..ad9ac14 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.cpp +++ b/qmidiplayer-desktop/qmpsettingswindow.cpp @@ -1,3 +1,4 @@ +#include <QPlainTextEdit> #include <QFileDialog> #include <QDir> #include "qmpsettingswindow.hpp" @@ -247,7 +248,7 @@ void qmpSettingsWindow::settingsUpdate() settings->setValue( QString("PluginSwitch/")+ui->twPluginList->item(i,1)->text(), ((QCheckBox*)ui->twPluginList->cellWidget(i,0))->isChecked()?1:0); - updateCustomeOptions(); + updateCustomOptions(); settings->sync(); } @@ -322,15 +323,33 @@ void qmpSettingsWindow::updatePluginList(qmpPluginManager *pmgr) ui->twPluginList->setColumnWidth(3,128); } -void qmpSettingsWindow::updateCustomeOptions() +void qmpSettingsWindow::updateCustomOptions() { for(auto i=customOptions.begin();i!=customOptions.end();++i) switch(i->second.type) { - case 0: + case 0:case 1: + { QSpinBox* sb=(QSpinBox*)i->second.widget; settings->setValue(QString(i->first.c_str()),sb->value()); - break; + break; + } + case 2: + { + settings->setValue(QString(i->first.c_str()),((QCheckBox*)i->second.widget)->isChecked()?1:0); + break; + } + case 3: + { + QDoubleSpinBox* sb=(QDoubleSpinBox*)i->second.widget; + settings->setValue(QString(i->first.c_str()),sb->value()); + break; + } + case 4: + { + QPlainTextEdit* te=(QPlainTextEdit*)i->second.widget; + settings->setValue(QString(i->first.c_str()),te->toPlainText()); + } } } @@ -344,20 +363,24 @@ void qmpSettingsWindow::registerOptionInt(std::string tab,std::string desc,std:: customOptions[key].type=0; if(desc.length()) { - QFormLayout* page=NULL; + QGridLayout* page=NULL; if(customOptPages[tab])page=customOptPages[tab]; else { QWidget* w=new QWidget; - page=new QFormLayout(w);w->setLayout(page); + page=new QGridLayout(w); + w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); ui->tabWidget->addTab(w,QString(tab.c_str())); customOptPages[tab]=page; } QSpinBox* sb=new QSpinBox(page->parentWidget()); QLabel* lb=new QLabel(desc.c_str(),page->parentWidget()); customOptions[key].widget=sb; - lb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); - page->addRow(lb,sb); + sb->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); + lb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + int row=page->rowCount(); + page->addWidget(lb,row,0); + page->addWidget(sb,row,1); sb->setMaximum(max); sb->setMinimum(min); sb->setValue(settings->value(QString(key.c_str()),defaultval).toInt()); @@ -367,7 +390,169 @@ int qmpSettingsWindow::getOptionInt(std::string key) { return settings->value(QString(key.c_str()),customOptions[key].defaultval).toInt(); } -void qmpSettingsWindow::SetOptionInt(std::string key,int val) +void qmpSettingsWindow::setOptionInt(std::string key,int val) +{ + settings->setValue(QString(key.c_str()),val); + ((QSpinBox*)customOptions[key].widget)->setValue(val); +} + +void qmpSettingsWindow::registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval) +{ + customOptions[key].widget=NULL; + customOptions[key].desc=desc; + customOptions[key].defaultval=defaultval; + customOptions[key].minv=min; + customOptions[key].maxv=max; + customOptions[key].type=1; + if(desc.length()) + { + QGridLayout* page=NULL; + if(customOptPages[tab])page=customOptPages[tab]; + else + { + QWidget* w=new QWidget; + page=new QGridLayout(w); + w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + ui->tabWidget->addTab(w,QString(tab.c_str())); + customOptPages[tab]=page; + } + QSpinBox* sb=new QSpinBox(page->parentWidget()); + QLabel* lb=new QLabel(desc.c_str(),page->parentWidget()); + customOptions[key].widget=sb; + sb->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); + lb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + int row=page->rowCount(); + page->addWidget(lb,row,0); + page->addWidget(sb,row,1); + sb->setMaximum(max); + sb->setMinimum(min); + sb->setValue(settings->value(QString(key.c_str()),defaultval).toUInt()); + } +} +unsigned qmpSettingsWindow::getOptionUint(std::string key) +{ + return settings->value(QString(key.c_str()),customOptions[key].defaultval).toUInt(); +} +void qmpSettingsWindow::setOptionUint(std::string key,unsigned val) +{ + settings->setValue(QString(key.c_str()),val); + ((QSpinBox*)customOptions[key].widget)->setValue(val); +} + +void qmpSettingsWindow::registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval) +{ + customOptions[key].widget=NULL; + customOptions[key].desc=desc; + customOptions[key].defaultval=defaultval; + customOptions[key].type=2; + if(desc.length()) + { + QGridLayout* page=NULL; + if(customOptPages[tab])page=customOptPages[tab]; + else + { + QWidget* w=new QWidget; + page=new QGridLayout(w); + w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + ui->tabWidget->addTab(w,QString(tab.c_str())); + customOptPages[tab]=page; + } + QCheckBox* cb=new QCheckBox(desc.c_str(),page->parentWidget()); + customOptions[key].widget=cb; + cb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + int row=page->rowCount(); + page->addWidget(cb,row,0,1,2); + cb->setChecked(settings->value(QString(key.c_str()),(int)defaultval).toInt()); + } +} +bool qmpSettingsWindow::getOptionBool(std::string key) +{ + return settings->value(QString(key.c_str()),(int)customOptions[key].defaultval.toBool()).toInt(); +} +void qmpSettingsWindow::setOptionBool(std::string key,bool val) +{ + settings->setValue(QString(key.c_str()),val?1:0); + ((QCheckBox*)customOptions[key].widget)->setChecked(val); +} + +void qmpSettingsWindow::registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval) +{ + customOptions[key].widget=NULL; + customOptions[key].desc=desc; + customOptions[key].defaultval=defaultval; + customOptions[key].minv=min; + customOptions[key].maxv=max; + customOptions[key].type=3; + if(desc.length()) + { + QGridLayout* page=NULL; + if(customOptPages[tab])page=customOptPages[tab]; + else + { + QWidget* w=new QWidget; + page=new QGridLayout(w); + w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + ui->tabWidget->addTab(w,QString(tab.c_str())); + customOptPages[tab]=page; + } + QDoubleSpinBox* sb=new QDoubleSpinBox(page->parentWidget()); + QLabel* lb=new QLabel(desc.c_str(),page->parentWidget()); + customOptions[key].widget=sb; + sb->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); + lb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + int row=page->rowCount(); + page->addWidget(lb,row,0); + page->addWidget(sb,row,1); + sb->setMaximum(max); + sb->setMinimum(min); + sb->setValue(settings->value(QString(key.c_str()),defaultval).toDouble()); + } +} +double qmpSettingsWindow::getOptionDouble(std::string key) +{ + return settings->value(QString(key.c_str()),customOptions[key].defaultval).toDouble(); +} +void qmpSettingsWindow::setOptionDouble(std::string key,double val) { settings->setValue(QString(key.c_str()),val); + ((QDoubleSpinBox*)customOptions[key].widget)->setValue(val); +} + +void qmpSettingsWindow::registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval) +{ + customOptions[key].widget=NULL; + customOptions[key].desc=desc; + customOptions[key].defaultval=QString(defaultval.c_str()); + customOptions[key].type=4; + if(desc.length()) + { + QGridLayout* page=NULL; + if(customOptPages[tab])page=customOptPages[tab]; + else + { + QWidget* w=new QWidget; + page=new QGridLayout(w); + w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + ui->tabWidget->addTab(w,QString(tab.c_str())); + customOptPages[tab]=page; + } + QPlainTextEdit* te=new QPlainTextEdit(page->parentWidget()); + QLabel* lb=new QLabel(desc.c_str(),page->parentWidget()); + customOptions[key].widget=te; + te->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); + lb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + int row=page->rowCount(); + page->addWidget(lb,row,0); + page->addWidget(te,row,1); + te->setPlainText(defaultval.c_str()); + } +} +std::string qmpSettingsWindow::getOptionString(std::string key) +{ + return settings->value(QString(key.c_str()),customOptions[key].defaultval).toString().toStdString(); +} +void qmpSettingsWindow::setOptionString(std::string key,std::string val) +{ + settings->setValue(QString(key.c_str()),QString(val.c_str())); + ((QPlainTextEdit*)customOptions[key].widget)->setPlainText(val.c_str()); } diff --git a/qmidiplayer-desktop/qmpsettingswindow.hpp b/qmidiplayer-desktop/qmpsettingswindow.hpp index 13442fd..efa69d5 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.hpp +++ b/qmidiplayer-desktop/qmpsettingswindow.hpp @@ -34,7 +34,19 @@ class qmpSettingsWindow:public QDialog void updatePluginList(qmpPluginManager *pmgr); void registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval); int getOptionInt(std::string key); - void SetOptionInt(std::string key,int val); + void setOptionInt(std::string key,int val); + void registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval); + unsigned getOptionUint(std::string key); + void setOptionUint(std::string key,unsigned val); + void registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval); + bool getOptionBool(std::string key); + void setOptionBool(std::string key,bool val); + void registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval); + double getOptionDouble(std::string key); + void setOptionDouble(std::string key,double val); + void registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval); + std::string getOptionString(std::string key); + void setOptionString(std::string key,std::string val); signals: void dialogClosing(); @@ -56,8 +68,8 @@ class qmpSettingsWindow:public QDialog Ui::qmpSettingsWindow *ui; void settingsUpdate(); std::map<std::string,qmpCustomOption> customOptions; - std::map<std::string,QFormLayout*> customOptPages; - void updateCustomeOptions(); + std::map<std::string,QGridLayout*> customOptPages; + void updateCustomOptions(); static QSettings *settings; static QComboBox* outwidget; public: |