diff options
author | Chris Xiong <chirs241097@gmail.com> | 2016-05-13 23:55:42 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2016-05-13 23:55:42 +0800 |
commit | a3a51ea01c0c571d0859f1cb5147dcd003bc8c71 (patch) | |
tree | eeb1a7faa41ed2536fd9f55b8c389fab297e8422 /qmidiplayer-desktop/qmpsettingswindow.cpp | |
parent | a84ae874f0334172900d611fc098de8433f54e4c (diff) | |
download | QMidiPlayer-a3a51ea01c0c571d0859f1cb5147dcd003bc8c71.tar.xz |
Added enumerate integer options support.
Workaroud for different fonts locations in arch linux.
Diffstat (limited to 'qmidiplayer-desktop/qmpsettingswindow.cpp')
-rw-r--r-- | qmidiplayer-desktop/qmpsettingswindow.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp index 2d6912c..b47c2ba 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.cpp +++ b/qmidiplayer-desktop/qmpsettingswindow.cpp @@ -357,6 +357,13 @@ void qmpSettingsWindow::updateCustomOptions() { QLineEdit* te=(QLineEdit*)i->second.widget;if(!i->second.widget)break; settings->setValue(QString(i->first.c_str()),te->text()); + break; + } + case 5: + { + QComboBox* cb=(QComboBox*)i->second.widget;if(!i->second.widget)break; + settings->setValue(QString(i->first.c_str()),cb->currentIndex()); + break; } } } @@ -568,3 +575,45 @@ void qmpSettingsWindow::setOptionString(std::string key,std::string val) if(customOptions[key].widget) ((QLineEdit*)customOptions[key].widget)->setText(val.c_str()); } + +void qmpSettingsWindow::registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval) +{ + customOptions[key].widget=NULL; + customOptions[key].desc=desc; + customOptions[key].defaultval=defaultval; + customOptions[key].type=5; + 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; + } + QComboBox* sb=new QComboBox(page->parentWidget()); + QLabel* lb=new QLabel(desc.c_str(),page->parentWidget()); + customOptions[key].widget=sb; + for(unsigned i=0;i<options.size();++i)sb->addItem(options[i].c_str()); + sb->setCurrentIndex(settings->value(QString(key.c_str()),defaultval).toInt()); + 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); + + } +} +int qmpSettingsWindow::getOptionEnumInt(std::string key) +{ + return settings->value(QString(key.c_str()),customOptions[key].defaultval).toInt(); +} +void qmpSettingsWindow::setOptionEnumInt(std::string key,int val) +{ + settings->setValue(QString(key.c_str()),val); + if(customOptions[key].widget) + ((QComboBox*)customOptions[key].widget)->setCurrentIndex(val); +} |