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

Improved status button

This commit is contained in:
Kevin Flynn 2014-07-05 13:54:27 -07:00
parent a31304d9e2
commit 46784cc1cc
4 changed files with 42 additions and 26 deletions

View File

@ -5,10 +5,13 @@ QPushButton
border: none; border: none;
border-radius: 6px; border-radius: 6px;
} }
QPushButton:hover
/*Disabled due to a bug preventing button status from
resetting to default after menu item pressed
QPushButton:hover
{ {
background-color: rgb(75,75,75); background-color: rgb(75,75,75);
} }*/
QPushButton:pressed QPushButton:pressed
{ {

View File

@ -2028,13 +2028,10 @@ QSplitter:handle{
<widget class="QPushButton" name="statusButton"> <widget class="QPushButton" name="statusButton">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>21</width> <width>20</width>
<height>40</height> <height>40</height>
</size> </size>
</property> </property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -2048,6 +2045,15 @@ QSplitter:handle{
<height>10</height> <height>10</height>
</size> </size>
</property> </property>
<property name="autoExclusive">
<bool>false</bool>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>

View File

@ -147,6 +147,15 @@ Widget::Widget(QWidget *parent) :
QTextStream statusButtonStylesheetStream(&f1); QTextStream statusButtonStylesheetStream(&f1);
ui->statusButton->setStyleSheet(statusButtonStylesheetStream.readAll()); ui->statusButton->setStyleSheet(statusButtonStylesheetStream.readAll());
QMenu *statusButtonMenu = new QMenu(ui->statusButton);
QAction* setStatusOnline = statusButtonMenu->addAction(tr("Online","Button to set your status to 'Online'"));
setStatusOnline->setIcon(QIcon(":ui/statusButton/dot_online.png"));
QAction* setStatusAway = statusButtonMenu->addAction(tr("Away","Button to set your status to 'Away'"));
setStatusAway->setIcon(QIcon(":ui/statusButton/dot_idle.png"));
QAction* setStatusBusy = statusButtonMenu->addAction(tr("Busy","Button to set your status to 'Busy'"));
setStatusBusy->setIcon(QIcon(":ui/statusButton/dot_busy.png"));
ui->statusButton->setMenu(statusButtonMenu);
this->setMouseTracking(true); this->setMouseTracking(true);
QList<QWidget*> widgets = this->findChildren<QWidget*>(); QList<QWidget*> widgets = this->findChildren<QWidget*>();
@ -212,7 +221,9 @@ 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->statusButton, SIGNAL(clicked()), this, SLOT(statusButtonClicked())); connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
connect(&settingsForm.name, SIGNAL(textEdited(QString)), this, SLOT(onUsernameChanged(QString))); connect(&settingsForm.name, SIGNAL(textEdited(QString)), this, SLOT(onUsernameChanged(QString)));
connect(&settingsForm.statusText, SIGNAL(textEdited(QString)), this, SLOT(onStatusMessageChanged(QString))); connect(&settingsForm.statusText, SIGNAL(textEdited(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)));
@ -1113,23 +1124,17 @@ void Widget::minimizeBtnClicked()
} }
} }
void Widget::statusButtonClicked() void Widget::setStatusOnline()
{ {
QMenu menu; core->setStatus(Status::Online);
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'")); void Widget::setStatusAway()
away->setIcon(QIcon(":ui/statusButton/dot_idle.png")); {
QAction* busy = menu.addAction(tr("Busy","Button to set your status to 'Busy'")); core->setStatus(Status::Away);
busy->setIcon(QIcon(":ui/statusButton/dot_busy.png")); }
ui->statusButton->setMenu(&menu); void Widget::setStatusBusy()
//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()))); core->setStatus(Status::Busy);
if (selectedItem == online)
core->setStatus(Status::Online);
else if (selectedItem == away)
core->setStatus(Status::Away);
else if (selectedItem == busy)
core->setStatus(Status::Busy);
} }

View File

@ -93,7 +93,9 @@ private slots:
void copyFriendIdToClipboard(int friendId); void copyFriendIdToClipboard(int friendId);
void removeGroup(int groupId); void removeGroup(int groupId);
void splitterMoved(int pos, int index); void splitterMoved(int pos, int index);
void statusButtonClicked(); void setStatusOnline();
void setStatusAway();
void setStatusBusy();
protected slots: protected slots:
void moveWindow(QMouseEvent *e); void moveWindow(QMouseEvent *e);