From 056cf1d65801082db8dd2521cbad4d4e8c9add21 Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Thu, 3 Jul 2014 19:33:08 +0200 Subject: [PATCH] Context menu to set status Closes #62 --- toxgui.pro | 6 ++-- widget.ui | 51 +++++++--------------------------- widget/tool/clickablelabel.cpp | 11 ++++++++ widget/tool/clickablelabel.h | 20 +++++++++++++ widget/widget.cpp | 20 +++++++++++++ widget/widget.h | 1 + 6 files changed, 66 insertions(+), 43 deletions(-) create mode 100644 widget/tool/clickablelabel.cpp create mode 100644 widget/tool/clickablelabel.h diff --git a/toxgui.pro b/toxgui.pro index 45b240f39..91fdfd642 100644 --- a/toxgui.pro +++ b/toxgui.pro @@ -62,7 +62,8 @@ HEADERS += widget/form/addfriendform.h \ widget/selfcamview.h \ widget/videosurface.h \ widget/camera.h \ - widget/netcamview.h + widget/netcamview.h \ + widget/tool/clickablelabel.h SOURCES += \ widget/form/addfriendform.cpp \ @@ -92,4 +93,5 @@ SOURCES += \ widget/selfcamview.cpp \ widget/videosurface.cpp \ widget/camera.cpp \ - widget/netcamview.cpp + widget/netcamview.cpp \ + widget/tool/clickablelabel.cpp diff --git a/widget.ui b/widget.ui index 3ec467ccc..e4141d6e5 100644 --- a/widget.ui +++ b/widget.ui @@ -226,16 +226,7 @@ true - - 0 - - - 0 - - - 0 - - + 0 @@ -704,16 +695,7 @@ 0 - - 0 - - - 0 - - - 0 - - + 0 @@ -1693,7 +1675,7 @@ Your status - + 170 @@ -2189,16 +2171,7 @@ 0 - - 0 - - - 0 - - - 0 - - + 0 @@ -2735,16 +2708,7 @@ 0 - - 0 - - - 0 - - - 0 - - + 0 @@ -2858,6 +2822,11 @@ QLabel
widget/tool/editablelabelwidget.h
+ + ClickableLabel + QLabel +
widget/tool/clickablelabel.h
+
diff --git a/widget/tool/clickablelabel.cpp b/widget/tool/clickablelabel.cpp new file mode 100644 index 000000000..760122edb --- /dev/null +++ b/widget/tool/clickablelabel.cpp @@ -0,0 +1,11 @@ +#include "clickablelabel.h" + +ClickableLabel::ClickableLabel(QWidget *parent) : + QLabel(parent) +{ +} + +void ClickableLabel::mousePressEvent(QMouseEvent* event) +{ + emit clicked(); +} diff --git a/widget/tool/clickablelabel.h b/widget/tool/clickablelabel.h new file mode 100644 index 000000000..78b1be2b6 --- /dev/null +++ b/widget/tool/clickablelabel.h @@ -0,0 +1,20 @@ +#ifndef CLICKABLELABEL_H +#define CLICKABLELABEL_H + +#include + +class ClickableLabel : public QLabel +{ + Q_OBJECT +public: + explicit ClickableLabel(QWidget *parent = 0); + +signals: + void clicked(); + +protected: + void mousePressEvent ( QMouseEvent * event ); + +}; + +#endif // CLICKABLELABEL_H diff --git a/widget/widget.cpp b/widget/widget.cpp index fcad53dce..f51fa7850 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -200,6 +200,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(&settingsForm.name, SIGNAL(textChanged(QString)), this, SLOT(onUsernameChanged(QString))); connect(&settingsForm.statusText, SIGNAL(textChanged(QString)), this, SLOT(onStatusMessageChanged(QString))); connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,QString))); @@ -1099,3 +1100,22 @@ void Widget::minimizeBtnClicked() } } +void Widget::onStatusImgClicked() +{ + QMenu menu; + menu.addAction("Online"); + menu.addAction("Away"); + menu.addAction("Busy"); + + QPoint pos = QCursor::pos(); + QAction* selectedItem = menu.exec(pos); + if (selectedItem) + { + if (selectedItem->text() == "Online") + core->setStatus(Status::Online); + else if (selectedItem->text() == "Away") + core->setStatus(Status::Away); + else if (selectedItem->text() == "Busy") + core->setStatus(Status::Busy); + } +} diff --git a/widget/widget.h b/widget/widget.h index edd2d73ba..2357e7ffd 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -88,6 +88,7 @@ private slots: void removeFriend(int friendId); void copyFriendIdToClipboard(int friendId); void removeGroup(int groupId); + void onStatusImgClicked(); protected slots: void moveWindow(QMouseEvent *e);