summaryrefslogtreecommitdiffstats
path: root/pacman-c++/client.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-04-09 15:28:00 +0200
committermanuel <manuel@mausz.at>2011-04-09 15:28:00 +0200
commitb0d6e4fcf33d21b24d2e9bbf7c5abf2065f0a4b3 (patch)
treefecad081d78a75463be914f2a67ae80c9bc9da7c /pacman-c++/client.cpp
parent13199a5212e210206b8d6b938f7c1683760cf226 (diff)
downloadfoop-b0d6e4fcf33d21b24d2e9bbf7c5abf2065f0a4b3.tar.gz
foop-b0d6e4fcf33d21b24d2e9bbf7c5abf2065f0a4b3.tar.bz2
foop-b0d6e4fcf33d21b24d2e9bbf7c5abf2065f0a4b3.zip
move sound toggle icon to mainwidget
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);