diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2013-12-30 23:39:10 +0100 |
---|---|---|
committer | Jan Dalheimer <jan@dalheimer.de> | 2013-12-30 23:39:10 +0100 |
commit | 8cfd0881ac3fcbb45fd42dedcb1caf0be38eacaf (patch) | |
tree | 15c704510fc4f3c783e609dd476add7d033fcf22 /InstanceDelegate.cpp | |
parent | e6be883d14a4147ffd58a1c8066bb70879d775fb (diff) | |
download | PrismLauncher-8cfd0881ac3fcbb45fd42dedcb1caf0be38eacaf.tar.gz PrismLauncher-8cfd0881ac3fcbb45fd42dedcb1caf0be38eacaf.tar.bz2 PrismLauncher-8cfd0881ac3fcbb45fd42dedcb1caf0be38eacaf.zip |
Progress indicators
Diffstat (limited to 'InstanceDelegate.cpp')
-rw-r--r-- | InstanceDelegate.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/InstanceDelegate.cpp b/InstanceDelegate.cpp index 5020b8b6..50cead55 100644 --- a/InstanceDelegate.cpp +++ b/InstanceDelegate.cpp @@ -20,6 +20,8 @@ #include <QApplication> #include <QtCore/qmath.h> +#include "CategorizedView.h" + // Origin: Qt static void viewItemTextLayout(QTextLayout &textLayout, int lineWidth, qreal &height, qreal &widthUsed) @@ -85,6 +87,26 @@ void drawFocusRect(QPainter *painter, const QStyleOptionViewItemV4 &option, cons painter->setRenderHint(QPainter::Antialiasing); } +// TODO this can be made a lot prettier +void drawProgressOverlay(QPainter *painter, const QStyleOptionViewItemV4 &option, const int value, const int maximum) +{ + if (maximum == 0 || value == maximum) + { + return; + } + + painter->save(); + + qreal percent = (qreal)value / (qreal)maximum; + QColor color = option.palette.color(QPalette::Dark); + color.setAlphaF(0.70f); + painter->setBrush(color); + painter->setPen(QPen(QBrush(), 0)); + painter->drawPie(option.rect, 90 * 16, -percent * 360 * 60); + + painter->restore(); +} + static QSize viewItemTextSize(const QStyleOptionViewItemV4 *option) { QStyle *style = option->widget ? option->widget->style() : QApplication::style(); @@ -229,6 +251,9 @@ void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti line.draw(painter, position); } + drawProgressOverlay(painter, opt, index.data(CategorizedViewRoles::ProgressValueRole).toInt(), + index.data(CategorizedViewRoles::ProgressMaximumRole).toInt()); + painter->restore(); } |