-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcombo_switchaction.cpp
61 lines (52 loc) · 2.04 KB
/
combo_switchaction.cpp
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
#include "combo_switchaction.h"
SwitchActionComboBox::SwitchActionComboBox(QWidget *parent) : QComboBox(parent)
{
// Connect to my custom signal
connect(this, SIGNAL(editTextChanged(QString)), this, SLOT(SwitchActionChangedSlot(QString)));
connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(SwitchActionChangedSlot(QString)));
}
void SwitchActionComboBox::setActions(switch_function sf)
{
// First clear all prior items
this->clear();
// Different actions are available for different switch functions
switch (sf)
{
case SF_USER:
this->insertItem(0, "Play", ACTION_ONSTART);
this->insertItem(1, "Repeat", ACTION_REPEATTOGGLE);
this->insertItem(2, "Stop", ACTION_OFFSTOP);
break;
case SF_SOUNDBANK:
this->insertItem(0, "Play/Stop", ACTION_ONSTART);
this->insertItem(1, "Next", ACTION_PLAYNEXT);
this->insertItem(2, "Previous", ACTION_PLAYPREV);
this->insertItem(3, "Random", ACTION_PLAYRANDOM);
break;
case SF_MG:
this->insertItem(0, "Start", ACTION_ONSTART);
this->insertItem(1, "Stop", ACTION_OFFSTOP);
this->insertItem(2, "Toggle", ACTION_REPEATTOGGLE);
break;
case SF_LIGHT:
this->insertItem(0, "On", ACTION_ONSTART);
this->insertItem(1, "Off", ACTION_OFFSTOP);
this->insertItem(2, "Toggle", ACTION_REPEATTOGGLE);
this->insertItem(3, "Start Blink", ACTION_STARTBLINK);
this->insertItem(4, "Toggle Blink", ACTION_TOGGLEBLINK);
this->insertItem(5, "Flash", ACTION_FLASH);
break;
default:
return;
}
}
void SwitchActionComboBox::SwitchActionChangedSlot(const QString &)
{
// Send out custom signal with a pointer to this box
emit SwitchActionChanged(this);
}
// This returns the current actual sound action
switch_action SwitchActionComboBox::getCurrentSwitchAction(void)
{
return switch_action(this->currentData().toInt());
}