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/selfcamview.h \
widget/videosurface.h \ widget/videosurface.h \
widget/camera.h \ widget/camera.h \
widget/netcamview.h widget/netcamview.h \
widget/tool/clickablelabel.h
SOURCES += \ SOURCES += \
widget/form/addfriendform.cpp \ widget/form/addfriendform.cpp \
@ -92,4 +93,5 @@ SOURCES += \
widget/selfcamview.cpp \ widget/selfcamview.cpp \
widget/videosurface.cpp \ widget/videosurface.cpp \
widget/camera.cpp \ widget/camera.cpp \
widget/netcamview.cpp widget/netcamview.cpp \
widget/tool/clickablelabel.cpp

View File

@ -226,16 +226,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="leftMargin"> <property name="margin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing"> <property name="spacing">
@ -704,16 +695,7 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -1693,7 +1675,7 @@
<string>Your status</string> <string>Your status</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="statImg"> <widget class="ClickableLabel" name="statImg">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>170</x> <x>170</x>
@ -2189,16 +2171,7 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -2735,16 +2708,7 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -2858,6 +2822,11 @@
<extends>QLabel</extends> <extends>QLabel</extends>
<header>widget/tool/editablelabelwidget.h</header> <header>widget/tool/editablelabelwidget.h</header>
</customwidget> </customwidget>
<customwidget>
<class>ClickableLabel</class>
<extends>QLabel</extends>
<header>widget/tool/clickablelabel.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="res.qrc"/> <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->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked()));
connect(ui->nameLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onUsernameChanged(QString,QString))); 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->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.name, SIGNAL(textChanged(QString)), this, SLOT(onUsernameChanged(QString)));
connect(&settingsForm.statusText, SIGNAL(textChanged(QString)), this, SLOT(onStatusMessageChanged(QString))); connect(&settingsForm.statusText, SIGNAL(textChanged(QString)), this, SLOT(onStatusMessageChanged(QString)));
connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,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 removeFriend(int friendId);
void copyFriendIdToClipboard(int friendId); void copyFriendIdToClipboard(int friendId);
void removeGroup(int groupId); void removeGroup(int groupId);
void onStatusImgClicked();
protected slots: protected slots:
void moveWindow(QMouseEvent *e); void moveWindow(QMouseEvent *e);