1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Context menu to set status

Closes #62
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-07-03 19:33:08 +02:00
parent 292be5b111
commit 056cf1d658
6 changed files with 66 additions and 43 deletions

View File

@ -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

View File

@ -226,16 +226,7 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
@ -704,16 +695,7 @@
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -1693,7 +1675,7 @@
<string>Your status</string>
</property>
</widget>
<widget class="QLabel" name="statImg">
<widget class="ClickableLabel" name="statImg">
<property name="geometry">
<rect>
<x>170</x>
@ -2189,16 +2171,7 @@
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2735,16 +2708,7 @@
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2858,6 +2822,11 @@
<extends>QLabel</extends>
<header>widget/tool/editablelabelwidget.h</header>
</customwidget>
<customwidget>
<class>ClickableLabel</class>
<extends>QLabel</extends>
<header>widget/tool/clickablelabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="res.qrc"/>

View File

@ -0,0 +1,11 @@
#include "clickablelabel.h"
ClickableLabel::ClickableLabel(QWidget *parent) :
QLabel(parent)
{
}
void ClickableLabel::mousePressEvent(QMouseEvent* event)
{
emit clicked();
}

View File

@ -0,0 +1,20 @@
#ifndef CLICKABLELABEL_H
#define CLICKABLELABEL_H
#include <QLabel>
class ClickableLabel : public QLabel
{
Q_OBJECT
public:
explicit ClickableLabel(QWidget *parent = 0);
signals:
void clicked();
protected:
void mousePressEvent ( QMouseEvent * event );
};
#endif // CLICKABLELABEL_H

View File

@ -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);
}
}

View File

@ -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);