From b0d6e4fcf33d21b24d2e9bbf7c5abf2065f0a4b3 Mon Sep 17 00:00:00 2001 From: manuel Date: Sat, 9 Apr 2011 15:28:00 +0200 Subject: move sound toggle icon to mainwidget --- pacman-c++/client.cpp | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) (limited to 'pacman-c++/client.cpp') 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 @@ #include "client.h" -#include "audioplayer.h" -#include "clicklabel.h" Client::Client() { - QAction *quitAction = new QAction("E&xit", this); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - QMenu *fileMenu = menuBar()->addMenu("File"); - fileMenu->addAction(quitAction); - - ClickLabel *toggleSound = new ClickLabel("Toggle Sound", this); - toggleSound->setFixedWidth(20); - toggleSound->setFixedHeight(16); - toggleSound->setAlignment(Qt::AlignBottom); - bool sound = AudioPlayer::self()->isWorking(); - QImage img(sound ? ":/soundon" : ":/soundoff"); - img.setColor(1, menuBar()->palette().color(sound ? QPalette::Active : QPalette::Disabled, - QPalette::ButtonText).rgba()); - toggleSound->setPixmap(QPixmap::fromImage(img)); - if (sound) - connect(toggleSound, SIGNAL(clicked()), this, SLOT(toggleSound())); - - menuBar()->setCornerWidget(toggleSound); - - m_mainWidget = new MainWidget(); + m_mainWidget = new MainWidget(this, this); setCentralWidget(m_mainWidget); } -void Client::toggleSound() const -{ - if (!AudioPlayer::self()->isWorking()) - return; - - bool muted = AudioPlayer::self()->isMuted(); - QImage img(muted ? ":/soundon" : ":/soundoff"); - img.setColor(1, menuBar()->palette().color(muted ? QPalette::Active : QPalette::Disabled, - QPalette::ButtonText).rgba()); - ClickLabel *tmp = qobject_cast(menuBar()->cornerWidget()); - tmp->setPixmap(QPixmap::fromImage(img)); - AudioPlayer::self()->setMuted(!muted); -} - int main(int argc, char ** argv) { QApplication app(argc, argv); -- cgit v1.2.3