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:
parent
a31304d9e2
commit
46784cc1cc
|
@ -5,10 +5,13 @@ QPushButton
|
|||
border: none;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
/*Disabled due to a bug preventing button status from
|
||||
resetting to default after menu item pressed
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: rgb(75,75,75);
|
||||
}
|
||||
}*/
|
||||
|
||||
QPushButton:pressed
|
||||
{
|
||||
|
|
14
widget.ui
14
widget.ui
|
@ -2028,13 +2028,10 @@ QSplitter:handle{
|
|||
<widget class="QPushButton" name="statusButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -2048,6 +2045,15 @@ QSplitter:handle{
|
|||
<height>10</height>
|
||||
</size>
|
||||
</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">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
|
|
@ -147,6 +147,15 @@ Widget::Widget(QWidget *parent) :
|
|||
QTextStream statusButtonStylesheetStream(&f1);
|
||||
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);
|
||||
|
||||
QList<QWidget*> widgets = this->findChildren<QWidget*>();
|
||||
|
@ -212,7 +221,9 @@ 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->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.statusText, SIGNAL(textEdited(QString)), this, SLOT(onStatusMessageChanged(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;
|
||||
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"));
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
void Widget::setStatusAway()
|
||||
{
|
||||
core->setStatus(Status::Away);
|
||||
else if (selectedItem == busy)
|
||||
}
|
||||
|
||||
void Widget::setStatusBusy()
|
||||
{
|
||||
core->setStatus(Status::Busy);
|
||||
}
|
||||
|
|
|
@ -93,7 +93,9 @@ private slots:
|
|||
void copyFriendIdToClipboard(int friendId);
|
||||
void removeGroup(int groupId);
|
||||
void splitterMoved(int pos, int index);
|
||||
void statusButtonClicked();
|
||||
void setStatusOnline();
|
||||
void setStatusAway();
|
||||
void setStatusBusy();
|
||||
|
||||
protected slots:
|
||||
void moveWindow(QMouseEvent *e);
|
||||
|
|
Loading…
Reference in New Issue
Block a user