summaryrefslogtreecommitdiffstats
path: root/pacman-c++/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++/client.cpp')
-rw-r--r--pacman-c++/client.cpp38
1 files changed, 1 insertions, 37 deletions
diff --git a/pacman-c++/client.cpp b/pacman-c++/client.cpp
index 7827591..2135636 100644
--- a/pacman-c++/client.cpp
+++ b/pacman-c++/client.cpp
@@ -1,47 +1,11 @@
1#include "client.h" 1#include "client.h"
2#include "audioplayer.h"
3#include "clicklabel.h"
4 2
5Client::Client() 3Client::Client()
6{ 4{
7 QAction *quitAction = new QAction("E&xit", this); 5 m_mainWidget = new MainWidget(this, this);
8 connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
9
10 QMenu *fileMenu = menuBar()->addMenu("File");
11 fileMenu->addAction(quitAction);
12
13 ClickLabel *toggleSound = new ClickLabel("Toggle Sound", this);
14 toggleSound->setFixedWidth(20);
15 toggleSound->setFixedHeight(16);
16 toggleSound->setAlignment(Qt::AlignBottom);
17 bool sound = AudioPlayer::self()->isWorking();
18 QImage img(sound ? ":/soundon" : ":/soundoff");
19 img.setColor(1, menuBar()->palette().color(sound ? QPalette::Active : QPalette::Disabled,
20 QPalette::ButtonText).rgba());
21 toggleSound->setPixmap(QPixmap::fromImage(img));
22 if (sound)
23 connect(toggleSound, SIGNAL(clicked()), this, SLOT(toggleSound()));
24
25 menuBar()->setCornerWidget(toggleSound);
26
27 m_mainWidget = new MainWidget();
28 setCentralWidget(m_mainWidget); 6 setCentralWidget(m_mainWidget);
29} 7}
30 8
31void Client::toggleSound() const
32{
33 if (!AudioPlayer::self()->isWorking())
34 return;
35
36 bool muted = AudioPlayer::self()->isMuted();
37 QImage img(muted ? ":/soundon" : ":/soundoff");
38 img.setColor(1, menuBar()->palette().color(muted ? QPalette::Active : QPalette::Disabled,
39 QPalette::ButtonText).rgba());
40 ClickLabel *tmp = qobject_cast<ClickLabel *>(menuBar()->cornerWidget());
41 tmp->setPixmap(QPixmap::fromImage(img));
42 AudioPlayer::self()->setMuted(!muted);
43}
44
45int main(int argc, char ** argv) 9int main(int argc, char ** argv)
46{ 10{
47 QApplication app(argc, argv); 11 QApplication app(argc, argv);