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

Merge pull request #88 from F1ynn/master

Added proper status button
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-07-06 00:02:49 +02:00
commit 7608d4ef24
10 changed files with 90 additions and 45 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,23 @@
QPushButton
{
background: none;
background-color: rgb(65,65,65);
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
{
background-color: rgb(55,55,55);
}
QPushButton:focus {
outline: none;
}

View File

@ -2025,32 +2025,36 @@ QSplitter:handle{
</spacer>
</item>
<item>
<widget class="ClickableLabel" name="statImg">
<widget class="QPushButton" name="statusButton">
<property name="minimumSize">
<size>
<width>40</width>
<width>20</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>
<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="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>
</widget>
@ -2077,6 +2081,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 +2098,7 @@ QSplitter:handle{
<rect>
<x>0</x>
<y>0</y>
<width>256</width>
<width>255</width>
<height>199</height>
</rect>
</property>
@ -3280,11 +3287,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

@ -118,7 +118,9 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
infoLayout->setSpacing(4);
textLayout->addWidget(size);
textLayout->addStretch(0);
textLayout->addWidget(speed);
textLayout->addStretch(0);
textLayout->addWidget(eta);
textLayout->setMargin(2);
textLayout->setSpacing(5);

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,20 @@ 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());
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*>();
@ -210,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->statImg, SIGNAL(clicked()), this, SLOT(onStatusImgClicked()));
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)));
@ -303,13 +316,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,19 +1124,17 @@ void Widget::minimizeBtnClicked()
}
}
void Widget::onStatusImgClicked()
void Widget::setStatusOnline()
{
QMenu menu;
QAction* online = menu.addAction(tr("Online","Button to set your status to 'Online'"));
QAction* away = menu.addAction(tr("Away","Button to set your status to 'Away'"));
QAction* busy = menu.addAction(tr("Busy","Button to set your status to 'Busy'"));
QPoint pos = QCursor::pos();
QAction* selectedItem = menu.exec(pos);
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);
}

View File

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