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

Merge pull request #80 from F1ynn/fix-widget-win8

Small widget improvements
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-07-05 07:22:24 +02:00
commit 8e46c78068
8 changed files with 334 additions and 19 deletions

BIN
debug/filetransfertwidget.o Normal file

Binary file not shown.

View File

@ -102,5 +102,6 @@
<file>img/status/dot_busy_notification.png</file> <file>img/status/dot_busy_notification.png</file>
<file>translations/fr.qm</file> <file>translations/fr.qm</file>
<file>translations/ru.qm</file> <file>translations/ru.qm</file>
<file>ui/fileTransferWidget/fileTransferWidget.css</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -0,0 +1,26 @@
#default {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
background-color: rgb(209,209,209);
}
#error {
border-radius: 6px;
background-color: rgb(200,78,78);
}
#success {
background-color: rgb(107,194,96);
border-radius: 6px;
}
QProgressBar {
background-color: transparent;
border: 1px solid black;
height: 11px;
}
QProgressBar::chunk {
background-color: black;
width: 2px;
}

272
widget.ui
View File

@ -243,6 +243,51 @@
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base"> <colorrole role="Base">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
@ -261,8 +306,80 @@
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
<colorrole role="Highlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="HighlightedText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active> </active>
<inactive> <inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base"> <colorrole role="Base">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
@ -281,8 +398,80 @@
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
<colorrole role="Highlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="HighlightedText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive> </inactive>
<disabled> <disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base"> <colorrole role="Base">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
@ -301,12 +490,57 @@
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
<colorrole role="Highlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="HighlightedText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled> </disabled>
</palette> </palette>
</property> </property>
<property name="mouseTracking"> <property name="mouseTracking">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">QSplitter{
color: rgb(255, 255, 255);
background-color: rgb(255, 255, 255);
alternate-background-color: rgb(255, 255, 255);
border-color: rgb(255, 255, 255);
gridline-color: rgb(255, 255, 255);
selection-color: rgb(255, 255, 255);
selection-background-color: rgb(255, 255, 255);
}
QSplitter:handle{
color: rgb(255, 255, 255);
background-color: rgb(255, 255, 255);
}</string>
</property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -781,7 +1015,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<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>
@ -1252,6 +1495,9 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item> <item>
<widget class="EditableLabelWidget" name="nameLabel"> <widget class="EditableLabelWidget" name="nameLabel">
<property name="enabled"> <property name="enabled">
@ -1845,7 +2091,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>258</width> <width>256</width>
<height>199</height> <height>199</height>
</rect> </rect>
</property> </property>
@ -2291,7 +2537,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<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>
@ -2892,7 +3147,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<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>

View File

