diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-04-05 11:01:48 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-04-05 11:01:48 (GMT) |
commit | 348a4f13c5f00a27ad5c7e4f392948de7cc454e3 (patch) | |
tree | 43392423f5939190075d62aaae1478f52571af5c /Swift/QtUI | |
parent | 326cd32e2c9e3ec9bac54f5bb952928680c93749 (diff) | |
download | swift-348a4f13c5f00a27ad5c7e4f392948de7cc454e3.zip swift-348a4f13c5f00a27ad5c7e4f392948de7cc454e3.tar.bz2 |
Persist Sound Toggleness.
Resolves: #192
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtLoginWindow.cpp | 22 | ||||
-rw-r--r-- | Swift/QtUI/QtLoginWindow.h | 4 |
2 files changed, 19 insertions, 7 deletions
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index 4f6b423..ff2a50b 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -1,5 +1,7 @@ #include "QtLoginWindow.h" +#include <boost/bind.hpp> + #include "Swift/Controllers/UIEvents/UIEventStream.h" #include "Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h" #include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h" @@ -117,21 +119,29 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { connect(xmlConsoleAction, SIGNAL(activated()), SLOT(handleShowXMLConsole())); toolsMenu_->addAction(xmlConsoleAction); - QAction* toggleSoundsAction = new QAction(tr("Toggle Sounds"), this); - toggleSoundsAction->setCheckable(true); - toggleSoundsAction->setChecked(true); - connect(toggleSoundsAction, SIGNAL(toggled(bool)), SLOT(handleToggleSounds(bool))); - swiftMenu_->addAction(toggleSoundsAction); + toggleSoundsAction_ = new QAction(tr("Toggle Sounds"), this); + toggleSoundsAction_->setCheckable(true); + toggleSoundsAction_->setChecked(true); + connect(toggleSoundsAction_, SIGNAL(toggled(bool)), SLOT(handleToggleSounds(bool))); + swiftMenu_->addAction(toggleSoundsAction_); QAction* quitAction = new QAction("Quit", this); connect(quitAction, SIGNAL(activated()), SLOT(handleQuit())); swiftMenu_->addAction(quitAction); - + setInitialMenus(); + uiEventStream_->onUIEvent.connect(boost::bind(&QtLoginWindow::handleUIEvent, this, _1)); this->show(); } +void QtLoginWindow::handleUIEvent(boost::shared_ptr<UIEvent> event) { + boost::shared_ptr<ToggleSoundsUIEvent> soundEvent = boost::dynamic_pointer_cast<ToggleSoundsUIEvent>(event); + if (soundEvent) { + toggleSoundsAction_->setChecked(soundEvent->getEnabled()); + } +} + /** * Move and resize the window, but respect minimum sizes. * (Like QWidget::setGeometry, only that will truncate the window diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index 40ea4ec..69327e9 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -10,6 +10,7 @@ #include <QMenuBar> #include "Swift/Controllers/UIInterfaces/LoginWindow.h" +#include "Swift/Controllers/UIEvents/UIEventStream.h" #include "Swift/Controllers/MainWindow.h" #include "QtAboutWidget.h" @@ -18,7 +19,6 @@ class QToolButton; class QComboBox; namespace Swift { - class UIEventStream; class QtLoginWindow : public QMainWindow, public LoginWindow { Q_OBJECT public: @@ -45,6 +45,7 @@ namespace Swift { void handleUsernameTextChanged(); void resizeEvent(QResizeEvent* event); void moveEvent(QMoveEvent* event); + void handleUIEvent(boost::shared_ptr<UIEvent> event); private: void setInitialMenus(); @@ -62,6 +63,7 @@ namespace Swift { QMenuBar* menuBar_; QMenu* swiftMenu_; QMenu* toolsMenu_; + QAction* toggleSoundsAction_; UIEventStream* uiEventStream_; QPointer<QtAboutWidget> aboutDialog_; }; |