From a31304d9e21688c95f5384b632c99eebe19bf13f Mon Sep 17 00:00:00 2001 From: Kevin Flynn Date: Sat, 5 Jul 2014 12:30:00 -0700 Subject: [PATCH] Added proper status button Pixels in status image are shifted slightly, but since this involves changing the .ui file it's better to merge sooner rather than later. --- res.qrc | 5 ++++ ui/statusButton/dot_away.png | Bin 0 -> 345 bytes ui/statusButton/dot_busy.png | Bin 0 -> 292 bytes ui/statusButton/dot_idle.png | Bin 0 -> 333 bytes ui/statusButton/dot_online.png | Bin 0 -> 259 bytes ui/statusButton/statusButton.css | 20 ++++++++++++++++ widget.ui | 38 ++++++++++++++----------------- widget/widget.cpp | 28 ++++++++++++++--------- widget/widget.h | 2 +- 9 files changed, 60 insertions(+), 33 deletions(-) create mode 100644 ui/statusButton/dot_away.png create mode 100644 ui/statusButton/dot_busy.png create mode 100644 ui/statusButton/dot_idle.png create mode 100644 ui/statusButton/dot_online.png create mode 100644 ui/statusButton/statusButton.css diff --git a/res.qrc b/res.qrc index d57f705fd..33995781f 100644 --- a/res.qrc +++ b/res.qrc @@ -103,5 +103,10 @@ translations/fr.qm translations/ru.qm ui/fileTransferWidget/fileTransferWidget.css + ui/statusButton/dot_away.png + ui/statusButton/dot_busy.png + ui/statusButton/dot_idle.png + ui/statusButton/dot_online.png + ui/statusButton/statusButton.css diff --git a/ui/statusButton/dot_away.png b/ui/statusButton/dot_away.png new file mode 100644 index 0000000000000000000000000000000000000000..0a55cf1faa379daac8a4ff0e45c016715005d69f GIT binary patch literal 345 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyDx`7I;J! z19e;nVMZs7*%d%R_7YEDSN41CtU}Tj|2zI42MRs&ba4!kxLkT+uU>PaOxwrT|M;I~ zsIW!tHlOHmZ@HMCW0HV;XXB3uovkJka~zj;R!C*`9NQY7hPcmB!DV>m-+M zQQa|Vi=fLJrCxif-ek2cMf=#=+WsDhJFqYQ{rCMd4jCMo$M4W2`A_hY&VmDVh9Ydf z+}YKv72HeoHkjmX?^k=QwN&=trlso`+)^tQGyOlLR2*3+8hAsmVRqWN*}sfs_!`t2 kmR#Sp&U)>^1?(Sq+Yg3uls^6t0Q50~r>mdKI;Vst01iBc5dZ)H literal 0 HcmV?d00001 diff --git a/ui/statusButton/dot_busy.png b/ui/statusButton/dot_busy.png new file mode 100644 index 0000000000000000000000000000000000000000..6813c1cc9dfc93dbcb9c6bf43e11e051880fc183 GIT binary patch literal 292 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyDx`7I;J! z19e;nVMZs7*%d%R_7YEDSN41CtU@v}J*Rpv0);kux;TbNT<$%u>vbehqV?nb|4j)3 zg{p^GVh^)EWcA&}JloZvQ_taW!@-SGCYpOR?in3T3-HN1Vw17+kiw6TM-CT1nB%zI zH7ALGwQbem$g_LeE-h8QlOQQ>ahz#g)Dcb|-6ZC6i=&Qb=X@a`E?# jLzm}#Xqr1~C-?kS_e~e~&Ry~c=y(QCS3j3^P6Vf4u_bxCyDx`7I;J! z19e;nVMZs7*%d%R_7YEDSN41CtU@wE*+mPk0flaPx;TbNTy8zH-pjd=;poTrKN}MS zB&!7uYD=Y-Ur)Pa@P#)=?4ZdW{s)H+EC_3ETHtDU*FMAO%{|r2^BfjeTCf4u_bxCyDx`7I;J! z19e;nVMZs7*%d%R_7YEDSN41CtU@yEZ0lWYfkG2JT^vIsF85xr<~kH0((IqAVKH(@(P&)~=Y&tA-3_w%${z%uiy y%+PK78?P~M4Hfn)|0-kmdeL&{yD9D32l#JC>KRP^yGaG;HU>{uKbLh*2~7a7xL - + - 40 + 21 40 - - - 40 - 40 - - - - Qt::LeftToRight + + true - - :/img/status/dot_away_2x.png + + + :/ui/statusButton/dot_away.png:/ui/statusButton/dot_away.png - - Qt::AlignCenter + + + 10 + 10 + - + true @@ -2077,6 +2075,9 @@ QSplitter:handle{ Qt::RightToLeft + + true + QFrame::NoFrame @@ -2091,7 +2092,7 @@ QSplitter:handle{ 0 0 - 256 + 255 199 @@ -3280,11 +3281,6 @@ QSplitter:handle{ QLabel
widget/tool/editablelabelwidget.h
- - ClickableLabel - QLabel -
widget/tool/clickablelabel.h
-
diff --git a/widget/widget.cpp b/widget/widget.cpp index ad656e475..939c8aa4f 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -125,9 +125,6 @@ Widget::Widget(QWidget *parent) : isWindowMinimized = 0; - //centralLayout = new QSplitter(ui->centralWidget); - - ui->mainContent->setLayout(new QVBoxLayout()); ui->mainHead->setLayout(new QVBoxLayout()); ui->mainHead->layout()->setMargin(0); @@ -145,6 +142,11 @@ Widget::Widget(QWidget *parent) : ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}"); ui->friendList->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + QFile f1(":/ui/statusButton/statusButton.css"); + f1.open(QFile::ReadOnly | QFile::Text); + QTextStream statusButtonStylesheetStream(&f1); + ui->statusButton->setStyleSheet(statusButtonStylesheetStream.readAll()); + this->setMouseTracking(true); QList widgets = this->findChildren(); @@ -210,7 +212,7 @@ Widget::Widget(QWidget *parent) : connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked())); connect(ui->nameLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onUsernameChanged(QString,QString))); connect(ui->statusLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onStatusMessageChanged(QString,QString))); - connect(ui->statImg, SIGNAL(clicked()), this, SLOT(onStatusImgClicked())); + connect(ui->statusButton, SIGNAL(clicked()), this, SLOT(statusButtonClicked())); connect(&settingsForm.name, SIGNAL(textEdited(QString)), this, SLOT(onUsernameChanged(QString))); connect(&settingsForm.statusText, SIGNAL(textEdited(QString)), this, SLOT(onStatusMessageChanged(QString))); connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,QString))); @@ -303,13 +305,13 @@ void Widget::onFailedToStartCore() void Widget::onStatusSet(Status status) { if (status == Status::Online) - ui->statImg->setPixmap(QPixmap(":img/status/dot_online_2x.png")); + ui->statusButton->setIcon(QIcon(":ui/statusButton/dot_online.png")); else if (status == Status::Away) - ui->statImg->setPixmap(QPixmap(":img/status/dot_idle_2x.png")); + ui->statusButton->setIcon(QIcon(":ui/statusButton/dot_idle.png")); else if (status == Status::Busy) - ui->statImg->setPixmap(QPixmap(":img/status/dot_busy_2x.png")); + ui->statusButton->setIcon(QIcon(":ui/statusButton/dot_busy.png")); else if (status == Status::Offline) - ui->statImg->setPixmap(QPixmap(":img/status/dot_away_2x.png")); + ui->statusButton->setIcon(QIcon(":ui/statusButton/dot_away.png")); } void Widget::onAddClicked() @@ -1111,15 +1113,19 @@ void Widget::minimizeBtnClicked() } } -void Widget::onStatusImgClicked() +void Widget::statusButtonClicked() { QMenu menu; QAction* online = menu.addAction(tr("Online","Button to set your status to 'Online'")); + online->setIcon(QIcon(":ui/statusButton/dot_online.png")); QAction* away = menu.addAction(tr("Away","Button to set your status to 'Away'")); + away->setIcon(QIcon(":ui/statusButton/dot_idle.png")); QAction* busy = menu.addAction(tr("Busy","Button to set your status to 'Busy'")); + busy->setIcon(QIcon(":ui/statusButton/dot_busy.png")); - QPoint pos = QCursor::pos(); - QAction* selectedItem = menu.exec(pos); + ui->statusButton->setMenu(&menu); + //Ugly hack since QMenu wouldn't show up properly on Win32 + QAction* selectedItem = ui->statusButton->menu()->exec(ui->statusButton->mapToGlobal(QPoint(0,ui->statusButton->height()))); if (selectedItem == online) core->setStatus(Status::Online); else if (selectedItem == away) diff --git a/widget/widget.h b/widget/widget.h index 24ae6451c..309b1fcaf 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -92,8 +92,8 @@ private slots: void removeFriend(int friendId); void copyFriendIdToClipboard(int friendId); void removeGroup(int groupId); - void onStatusImgClicked(); void splitterMoved(int pos, int index); + void statusButtonClicked(); protected slots: void moveWindow(QMouseEvent *e);