@ -4,6 +4,7 @@
#include "math.h" #include "math.h"
#include <QFileDialog> #include <QFileDialog>
#include <QPixmap> #include <QPixmap>
#include <QPainter>
FileTransfertWidget::FileTransfertWidget(ToxFile File) FileTransfertWidget::FileTransfertWidget(ToxFile File)
: lastUpdate{QDateTime::currentDateTime()}, lastBytesSent{0}, : lastUpdate{QDateTime::currentDateTime()}, lastBytesSent{0},
@ -17,6 +18,11 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
buttonWidget = new QWidget(); buttonWidget = new QWidget();
QFont prettysmall; QFont prettysmall;
prettysmall.setPixelSize(10); prettysmall.setPixelSize(10);
this->setObjectName("default");
QFile f0(":/ui/fileTransferWidget/fileTransferWidget.css");
f0.open(QFile::ReadOnly | QFile::Text);
QTextStream fileTransfertWidgetStylesheet(&f0);
this->setStyleSheet(fileTransfertWidgetStylesheet.readAll());
QPalette greybg; QPalette greybg;
greybg.setColor(QPalette::Window, QColor(209,209,209)); greybg.setColor(QPalette::Window, QColor(209,209,209));
greybg.setColor(QPalette::Base, QColor(150,150,150)); greybg.setColor(QPalette::Base, QColor(150,150,150));
@ -41,6 +47,7 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
progress->setValue(0); progress->setValue(0);
progress->setMinimumHeight(11); progress->setMinimumHeight(11);
progress->setFont(prettysmall); progress->setFont(prettysmall);
progress->setTextVisible(false);
QPalette whitebg; QPalette whitebg;
whitebg.setColor(QPalette::Window, QColor(255,255,255)); whitebg.setColor(QPalette::Window, QColor(255,255,255));
buttonWidget->setPalette(whitebg); buttonWidget->setPalette(whitebg);
@ -111,9 +118,11 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
infoLayout->setSpacing(4); infoLayout->setSpacing(4);
textLayout->addWidget(size); textLayout->addWidget(size);
textLayout->addStretch(.5);
textLayout->addWidget(speed); textLayout->addWidget(speed);
textLayout->addStretch(.5);
textLayout->addWidget(eta); textLayout->addWidget(eta);
textLayout->setMargin(0); textLayout->setMargin(2);
textLayout->setSpacing(5); textLayout->setSpacing(5);
buttonLayout->addWidget(topright); buttonLayout->addWidget(topright);
@ -164,6 +173,7 @@ void FileTransfertWidget::onFileTransferCancelled(int FriendId, int FileNum, Tox
{ {
if (FileNum != fileNum || FriendId != friendId || Direction != direction) if (FileNum != fileNum || FriendId != friendId || Direction != direction)
return; return;
buttonLayout->setContentsMargins(0,0,0,0);
disconnect(topright); disconnect(topright);
disconnect(Widget::getInstance()->getCore(),0,this,0); disconnect(Widget::getInstance()->getCore(),0,this,0);
progress->hide(); progress->hide();
@ -175,9 +185,12 @@ void FileTransfertWidget::onFileTransferCancelled(int FriendId, int FileNum, Tox
whiteText.setColor(QPalette::WindowText, Qt::white); whiteText.setColor(QPalette::WindowText, Qt::white);
filename->setPalette(whiteText); filename->setPalette(whiteText);
size->setPalette(whiteText); size->setPalette(whiteText);
QPalette toxred; this->setObjectName("error");
toxred.setColor(QPalette::Window, QColor(200,78,78)); // Tox Red this->style()->polish(this);
setPalette(toxred);
//Toggle window visibility to fix draw order bug
this->hide();
this->show();
} }
void FileTransfertWidget::onFileTransferFinished(ToxFile File) void FileTransfertWidget::onFileTransferFinished(ToxFile File)
@ -191,14 +204,17 @@ void FileTransfertWidget::onFileTransferFinished(ToxFile File)
eta->hide(); eta->hide();
topright->hide(); topright->hide();
bottomright->hide(); bottomright->hide();
buttonLayout->setContentsMargins(0,0,0,0);
QPalette whiteText; QPalette whiteText;
whiteText.setColor(QPalette::WindowText, Qt::white); whiteText.setColor(QPalette::WindowText, Qt::white);
filename->setPalette(whiteText); filename->setPalette(whiteText);
size->setPalette(whiteText); size->setPalette(whiteText);
// TODO: Maybe just replace the whole buttonWidget with a single round CSS that shows the accept icon this->setObjectName("success");
QPalette toxgreen; this->style()->polish(this);
toxgreen.setColor(QPalette::Window, QColor(107,194,96)); // Tox Green
setPalette(toxgreen); //Toggle window visibility to fix draw order bug
this->hide();
this->show();
if (File.direction == ToxFile::RECEIVING) if (File.direction == ToxFile::RECEIVING)
{ {
@ -251,3 +267,11 @@ void FileTransfertWidget::pauseResumeSend()
{ {
Widget::getInstance()->getCore()->pauseResumeFileSend(friendId, fileNum); Widget::getInstance()->getCore()->pauseResumeFileSend(friendId, fileNum);
} }
void FileTransfertWidget::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

View File

@ -16,6 +16,7 @@ struct ToxFile;
class FileTransfertWidget : public QWidget class FileTransfertWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
FileTransfertWidget(ToxFile File); FileTransfertWidget(ToxFile File);
@ -48,6 +49,7 @@ private:
QString savePath; QString savePath;
ToxFile::FileDirection direction; ToxFile::FileDirection direction;
QString stopFileButtonStylesheet, pauseFileButtonStylesheet, acceptFileButtonStylesheet; QString stopFileButtonStylesheet, pauseFileButtonStylesheet, acceptFileButtonStylesheet;
void paintEvent(QPaintEvent *);
}; };
#endif // FILETRANSFERTWIDGET_H #endif // FILETRANSFERTWIDGET_H

View File

@ -55,11 +55,11 @@ EditableLabelWidget::EditableLabelWidget(QWidget* parent) :
lineEdit->setMinimumHeight(label->fontMetrics().lineSpacing() + LINE_SPACING_OFFSET); lineEdit->setMinimumHeight(label->fontMetrics().lineSpacing() + LINE_SPACING_OFFSET);
// Set dark background for >windows // Set dark background for >windows
QColor toxDarkAsMySoul(28,28,28); //QColor toxDarkAsMySoul(28,28,28);
QPalette darkPal; //QPalette darkPal;
darkPal.setColor(QPalette::Window, toxDarkAsMySoul); //darkPal.setColor(QPalette::Window, toxDarkAsMySoul);
darkPal.setColor(QPalette::Base, toxDarkAsMySoul); //darkPal.setColor(QPalette::Base, toxDarkAsMySoul);
lineEdit->setPalette(darkPal); //lineEdit->setPalette(darkPal);
connect(lineEdit, &EscLineEdit::editingFinished, this, &EditableLabelWidget::onLabelChangeSubmited); connect(lineEdit, &EscLineEdit::editingFinished, this, &EditableLabelWidget::onLabelChangeSubmited);
connect(lineEdit, &EscLineEdit::escPressed, this, &EditableLabelWidget::onLabelChangeCancelled); connect(lineEdit, &EscLineEdit::escPressed, this, &EditableLabelWidget::onLabelChangeCancelled);

View File

@ -138,7 +138,6 @@ Widget::Widget(QWidget *parent) :
friendListWidget->layout()->setSpacing(0); friendListWidget->layout()->setSpacing(0);
friendListWidget->layout()->setMargin(0); friendListWidget->layout()->setMargin(0);
friendListWidget->setLayoutDirection(Qt::LeftToRight); friendListWidget->setLayoutDirection(Qt::LeftToRight);
//friendListWidget->
ui->friendList->setWidget(friendListWidget); ui->friendList->setWidget(friendListWidget);
ui->nameLabel->setText(Settings::getInstance().getUsername()); ui->nameLabel->setText(Settings::getInstance().getUsername());
@ -146,7 +145,6 @@ Widget::Widget(QWidget *parent) :
ui->statusLabel->setText(Settings::getInstance().getStatusMessage()); ui->statusLabel->setText(Settings::getInstance().getStatusMessage());
ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}"); ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}");
ui->friendList->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); ui->friendList->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
ui->centralWidget->setStyleSheet("QSplitter{background-color: white;}");
this->setMouseTracking(true); this->setMouseTracking(true);