From 585b65f17d50dfbb14b25e5372819033c964e79d Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Sun, 16 Aug 2009 10:16:33 +0100 Subject: Adding the start of a 'me view' to the head of the roster. diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index a05d3bf..03c6150 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -22,7 +22,7 @@ QtLoginWindow::QtLoginWindow(const String& defaultJID, const String& defaultPass QBoxLayout *topLayout = new QBoxLayout(QBoxLayout::TopToBottom, centralWidget); stack_ = new QStackedWidget(centralWidget); topLayout->addWidget(stack_); - topLayout->setMargin(5); + topLayout->setMargin(0); QWidget *wrapperWidget = new QWidget(this); wrapperWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, wrapperWidget); diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index fffd478..9fa209b 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -4,7 +4,6 @@ #include "QtSwiftUtil.h" #include "Roster/QtTreeWidgetFactory.h" #include "Roster/QtTreeWidget.h" -#include "QtStatusWidget.h" #include #include @@ -22,9 +21,11 @@ QtMainWindow::QtMainWindow(QtTreeWidgetFactory *treeWidgetFactory) : QWidget() { QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); - statusWidget_ = new QtStatusWidget(this); - connect(statusWidget_, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&)), this, SLOT(handleStatusChanged(StatusShow::Type, const QString&))); - mainLayout->addWidget(statusWidget_); + meView_ = new QtRosterHeader(this); + mainLayout->addWidget(meView_); + //statusWidget_ = new QtStatusWidget(this); + connect(meView_, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&)), this, SLOT(handleStatusChanged(StatusShow::Type, const QString&))); + //mainLayout->addWidget(statusWidget_); treeWidget_ = dynamic_cast(treeWidgetFactory->createTreeWidget()); mainLayout->addWidget(treeWidget_); diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h index 6f4b5f7..f56262d 100644 --- a/Swift/QtUI/QtMainWindow.h +++ b/Swift/QtUI/QtMainWindow.h @@ -4,6 +4,7 @@ #include #include #include "Swift/Controllers/MainWindow.h" +#include "Swift/QtUI/QtRosterHeader.h" #include @@ -14,7 +15,6 @@ class QPushButton; namespace Swift { class QtTreeWidget; class QtTreeWidgetFactory; - class QtStatusWidget; class TreeWidget; @@ -31,11 +31,12 @@ namespace Swift { void handleJoinMUCDialogComplete(const JID& muc, const QString& nick); private: std::vector menus_; - QtStatusWidget *statusWidget_; - QLineEdit *muc_; - QLineEdit *mucNick_; - QPushButton *mucButton_; - QtTreeWidget *treeWidget_; + //QtStatusWidget* statusWidget_; + QLineEdit* muc_; + QLineEdit* mucNick_; + QPushButton* mucButton_; + QtTreeWidget* treeWidget_; + QtRosterHeader* meView_; }; } diff --git a/Swift/QtUI/QtRosterHeader.cpp b/Swift/QtUI/QtRosterHeader.cpp new file mode 100644 index 0000000..7401b30 --- /dev/null +++ b/Swift/QtUI/QtRosterHeader.cpp @@ -0,0 +1,71 @@ +#include "QtRosterHeader.h" + +#include +#include +#include +#include + +#include "QtStatusWidget.h" + +namespace Swift { +QtRosterHeader::QtRosterHeader(QWidget* parent) : QWidget(parent) { + QVBoxLayout* vLayout = new QVBoxLayout(); + vLayout->setSpacing(0); + vLayout->setContentsMargins(0,0,0,0); + setLayout(vLayout); + + //QHBoxLayout* topLayout = new QHBoxLayout(); + //vLayout->addLayout(topLayout); + + toolBar_ = new QToolBar(this); + vLayout->addWidget(toolBar_); + + statusWidget_ = new QtStatusWidget(this); + toolBar_->addWidget(statusWidget_); + statusWidget_->resize(50, statusWidget_->height()); + connect(statusWidget_, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&)), this, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&))); + + nameLabel_ = new QLabel(this); + setName("Me"); + //topLayout->addWidget(nameLabel_); + toolBar_->addWidget(nameLabel_); + + QHBoxLayout* expandedLayout = new QHBoxLayout(); + expandedLayout->setContentsMargins(5,5,5,5); + expandedLayout->setSpacing(11); + + avatarLabel_ = new QLabel(this); + setAvatar(":/icons/avatar.png"); + expandedLayout->addWidget(avatarLabel_); + + statusEdit_ = new QTextEdit(this); + expandedLayout->addWidget(statusEdit_); + statusEdit_->resize(statusEdit_->width(), 64); + statusEdit_->setAcceptRichText(false); + statusEdit_->setReadOnly(false); + setStatusText("Could be here, could be away."); + + vLayout->addLayout(expandedLayout); + + setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed)); +} + +void QtRosterHeader::setStatusText(const QString& statusMessage) { + statusEdit_->setText(statusMessage); +} + +void QtRosterHeader::setName(const QString& name) { + QString escapedName = name; + escapedName.replace("<","<"); + nameLabel_->setText("" + escapedName + ""); +} + +void QtRosterHeader::setAvatar(const QString& path) { + avatarLabel_->setPixmap(QIcon(path).pixmap(64, 64)); +} + +QSize QtRosterHeader::sizeHint() const { + return minimumSizeHint(); +} + +} diff --git a/Swift/QtUI/QtRosterHeader.h b/Swift/QtUI/QtRosterHeader.h new file mode 100644 index 0000000..94b7249 --- /dev/null +++ b/Swift/QtUI/QtRosterHeader.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "Swiften/Elements/StatusShow.h" + +namespace Swift { + class QtStatusWidget; + + class QtRosterHeader : public QWidget { + Q_OBJECT + public: + QtRosterHeader(QWidget* parent = NULL); + void setAvatar(const QString& path); + void setName(const QString& name); + void setStatusText(const QString& statusMessage); + QSize sizeHint() const; + signals: + void onChangeStatusRequest(StatusShow::Type showType, const QString &statusMessage); + private: + QLabel* avatarLabel_; + QLabel* nameLabel_; + QTextEdit* statusEdit_; + QToolBar* toolBar_; + QtStatusWidget* statusWidget_; + }; +} diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index c64ae61..cd810a4 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -67,6 +67,7 @@ sources = [ "Roster/QtTreeWidget.cpp", "Roster/QtTreeWidgetItem.cpp", "Roster/RosterDelegate.cpp", + "QtRosterHeader.cpp", "qrc_DefaultTheme.cc", "qrc_Swift.cc", ] -- cgit v0.10.2-6-g49f6