aboutsummaryrefslogblamecommitdiff
path: root/qmidiplayer-desktop/qmpmainwindow.hpp
blob: 0b835e7b92fc14ad3b73711eb013dfb373f87a49 (plain) (tree)
1
2
3
4
5
6
7
8
9





                       
                     

                          
                      

                  
                  

                       

                 
                                  
                        
                             
                                

                            
                                
                            
 

                                                                                                                                     



                            

















                                                                              
                                      




                                                            
                            
                                                    
                                                  

                                                            
                                 
                                                        
                                                                         
                                                 
                                                
                                      
                                            
                                       
                                         

                                                     
                                 

                                                                          
                                   



                                              
                                                
                                                 
                                                   
                                         

                                          
                                         
                                             

                                                                                 
                                             

                              
                              
                              
 

                                             

                                                  
                     





                                        
                                                                    
                                           
                                           


                                                         
                                       





                                                      
                                              
 
                                                
                                   
                                   
 
                

                                                                

  
                         
#ifndef QMPMAINWINDOW_H
#define QMPMAINWINDOW_H

#include <QMainWindow>
#include <QTimer>
#include <QCloseEvent>
#include <QMoveEvent>
#include <QDropEvent>
#include <QDragEnterEvent>
#include <QMouseEvent>
#include <QAction>
#include <QMenu>
#include <QSlider>
#include <QPointer>
#include <QApplication>
#include <thread>
#include <chrono>
#include "../core/qmpmidiplay.hpp"
#include "qmpplugin.hpp"
#include "qmpplistwindow.hpp"
#include "qmpchannelswindow.hpp"
#include "qmpefxwindow.hpp"
#include "qmpinfowindow.hpp"
#include "qmpsettingswindow.hpp"
#include "qmphelpwindow.hpp"

#define getThemedIcon(x) (qmpMainWindow::getInstance()->isDarkTheme()?QString(x).insert(QString(x).lastIndexOf('.'),"_i"):QString(x))

namespace Ui {
	class qmpMainWindow;
}

class QClickableSlider:public QSlider
{
	Q_OBJECT
	public:
		explicit QClickableSlider(QWidget *parent=0):QSlider(parent){}
	protected:
		void mouseReleaseEvent(QMouseEvent *e)
		{
			QSlider::mouseReleaseEvent(e);
			if(e->buttons()^Qt::LeftButton)
			{
				double p=e->pos().x()/(double)width();
				setValue(p*(maximum()-minimum())+minimum());
				emit sliderReleased();
			}
		}
};

class qmpMainWindow:public QMainWindow
{
	Q_OBJECT

	public:
		explicit qmpMainWindow(QWidget *parent = 0);
		void init();
		void closeEvent(QCloseEvent *event);
		void moveEvent(QMoveEvent *event);
		void dropEvent(QDropEvent *event);
		void dragEnterEvent(QDragEnterEvent *event);
		~qmpMainWindow();
		CMidiPlayer* getPlayer(){return player;}
		qmpSettingsWindow* getSettingsWindow(){return settingsw;}
		QTimer* getTimer(){return timer;}
		bool isFinalizing(){return fin;}
		QString getFileName();
		void switchTrack(QString s);
		std::string getTitle();
		std::wstring getWTitle();
		uint32_t getPlaybackPercentage();
		void playerSeek(uint32_t percentage);
		int pharseArgs();
		int registerVisualizationIntf(qmpVisualizationIntf* intf);
		void unregisterVisualizationIntf(int handle);
		bool isDarkTheme();

	private slots:
		void on_pbPlayPause_clicked();
		void updateWidgets();
		void on_hsTimer_sliderPressed();
		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 on_pushButton_clicked();

		void on_pbVisualization_clicked();

	public slots:
		void dialogClosed();
		void selectionChanged();

	private:
		Ui::qmpMainWindow *ui;
		QTimer *timer;
		bool playing,stopped,dragging,fin,singleFS,havemidi;
		std::thread *playerTh=NULL;
		std::thread *renderTh=NULL;
		std::chrono::steady_clock::time_point st;
		double offset;
		CMidiPlayer *player;
		qmpPluginManager *pmgr;
		QPointer<qmpPlistWindow> plistw;
		QPointer<qmpChannelsWindow> chnlw;
		QPointer<qmpEfxWindow> efxw;
		QPointer<qmpInfoWindow> infow;
		QPointer<qmpSettingsWindow> settingsw;
		QPointer<qmpHelpWindow> helpw;
		qmpVisualizationIntf* VIs[16];

		QAction *fnA1,*fnA2,*fnA3,*fnA4;
		void onfnChanged();
		void playerSetup();

	private:
		static qmpMainWindow* ref;
	public: static qmpMainWindow* getInstance(){return ref;}
};

#endif // QMPMAINWINDOW_H