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

Added proper status button

Pixels in status image are shifted slightly, but since this involves
changing the .ui file it's better to merge sooner rather than later.
This commit is contained in:
Kevin Flynn 2014-07-05 12:30:00 -07:00
parent d1a3a42d88
commit a31304d9e2
9 changed files with 60 additions and 33 deletions

View File

@ -103,5 +103,10 @@
<file>translations/fr.qm</file>
<file>translations/ru.qm</file>
<file>ui/fileTransferWidget/fileTransferWidget.css</file>
<file>ui/statusButton/dot_away.png</file>
<file>ui/statusButton/dot_busy.png</file>
<file>ui/statusButton/dot_idle.png</file>
<file>ui/statusButton/dot_online.png</file>
<file>ui/statusButton/statusButton.css</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

View File

@ -0,0 +1,20 @@
QPushButton
{
background: none;
background-color: rgb(65,65,65);
border: none;
border-radius: 6px;
}
QPushButton:hover
{
background-color: rgb(75,75,75);
}
QPushButton:pressed
{
background-color: rgb(55,55,55);
}
QPushButton:focus {
outline: none;
}

View File

@ -2025,32 +2025,30 @@ QSplitter:handle{
</spacer>
</item>
<item>
<widget class="ClickableLabel" name="statImg">
<widget class="QPushButton" name="statusButton">
<property name="minimumSize">
<size>
<width>40</width>
<width>21</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="res.qrc">:/img/status/dot_away_2x.png</pixmap>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/ui/statusButton/dot_away.png</normaloff>:/ui/statusButton/dot_away.png</iconset>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<property name="iconSize">
<size>
<width>10</width>
<height>10</height>
</size>
</property>
<property name="wordWrap">
<property name="flat">
<bool>true</bool>
</property>
</widget>
@ -2077,6 +2075,9 @@ QSplitter:handle{
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
@ -2091,7 +2092,7 @@ QSplitter:handle{
<rect>
<x>0</x>
<y>0</y>
<width>256</width>
<width>255</width>
<height>199</height>
</rect>
</property>
@ -3280,11 +3281,6 @@ QSplitter:handle{
<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

@ -125,9 +125,6 @@ Widget::Widget(QWidget *parent) :
isWindowMinimized = 0;
//centralLayout = new QSplitter(ui->centralWidget);
ui->mainContent->setLayout(new QVBoxLayout());
ui->mainHead->setLayout(new QVBoxLayout());
ui->mainHead->layout()->setMargin(0);
@ -145,6 +142,11 @@ Widget::Widget(QWidget *parent) :
ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}");
ui->friendList->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
QFile f1(":/ui/statusButton/statusButton.css");
f1.open(QFile::ReadOnly | QFile::Text);
QTextStream statusButtonStylesheetStream(&f1);
ui->statusButton->setStyleSheet(statusButtonStylesheetStream.readAll());
this->setMouseTracking(true);
QList<QWidget*> widgets = this->findChildren<QWidget*>();
@ -210,7 +212,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(ui->statusButton, SIGNAL(clicked()), this, SLOT(statusButtonClicked()));
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)));
@ -303,13 +305,13 @@ void Widget::onFailedToStartCore()
void Widget::onStatusSet(Status status)
{
if (status == Status::Online)
ui->statImg->setPixmap(QPixmap(":img/status/dot_online_2x.png"));
ui->statusButton->setIcon(QIcon(":ui/statusButton/dot_online.png"));
else if (status == Status::Away)
ui->statImg->setPixmap(QPixmap(":img/status/dot_idle_2x.png"));
ui->statusButton->setIcon(QIcon(":ui/statusButton/dot_idle.png"));
else if (status == Status::Busy)
ui->statImg->setPixmap(QPixmap(":img/status/dot_busy_2x.png"));
ui->statusButton->setIcon(QIcon(":ui/statusButton/dot_busy.png"));
else if (status == Status::Offline)
ui->statImg->setPixmap(QPixmap(":img/status/dot_away_2x.png"));
ui->statusButton->setIcon(QIcon(":ui/statusButton/dot_away.png"));
}
void Widget::onAddClicked()
@ -1111,15 +1113,19 @@ void Widget::minimizeBtnClicked()
}
}
void Widget::onStatusImgClicked()
void Widget::statusButtonClicked()
{
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"));
QPoint pos = QCursor::pos();
QAction* selectedItem = menu.exec(pos);
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)

View File

@ -92,8 +92,8 @@ private slots:
void removeFriend(int friendId);
void copyFriendIdToClipboard(int friendId);
void removeGroup(int groupId);
void onStatusImgClicked();
void splitterMoved(int pos, int index);
void statusButtonClicked();
protected slots:
void moveWindow(QMouseEvent *e);