aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-02 23:51:25 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-02 23:51:25 +0800
commitbb82e7dfe2c6f3ee40a79f949db68cdd2c28456b (patch)
tree1b68efe784c44f7ce661c65adb7db2e80eb74380 /qmidiplayer-desktop
parent85ccf22f3d2340e80ce2a109bbe610da1b92ca7d (diff)
downloadQMidiPlayer-bb82e7dfe2c6f3ee40a79f949db68cdd2c28456b.tar.xz
Finally finished the option proxying infrastructure...
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp15
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.cpp54
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.hpp12
3 files changed, 71 insertions, 10 deletions
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp
index ce041ec..7b089d7 100644
--- a/qmidiplayer-desktop/qmpplugin.cpp
+++ b/qmidiplayer-desktop/qmpplugin.cpp
@@ -118,18 +118,19 @@ int qmpPluginAPI::registerVisualizationIntf(qmpVisualizationIntf* intf)
void qmpPluginAPI::unregisterVisualizationIntf(int intfhandle)
{qmw->unregisterVisualizationIntf(intfhandle);}
-void qmpPluginAPI::registerOptionInt(std::string,std::string,int,int,int){}
-int qmpPluginAPI::getOptionInt(std::string){return 0;}
-void qmpPluginAPI::setOptionInt(std::string,int){}
-void qmpPluginAPI::registerOptionUint(std::string,std::string,unsigned,unsigned,unsigned){}
+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,bool){}
+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,double,double,double){}
+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){}
+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){}
diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp
index a0daf48..011aaeb 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.cpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.cpp
@@ -17,7 +17,7 @@ qmpSettingsWindow::qmpSettingsWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::qmpSettingsWindow)
{
- ui->setupUi(this);
+ ui->setupUi(this);customOptions.clear();customOptPages.clear();
connect(this,SIGNAL(dialogClosing()),parent,SLOT(dialogClosed()));
settings=new QSettings(QDir::homePath()+QString("/.config/qmprc"),QSettings::IniFormat);
settingsInit();outwidget=ui->cbOutputDevice;
@@ -247,7 +247,7 @@ void qmpSettingsWindow::settingsUpdate()
settings->setValue(
QString("PluginSwitch/")+ui->twPluginList->item(i,1)->text(),
((QCheckBox*)ui->twPluginList->cellWidget(i,0))->isChecked()?1:0);
-
+ updateCustomeOptions();
settings->sync();
}
@@ -321,3 +321,53 @@ void qmpSettingsWindow::updatePluginList(qmpPluginManager *pmgr)
ui->twPluginList->setColumnWidth(2,64);
ui->twPluginList->setColumnWidth(3,128);
}
+
+void qmpSettingsWindow::updateCustomeOptions()
+{
+ for(auto i=customOptions.begin();i!=customOptions.end();++i)
+ switch(i->second.type)
+ {
+ case 0:
+ QSpinBox* sb=(QSpinBox*)i->second.widget;
+ settings->setValue(QString(i->first.c_str()),sb->value());
+ break;
+ }
+}
+
+void qmpSettingsWindow::registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval)
+{
+ customOptions[key].widget=NULL;
+ customOptions[key].desc=desc;
+ customOptions[key].defaultval=defaultval;
+ customOptions[key].minv=min;
+ customOptions[key].maxv=max;
+ customOptions[key].type=0;
+ if(desc.length())
+ {
+ QFormLayout* page=NULL;
+ if(customOptPages[tab])page=customOptPages[tab];
+ else
+ {
+ QWidget* w=new QWidget;
+ page=new QFormLayout(w);w->setLayout(page);
+ 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->setMaximum(max);
+ sb->setMinimum(min);
+ sb->setValue(settings->value(QString(key.c_str()),defaultval).toInt());
+ }
+}
+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)
+{
+ settings->setValue(QString(key.c_str()),val);
+}
diff --git a/qmidiplayer-desktop/qmpsettingswindow.hpp b/qmidiplayer-desktop/qmpsettingswindow.hpp
index 554afd3..13442fd 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.hpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.hpp
@@ -14,6 +14,13 @@ namespace Ui {
class qmpSettingsWindow;
}
+struct qmpCustomOption
+{
+ QWidget* widget;
+ std::string desc;int type;
+ QVariant defaultval,minv,maxv;
+};
+
class qmpSettingsWindow:public QDialog
{
Q_OBJECT
@@ -25,7 +32,9 @@ class qmpSettingsWindow:public QDialog
void settingsInit();
QListWidget* getSFWidget();
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);
signals:
void dialogClosing();
@@ -46,8 +55,9 @@ class qmpSettingsWindow:public QDialog
private:
Ui::qmpSettingsWindow *ui;
void settingsUpdate();
- std::map<std::string,QWidget*> customOptWidgets;
+ std::map<std::string,qmpCustomOption> customOptions;
std::map<std::string,QFormLayout*> customOptPages;
+ void updateCustomeOptions();
static QSettings *settings;
static QComboBox* outwidget;
public: