aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpmainwindow.hpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2017-02-12 00:29:01 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2017-02-12 00:29:01 +0800
commitd779d32c8c32e0e0c22662046498620b11fa46de (patch)
treeba63a0d33d1fb6a07bca30d74dd72934b9ef69ce /qmidiplayer-desktop/qmpmainwindow.hpp
parentacf466561f17bf0eb6c19ea0467b27f5392aeb36 (diff)
downloadQMidiPlayer-d779d32c8c32e0e0c22662046498620b11fa46de.tar.xz
New functionality API. Port built-in features to the new API.
Start the revamp of the main Window. Credit of the new design goes to @BLumia.
Diffstat (limited to 'qmidiplayer-desktop/qmpmainwindow.hpp')
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.hpp128
1 files changed, 114 insertions, 14 deletions
diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp
index 0b835e7..395b833 100644
--- a/qmidiplayer-desktop/qmpmainwindow.hpp
+++ b/qmidiplayer-desktop/qmpmainwindow.hpp
@@ -10,11 +10,13 @@
#include <QMouseEvent>
#include <QAction>
#include <QMenu>
+#include <QIcon>
#include <QSlider>
#include <QPointer>
#include <QApplication>
#include <thread>
#include <chrono>
+#include <map>
#include "../core/qmpmidiplay.hpp"
#include "qmpplugin.hpp"
#include "qmpplistwindow.hpp"
@@ -25,6 +27,7 @@
#include "qmphelpwindow.hpp"
#define getThemedIcon(x) (qmpMainWindow::getInstance()->isDarkTheme()?QString(x).insert(QString(x).lastIndexOf('.'),"_i"):QString(x))
+#define getThemedIconc(x) ((qmpMainWindow::getInstance()->isDarkTheme()?QString(x).insert(QString(x).lastIndexOf('.'),"_i"):QString(x)).toStdString().c_str())
namespace Ui {
class qmpMainWindow;
@@ -48,6 +51,72 @@ class QClickableSlider:public QSlider
}
};
+class QReflectiveAction:public QAction
+{
+ Q_OBJECT
+ private:
+ std::string reflt;
+ signals:
+ void onClick(std::string s);
+ private slots:
+ void triggerslot(){
+ emit(onClick(reflt));
+ }
+ public:
+ explicit QReflectiveAction(const QIcon& icon,const QString& text,const std::string& ref):
+ QAction(icon,text),reflt(ref){
+ connect(this,SIGNAL(triggered(bool)),this,SLOT(triggerslot()));
+ }
+};
+
+class QReflectivePushButton:public QPushButton
+{
+ Q_OBJECT
+ private:
+ std::string reflt;
+ signals:
+ void onClick(std::string s);
+ private slots:
+ void clickslot(){
+ emit(onClick(reflt));
+ }
+ public:
+ explicit QReflectivePushButton(const QIcon& icon,const QString& text,const std::string& ref):
+ QPushButton(icon,""),reflt(ref){
+ connect(this,SIGNAL(clicked(bool)),this,SLOT(clickslot()));
+ setToolTip(text);
+ }
+};
+
+class qmpFuncPrivate
+{
+ private:
+ qmpFuncBaseIntf* _i;
+ QIcon _icon;
+ std::string des;
+ bool _checkable,checked,visual;
+ QReflectiveAction* asgna;
+ QReflectivePushButton* asgnb;
+ public:
+ qmpFuncPrivate(){}
+ qmpFuncPrivate(qmpFuncBaseIntf* i,std::string _desc,const char* icon,int iconlen,bool checkable,bool _isv);
+ ~qmpFuncPrivate(){asgna=NULL;asgnb=NULL;}
+ qmpFuncBaseIntf* i(){return _i;}
+ void setAssignedControl(QReflectiveAction* a){asgna=a;if(!a)return;asgna->setCheckable(_checkable);asgna->setChecked(checked);}
+ void setAssignedControl(QReflectivePushButton* a){asgnb=a;if(!a)return;asgnb->setCheckable(_checkable);asgnb->setChecked(checked);}
+ const QIcon& icon(){return _icon;}
+ const std::string& desc(){return des;}
+ bool isVisualization(){return visual;}
+ bool isCheckable(){return _checkable;}
+ bool isChecked(){return checked;}
+ void setEnabled(bool e){if(asgna)asgna->setEnabled(e);if(asgnb)asgnb->setEnabled(e);}
+ void setChecked(bool _c){checked=_c;if(asgna)asgna->setChecked(checked);if(asgnb)asgnb->setChecked(checked);}
+};
+
+class qmpRenderFunc;
+class qmpPanicFunc;
+class qmpReloadSynthFunc;
+
class qmpMainWindow:public QMainWindow
{
Q_OBJECT
@@ -71,9 +140,18 @@ class qmpMainWindow:public QMainWindow
uint32_t getPlaybackPercentage();
void playerSeek(uint32_t percentage);
int pharseArgs();
- int registerVisualizationIntf(qmpVisualizationIntf* intf);
- void unregisterVisualizationIntf(int handle);
+ void registerVisualizationIntf(qmpVisualizationIntf* intf,std::string name,std::string desc,const char* icon,int iconlen);
+ void unregisterVisualizationIntf(std::string name);
+ void registerFunctionality(qmpFuncBaseIntf* i,std::string name,std::string desc,const char* icon,int iconlen,bool checkable,bool isv=false);
+ void unregisterFunctionality(std::string name);
+ void setFuncState(std::string name,bool state);
+ void setFuncEnabled(std::string name,bool enable);
bool isDarkTheme();
+ void startRender();
+ void reloadSynth();
+ void setupWidget();
+ std::vector<std::string>& getWidgets(int w);
+ std::map<std::string,qmpFuncPrivate>& getFunc();
private slots:
void on_pbPlayPause_clicked();
@@ -82,22 +160,13 @@ class qmpMainWindow:public QMainWindow
void on_hsTimer_sliderReleased();
void on_vsMasterVol_valueChanged();
void on_pbStop_clicked();
- void on_pbPList_clicked();
void on_pbPrev_clicked();
void on_pbNext_clicked();
- void on_pbChannels_clicked();
- void on_pbEfx_clicked();
void on_lbFileName_customContextMenuRequested(const QPoint &pos);
void on_pbSettings_clicked();
- void onfnA1();
- void onfnA2();
- void onfnA3();
- void onfnA4();
-
+ void funcReflector(std::string reflt);
void on_pushButton_clicked();
- void on_pbVisualization_clicked();
-
public slots:
void dialogClosed();
void selectionChanged();
@@ -118,9 +187,12 @@ class qmpMainWindow:public QMainWindow
QPointer<qmpInfoWindow> infow;
QPointer<qmpSettingsWindow> settingsw;
QPointer<qmpHelpWindow> helpw;
- qmpVisualizationIntf* VIs[16];
+ std::map<std::string,qmpFuncPrivate> mfunc;
+ qmpRenderFunc* renderf;
+ qmpPanicFunc* panicf;
+ qmpReloadSynthFunc* reloadsynf;
+ std::vector<std::string> enabled_buttons,enabled_actions;
- QAction *fnA1,*fnA2,*fnA3,*fnA4;
void onfnChanged();
void playerSetup();
@@ -129,4 +201,32 @@ class qmpMainWindow:public QMainWindow
public: static qmpMainWindow* getInstance(){return ref;}
};
+class qmpRenderFunc:public qmpFuncBaseIntf
+{
+ private:
+ qmpMainWindow *p;
+ public:
+ qmpRenderFunc(qmpMainWindow *par){p=par;}
+ void show(){p->startRender();}
+ void close(){}
+};
+class qmpPanicFunc:public qmpFuncBaseIntf
+{
+ private:
+ qmpMainWindow *p;
+ public:
+ qmpPanicFunc(qmpMainWindow *par){p=par;}
+ void show(){p->getPlayer()->playerPanic();}
+ void close(){}
+};
+class qmpReloadSynthFunc:public qmpFuncBaseIntf
+{
+ private:
+ qmpMainWindow *p;
+ public:
+ qmpReloadSynthFunc(qmpMainWindow *par){p=par;}
+ void show(){p->reloadSynth();}
+ void close(){}
+};
+
#endif // QMPMAINWINDOW_H