aboutsummaryrefslogtreecommitdiff
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
parent85ccf22f3d2340e80ce2a109bbe610da1b92ca7d (diff)
downloadQMidiPlayer-bb82e7dfe2c6f3ee40a79f949db68cdd2c28456b.tar.xz
Finally finished the option proxying infrastructure...
-rw-r--r--ChangeLog5
-rw-r--r--include/qmpcorepublic.hpp10
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp15
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.cpp54
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.hpp12
-rw-r--r--visualization/qmpvisualization.cpp15
6 files changed, 92 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 2dda1bd..db9d2e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
-2016-04-30 0.7.8 beta
+2016-05-02 0.7.8 beta
+Finally finished the option proxying infrastructure...
+
+2016-05-01 0.7.8 beta
Give the visualization a clearer look...
Now highlights playing notes.
Avoid a crash in file reading.
diff --git a/include/qmpcorepublic.hpp b/include/qmpcorepublic.hpp
index e17bf84..b872041 100644
--- a/include/qmpcorepublic.hpp
+++ b/include/qmpcorepublic.hpp
@@ -73,19 +73,19 @@ class qmpPluginAPI
//if desc=="", the option won't be visible in the settings form.
//it will only show up in the configuration file.
- virtual void registerOptionInt(std::string desc,std::string key,int min,int max,int defaultval);
+ virtual void registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval);
virtual int getOptionInt(std::string key);
virtual void setOptionInt(std::string key,int val);
- virtual void registerOptionUint(std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval);
+ virtual void registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval);
virtual unsigned getOptionUint(std::string key);
virtual void setOptionUint(std::string key,unsigned val);
- virtual void registerOptionBool(std::string desc,std::string key,bool defaultval);
+ virtual void registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval);
virtual bool getOptionBool(std::string key);
virtual void setOptionBool(std::string key,bool val);
- virtual void registerOptionDouble(std::string desc,std::string key,double min,double max,double defaultval);
+ virtual void registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval);
virtual double getOptionDouble(std::string key);
virtual void setOptionDouble(std::string key,double val);
- virtual void registerOptionString(std::string desc,std::string key,std::string defaultval);
+ 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);
};
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:
diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp
index 28a10d4..30d2437 100644
--- a/visualization/qmpvisualization.cpp
+++ b/visualization/qmpvisualization.cpp
@@ -5,9 +5,9 @@
#include <algorithm>
#include "qmpvisualization.hpp"
-const int viewdist=100;
-const int notestretch=100;//length of quarter note
-const int minnotelength=100;
+int viewdist=100;
+int notestretch=100;//length of quarter note
+int minnotelength=100;
const int noteappearance=1;
DWORD iccolors[]={0XFFFF0000,0XFFFF8000,0XFFFFBF00,0XFFFFFF00,
0XFFBFFF00,0XFF80FF00,0XFF00FF00,0XFF00FFBF,
@@ -60,6 +60,9 @@ void qmpVisualization::showThread()
printf("W: Font load failed.\n");
pos[0]=-0;pos[1]=70;pos[2]=20;
rot[0]=0;rot[1]=90;rot[2]=90;ctk=0;
+ viewdist=api->getOptionInt("Visualization/viewdist");
+ notestretch=api->getOptionInt("Visualization/notestretch");
+ minnotelength=api->getOptionInt("Visualization/minnotelen");
sm->smMainLoop();
}
void qmpVisualization::show()
@@ -244,6 +247,12 @@ void qmpVisualization::init()
hvif=api->registerVisualizationIntf(vi);
herif=api->registerEventReaderIntf(cb,NULL);
hehif=api->registerEventHandlerIntf(hcb,NULL);
+ api->registerOptionInt("Visualization","View distance","Visualization/viewdist",20,1000,100);
+ api->registerOptionInt("Visualization","Note stretch","Visualization/notestretch",20,500,100);
+ api->registerOptionInt("Visualization","Minimum note length","Visualization/minnotelen",20,500,100);
+ viewdist=api->getOptionInt("Visualization/viewdist");
+ notestretch=api->getOptionInt("Visualization/notestretch");
+ minnotelength=api->getOptionInt("Visualization/minnotelen");
}
void qmpVisualization::deinit()
{