From 13fca5100f1e28a538e7900d011714d94f6b1b10 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Thu, 28 Apr 2016 23:40:42 +0800 Subject: Now it is possible to disable plugins in the plugin list. --- ChangeLog | 4 ++++ include/qmpcorepublic.hpp | 6 ++++-- qmidiplayer-desktop/qmpmainwindow.cpp | 12 +++++++++-- qmidiplayer-desktop/qmpplugin.cpp | 10 +++++++-- qmidiplayer-desktop/qmpplugin.hpp | 2 +- qmidiplayer-desktop/qmpsettingswindow.cpp | 29 +++++++++++++++++++++++++ qmidiplayer-desktop/qmpsettingswindow.hpp | 2 ++ qmidiplayer-desktop/qmpsettingswindow.ui | 35 +++++++++++++++++++++++++++++-- visualization/qmpvisualization.cpp | 9 +++++--- visualization/qmpvisualization.hpp | 1 + 10 files changed, 98 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7d5fbc..727e2d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-04-28 0.7.8 beta +List plugins in settings window. +Plugins can be disabled now. + 2016-04-27 0.7.8 beta Show file name in window title. Handle pitch bend in visualization. diff --git a/include/qmpcorepublic.hpp b/include/qmpcorepublic.hpp index a8e3fa8..03e99a0 100644 --- a/include/qmpcorepublic.hpp +++ b/include/qmpcorepublic.hpp @@ -63,15 +63,17 @@ class qmpPluginAPI virtual double getPitchBend(int ch); virtual bool getChannelMask(int ch); virtual std::string getTitle(); + virtual int registerVisualizationIntf(qmpVisualizationIntf* intf); virtual void unregisterVisualizationIntf(int intfhandle); virtual int registerEventReaderIntf(IMidiCallBack* cb,void* userdata); virtual void unregisterEventReaderIntf(int intfhandle); virtual int registerEventHandlerIntf(IMidiCallBack* cb,void* userdata); virtual void unregisterEventHandlerIntf(int intfhandle); - virtual void registerOptionInt(std::string desc,std::string key,int defaultval); + + virtual void registerOptionInt(std::string desc,std::string key,int min,int max,int defaultval); virtual int getOptionInt(std::string key); - virtual void registerOptionDouble(std::string desc,std::string key,double defaultval); + virtual void registerOptionDouble(std::string desc,std::string key,double min,double max,double defaultval); virtual double getOptionDouble(std::string key); virtual void registerOptionString(std::string desc,std::string key,std::string defaultval); virtual std::string getOptionString(std::string key); diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp index 58b28b7..d25cadd 100644 --- a/qmidiplayer-desktop/qmpmainwindow.cpp +++ b/qmidiplayer-desktop/qmpmainwindow.cpp @@ -80,7 +80,7 @@ void qmpMainWindow::init() ui->lbFileName->addAction(fnA1); ui->lbFileName->addAction(fnA2); ui->lbFileName->addAction(fnA3); - pmgr->scanPlugins();pmgr->initPlugins(); + pmgr->scanPlugins();settingsw->updatePluginList(pmgr);pmgr->initPlugins(); if(singleFS){player->fluidPreInitialize();playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) LOAD_SOUNDFONT;} @@ -655,7 +655,15 @@ void qmpMainWindow::on_pushButton_clicked() void qmpMainWindow::on_pbVisualization_clicked() { if(ui->pbVisualization->isChecked()) - {for(int i=0;i<16;++i)if(VIs[i])VIs[i]->show();} + { + bool havevis=false; + for(int i=0;i<16;++i)if(VIs[i])VIs[i]->show(),havevis=true; + if(!havevis) + { + QMessageBox::information(this,tr("No visualization plugin enabled"),tr("No visualization plugin enabled. Please enable at least one in plugin settings.")); + ui->pbVisualization->setChecked(false); + } + } else {for(int i=0;i<16;++i)if(VIs[i])VIs[i]->close();} } diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp index 837f4db..3db7b08 100644 --- a/qmidiplayer-desktop/qmpplugin.cpp +++ b/qmidiplayer-desktop/qmpplugin.cpp @@ -58,12 +58,18 @@ qmpPluginManager::qmpPluginManager() } qmpPluginManager::~qmpPluginManager() { + for(unsigned i=0;i *qmpPluginManager::getPlugins() +{ + return &plugins; +} void qmpPluginManager::initPlugins() { for(unsigned i=0;iinit(); } @@ -111,9 +117,9 @@ int qmpPluginAPI::registerVisualizationIntf(qmpVisualizationIntf* intf) {return qmw->registerVisualizationIntf(intf);} void qmpPluginAPI::unregisterVisualizationIntf(int intfhandle) {qmw->unregisterVisualizationIntf(intfhandle);} -void qmpPluginAPI::registerOptionInt(std::string,std::string,int){} +void qmpPluginAPI::registerOptionInt(std::string,std::string,int,int,int){} int qmpPluginAPI::getOptionInt(std::string){return 0;} -void qmpPluginAPI::registerOptionDouble(std::string,std::string,double){} +void qmpPluginAPI::registerOptionDouble(std::string,std::string,double,double,double){} double qmpPluginAPI::getOptionDouble(std::string){return 0;} void qmpPluginAPI::registerOptionString(std::string,std::string,std::string){} std::string qmpPluginAPI::getOptionString(std::string){return "";} diff --git a/qmidiplayer-desktop/qmpplugin.hpp b/qmidiplayer-desktop/qmpplugin.hpp index 81a16a7..836cee2 100644 --- a/qmidiplayer-desktop/qmpplugin.hpp +++ b/qmidiplayer-desktop/qmpplugin.hpp @@ -19,7 +19,7 @@ class qmpPluginManager public: qmpPluginManager(); ~qmpPluginManager(); - std::vector getPlugins() const; + std::vector *getPlugins(); void scanPlugins(); void initPlugins(); void deinitPlugins(); diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp index 985fb6e..d59d2be 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.cpp +++ b/qmidiplayer-desktop/qmpsettingswindow.cpp @@ -242,6 +242,12 @@ void qmpSettingsWindow::settingsUpdate() } settings->setValue("Behavior/SingleInstance",ui->cbPersistentfs->isChecked()?1:0); + + for(int i=0;itwPluginList->rowCount();++i) + settings->setValue( + QString("PluginSwitch/")+ui->twPluginList->item(i,1)->text(), + ((QCheckBox*)ui->twPluginList->cellWidget(i,0))->isChecked()?1:0); + settings->sync(); } @@ -294,3 +300,26 @@ void qmpSettingsWindow::on_cbAutoBS_stateChanged() { ui->lbBSMode->setText(ui->cbAutoBS->isChecked()?"Fallback bank select mode":"Bank select mode"); } + +void qmpSettingsWindow::updatePluginList(qmpPluginManager *pmgr) +{ + std::vector *plugins=pmgr->getPlugins(); + for(unsigned i=0;isize();++i) + { + ui->twPluginList->insertRow(i); + ui->twPluginList->setCellWidget(i,0,new QCheckBox("")); + if(settings->value(QString("PluginSwitch/")+QString(plugins->at(i).name.c_str()),0).toInt()) + {((QCheckBox*)ui->twPluginList->cellWidget(i,0))->setChecked(true);plugins->at(i).enabled=true;} + else + {((QCheckBox*)ui->twPluginList->cellWidget(i,0))->setChecked(false);plugins->at(i).enabled=false;} + ui->twPluginList->setItem(i,1,new QTableWidgetItem(plugins->at(i).name.c_str())); + ui->twPluginList->setItem(i,2,new QTableWidgetItem(plugins->at(i).version.c_str())); + ui->twPluginList->setItem(i,3,new QTableWidgetItem(plugins->at(i).path.c_str())); + for(int j=1;j<=3;++j) + ui->twPluginList->item(i,j)->setFlags(ui->twPluginList->item(i,j)->flags()^Qt::ItemIsEditable); + } + ui->twPluginList->setColumnWidth(0,22); + ui->twPluginList->setColumnWidth(1,192); + ui->twPluginList->setColumnWidth(2,64); + ui->twPluginList->setColumnWidth(3,128); +} diff --git a/qmidiplayer-desktop/qmpsettingswindow.hpp b/qmidiplayer-desktop/qmpsettingswindow.hpp index 6c95663..f7bfae9 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.hpp +++ b/qmidiplayer-desktop/qmpsettingswindow.hpp @@ -6,6 +6,7 @@ #include #include #include +#include "qmpplugin.hpp" namespace Ui { class qmpSettingsWindow; @@ -21,6 +22,7 @@ class qmpSettingsWindow:public QDialog void closeEvent(QCloseEvent *event); void settingsInit(); QListWidget* getSFWidget(); + void updatePluginList(qmpPluginManager *pmgr); signals: void dialogClosing(); diff --git a/qmidiplayer-desktop/qmpsettingswindow.ui b/qmidiplayer-desktop/qmpsettingswindow.ui index 96d0a43..cc9064f 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.ui +++ b/qmidiplayer-desktop/qmpsettingswindow.ui @@ -6,13 +6,13 @@ 0 0 - 494 + 495 445 - 494 + 495 445 @@ -564,6 +564,37 @@ + + + Plugins + + + + + + + E + + + + + Name + + + + + Version + + + + + Path + + + + + + diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp index 1e64b22..1a11334 100644 --- a/visualization/qmpvisualization.cpp +++ b/visualization/qmpvisualization.cpp @@ -238,13 +238,16 @@ void qmpVisualization::init() vi=new CDemoVisualization(this); h=new CMidiVisualHandler(this); closeh=new CloseHandler(this); - api->registerVisualizationIntf(vi); - api->registerEventReaderIntf(cb,NULL); - api->registerEventHandlerIntf(hcb,NULL); + hvif=api->registerVisualizationIntf(vi); + herif=api->registerEventReaderIntf(cb,NULL); + hehif=api->registerEventHandlerIntf(hcb,NULL); } void qmpVisualization::deinit() { close(); + api->unregisterVisualizationIntf(hvif); + api->unregisterEventReaderIntf(herif); + api->unregisterEventHandlerIntf(hehif); delete cb;delete hcb;delete vi; delete h;delete closeh; } diff --git a/visualization/qmpvisualization.hpp b/visualization/qmpvisualization.hpp index afc57a4..787b218 100644 --- a/visualization/qmpvisualization.hpp +++ b/visualization/qmpvisualization.hpp @@ -53,6 +53,7 @@ class qmpVisualization:public qmpPluginIntf uint32_t ctc,ctk,fintk,elb; double etps; bool shouldclose,playing; + int hvif,herif,hehif; void drawCube(smvec3d a,smvec3d b,DWORD col,SMTEX tex); void showThread(); public: -- cgit v1.2.3