From 4c8c448a6de8b33e4a64271d6b2d0d25e00043ab Mon Sep 17 00:00:00 2001 From: manuel Date: Sat, 9 Apr 2011 16:01:36 +0200 Subject: store sound muted in local settings --- pacman-c++/mainwidget.cpp | 46 ++-------------------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) (limited to 'pacman-c++/mainwidget.cpp') diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp index 02ece0f..06a0b9c 100644 --- a/pacman-c++/mainwidget.cpp +++ b/pacman-c++/mainwidget.cpp @@ -1,15 +1,12 @@ #include "mainwidget.h" #include "actor.h" #include "block.h" -#include "bonuspoint.h" -#include "point.h" #include "constants.h" #include "audioplayer.h" -#include "clicklabel.h" #include "util.h" -MainWidget::MainWidget(QMainWindow *window, QWidget *parent) - : SceneHolder(parent), m_mainwindow(window), m_currentKey(0), m_running(false) +MainWidget::MainWidget(QWidget *parent) + : SceneHolder(parent), m_currentKey(0), m_running(false) { createGui(); updateMap(Util::createDummyMap()); @@ -26,7 +23,6 @@ MainWidget::MainWidget(QMainWindow *window, QWidget *parent) void MainWidget::createGui() { - createMenu(); setFocusPolicy(Qt::StrongFocus); QVBoxLayout *layout = new QVBoxLayout(this); @@ -68,29 +64,6 @@ void MainWidget::createGui() setLayout(layout); } -void MainWidget::createMenu() -{ - QAction *quitAction = new QAction("E&xit", this); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - QMenu *fileMenu = m_mainwindow->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, m_mainwindow->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())); - - m_mainwindow->menuBar()->setCornerWidget(toggleSound); -} - void MainWidget::updateScore() { QMapIterator i(m_actors); @@ -213,18 +186,3 @@ void MainWidget::playerScoreClicked() tmp->setChecked(true); return; } - -void MainWidget::toggleSound() const -{ - if (!AudioPlayer::self()->isWorking()) - return; - - bool muted = AudioPlayer::self()->isMuted(); - QImage img(muted ? ":/soundon" : ":/soundoff"); - img.setColor(1, m_mainwindow->menuBar()->palette().color( - muted ? QPalette::Active : QPalette::Disabled, - QPalette::ButtonText).rgba()); - ClickLabel *tmp = qobject_cast(m_mainwindow->menuBar()->cornerWidget()); - tmp->setPixmap(QPixmap::fromImage(img)); - AudioPlayer::self()->setMuted(!muted); -} -- cgit v1.2.3