summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-10-16 15:18:28 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-10-16 15:18:28 (GMT)
commitd53de780a1b7239d0a2299629b38d5b264d16abc (patch)
treea0179241b5d4b987551dae618389d21d7d9a0b0e
parent6c37154aa16d7ff9a6bcd348de7df4c6be487c6d (diff)
Tweak the progress thing a bit
-rw-r--r--src/part/progressBox.cpp21
-rw-r--r--src/part/progressBox.h2
2 files changed, 13 insertions, 10 deletions
diff --git a/src/part/progressBox.cpp b/src/part/progressBox.cpp
index 4989fdc..344c36c 100644
--- a/src/part/progressBox.cpp
+++ b/src/part/progressBox.cpp
@@ -40,6 +40,7 @@
ProgressBox::ProgressBox(QWidget *parent, Filelight::Part *part, Filelight::ScanManager *scanManager)
: QWidget(parent)
, m_manager(scanManager)
+ , m_colorScheme(QPalette::Active, KColorScheme::Tooltip)
{
hide();
@@ -50,7 +51,7 @@ ProgressBox::ProgressBox(QWidget *parent, Filelight::Part *part, Filelight::Scan
setText(999999);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- setMinimumSize(200, 200);
+ setMinimumSize(300, 300);
connect(&m_timer, &QTimer::timeout, this, &ProgressBox::report);
connect(part, &Filelight::Part::started, this, &ProgressBox::start);
@@ -96,21 +97,22 @@ ProgressBox::setText(int files)
}
#define PIECES_NUM 4
-static const float angleFactor[] = { -0.75, 0.5, 1.0, -0.3 };
-static const int length[] = { 30, 40, 50, 60 };
-static const int aLength[] = { 300, 2000, 200, 2000 };
+static const float angleFactor[] = { -0.25, 0.9, -1.0, 0.3 };
+static const float length[] = { 1.0, 1.0, 1.0, 1.0 };
+static const int aLength[] = { 2000, 2000, 2000, 2000 };
void ProgressBox::paintEvent(QPaintEvent*)
{
- KColorScheme view = KColorScheme(QPalette::Active, KColorScheme::Tooltip);
QPainter paint(this);
+ paint.setPen(Qt::transparent);
paint.setRenderHint(QPainter::Antialiasing);
static int tick = 0;
tick+=16;
for (int i=0; i<PIECES_NUM; i++) {
- const QRect rect(length[i]/2, length[i]/2, 200- length[i], 200-length[i]);
+ const int size = qMin(width(), height()) * length[i];
+ const QRect rect(width() / 2 - size / 2, height() / 2 - size / 2, size, size);
int angle = angleFactor[i] + tick*angleFactor[i];
QRadialGradient gradient(rect.center(), sin(angle/160.0f) * 100);
gradient.setColorAt(0, QColor::fromHsv(abs(angle/16) % 360 , 160, 255));
@@ -120,12 +122,11 @@ void ProgressBox::paintEvent(QPaintEvent*)
paint.drawPie(QRect(rect), angle, aLength[i]);
}
- paint.setBrush(view.background(KColorScheme::ActiveBackground));
- paint.setPen(view.foreground().color());
paint.translate(0.5, 0.5);
- QRectF textRect(100 - m_textWidth/2 - 5, 100 - m_textHeight - 5, m_textWidth + 10, m_textHeight + 10);
- paint.drawRoundedRect(textRect, 5, 5);
+ QRectF textRect(width() / 2 - m_textWidth/2 - 5, width() / 2 - m_textHeight - 5, m_textWidth + 10, m_textHeight + 10);
+ paint.fillRect(textRect, m_colorScheme.background(KColorScheme::ActiveBackground).color());
paint.translate(-0.5, -0.5);
+ paint.setPen(m_colorScheme.foreground().color());
paint.drawText(textRect, Qt::AlignCenter, m_text);
}
diff --git a/src/part/progressBox.h b/src/part/progressBox.h
index 95cef07..c0aace3 100644
--- a/src/part/progressBox.h
+++ b/src/part/progressBox.h
@@ -24,6 +24,7 @@
#include <QLabel>
#include <QTimer>
+#include <KColorScheme>
namespace Filelight {
class ScanManager;
@@ -54,6 +55,7 @@ private:
QString m_text;
int m_textWidth;
int m_textHeight;
+ KColorScheme m_colorScheme;
};
#endif