summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-09-29 08:07:05 (GMT)
committerKevin Smith <git@kismith.co.uk>2014-10-17 20:11:30 (GMT)
commit38b0cb785fea8eae5e48fae56440695fdfd10ee1 (patch)
tree78bb8ce9a6bcbc397805bcd433b96b3b23994f09 /Swift/QtUI/QtNameWidget.cpp
parent1722d220533a78e8b2acbcd571631960656e78f8 (diff)
downloadswift-38b0cb785fea8eae5e48fae56440695fdfd10ee1.zip
swift-38b0cb785fea8eae5e48fae56440695fdfd10ee1.tar.bz2
Disable online only actions when offline.
Disabling action, menu items and drag 'n' drop which require an online connection when the user is offline. Test-Information: Checked by going offline and checking the relevant actions and menu items. Change-Id: Iacfa2c9f815d3b9bbad9ca4c2d0d04f95ce9a9e4
Diffstat (limited to 'Swift/QtUI/QtNameWidget.cpp')
-rw-r--r--Swift/QtUI/QtNameWidget.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/Swift/QtUI/QtNameWidget.cpp b/Swift/QtUI/QtNameWidget.cpp
index 08e32f5..c172caa 100644
--- a/Swift/QtUI/QtNameWidget.cpp
+++ b/Swift/QtUI/QtNameWidget.cpp
@@ -1,8 +1,8 @@
/*
- * Copyright (c) 2010-2012 Remko Tronçon
+ * Copyright (c) 2010-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "QtNameWidget.h"
@@ -14,13 +14,13 @@
#include <Swift/QtUI/QtElidingLabel.h>
#include <Swift/QtUI/QtSettingsProvider.h>
#include <Swift/QtUI/QtUISettingConstants.h>
namespace Swift {
-QtNameWidget::QtNameWidget(SettingsProvider* settings, QWidget *parent) : QWidget(parent), settings(settings) {
+QtNameWidget::QtNameWidget(SettingsProvider* settings, QWidget *parent) : QWidget(parent), settings(settings), isOnline_(false) {
QHBoxLayout* mainLayout = new QHBoxLayout(this);
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
mode = settings->getSetting(QtUISettingConstants::SHOW_NICK_IN_ROSTER_HEADER) ? ShowNick : ShowJID;
@@ -38,12 +38,16 @@ void QtNameWidget::setNick(const QString& nick) {
void QtNameWidget::setJID(const QString& jid) {
this->jid = jid;
updateText();
}
+void QtNameWidget::setOnline(const bool isOnline) {
+ isOnline_ = isOnline;
+}
+
void QtNameWidget::mousePressEvent(QMouseEvent* event) {
QMenu menu;
bool hasNick = !nick.isEmpty();
QAction* showAsNick = new QAction(hasNick ? tr("Show Nickname") : tr("(No Nickname Set)"), this);
showAsNick->setCheckable(true);
@@ -59,12 +63,13 @@ void QtNameWidget::mousePressEvent(QMouseEvent* event) {
showAsJID->setChecked(true);
}
menu.addAction(showAsJID);
QAction* editProfile = new QAction(tr("Edit Profile"), this);
menu.addAction(editProfile);
+ editProfile->setEnabled(isOnline_);
QAction* result = menu.exec(event->globalPos());
if (result == showAsJID) {
mode = ShowJID;
}
else if (result == showAsNick) {