mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Improve file transfer dialog
This commit is contained in:
parent
ae16480dc3
commit
9c7998d38b
1
res.qrc
1
res.qrc
@ -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>
|
||||||
|
15
ui/fileTransferWidget/fileTransferWidget.css
Normal file
15
ui/fileTransferWidget/fileTransferWidget.css
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#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 {
|
||||||
|
border-radius: 6px;
|
||||||
|
background-color: rgb(107,194,96);
|
||||||
|
}
|
@ -4,11 +4,13 @@
|
|||||||
#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},
|
||||||
fileNum{File.fileNum}, friendId{File.friendId}, direction{File.direction}
|
fileNum{File.fileNum}, friendId{File.friendId}, direction{File.direction}
|
||||||
{
|
{
|
||||||
|
background = new QFrame;
|
||||||
pic=new QLabel(), filename=new QLabel(), size=new QLabel(), speed=new QLabel(), eta=new QLabel();
|
pic=new QLabel(), filename=new QLabel(), size=new QLabel(), speed=new QLabel(), eta=new QLabel();
|
||||||
topright = new QPushButton(), bottomright = new QPushButton();
|
topright = new QPushButton(), bottomright = new QPushButton();
|
||||||
progress = new QProgressBar();
|
progress = new QProgressBar();
|
||||||
@ -17,6 +19,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));
|
||||||
@ -164,6 +171,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,15 +183,15 @@ 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileTransfertWidget::onFileTransferFinished(ToxFile File)
|
void FileTransfertWidget::onFileTransferFinished(ToxFile File)
|
||||||
{
|
{
|
||||||
if (File.fileNum != fileNum || File.friendId != friendId || File.direction != direction)
|
if (File.fileNum != fileNum || File.friendId != friendId || File.direction != direction)
|
||||||
return;
|
return;
|
||||||
|
buttonLayout->setContentsMargins(0,0,0,0);
|
||||||
topright->disconnect();
|
topright->disconnect();
|
||||||
disconnect(Widget::getInstance()->getCore(),0,this,0);
|
disconnect(Widget::getInstance()->getCore(),0,this,0);
|
||||||
progress->hide();
|
progress->hide();
|
||||||
@ -195,10 +203,8 @@ void FileTransfertWidget::onFileTransferFinished(ToxFile File)
|
|||||||
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);
|
|
||||||
|
|
||||||
if (File.direction == ToxFile::RECEIVING)
|
if (File.direction == ToxFile::RECEIVING)
|
||||||
{
|
{
|
||||||
@ -251,3 +257,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);
|
||||||
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user