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

New file transfer widget, round buttons

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-06-28 15:52:17 +02:00
parent f906d5b8f4
commit 23ed263fd4
14 changed files with 107 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

View File

@ -0,0 +1,22 @@
QPushButton
{
background-color: transparent;
background-image: url("ui/acceptFileButton/default.png");
background-repeat: none;
border: none;
width: 24px;
height: 24px;
}
QPushButton:hover
{
background-image: url("ui/acceptFileButton/hover.png");
}
QPushButton:pressed
{
background-image: url("ui/acceptFileButton/pressed.png");
}
QPushButton:focus {
outline: none;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

View File

@ -0,0 +1,22 @@
QPushButton
{
background-color: transparent;
background-image: url("ui/pauseFileButton/default.png");
background-repeat: none;
border: none;
width: 24px;
height: 24px;
}
QPushButton:hover
{
background-image: url("ui/pauseFileButton/hover.png");
}
QPushButton:pressed
{
background-image: url("ui/pauseFileButton/pressed.png");
}
QPushButton:focus {
outline: none;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

BIN
ui/stopFileButton/hover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

View File

@ -0,0 +1,22 @@
QPushButton
{
background-color: transparent;
background-image: url("ui/stopFileButton/default.png");
background-repeat: none;
border: none;
width: 24px;
height: 24px;
}
QPushButton:hover
{
background-image: url("ui/stopFileButton/hover.png");
}
QPushButton:pressed
{
background-image: url("ui/stopFileButton/pressed.png");
}
QPushButton:focus {
outline: none;
}

View File

@ -13,6 +13,7 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
progress = new QProgressBar(); progress = new QProgressBar();
mainLayout = new QHBoxLayout(), textLayout = new QHBoxLayout(); mainLayout = new QHBoxLayout(), textLayout = new QHBoxLayout();
infoLayout = new QVBoxLayout(), buttonLayout = new QVBoxLayout(); infoLayout = new QVBoxLayout(), buttonLayout = new QVBoxLayout();
buttonWidget = new QWidget();
QFont prettysmall; QFont prettysmall;
prettysmall.setPixelSize(10); prettysmall.setPixelSize(10);
QPalette greybg; QPalette greybg;
@ -21,7 +22,7 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
setPalette(greybg); setPalette(greybg);
setAutoFillBackground(true); setAutoFillBackground(true);
setMinimumSize(250,50); setMinimumSize(250,58);
setLayout(mainLayout); setLayout(mainLayout);
mainLayout->setMargin(0); mainLayout->setMargin(0);
@ -38,11 +39,31 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
progress->setValue(0); progress->setValue(0);
progress->setMinimumHeight(11); progress->setMinimumHeight(11);
progress->setFont(prettysmall); progress->setFont(prettysmall);
QPalette whitebg;
whitebg.setColor(QPalette::Window, QColor(255,255,255));
buttonWidget->setPalette(whitebg);
buttonWidget->setAutoFillBackground(true);
buttonWidget->setLayout(buttonLayout);
topright->setIcon(QIcon("img/button icons/no_2x.png")); QFile f1("ui/stopFileButton/style.css");
f1.open(QFile::ReadOnly | QFile::Text);
QTextStream stopFileButtonStylesheetStream(&f1);
stopFileButtonStylesheet = stopFileButtonStylesheetStream.readAll();
QFile f2("ui/pauseFileButton/style.css");
f2.open(QFile::ReadOnly | QFile::Text);
QTextStream pauseFileButtonStylesheetStream(&f2);
pauseFileButtonStylesheet = pauseFileButtonStylesheetStream.readAll();
QFile f3("ui/acceptFileButton/style.css");
f3.open(QFile::ReadOnly | QFile::Text);
QTextStream acceptFileButtonStylesheetStream(&f3);
acceptFileButtonStylesheet = acceptFileButtonStylesheetStream.readAll();
topright->setStyleSheet(stopFileButtonStylesheet);
if (File.direction == ToxFile::SENDING) if (File.direction == ToxFile::SENDING)
{ {
bottomright->setIcon(QIcon("img/button icons/pause_2x.png")); bottomright->setStyleSheet(pauseFileButtonStylesheet);
connect(topright, SIGNAL(clicked()), this, SLOT(cancelTransfer())); connect(topright, SIGNAL(clicked()), this, SLOT(cancelTransfer()));
connect(bottomright, SIGNAL(clicked()), this, SLOT(pauseResumeSend())); connect(bottomright, SIGNAL(clicked()), this, SLOT(pauseResumeSend()));
@ -55,7 +76,7 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
} }
else else
{ {
bottomright->setIcon(QIcon("img/button icons/yes_2x.png")); bottomright->setStyleSheet(acceptFileButtonStylesheet);
connect(topright, SIGNAL(clicked()), this, SLOT(rejectRecvRequest())); connect(topright, SIGNAL(clicked()), this, SLOT(rejectRecvRequest()));
connect(bottomright, SIGNAL(clicked()), this, SLOT(acceptRecvRequest())); connect(bottomright, SIGNAL(clicked()), this, SLOT(acceptRecvRequest()));
} }
@ -63,24 +84,29 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
QPalette toxgreen; QPalette toxgreen;
toxgreen.setColor(QPalette::Button, QColor(107,194,96)); // Tox Green toxgreen.setColor(QPalette::Button, QColor(107,194,96)); // Tox Green
topright->setIconSize(QSize(10,10)); topright->setIconSize(QSize(10,10));
topright->setFixedSize(25,25); topright->setMinimumSize(25,28);
topright->setFlat(true); topright->setFlat(true);
topright->setAutoFillBackground(true); topright->setAutoFillBackground(true);
topright->setPalette(toxgreen); topright->setPalette(toxgreen);
bottomright->setIconSize(QSize(10,10)); bottomright->setIconSize(QSize(10,10));
bottomright->setFixedSize(25,25); bottomright->setMinimumSize(25,28);
bottomright->setFlat(true); bottomright->setFlat(true);
bottomright->setAutoFillBackground(true); bottomright->setAutoFillBackground(true);
bottomright->setPalette(toxgreen); bottomright->setPalette(toxgreen);
mainLayout->addStretch();
mainLayout->addWidget(pic); mainLayout->addWidget(pic);
mainLayout->addLayout(infoLayout); mainLayout->addLayout(infoLayout,3);
mainLayout->addLayout(buttonLayout); mainLayout->addStretch();
mainLayout->addWidget(buttonWidget);
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
infoLayout->addWidget(filename); infoLayout->addWidget(filename);
infoLayout->addLayout(textLayout); infoLayout->addLayout(textLayout);
infoLayout->addWidget(progress); infoLayout->addWidget(progress);
infoLayout->setMargin(5); infoLayout->setMargin(4);
infoLayout->setSpacing(4);
textLayout->addWidget(size); textLayout->addWidget(size);
textLayout->addWidget(speed); textLayout->addWidget(speed);
@ -91,7 +117,7 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
buttonLayout->addWidget(topright); buttonLayout->addWidget(topright);
buttonLayout->addSpacing(2); buttonLayout->addSpacing(2);
buttonLayout->addWidget(bottomright); buttonLayout->addWidget(bottomright);
buttonLayout->setMargin(0); buttonLayout->setContentsMargins(2,0,0,0);
buttonLayout->setSpacing(0); buttonLayout->setSpacing(0);
} }
@ -157,10 +183,9 @@ void FileTransfertWidget::onFileTransferFinished(ToxFile File)
progress->hide(); progress->hide();
speed->hide(); speed->hide();
eta->hide(); eta->hide();
topright->setIcon(QIcon("img/button icons/yes_2x.png")); topright->hide();
buttonLayout->addStretch();
buttonLayout->setSpacing(0);
bottomright->hide(); bottomright->hide();
// TODO: Maybe just replace the whole buttonWidget with a single round CSS that shows the accept icon
QPalette toxgreen; QPalette toxgreen;
toxgreen.setColor(QPalette::Window, QColor(107,194,96)); // Tox Green toxgreen.setColor(QPalette::Window, QColor(107,194,96)); // Tox Green
setPalette(toxgreen); setPalette(toxgreen);
@ -201,7 +226,7 @@ void FileTransfertWidget::acceptRecvRequest()
savePath = path; savePath = path;
bottomright->setIcon(QIcon("img/button icons/pause_2x.png")); bottomright->setStyleSheet(pauseFileButtonStylesheet);
bottomright->disconnect(); bottomright->disconnect();
connect(bottomright, SIGNAL(clicked()), this, SLOT(pauseResumeRecv())); connect(bottomright, SIGNAL(clicked()), this, SLOT(pauseResumeRecv()));
Widget::getInstance()->getCore()->acceptFileRecvRequest(friendId, fileNum); Widget::getInstance()->getCore()->acceptFileRecvRequest(friendId, fileNum);

View File

@ -40,12 +40,14 @@ private:
QProgressBar *progress; QProgressBar *progress;
QHBoxLayout *mainLayout, *textLayout; QHBoxLayout *mainLayout, *textLayout;
QVBoxLayout *infoLayout, *buttonLayout; QVBoxLayout *infoLayout, *buttonLayout;
QWidget* buttonWidget;
QDateTime lastUpdate; QDateTime lastUpdate;
long long lastBytesSent; long long lastBytesSent;
int fileNum; int fileNum;
int friendId; int friendId;
QString savePath; QString savePath;
ToxFile::FileDirection direction; ToxFile::FileDirection direction;
QString stopFileButtonStylesheet, pauseFileButtonStylesheet, acceptFileButtonStylesheet;
}; };
#endif // FILETRANSFERTWIDGET_H #endif // FILETRANSFERTWIDGET_H