From aa8af83ff8889aa136e9152b2cca9a88d99c5f47 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 23 Apr 2016 23:50:31 +0800 Subject: Add stubs for plugin support. --- qmidiplayer-desktop/qmidiplayer-desktop.pro | 9 +++-- qmidiplayer-desktop/qmpchannelswindow.hpp | 4 +- qmidiplayer-desktop/qmphelpwindow.hpp | 2 +- qmidiplayer-desktop/qmpmainwindow.cpp | 4 +- qmidiplayer-desktop/qmpmainwindow.hpp | 3 ++ qmidiplayer-desktop/qmpplugin.cpp | 58 +++++++++++++++++++++++++++++ qmidiplayer-desktop/qmpplugin.hpp | 26 +++++++++++++ qmidiplayer-desktop/qmpsettingswindow.hpp | 2 +- 8 files changed, 99 insertions(+), 9 deletions(-) create mode 100644 qmidiplayer-desktop/qmpplugin.cpp create mode 100644 qmidiplayer-desktop/qmpplugin.hpp (limited to 'qmidiplayer-desktop') diff --git a/qmidiplayer-desktop/qmidiplayer-desktop.pro b/qmidiplayer-desktop/qmidiplayer-desktop.pro index 4eaf3dd..9e169e6 100644 --- a/qmidiplayer-desktop/qmidiplayer-desktop.pro +++ b/qmidiplayer-desktop/qmidiplayer-desktop.pro @@ -26,7 +26,8 @@ SOURCES += main.cpp\ qmpsettingswindow.cpp \ qmphelpwindow.cpp \ qdialskulpturestyle.cpp \ - ../core/qmpmidimapperrtmidi.cpp + ../core/qmpmidimapperrtmidi.cpp \ + qmpplugin.cpp HEADERS += qmpmainwindow.hpp \ ../core/qmpmidiplay.hpp \ @@ -39,7 +40,9 @@ HEADERS += qmpmainwindow.hpp \ qmpsettingswindow.hpp \ qmphelpwindow.hpp \ qdialskulpturestyle.hpp \ - ../core/qmpmidimappers.hpp + ../core/qmpmidimappers.hpp \ + ../include/qmpcorepublic.hpp \ + qmpplugin.hpp FORMS += qmpmainwindow.ui \ qmpplistwindow.ui \ @@ -78,7 +81,7 @@ unix{ menu.path = $${DATADIR}/menu menu.files += ./menu/$${TARGET} QMAKE_CXXFLAGS += -Wall - LIBS += -lfluidsynth -lrtmidi + LIBS += -lfluidsynth -lrtmidi -ldl } win32{ #change these before building... diff --git a/qmidiplayer-desktop/qmpchannelswindow.hpp b/qmidiplayer-desktop/qmpchannelswindow.hpp index fef6ab7..15a53d6 100644 --- a/qmidiplayer-desktop/qmpchannelswindow.hpp +++ b/qmidiplayer-desktop/qmpchannelswindow.hpp @@ -59,11 +59,11 @@ class QDCComboBox:public QComboBox void indexChangedSlot(int idx){emit(onChange(id,idx));} }; -class qmpCWNoteOnCB:public QObject,public CMidiCallBack +class qmpCWNoteOnCB:public QObject,public IMidiCallBack { Q_OBJECT public: - void callBack(void *data){if(data)data=NULL;emit(onNoteOn());} + void callBack(void*,void*){emit onNoteOn();} signals: void onNoteOn(); }; diff --git a/qmidiplayer-desktop/qmphelpwindow.hpp b/qmidiplayer-desktop/qmphelpwindow.hpp index 8264fcd..209a753 100644 --- a/qmidiplayer-desktop/qmphelpwindow.hpp +++ b/qmidiplayer-desktop/qmphelpwindow.hpp @@ -2,7 +2,7 @@ #define QMPHELPWINDOW_H #include -#define APP_VERSION "0.7.2" +#define APP_VERSION "0.7.8" namespace Ui { class qmpHelpWindow; diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp index 73c2895..84697a4 100644 --- a/qmidiplayer-desktop/qmpmainwindow.cpp +++ b/qmidiplayer-desktop/qmpmainwindow.cpp @@ -49,7 +49,7 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) : ui->lnPolyphone->display("00000-00000"); ui->lbFileName->setText("");ref=this; playing=false;stopped=true;dragging=false; - settingsw=new qmpSettingsWindow(this); + settingsw=new qmpSettingsWindow(this);pmgr=new qmpPluginManager(); plistw=new qmpPlistWindow(this);player=NULL;timer=NULL; singleFS=qmpSettingsWindow::getSettingsIntf()->value("Behavior/SingleInstance",0).toInt(); } @@ -58,7 +58,7 @@ qmpMainWindow::~qmpMainWindow() { if(player)delete player; if(timer)delete timer; - delete ui; + delete pmgr;delete ui; } void qmpMainWindow::init() diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp index 2f3876d..b88169b 100644 --- a/qmidiplayer-desktop/qmpmainwindow.hpp +++ b/qmidiplayer-desktop/qmpmainwindow.hpp @@ -15,6 +15,7 @@ #include #include #include "../core/qmpmidiplay.hpp" +#include "qmpplugin.hpp" #include "qmpplistwindow.hpp" #include "qmpchannelswindow.hpp" #include "qmpefxwindow.hpp" @@ -57,6 +58,7 @@ class qmpMainWindow:public QMainWindow void dragEnterEvent(QDragEnterEvent *event); ~qmpMainWindow(); CMidiPlayer* getPlayer(){return player;} + qmpSettingsWindow* getSettingsWindow(){return settingsw;} QTimer* getTimer(){return timer;} bool isFinalizing(){return fin;} QString getFileName(); @@ -95,6 +97,7 @@ class qmpMainWindow:public QMainWindow std::chrono::steady_clock::time_point st; double offset; CMidiPlayer *player; + qmpPluginManager *pmgr; qmpPlistWindow *plistw; qmpChannelsWindow *chnlw; qmpEfxWindow *efxw; diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp new file mode 100644 index 0000000..4da1698 --- /dev/null +++ b/qmidiplayer-desktop/qmpplugin.cpp @@ -0,0 +1,58 @@ +#ifdef _WIN32 +#include +#else +#include +#include +#endif +#include +#include "qmpplugin.hpp" +#include "qmpmainwindow.hpp" +#include "qmpsettingswindow.hpp" +qmpPluginAPI pluginAPI; +qmpMainWindow* qmw; +qmpSettingsWindow* qsw; +#ifdef _WIN32 +#else +void qmpPluginManager::scanPlugins() +{ + DIR *dir; + struct dirent *file; + std::vector cpluginpaths; + if((dir=opendir("/usr/lib/qmidiplayer/"))) + { + while((file=readdir(dir))) + if(strcmp(file->d_name+strlen(file->d_name)-3,".so")==0) + cpluginpaths.push_back(std::string("/usr/lib/qmidiplayer/")+std::string(file->d_name)); + closedir(dir); + } + if((dir=opendir("./"))) + { + while((file=readdir(dir))) + if(strcmp(file->d_name+strlen(file->d_name)-3,".so")==0) + cpluginpaths.push_back(std::string("./")+std::string(file->d_name)); + closedir(dir); + } + for(unsigned i=0;ipluginGetName()),std::string(intf->pluginGetVersion()),std::string(cpluginpaths[i]),intf)); + } +} +#endif +qmpPluginManager::qmpPluginManager() +{ + qmw=qmpMainWindow::getInstance(); + qsw=qmw->getSettingsWindow(); +} +qmpPluginManager::~qmpPluginManager() +{ + qmw=NULL;qsw=NULL; +} + +uint32_t qmpPluginAPI::getDivision() +{return qmw->getPlayer()->getDivision();} diff --git a/qmidiplayer-desktop/qmpplugin.hpp b/qmidiplayer-desktop/qmpplugin.hpp new file mode 100644 index 0000000..8d14596 --- /dev/null +++ b/qmidiplayer-desktop/qmpplugin.hpp @@ -0,0 +1,26 @@ +#ifndef QMPPLUGIN_H +#define QMPPLUGIN_H +#include +#include +#include "../include/qmpcorepublic.hpp" +struct qmpPlugin +{ + std::string name,version,path; + qmpPluginIntf* interface; + bool enabled; + qmpPlugin(std::string _n,std::string _v,std::string _p,qmpPluginIntf* _i) + {name=_n;version=_v;path=_p;interface=_i;enabled=false;} +}; +class qmpPluginManager +{ + private: + std::vector plugins; + public: + qmpPluginManager(); + ~qmpPluginManager(); + std::vector getPlugins() const; + void scanPlugins(); + void initPlugins(); + void deinitPlugins(); +}; +#endif // QMPPLUGIN_H diff --git a/qmidiplayer-desktop/qmpsettingswindow.hpp b/qmidiplayer-desktop/qmpsettingswindow.hpp index cac691e..6c95663 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.hpp +++ b/qmidiplayer-desktop/qmpsettingswindow.hpp @@ -38,7 +38,7 @@ class qmpSettingsWindow:public QDialog void on_cbAutoBS_stateChanged(); - private: + private: Ui::qmpSettingsWindow *ui; void settingsUpdate(); static QSettings *settings; -- cgit v1.2.3