diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-11-12 23:43:20 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-11-12 23:52:53 (GMT) |
commit | 759dfaf9283ed07696a060a5ca92bef2699b1b65 (patch) | |
tree | 8e96fe7e60ad6da1e5ac20aae26a3366d4923e44 /Swift/QtUI | |
parent | 040207607ac43f1a03a8b030edb46538a12ca00e (diff) | |
download | swift-759dfaf9283ed07696a060a5ca92bef2699b1b65.zip swift-759dfaf9283ed07696a060a5ca92bef2699b1b65.tar.bz2 |
Persist toggle show offline.
Resolves: #689
Release-Notes: The toggle state for showing offline contacts will now persist between restarts.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 29 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindow.h | 3 |
2 files changed, 26 insertions, 6 deletions
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index f737e30..710ef61 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -7,6 +7,7 @@ #include "QtMainWindow.h" #include <boost/optional.hpp> +#include <boost/bind.hpp> #include <QBoxLayout> #include <QComboBox> @@ -26,6 +27,7 @@ #include "Swift/Controllers/UIEvents/AddContactUIEvent.h" #include "Swift/Controllers/UIEvents/RequestMUCSearchUIEvent.h" #include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h" +#include "Swift/Controllers/UIEvents/ToggleShowOfflineUIEvent.h" namespace Swift { @@ -71,11 +73,11 @@ QtMainWindow::QtMainWindow(UIEventStream* uiEventStream) : QWidget(), MainWindow QMenu* viewMenu = new QMenu(tr("View"), this); menus_.push_back(viewMenu); - QAction* showOfflineAction = new QAction("Show offline contacts", this); - showOfflineAction->setCheckable(true); - showOfflineAction->setChecked(false); - connect(showOfflineAction, SIGNAL(toggled(bool)), SLOT(handleShowOfflineToggled(bool))); - viewMenu->addAction(showOfflineAction); + showOfflineAction_ = new QAction("Show offline contacts", this); + showOfflineAction_->setCheckable(true); + showOfflineAction_->setChecked(false); + connect(showOfflineAction_, SIGNAL(toggled(bool)), SLOT(handleShowOfflineToggled(bool))); + viewMenu->addAction(showOfflineAction_); QMenu* actionsMenu = new QMenu(tr("Actions"), this); menus_.push_back(actionsMenu); @@ -88,9 +90,13 @@ QtMainWindow::QtMainWindow(UIEventStream* uiEventStream) : QWidget(), MainWindow QAction* signOutAction = new QAction("Sign Out", this); connect(signOutAction, SIGNAL(triggered()), SLOT(handleSignOutAction())); actionsMenu->addAction(signOutAction); + + lastOfflineState_ = false; + uiEventStream_->onUIEvent.connect(boost::bind(&QtMainWindow::handleUIEvent, this, _1)); } QtMainWindow::~QtMainWindow() { + uiEventStream_->onUIEvent.disconnect(boost::bind(&QtMainWindow::handleUIEvent, this, _1)); delete contextMenu_; } @@ -141,8 +147,19 @@ void QtMainWindow::handleStatusChanged(StatusShow::Type showType, const QString onChangeStatusRequest(showType, Q2PSTRING(statusMessage)); } +void QtMainWindow::handleUIEvent(boost::shared_ptr<UIEvent> event) { + boost::shared_ptr<ToggleShowOfflineUIEvent> toggleEvent = boost::dynamic_pointer_cast<ToggleShowOfflineUIEvent>(event); + if (toggleEvent) { + handleShowOfflineToggled(toggleEvent->getShow()); + } +} + void QtMainWindow::handleShowOfflineToggled(bool state) { - onShowOfflineToggled(state); + if (state != lastOfflineState_) { + lastOfflineState_ = state; + showOfflineAction_->setChecked(state); + uiEventStream_->onUIEvent(boost::shared_ptr<UIEvent>(new ToggleShowOfflineUIEvent(state))); + } } void QtMainWindow::setMyName(const String& name) { diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h index c92c62a..9e200b1 100644 --- a/Swift/QtUI/QtMainWindow.h +++ b/Swift/QtUI/QtMainWindow.h @@ -48,6 +48,7 @@ namespace Swift { void setRosterModel(Roster* roster); private slots: void handleStatusChanged(StatusShow::Type showType, const QString &statusMessage); + void handleUIEvent(boost::shared_ptr<UIEvent> event); void handleShowOfflineToggled(bool); void handleJoinMUCAction(); void handleSignOutAction(); @@ -59,6 +60,7 @@ namespace Swift { QtTreeWidget* treeWidget_; QtRosterHeader* meView_; QAction* addAction_; + QAction* showOfflineAction_; QtTabWidget* tabs_; QWidget* contactsTabWidget_; QWidget* eventsTabWidget_; @@ -66,6 +68,7 @@ namespace Swift { QtChatListWindow* chatListWindow_; UIEventStream* uiEventStream_; QtRosterContextMenu* contextMenu_; + bool lastOfflineState_; }; } |