aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-13 23:55:42 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-13 23:55:42 +0800
commita3a51ea01c0c571d0859f1cb5147dcd003bc8c71 (patch)
treeeeb1a7faa41ed2536fd9f55b8c389fab297e8422 /qmidiplayer-desktop
parenta84ae874f0334172900d611fc098de8433f54e4c (diff)
downloadQMidiPlayer-a3a51ea01c0c571d0859f1cb5147dcd003bc8c71.tar.xz
Added enumerate integer options support.
Workaroud for different fonts locations in arch linux.
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp4
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.cpp49
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.hpp5
3 files changed, 58 insertions, 0 deletions
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp
index d67e08a..79ea93c 100644
--- a/qmidiplayer-desktop/qmpplugin.cpp
+++ b/qmidiplayer-desktop/qmpplugin.cpp
@@ -157,3 +157,7 @@ void qmpPluginAPI::registerOptionString(std::string tab,std::string desc,std::st
{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);}
+void qmpPluginAPI::registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval)
+{qsw->registerOptionEnumInt(tab,desc,key,options,defaultval);}
+int qmpPluginAPI::getOptionEnumInt(std::string key){return qsw->getOptionEnumInt(key);}
+void qmpPluginAPI::setOptionEnumInt(std::string key,int val){return qsw->setOptionEnumInt(key,val);}
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);
+}
diff --git a/qmidiplayer-desktop/qmpsettingswindow.hpp b/qmidiplayer-desktop/qmpsettingswindow.hpp
index 3820279..9f5e6cf 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.hpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.hpp
@@ -1,7 +1,9 @@
#ifndef QMPSETTINGSWINDOW_H
#define QMPSETTINGSWINDOW_H
+#include <string>
#include <map>
+#include <vector>
#include <QDialog>
#include <QCloseEvent>
#include <QSettings>
@@ -83,6 +85,9 @@ class qmpSettingsWindow:public QDialog
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);
+ void registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval);
+ int getOptionEnumInt(std::string key);
+ void setOptionEnumInt(std::string key,int val);
signals:
void dialogClosing();