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
|
#include "mediaoverrider.h"
MediaOverrider::MediaOverrider(int argc, char **argv, QObject *parent):
QObject(parent), app(argc, argv)
{
// MTheme::loadCSS("MediaOverrider.css");
window = new MApplicationWindow;
page = new MApplicationPage;
layout = new MLayout;
policy = new MGridLayoutPolicy(layout);
policy->setSpacing(10);
page->setTitle("Resource Overrider");
MLabel * label = new MLabel("Press the toggle buttons to change overrides");
policy->addItem(label, 0, 1);
label->setObjectName("label");
label->setAlignment(Qt::AlignCenter);
muteButton = new MButton(page->centralWidget());
muteButton->setText("Mute");
muteButton->setViewType(MButton::toggleType);
muteButton->setCheckable(true);
policy->addItem(muteButton, 1, 0);
muteButton->setObjectName("button");
privacyButton = new MButton(page->centralWidget());
privacyButton->setText("Privacy");
privacyButton->setViewType(MButton::toggleType);
privacyButton->setCheckable(true);
policy->addItem(privacyButton, 1, 1);
privacyButton->setObjectName("button");
btButton = new MButton(page->centralWidget());
btButton->setText("BT");
btButton->setViewType(MButton::toggleType);
btButton->setCheckable(true);
policy->addItem(btButton, 1, 2);
btButton->setObjectName("button");
page->centralWidget()->setLayout(layout);
mute = ResourcePolicy::createMute(this);
privacyOverride = ResourcePolicy::createPrivacyOverride(this);
btOverride = ResourcePolicy::createBluetoothOVerride(this);
QObject::connect(mute, SIGNAL(changed(bool)), this, SLOT(handleMuteChange(bool)));
QObject::connect(muteButton, SIGNAL(toggled(bool)), mute, SLOT(request(bool)));
QObject::connect(privacyOverride, SIGNAL(changed(bool)), this, SLOT(handlePrivacyChange(bool)));
QObject::connect(privacyButton, SIGNAL(toggled(bool)), privacyOverride, SLOT(request(bool)));
QObject::connect(btOverride, SIGNAL(changed(bool)), this, SLOT(handleBtChange(bool)));
QObject::connect(btButton, SIGNAL(toggled(bool)), btOverride, SLOT(request(bool)));
}
MediaOverrider::~MediaOverrider()
{}
int MediaOverrider::run()
{
page->appear();
window->show();
return app.exec();
}
void MediaOverrider::handleMuteChange(bool newState)
{
muteButton->setChecked(newState);
}
void MediaOverrider::handlePrivacyChange(bool newState)
{
privacyButton->setChecked(newState);
}
void MediaOverrider::handleBtChange(bool newState)
{
btButton->setChecked(newState);
}
|