aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpchannelswindow.hpp
blob: ab3227f53a1da893d84374205a83efefb09d2db3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef QMPCHANNELSWINDOW_H
#define QMPCHANNELSWINDOW_H

#include <QLabel>
#include <QPushButton>
#include <QWidget>
#include <QComboBox>
#include <QShowEvent>
#include <QCloseEvent>
#include <QMoveEvent>
#include <QAbstractTableModel>
#include <QStyledItemDelegate>
#include "qmppresetselect.hpp"
#include "qmpchanneleditor.hpp"
#include "../core/qmpmidiplay.hpp"
#include "../core/qmpmidioutrtmidi.hpp"

namespace Ui {
	class qmpChannelsWindow;
}

class QDCPushButton:public QPushButton
{
	Q_OBJECT
	private:
		int id;
	protected:
		void mousePressEvent(QMouseEvent *event){QPushButton::mousePressEvent(event);emit onClick(id);}
	public:
		QDCPushButton(QString s):QPushButton(s){id=-1;}
		void setID(int _id){id=_id;}
		QSize sizeHint()const{return QSize();}
	signals:
		void onClick(int id);
};

class QDCComboBox:public QComboBox
{
	Q_OBJECT
	private:
		int id;
	public:
		QDCComboBox():QComboBox(){id=-1;connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(indexChangedSlot(int)));}
		void setID(int _id){id=_id;}
		QSize sizeHint()const{return QSize();}
		QSize minimumSizeHint()const{return QSize();}
	signals:
		void onChange(int id,int idx);
	public slots:
		void indexChangedSlot(int idx){emit(onChange(id,idx));}
};

class qmpChannelsWindow;

class qmpChannelFunc:public qmpFuncBaseIntf
{
	private:
		qmpChannelsWindow *p;
	public:
		qmpChannelFunc(qmpChannelsWindow *par);
		void show();
		void close();
};

class qmpChannelsModel:public QAbstractTableModel
{
	Q_OBJECT
	public:
		explicit qmpChannelsModel(QObject*parent=nullptr);
		int columnCount(const QModelIndex&parent=QModelIndex())const override;
		int rowCount(const QModelIndex&parent=QModelIndex())const override;
		QModelIndex parent(const QModelIndex&child)const override;
		QVariant data(const QModelIndex&index,int role=Qt::ItemDataRole::DisplayRole)const override;
		QVariant headerData(int section,Qt::Orientation orientation,int role=Qt::ItemDataRole::DisplayRole)const override;
		Qt::ItemFlags flags(const QModelIndex&idx)const override;
	public slots:
		void updateChannelActivity();
		void channelMSClicked(const QModelIndex&idx);
		void channelMSClearAll(int type);
	private:
		int evh;
		bool updatequeued;
		bool mute[16],solo[16];
};

class qmpDeviceItemDelegate:public QStyledItemDelegate
{
	Q_OBJECT
	public:
		explicit qmpDeviceItemDelegate(QWidget*parent=nullptr);
		void paint(QPainter*painter,const QStyleOptionViewItem&option,const QModelIndex&index)const override;
		QSize sizeHint(const QStyleOptionViewItem&option,const QModelIndex&index)const override;
		QWidget* createEditor(QWidget*parent,const QStyleOptionViewItem&option,const QModelIndex&index)const override;
		void setEditorData(QWidget*editor,const QModelIndex&index)const override;
		void setModelData(QWidget*editor,QAbstractItemModel*model,const QModelIndex&index)const override;
		void updateEditorGeometry(QWidget*editor,const QStyleOptionViewItem&option,const QModelIndex&index)const override;
	private:
		QWidget *par;
};

class qmpChannelsWindow:public QWidget
{
	Q_OBJECT

	public:
		explicit qmpChannelsWindow(QWidget *parent=nullptr);
		~qmpChannelsWindow();
		void showEvent(QShowEvent *event);
		void closeEvent(QCloseEvent *event);
	public slots:
		void showChannelEditorWindow(int chid);
		void on_pbUnmute_clicked();
		void on_pbUnsolo_clicked();

	signals:
		void noteOn();

	private:
		Ui::qmpChannelsWindow *ui;
		qmpPresetSelector *pselectw;
		qmpChannelEditor *ceditw;
		qmpChannelsModel *chmodel;
		QIcon *cha,*chi;
		qmpChannelFunc *chnlf;
		int eh;
};

#endif // QMPCHANNELSWINDOW_H