summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-06-27 16:06:49 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-07-07 10:49:04 (GMT)
commit14fd8e4363241e04b20da85dfc61e5f315e9b28d (patch)
treeb7a5450f73e98dd64c0367702575bb3f52e44ab4 /Swift/QtUI
parent9179b54ac93ddc88765c3cd984916d7ffd130d20 (diff)
downloadswift-contrib-14fd8e4363241e04b20da85dfc61e5f315e9b28d.zip
swift-contrib-14fd8e4363241e04b20da85dfc61e5f315e9b28d.tar.bz2
Show own tooltip when hovering over roster header.
Test-Information: Made combinations of presence/vcard/avatar changes and verified that the information in the tooltip was synchronized. Connect two clients and verify that the tooltip presence text reflects the local client presence only. Change-Id: I92af0f58f7045f3a15f2fae2f9cbc6e24a066923
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtMainWindow.cpp4
-rw-r--r--Swift/QtUI/QtMainWindow.h1
-rw-r--r--Swift/QtUI/QtRosterHeader.cpp28
-rw-r--r--Swift/QtUI/QtRosterHeader.h8
4 files changed, 35 insertions, 6 deletions
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp
index 1acc519..31a8234 100644
--- a/Swift/QtUI/QtMainWindow.cpp
+++ b/Swift/QtUI/QtMainWindow.cpp
@@ -308,70 +308,74 @@ void QtMainWindow::handleSettingChanged(const std::string& settingPath) {
void QtMainWindow::handleCompactRosterToggled(bool state) {
settings_->storeSetting(QtUISettingConstants::COMPACT_ROSTER, state);
compactRosterAction_->setChecked(settings_->getSetting(QtUISettingConstants::COMPACT_ROSTER));
}
void QtMainWindow::handleShowOfflineToggled(bool state) {
settings_->storeSetting(SettingConstants::SHOW_OFFLINE, state);
showOfflineAction_->setChecked(settings_->getSetting(SettingConstants::SHOW_OFFLINE));
}
void QtMainWindow::handleShowEmoticonsToggled(bool state) {
settings_->storeSetting(QtUISettingConstants::SHOW_EMOTICONS, state);
showEmoticonsAction_->setChecked(settings_->getSetting(QtUISettingConstants::SHOW_EMOTICONS));
}
void QtMainWindow::setMyNick(const std::string& nick) {
meView_->setNick(P2QSTRING(nick));
}
void QtMainWindow::setMyJID(const JID& jid) {
meView_->setJID(P2QSTRING(jid.toBare().toString()));
}
void QtMainWindow::setMyAvatarPath(const std::string& path) {
meView_->setAvatar(P2QSTRING(path));
}
void QtMainWindow::setMyStatusText(const std::string& status) {
meView_->setStatusText(P2QSTRING(status));
}
void QtMainWindow::setMyStatusType(StatusShow::Type type) {
meView_->setStatusType(type);
}
+void QtMainWindow::setMyContactRosterItem(boost::shared_ptr<ContactRosterItem> contact) {
+ meView_->setContactRosterItem(contact);
+}
+
void QtMainWindow::setConnecting() {
meView_->setConnecting();
}
void QtMainWindow::setStreamEncryptionStatus(bool tlsInPlaceAndValid) {
meView_->setStreamEncryptionStatus(tlsInPlaceAndValid);
}
void QtMainWindow::openCertificateDialog(const std::vector<Certificate::ref>& chain) {
openCertificateDialog(chain, this);
}
void QtMainWindow::openCertificateDialog(const std::vector<Certificate::ref>& chain, QWidget* parent) {
#if defined(SWIFTEN_PLATFORM_MACOSX)
CocoaUIHelpers::displayCertificateChainAsSheet(parent, chain);
#elif defined(SWIFTEN_PLATFORM_WINDOWS)
WinUIHelpers::displayCertificateChainAsSheet(parent, chain);
#else
QtCertificateViewerDialog::displayCertificateChainAsSheet(parent, chain);
#endif
}
void QtMainWindow::handleAdHocActionTriggered(bool /*checked*/) {
QAction* action = qobject_cast<QAction*>(sender());
assert(action);
DiscoItems::Item command = serverAdHocCommands_[serverAdHocCommandActions_.indexOf(action)];
uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestAdHocUIEvent(command)));
}
void QtMainWindow::setAvailableAdHocCommands(const std::vector<DiscoItems::Item>& commands) {
serverAdHocCommands_ = commands;
foreach (QAction* action, serverAdHocCommandActions_) {
delete action;
}
serverAdHocMenu_->clear();
diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h
index c489a9e..f1f6900 100644
--- a/Swift/QtUI/QtMainWindow.h
+++ b/Swift/QtUI/QtMainWindow.h
@@ -15,70 +15,71 @@
#include <Swift/Controllers/UIInterfaces/MainWindow.h>
#include <Swift/QtUI/QtRosterHeader.h>
#include <Swift/QtUI/EventViewer/QtEventWindow.h>
#include <Swift/QtUI/ChatList/QtChatListWindow.h>
#include <Swift/QtUI/QtLoginWindow.h>
class QComboBox;
class QLineEdit;
class QPushButton;
class QToolBar;
class QAction;
class QMenu;
class QTabWidget;
namespace Swift {
class QtRosterWidget;
class TreeWidget;
class UIEventStream;
class QtTabWidget;
class SettingsProvider;
class QtUIPreferences;
class StatusCache;
class QtMainWindow : public QWidget, public MainWindow {
Q_OBJECT
public:
QtMainWindow(SettingsProvider*, UIEventStream* eventStream, QtLoginWindow::QtMenus loginMenus, StatusCache* statusCache, bool emoticonsExist);
virtual ~QtMainWindow();
std::vector<QMenu*> getMenus() {return menus_;}
void setMyNick(const std::string& name);
void setMyJID(const JID& jid);
void setMyAvatarPath(const std::string& path);
void setMyStatusText(const std::string& status);
void setMyStatusType(StatusShow::Type type);
+ void setMyContactRosterItem(boost::shared_ptr<ContactRosterItem> contact);
void setConnecting();
void setStreamEncryptionStatus(bool tlsInPlaceAndValid);
void openCertificateDialog(const std::vector<Certificate::ref>& chain);
static void openCertificateDialog(const std::vector<Certificate::ref>& chain, QWidget* parent);
QtEventWindow* getEventWindow();
QtChatListWindow* getChatListWindow();
void setRosterModel(Roster* roster);
void setAvailableAdHocCommands(const std::vector<DiscoItems::Item>& commands);
void setBlockingCommandAvailable(bool isAvailable);
private slots:
void handleStatusChanged(StatusShow::Type showType, const QString &statusMessage);
void handleSettingChanged(const std::string& settingPath);
void handleCompactRosterToggled(bool);
void handleShowOfflineToggled(bool);
void handleShowEmoticonsToggled(bool);
void handleJoinMUCAction();
void handleViewLogsAction();
void handleSignOutAction();
void handleEditProfileAction();
void handleAddUserActionTriggered(bool checked);
void handleChatUserActionTriggered(bool checked);
void handleAdHocActionTriggered(bool checked);
void handleEventCountUpdated(int count);
void handleChatCountUpdated(int count);
void handleEditProfileRequest();
void handleTabChanged(int index);
void handleToggleRequestDeliveryReceipts(bool enabled);
void handleShowCertificateInfo();
void handleEditBlockingList();
private:
SettingsProvider* settings_;
QtLoginWindow::QtMenus loginMenus_;
std::vector<QMenu*> menus_;
QtRosterWidget* treeWidget_;
diff --git a/Swift/QtUI/QtRosterHeader.cpp b/Swift/QtUI/QtRosterHeader.cpp
index 2c8f244..69a0ef6 100644
--- a/Swift/QtUI/QtRosterHeader.cpp
+++ b/Swift/QtUI/QtRosterHeader.cpp
@@ -1,116 +1,134 @@
/*
* Copyright (c) 2010-2014 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "QtRosterHeader.h"
-#include <QHBoxLayout>
-#include <QVBoxLayout>
+#include <QBitmap>
+#include <qdebug.h>
#include <QFileInfo>
+#include <QHBoxLayout>
+#include <QHelpEvent>
#include <QIcon>
-#include <QSizePolicy>
-#include <qdebug.h>
#include <QMouseEvent>
#include <QPainter>
-#include <QBitmap>
+#include <QSizePolicy>
+#include <QToolTip>
+#include <QVBoxLayout>
#include "QtStatusWidget.h"
#include <Swift/QtUI/QtElidingLabel.h>
#include <Swift/QtUI/QtClickableLabel.h>
#include <Swift/QtUI/QtNameWidget.h>
+#include <Swift/QtUI/Roster/RosterTooltip.h>
#include "QtScaledAvatarCache.h"
namespace Swift {
QtRosterHeader::QtRosterHeader(SettingsProvider* settings, StatusCache* statusCache, QWidget* parent) : QWidget(parent), statusEdit_(NULL) {
QHBoxLayout* topLayout = new QHBoxLayout();
topLayout->setSpacing(3);
topLayout->setContentsMargins(4,4,4,4);
setLayout(topLayout);
setMinimumHeight(50);
setMaximumHeight(50);
avatarLabel_ = new QtClickableLabel(this);
avatarLabel_->setMinimumSize(avatarSize_, avatarSize_);
avatarLabel_->setMaximumSize(avatarSize_, avatarSize_);
avatarLabel_->setAlignment(Qt::AlignCenter);
setAvatar(":/icons/avatar.png");
avatarLabel_->setScaledContents(false);
topLayout->addWidget(avatarLabel_);
connect(avatarLabel_, SIGNAL(clicked()), this, SIGNAL(onEditProfileRequest()));
QVBoxLayout* rightLayout = new QVBoxLayout();
rightLayout->setSpacing(4);
rightLayout->setContentsMargins(4,0,0,0);
topLayout->addLayout(rightLayout);
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);
}
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);
}
+void QtRosterHeader::setContactRosterItem(boost::shared_ptr<ContactRosterItem> contact) {
+ contact_ = contact;
+}
+
void QtRosterHeader::setJID(const QString& jid) {
nameWidget_->setJID(jid);
}
const int QtRosterHeader::avatarSize_ = 40;
}
diff --git a/Swift/QtUI/QtRosterHeader.h b/Swift/QtUI/QtRosterHeader.h
index ad19178..eafbc02 100644
--- a/Swift/QtUI/QtRosterHeader.h
+++ b/Swift/QtUI/QtRosterHeader.h
@@ -1,58 +1,64 @@
/*
* Copyright (c) 2010 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <QWidget>
#include <QLabel>
#include <QPixmap>
#include <QSize>
#include <QToolButton>
#include <string>
-#include "Swiften/Elements/StatusShow.h"
+#include <Swiften/Elements/StatusShow.h>
+#include <Swiften/Elements/VCard.h>
+#include <Swift/Controllers/Roster/ContactRosterItem.h>
#include "QtTextEdit.h"
class QHBoxLayout;
namespace Swift {
class QtClickableLabel;
class QtStatusWidget;
class QtNameWidget;
class SettingsProvider;
class StatusCache;
class QtRosterHeader : public QWidget {
Q_OBJECT
public:
QtRosterHeader(SettingsProvider* settings, StatusCache* statusCache, QWidget* parent = NULL);
void setAvatar(const QString& path);
void setJID(const QString& jid);
void setNick(const QString& nick);
+ void setContactRosterItem(boost::shared_ptr<ContactRosterItem> contact);
void setStatusText(const QString& statusMessage);
void setStatusType(StatusShow::Type type);
void setConnecting();
void setStreamEncryptionStatus(bool tlsInPlace);
+ private:
+ bool event(QEvent* event);
signals:
void onChangeStatusRequest(StatusShow::Type showType, const QString &statusMessage);
void onEditProfileRequest();
void onShowCertificateInfo();
private slots:
void handleChangeStatusRequest(StatusShow::Type type, const QString &statusMessage);
private:
QString name_;
QtClickableLabel* avatarLabel_;
QtNameWidget* nameWidget_;
QtTextEdit* statusEdit_;
QtStatusWidget* statusWidget_;
QToolButton* securityInfoButton_;
static const int avatarSize_;
+ boost::shared_ptr<ContactRosterItem> contact_;
};
}