-
Notifications
You must be signed in to change notification settings - Fork 0
/
presetwidget.hpp
69 lines (56 loc) · 1.15 KB
/
presetwidget.hpp
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
#ifndef PRESETWIDGET_H
#define PRESETWIDGET_H
#define DEBUG_PRESETS false
#include <QWidget>
#include <QPushButton>
#include <QGridLayout>
#if DEBUG_PRESETS
#include <QDebug>
#endif
class PresetButton : public QPushButton {
Q_OBJECT
public:
PresetButton(int presetNum, QString name, QWidget *parent = nullptr)
: QPushButton(name, parent)
{
m_preset = presetNum;
connect(this, SIGNAL(clicked()), this,
SLOT(emitClickedPreset()));
};
public slots:
void emitClickedPreset() { emit clickedPreset(m_preset); };
signals:
void clickedPreset(int preset);
private:
int m_preset;
};
class PresetWidget : public QWidget {
Q_OBJECT
public:
PresetWidget(QWidget *parent = nullptr);
public slots:
void emitPreset(int preset);
void setRows(int rows)
{
clearLayout();
m_rows = rows;
setupLayout();
};
void setColumns(int columns)
{
clearLayout();
m_columns = columns;
setupLayout();
};
signals:
void presetSet(unsigned short preset);
void presetRecalled(unsigned short preset);
private:
QGridLayout *m_gridLayout;
QPushButton *m_storePosBtn;
int m_rows;
int m_columns;
void setupLayout();
void clearLayout();
};
#endif // PRESETWIDGET_H