diff options
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindow.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/QtRosterHeader.cpp | 28 | ||||
-rw-r--r-- | Swift/QtUI/QtRosterHeader.h | 8 |
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 @@ -340,6 +340,10 @@ 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(); } 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 @@ -47,6 +47,7 @@ namespace Swift { 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); 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 @@ -6,20 +6,23 @@ #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 { @@ -89,6 +92,17 @@ 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; @@ -105,6 +119,10 @@ 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); } 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 @@ -13,7 +13,9 @@ #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" @@ -34,11 +36,14 @@ namespace Swift { 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(); @@ -54,5 +59,6 @@ namespace Swift { QtStatusWidget* statusWidget_; QToolButton* securityInfoButton_; static const int avatarSize_; + boost::shared_ptr<ContactRosterItem> contact_; }; } |