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/QtRosterHeader.cpp
parent1722d220533a78e8b2acbcd571631960656e78f8 (diff)
downloadswift-contrib-38b0cb785fea8eae5e48fae56440695fdfd10ee1.zip
swift-contrib-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/QtRosterHeader.cpp')
-rw-r--r--Swift/QtUI/QtRosterHeader.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Swift/QtUI/QtRosterHeader.cpp b/Swift/QtUI/QtRosterHeader.cpp
index 69a0ef6..d5029ad 100644
--- a/Swift/QtUI/QtRosterHeader.cpp
+++ b/Swift/QtUI/QtRosterHeader.cpp
@@ -50,70 +50,78 @@ QtRosterHeader::QtRosterHeader(SettingsProvider* settings, StatusCache* statusCa
QHBoxLayout* nameAndSecurityLayout = new QHBoxLayout();
nameAndSecurityLayout->setContentsMargins(4,0,0,0);
nameWidget_ = new QtNameWidget(settings, this);
connect(nameWidget_, SIGNAL(onChangeNickRequest()), this, SIGNAL(onEditProfileRequest()));
nameAndSecurityLayout->addWidget(nameWidget_);
securityInfoButton_ = new QToolButton(this);
securityInfoButton_->setStyleSheet("QToolButton { border: none; } QToolButton:hover { border: 1px solid #bebebe; } QToolButton:pressed { border: 1px solid #757575; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #777777, stop: 1 #d4d4d4);}");
//securityInfoButton_->setAutoRaise(true);
securityInfoButton_->setIcon(QIcon(":/icons/lock.png"));
securityInfoButton_->setToolTip(tr("Connection is secured"));
connect(securityInfoButton_, SIGNAL(clicked()), this, SIGNAL(onShowCertificateInfo()));
nameAndSecurityLayout->addWidget(securityInfoButton_);
rightLayout->addLayout(nameAndSecurityLayout);
statusWidget_ = new QtStatusWidget(statusCache, this);
connect(statusWidget_, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&)), this, SLOT(handleChangeStatusRequest(StatusShow::Type, const QString&)));
rightLayout->addWidget(statusWidget_);
show();
}
void QtRosterHeader::handleChangeStatusRequest(StatusShow::Type type, const QString& text) {
emit onChangeStatusRequest(type, text);
}
void QtRosterHeader::setStatusText(const QString& statusMessage) {
statusWidget_->setStatusText(statusMessage);
}
void QtRosterHeader::setStatusType(StatusShow::Type type) {
statusWidget_->setStatusType(type);
+ if (type == StatusShow::None) {
+ nameWidget_->setOnline(false);
+ disconnect(avatarLabel_, SIGNAL(clicked()), this, SIGNAL(onEditProfileRequest()));
+ }
+ else {
+ nameWidget_->setOnline(true);
+ connect(avatarLabel_, SIGNAL(clicked()), this, SIGNAL(onEditProfileRequest()), Qt::UniqueConnection);
+ }
}
void QtRosterHeader::setConnecting() {
statusWidget_->setConnecting();
}
void QtRosterHeader::setStreamEncryptionStatus(bool tlsInPlace) {
securityInfoButton_->setVisible(tlsInPlace);
}
bool QtRosterHeader::event(QEvent* event) {
if (event->type() == QEvent::ToolTip) {
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
QtScaledAvatarCache scaledAvatarCache(avatarSize_);
QString text = RosterTooltip::buildDetailedTooltip(contact_.get(), &scaledAvatarCache);
QToolTip::showText(helpEvent->globalPos(), text);
return true;
}
return QWidget::event(event);
}
void QtRosterHeader::setAvatar(const QString& path) {
QString scaledAvatarPath = QtScaledAvatarCache(avatarSize_).getScaledAvatarPath(path);
QPixmap avatar;
if (QFileInfo(scaledAvatarPath).exists()) {
avatar.load(scaledAvatarPath);
}
else {
avatar = QPixmap(":/icons/avatar.png").scaled(avatarSize_, avatarSize_, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
avatarLabel_->setPixmap(avatar);
}
void QtRosterHeader::setNick(const QString& nick) {
nameWidget_->setNick(nick);