diff options
Diffstat (limited to 'Swift/QtUI/QtNameWidget.cpp')
-rw-r--r-- | Swift/QtUI/QtNameWidget.cpp | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/Swift/QtUI/QtNameWidget.cpp b/Swift/QtUI/QtNameWidget.cpp index 428b243..0610a00 100644 --- a/Swift/QtUI/QtNameWidget.cpp +++ b/Swift/QtUI/QtNameWidget.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2010-2014 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ -#include "QtNameWidget.h" +#include <Swift/QtUI/QtNameWidget.h> #include <QHBoxLayout> #include <QMenu> @@ -18,80 +18,80 @@ namespace Swift { QtNameWidget::QtNameWidget(SettingsProvider* settings, QWidget *parent) : QWidget(parent), settings(settings), isOnline_(false) { - QHBoxLayout* mainLayout = new QHBoxLayout(this); - mainLayout->setSpacing(0); - mainLayout->setContentsMargins(0,0,0,0); + QHBoxLayout* mainLayout = new QHBoxLayout(this); + mainLayout->setSpacing(0); + mainLayout->setContentsMargins(0,0,0,0); - mode = settings->getSetting(QtUISettingConstants::SHOW_NICK_IN_ROSTER_HEADER) ? ShowNick : ShowJID; + mode = settings->getSetting(QtUISettingConstants::SHOW_NICK_IN_ROSTER_HEADER) ? ShowNick : ShowJID; - textLabel = new QtElidingLabel(this); - QFont font = textLabel->font(); - font.setBold(true); - textLabel->setFont(font); - mainLayout->addWidget(textLabel); + textLabel = new QtElidingLabel(this); + QFont font = textLabel->font(); + font.setBold(true); + textLabel->setFont(font); + mainLayout->addWidget(textLabel); } void QtNameWidget::setNick(const QString& nick) { - this->nick = nick; - updateText(); + this->nick = nick; + updateText(); } void QtNameWidget::setJID(const QString& jid) { - this->jid = jid; - updateText(); + this->jid = jid; + updateText(); } void QtNameWidget::setOnline(const bool isOnline) { - isOnline_ = isOnline; + isOnline_ = isOnline; } void QtNameWidget::mousePressEvent(QMouseEvent* event) { - QMenu menu; - bool hasNick = !nick.isEmpty(); - - QAction* showAsNick = new QAction(hasNick ? tr("Show Nickname") : tr("(No Nickname Set)"), this); - showAsNick->setCheckable(true); - showAsNick->setEnabled(hasNick); - if (mode == ShowNick && hasNick) { - showAsNick->setChecked(true); - } - menu.addAction(showAsNick); - - QAction* showAsJID = new QAction(tr("Show Address"), this); - showAsJID->setCheckable(true); - if (mode == ShowJID || !hasNick) { - showAsJID->setChecked(true); - } - menu.addAction(showAsJID); - - QAction* editProfile = new QAction(tr("Edit Profile"), this); - menu.addAction(editProfile); - editProfile->setEnabled(isOnline_); - - QAction* result = menu.exec(event->globalPos()); - if (result == showAsJID) { - mode = ShowJID; - } - else if (result == showAsNick) { - mode = ShowNick; - } - else if (result == editProfile) { - emit onChangeNickRequest(); - } - settings->storeSetting(QtUISettingConstants::SHOW_NICK_IN_ROSTER_HEADER, mode == ShowNick); - updateText(); + QMenu menu; + bool hasNick = !nick.isEmpty(); + + QAction* showAsNick = new QAction(hasNick ? tr("Show Nickname") : tr("(No Nickname Set)"), this); + showAsNick->setCheckable(true); + showAsNick->setEnabled(hasNick); + if (mode == ShowNick && hasNick) { + showAsNick->setChecked(true); + } + menu.addAction(showAsNick); + + QAction* showAsJID = new QAction(tr("Show Address"), this); + showAsJID->setCheckable(true); + if (mode == ShowJID || !hasNick) { + showAsJID->setChecked(true); + } + menu.addAction(showAsJID); + + QAction* editProfile = new QAction(tr("Edit Profile"), this); + menu.addAction(editProfile); + editProfile->setEnabled(isOnline_); + + QAction* result = menu.exec(event->globalPos()); + if (result == showAsJID) { + mode = ShowJID; + } + else if (result == showAsNick) { + mode = ShowNick; + } + else if (result == editProfile) { + emit onChangeNickRequest(); + } + settings->storeSetting(QtUISettingConstants::SHOW_NICK_IN_ROSTER_HEADER, mode == ShowNick); + updateText(); } void QtNameWidget::updateText() { - QString text; - if (mode == ShowNick && !nick.isEmpty()) { - text = nick; - } - else { - text = jid; - } - text.replace("<","<"); - textLabel->setText(text); + QString text; + if (mode == ShowNick && !nick.isEmpty()) { + text = nick; + } + else { + text = jid; + } + text.replace("<","<"); + textLabel->setText(text); } } |