aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpsettingswindow.cpp
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/qmpsettingswindow.cpp
parent85ccf22f3d2340e80ce2a109bbe610da1b92ca7d (diff)
downloadQMidiPlayer-bb82e7dfe2c6f3ee40a79f949db68cdd2c28456b.tar.xz
Finally finished the option proxying infrastructure...
Diffstat (limited to 'qmidiplayer-desktop/qmpsettingswindow.cpp')
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.cpp54
1 files changed, 52 insertions, 2 deletions
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);
+}