summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-16 12:35:34 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-16 12:35:34 (GMT)
commit2ef0428c1f9559454654546f3cce32155cf5409d (patch)
treebaf692218db59e29385f128fd2ec3171918df172 /Swift/QtUI
parentc16133bf881a4eeb988d17ff318e4833a524997e (diff)
downloadswift-contrib-2ef0428c1f9559454654546f3cce32155cf5409d.zip
swift-contrib-2ef0428c1f9559454654546f3cce32155cf5409d.tar.bz2
Now show my avatar and JID in the 'me view'.
At the moment it's my JID rather than my Name, because the NickResolver doesn't cope with our own Name. Also: the name resizing sometimes doesn't work. If it doesn't for you, make the roster very wide and then slowly resize it down.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtMainWindow.cpp12
-rw-r--r--Swift/QtUI/QtMainWindow.h3
-rw-r--r--Swift/QtUI/QtRosterHeader.cpp32
-rw-r--r--Swift/QtUI/QtRosterHeader.h5
4 files changed, 46 insertions, 6 deletions
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp
index 9fa209b..cf4bfd2 100644
--- a/Swift/QtUI/QtMainWindow.cpp
+++ b/Swift/QtUI/QtMainWindow.cpp
@@ -68,5 +68,17 @@ void QtMainWindow::handleShowOfflineToggled(bool state) {
onShowOfflineToggled(state);
}
+void QtMainWindow::setMyName(const String& name) {
+ meView_->setName(P2QSTRING(name));
+}
+
+void QtMainWindow::setMyAvatarPath(const String& path) {
+ meView_->setAvatar(P2QSTRING(path));
+}
+
+void QtMainWindow::setMyStatusText(const String& status) {
+ meView_->setStatusText(P2QSTRING(status));
+}
+
}
diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h
index f56262d..44133af 100644
--- a/Swift/QtUI/QtMainWindow.h
+++ b/Swift/QtUI/QtMainWindow.h
@@ -24,6 +24,9 @@ namespace Swift {
QtMainWindow(QtTreeWidgetFactory *treeWidgetFactory);
TreeWidget* getTreeWidget();
std::vector<QMenu*> getMenus() {return menus_;}
+ void setMyName(const String& name);
+ void setMyAvatarPath(const String& path);
+ void setMyStatusText(const String& status);
private slots:
void handleStatusChanged(StatusShow::Type showType, const QString &statusMessage);
void handleShowOfflineToggled(bool);
diff --git a/Swift/QtUI/QtRosterHeader.cpp b/Swift/QtUI/QtRosterHeader.cpp
index c479643..86e64ca 100644
--- a/Swift/QtUI/QtRosterHeader.cpp
+++ b/Swift/QtUI/QtRosterHeader.cpp
@@ -4,6 +4,7 @@
#include <QVBoxLayout>
#include <QIcon>
#include <QSizePolicy>
+#include <qdebug.h>
#include "QtStatusWidget.h"
@@ -14,9 +15,6 @@ QtRosterHeader::QtRosterHeader(QWidget* parent) : QWidget(parent) {
vLayout->setContentsMargins(0,0,0,0);
setLayout(vLayout);
- //QHBoxLayout* topLayout = new QHBoxLayout();
- //vLayout->addLayout(topLayout);
-
toolBar_ = new QToolBar(this);
vLayout->addWidget(toolBar_);
@@ -27,8 +25,8 @@ QtRosterHeader::QtRosterHeader(QWidget* parent) : QWidget(parent) {
nameLabel_ = new QLabel(this);
setName("Me");
- //topLayout->addWidget(nameLabel_);
toolBar_->addWidget(nameLabel_);
+ //nameLabel_->setMaximumWidth(width() - 5 - statusWidget_->width());
QHBoxLayout* expandedLayout = new QHBoxLayout();
expandedLayout->setContentsMargins(5,5,5,5);
@@ -43,7 +41,7 @@ QtRosterHeader::QtRosterHeader(QWidget* parent) : QWidget(parent) {
statusEdit_->resize(statusEdit_->width(), 64);
statusEdit_->setAcceptRichText(false);
statusEdit_->setReadOnly(false);
- setStatusText("Could be here, could be away.");
+ setStatusText("");
vLayout->addLayout(expandedLayout);
@@ -51,6 +49,7 @@ QtRosterHeader::QtRosterHeader(QWidget* parent) : QWidget(parent) {
}
void QtRosterHeader::handleChangeStatusRequest(StatusShow::Type type) {
+ Q_UNUSED(type);
emitStatus();
}
@@ -63,9 +62,30 @@ void QtRosterHeader::setStatusText(const QString& statusMessage) {
}
void QtRosterHeader::setName(const QString& name) {
- QString escapedName = name;
+ name_ = name;
+ resizeNameLabel();
+}
+
+void QtRosterHeader::resizeNameLabel() {
+ QString escapedName = name_;
escapedName.replace("<","&lt;");
nameLabel_->setText("<b>" + escapedName + "</b>");
+ int reductionCount = 0;
+ while (nameLabel_->sizeHint().width() + statusWidget_->width() + 30 > width()) {
+ qDebug() << nameLabel_->sizeHint().width() << " " << statusWidget_->width() << " " << width();
+ reductionCount++;
+ QString reducedName = name_;
+ reducedName.remove(name_.length() - reductionCount, reductionCount);
+ reducedName.replace("<","&lt;");
+ nameLabel_->setText("<b>" + reducedName + + "...</b>");
+ qDebug() << "Shrunk " << escapedName << " down to " << reducedName;
+ }
+ nameLabel_->setToolTip(name_);
+}
+
+void QtRosterHeader::resizeEvent(QResizeEvent* event) {
+ QWidget::resizeEvent(event);
+ resizeNameLabel();
}
void QtRosterHeader::setAvatar(const QString& path) {
diff --git a/Swift/QtUI/QtRosterHeader.h b/Swift/QtUI/QtRosterHeader.h
index aeccf9a..ae510ee 100644
--- a/Swift/QtUI/QtRosterHeader.h
+++ b/Swift/QtUI/QtRosterHeader.h
@@ -7,6 +7,7 @@
#include <QSize>
#include <QToolBar>
+#include "Swiften/Base/String.h"
#include "Swiften/Elements/StatusShow.h"
namespace Swift {
@@ -25,7 +26,11 @@ namespace Swift {
void onChangeStatusRequest(StatusShow::Type showType, const QString &statusMessage);
private slots:
void handleChangeStatusRequest(StatusShow::Type type);
+ protected:
+ virtual void resizeEvent(QResizeEvent* event);
private:
+ void resizeNameLabel();
+ QString name_;
QLabel* avatarLabel_;
QLabel* nameLabel_;
QTextEdit* statusEdit_;