summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtRosterHeader.cpp')
-rw-r--r--Swift/QtUI/QtRosterHeader.cpp28
1 files changed, 23 insertions, 5 deletions
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,31 +1,34 @@
/*
* 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);
@@ -83,34 +86,49 @@ void QtRosterHeader::setStatusType(StatusShow::Type 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;
}