diff options
-rw-r--r-- | Swift/QtUI/QtStatusWidget.cpp | 23 | ||||
-rw-r--r-- | Swiften/Elements/StatusShow.h | 13 |
2 files changed, 31 insertions, 5 deletions
diff --git a/Swift/QtUI/QtStatusWidget.cpp b/Swift/QtUI/QtStatusWidget.cpp index e5a4eff..6281b52 100644 --- a/Swift/QtUI/QtStatusWidget.cpp +++ b/Swift/QtUI/QtStatusWidget.cpp @@ -20,6 +20,7 @@ #include "Swift/QtUI/QtElidingLabel.h" #include "Swift/QtUI/QtLineEdit.h" +#include "Swift/QtUI/QtSwiftUtil.h" namespace Swift { @@ -77,6 +78,12 @@ QtStatusWidget::QtStatusWidget(QWidget *parent) : QWidget(parent), editCursor_(Q menu_->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint ); menu_->setAlternatingRowColors(true); menu_->setFocusProxy(statusEdit_); + menu_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + menu_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + QSizePolicy policy(menu_->sizePolicy()); + policy.setVerticalPolicy(QSizePolicy::Expanding); + menu_->setSizePolicy(policy); + connect(menu_, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(handleItemClicked(QListWidgetItem*))); @@ -116,6 +123,11 @@ void QtStatusWidget::generateList() { item->setIcon(icons_[type]); item->setData(Qt::UserRole, QVariant(type)); } + foreach (StatusShow::Type type, icons_.keys()) { + QListWidgetItem* item = new QListWidgetItem(P2QSTRING(StatusShow::typeToFriendlyName(type)), menu_); + item->setIcon(icons_[type]); + item->setData(Qt::UserRole, QVariant(type)); + } } @@ -131,13 +143,12 @@ void QtStatusWidget::handleClicked() { if (x + width > screenWidth) { x = screenWidth - width; } + generateList(); + + height = menu_->sizeHintForRow(0) * menu_->count(); menu_->setGeometry(x, y, width, height); menu_->setMaximumWidth(width); - QSizePolicy policy(menu_->sizePolicy()); - policy.setVerticalPolicy(QSizePolicy::Expanding); - menu_->setSizePolicy(policy); - menu_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - generateList(); + menu_->show(); activateWindow(); @@ -174,6 +185,8 @@ StatusShow::Type QtStatusWidget::getSelectedStatusShow() { void QtStatusWidget::handleItemClicked(QListWidgetItem* item) { editing_ = false; selectedStatusType_ = (StatusShow::Type)(item->data(Qt::UserRole).toInt()); + newStatusText_ = item->data(Qt::DisplayRole).toString(); + statusEdit_->setText(newStatusText_); handleEditComplete(); } diff --git a/Swiften/Elements/StatusShow.h b/Swiften/Elements/StatusShow.h index 0501bf6..747ddf1 100644 --- a/Swiften/Elements/StatusShow.h +++ b/Swiften/Elements/StatusShow.h @@ -8,6 +8,7 @@ #define SWIFTEN_StatusShow_H #include "Swiften/Elements/Payload.h" +#include "Swiften/Base/String.h" namespace Swift { class StatusShow : public Payload { @@ -25,6 +26,18 @@ namespace Swift { return type_; } + static String typeToFriendlyName(Type type) { + switch (type) { + case Online: return "Available"; + case FFC: return "Available"; + case Away: return "Away"; + case XA: return "Away"; + case DND: return "Busy"; + case None: return "Offline"; + } + return "Unknown"; + } + private: Type type_; }; |