From a3a51ea01c0c571d0859f1cb5147dcd003bc8c71 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Fri, 13 May 2016 23:55:42 +0800 Subject: Added enumerate integer options support. Workaroud for different fonts locations in arch linux. --- ChangeLog | 4 +++ include/qmpcorepublic.hpp | 3 ++ qmidiplayer-desktop/qmpplugin.cpp | 4 +++ qmidiplayer-desktop/qmpsettingswindow.cpp | 49 +++++++++++++++++++++++++++++++ qmidiplayer-desktop/qmpsettingswindow.hpp | 5 ++++ visualization/qmpvisualization.cpp | 3 ++ 6 files changed, 68 insertions(+) diff --git a/ChangeLog b/ChangeLog index b6b2132..39eb59f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-05-13 0.8.1 alpha +Added enumerate integer options support. +Workaroud for different fonts locations in arch linux. + 2016-05-12 0.8.1 alpha Now channel labels are displayed correctly. Add an option to change the tint of the chequer board. diff --git a/include/qmpcorepublic.hpp b/include/qmpcorepublic.hpp index 8db9329..88c54a7 100644 --- a/include/qmpcorepublic.hpp +++ b/include/qmpcorepublic.hpp @@ -90,6 +90,9 @@ class qmpPluginAPI virtual void registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval); virtual std::string getOptionString(std::string key); virtual void setOptionString(std::string key,std::string val); + virtual void registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector options,int defaultval); + virtual int getOptionEnumInt(std::string key); + virtual void setOptionEnumInt(std::string key,int val); }; #ifdef QMP_MAIN } 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 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 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;iaddItem(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 #include +#include #include #include #include @@ -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 options,int defaultval); + int getOptionEnumInt(std::string key); + void setOptionEnumInt(std::string key,int val); signals: void dialogClosing(); diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp index f2c663e..607b2ea 100644 --- a/visualization/qmpvisualization.cpp +++ b/visualization/qmpvisualization.cpp @@ -79,10 +79,13 @@ void qmpVisualization::showThread() if(noteappearance==1)nebuf=new smEntity3DBuffer();else nebuf=NULL; tdscn=sm->smTargetCreate(wwidth*wsupersample,wheight*wsupersample,wmultisample); if(!font.loadTTF("/usr/share/fonts/truetype/freefont/FreeMono.ttf",16)) + if(!font.loadTTF("/usr/share/fonts/gnu-free-fonts/FreeMono.otf",16)) printf("W: Font load failed.\n"); if(!fonthdpi.loadTTF("/usr/share/fonts/truetype/freefont/FreeMono.ttf",180)) + if(!fonthdpi.loadTTF("/usr/share/fonts/gnu-free-fonts/FreeMono.otf",180)) printf("W: Font load failed.\n"); if(!font2.loadTTF("/usr/share/fonts/truetype/wqy/wqy-microhei.ttc",16)) + if(!font2.loadTTF("/usr/share/fonts/wenquanyi/wqy-microhei/wqy-microhei.ttc",16)) printf("W: Font load failed.\n"); pos[0]=0;pos[1]=120;pos[2]=70; rot[0]=0;rot[1]=75;rot[2]=90;ctk=0; -- cgit v1.2.3