mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
mockup (WIP)
This commit is contained in:
parent
936a34faf1
commit
faaa147a83
@ -34,7 +34,8 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
|
||||
, ui(new Ui::FileTransferWidget)
|
||||
, fileInfo(file)
|
||||
, lastTick(QTime::currentTime())
|
||||
, color(Style::getColor(Style::LightGrey))
|
||||
, backgroundColor(Style::getColor(Style::LightGrey))
|
||||
, buttonColor(Style::getColor(Style::Yellow))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -48,11 +49,11 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
|
||||
ui->progressLabel->setText("0kiB/s");
|
||||
ui->etaLabel->setText("");
|
||||
|
||||
colorAnimation = new QVariantAnimation(this);
|
||||
colorAnimation->setDuration(500);
|
||||
colorAnimation->setEasingCurve(QEasingCurve::OutCubic);
|
||||
connect(colorAnimation, &QVariantAnimation::valueChanged, this, [this](const QVariant& val) {
|
||||
color = val.value<QColor>();
|
||||
backgroundColorAnimation = new QVariantAnimation(this);
|
||||
backgroundColorAnimation->setDuration(500);
|
||||
backgroundColorAnimation->setEasingCurve(QEasingCurve::OutCubic);
|
||||
connect(backgroundColorAnimation, &QVariantAnimation::valueChanged, this, [this](const QVariant& val) {
|
||||
backgroundColor = val.value<QColor>();
|
||||
update();
|
||||
});
|
||||
|
||||
@ -121,11 +122,11 @@ void FileTransferWidget::acceptTransfer(const QString &filepath)
|
||||
|
||||
void FileTransferWidget::setColor(const QColor &c, bool whiteFont)
|
||||
{
|
||||
if(c != color)
|
||||
if(c != backgroundColor)
|
||||
{
|
||||
colorAnimation->setStartValue(color);
|
||||
colorAnimation->setEndValue(c);
|
||||
colorAnimation->start();
|
||||
backgroundColorAnimation->setStartValue(backgroundColor);
|
||||
backgroundColorAnimation->setEndValue(c);
|
||||
backgroundColorAnimation->start();
|
||||
}
|
||||
|
||||
setProperty("fontColor", whiteFont ? "white" : "black");
|
||||
@ -149,13 +150,27 @@ void FileTransferWidget::paintEvent(QPaintEvent *)
|
||||
// required by Hi-DPI support as border-image doesn't work.
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setBrush(QBrush(color));
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
qreal s = static_cast<qreal>(geometry().height()) / static_cast<qreal>(geometry().width());
|
||||
int r = 20;
|
||||
qreal ratio = static_cast<qreal>(geometry().height()) / static_cast<qreal>(geometry().width());
|
||||
const int r = 20;
|
||||
const int buttonFieldWidth = 34;
|
||||
const int lineWidth = 2;
|
||||
|
||||
painter.drawRoundRect(geometry(), r * s, r);
|
||||
// draw background
|
||||
painter.setBrush(QBrush(backgroundColor));
|
||||
painter.setClipRect(QRect(0,0,width()-buttonFieldWidth,height()));
|
||||
painter.drawRoundRect(geometry(), r * ratio, r);
|
||||
|
||||
// draw button background (top)
|
||||
painter.setBrush(QBrush(buttonColor));
|
||||
painter.setClipRect(QRect(width()-buttonFieldWidth+lineWidth,0,buttonFieldWidth,height()/2-lineWidth/2));
|
||||
painter.drawRoundRect(geometry(), r * ratio, r);
|
||||
|
||||
// draw button background (bottom)
|
||||
painter.setBrush(QBrush(buttonColor));
|
||||
painter.setClipRect(QRect(width()-buttonFieldWidth+lineWidth,height()/2+lineWidth/2,buttonFieldWidth,height()/2));
|
||||
painter.drawRoundRect(geometry(), r * ratio, r);
|
||||
}
|
||||
|
||||
void FileTransferWidget::onFileTransferInfo(ToxFile file)
|
||||
|
@ -69,8 +69,9 @@ private:
|
||||
ToxFile fileInfo;
|
||||
QTime lastTick;
|
||||
qint64 lastBytesSent = 0;
|
||||
QVariantAnimation* colorAnimation = nullptr;
|
||||
QColor color;
|
||||
QVariantAnimation* backgroundColorAnimation = nullptr;
|
||||
QColor backgroundColor;
|
||||
QColor buttonColor;
|
||||
|
||||
static const uint8_t TRANSFER_ROLLING_AVG_COUNT = 4;
|
||||
uint8_t meanIndex = 0;
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>532</width>
|
||||
<height>90</height>
|
||||
<height>238</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -79,6 +79,12 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>[preview]</string>
|
||||
</property>
|
||||
@ -251,8 +257,8 @@
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>25</width>
|
||||
<height>28</height>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
@ -260,19 +266,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>92</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="bottomButton">
|
||||
<property name="sizePolicy">
|
||||
@ -286,8 +279,8 @@
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>25</width>
|
||||
<height>28</height>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
@ -295,6 +288,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user