From 9a00b89112861cf81554da9e956b2b3b5cddbdf7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Mon, 7 Feb 2011 19:46:28 +0100
Subject: Now make the roster header *really* clickable.


diff --git a/Swift/QtUI/QtRosterHeader.cpp b/Swift/QtUI/QtRosterHeader.cpp
index 0fad137..57e7af1 100644
--- a/Swift/QtUI/QtRosterHeader.cpp
+++ b/Swift/QtUI/QtRosterHeader.cpp
@@ -15,6 +15,7 @@
 
 #include "QtStatusWidget.h"
 #include <Swift/QtUI/QtElidingLabel.h>
+#include <Swift/QtUI/QtClickableLabel.h>
 #include <Swift/QtUI/QtNameWidget.h>
 
 namespace Swift {
@@ -26,14 +27,14 @@ QtRosterHeader::QtRosterHeader(QtSettingsProvider* settings, QWidget* parent) :
 	setMinimumHeight(50);
 	setMaximumHeight(50);
 
-	avatarLabel_ = new QLabel(this);
+	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())); /* FIXME: clickableish signal for label */
+	connect(avatarLabel_, SIGNAL(clicked()), this, SIGNAL(onEditProfileRequest()));
 
 	QVBoxLayout* rightLayout = new QVBoxLayout();
 	rightLayout->setSpacing(4);
@@ -49,38 +50,12 @@ QtRosterHeader::QtRosterHeader(QtSettingsProvider* settings, QWidget* parent) :
 	connect(statusWidget_, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&)), this, SLOT(handleChangeStatusRequest(StatusShow::Type, const QString&)));
 	rightLayout->addWidget(statusWidget_);
 	show();
-	//statusWidget_->setMaximumWidth(60);
-
-	// statusEdit_ = new QtTextEdit(this);
-	// expandedLayout_->addWidget(statusEdit_);
-	// statusEdit_->resize(statusEdit_->width(), 64);
-	// statusEdit_->setAcceptRichText(false);
-	// statusEdit_->setReadOnly(false);
-	// setStatusText("");
-	// connect(statusEdit_, SIGNAL(returnPressed()), this, SLOT(emitStatus()));
-
-	//setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
 }
 
-// void QtRosterHeader::mousePressEvent(QMouseEvent* event) {
-// 	if (nameLabel_->underMouse() || (toolBar_->underMouse() && !statusWidget_->underMouse())) {
-// 		toggleExpanded();
-// 		event->accept();
-// 	} else {
-// 		event->ignore();
-// 	}
-	
-// }
-
-
 void QtRosterHeader::handleChangeStatusRequest(StatusShow::Type type, const QString& text) {
 	emit onChangeStatusRequest(type, text);
 }
 
-//void QtRosterHeader::emitStatus() {
-//	emit onChangeStatusRequest(statusWidget_->getSelectedStatusShow(), statusEdit_->toPlainText());
-//}
-
 void QtRosterHeader::setStatusText(const QString& statusMessage) {
 	statusWidget_->setStatusText(statusMessage);
 }
@@ -96,7 +71,7 @@ void QtRosterHeader::setConnecting() {
 void QtRosterHeader::setAvatar(const QString& path) {
 	QIcon avatar(path);
 	if (avatar.isNull()) {
-		qDebug() << "Setting null avatar";
+		//qDebug() << "Setting null avatar";
 		avatar = QIcon(":/icons/avatar.png");
 	} 
 	avatarLabel_->setPixmap(avatar.pixmap(avatarSize_, avatarSize_));
diff --git a/Swift/QtUI/QtRosterHeader.h b/Swift/QtUI/QtRosterHeader.h
index 6c76993..0dc611d 100644
--- a/Swift/QtUI/QtRosterHeader.h
+++ b/Swift/QtUI/QtRosterHeader.h
@@ -20,6 +20,7 @@
 class QHBoxLayout;
 
 namespace Swift {
+	class QtClickableLabel;
 	class QtStatusWidget;
 	class QtNameWidget;
 	class QtSettingsProvider;
@@ -44,7 +45,7 @@ namespace Swift {
 		void handleChangeStatusRequest(StatusShow::Type type, const QString &statusMessage);
 	private:
 		QString name_;
-		QLabel* avatarLabel_;
+		QtClickableLabel* avatarLabel_;
 		QtNameWidget* nameWidget_;
 		QtTextEdit* statusEdit_;
 		QToolBar* toolBar_;
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index d27dc8c..cc6db35 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -69,6 +69,7 @@ sources = [
     "QtUIFactory.cpp",
     "QtChatWindowFactory.cpp",
     "QtChatWindow.cpp",
+    "QtClickableLabel.cpp",
     "QtLoginWindow.cpp",
     "QtMainWindow.cpp",
     "QtProfileWindow.cpp",
-- 
cgit v0.10.2-6-g49f6