From 311b190f67bff3f1d43fa3947ef680feafef5716 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sun, 4 Mar 2018 20:06:33 +0100 Subject: [PATCH 1/3] Add Background to xprogressbar text for more readability. --- retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp b/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp index 5a3f2a8ef..9ab743f87 100644 --- a/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp +++ b/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp @@ -320,9 +320,14 @@ void xProgressBar::paint() // paint text? if (displayText) { - QLocale locale; + QRect bounding = painter->boundingRect(rect, Qt::AlignCenter, QLocale().toString(_pinfo.progress, 'f', 2) + "%"); + QColor color (255-textColor.red(), 255-textColor.green(), 255-textColor.blue(), 125); + painter->setPen(color); + painter->setBrush(QBrush(color)); + painter->drawRect(bounding.adjusted(2,2,-4,-4)); + painter->setPen(textColor); - painter->drawText(rect, Qt::AlignCenter, locale.toString(_pinfo.progress, 'f', 2) + "%"); + painter->drawText(rect, Qt::AlignCenter, QLocale().toString(_pinfo.progress, 'f', 2) + "%"); } backgroundColor.setRgb(255, 255, 255); From 7da73b35a94abb18a9a78a96fac45afaa6417558 Mon Sep 17 00:00:00 2001 From: Phenom Date: Mon, 5 Mar 2018 20:31:39 +0100 Subject: [PATCH 2/3] Add differents views depends ProgressBar width Less than text width: only show progress bar. Text width to 1.5 times: only show text. More than 1.5 times: show chunk and text. --- retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp b/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp index 9ab743f87..003904b30 100644 --- a/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp +++ b/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp @@ -233,7 +233,9 @@ void xProgressBar::paint() uint32_t ss = _pinfo.nb_chunks ; - if(ss > 1) // for small files we use a more progressive display + QRect bounding = painter->boundingRect(rect, Qt::AlignCenter, QLocale().toString(_pinfo.progress, 'f', 2) + "%"); + + if((ss > 1) && (rect.width() > (1.5*bounding.width()))) // for small files we use a more progressive display { if(!_pinfo.cmap._map.empty()) { @@ -303,7 +305,7 @@ void xProgressBar::paint() overPaintSelectedChunks( _pinfo.chunks_in_progress , QColor(170, 20,9), QColor(223,121,123), width,ss) ; overPaintSelectedChunks( _pinfo.chunks_in_checking , QColor(186,143,0), QColor(223,196, 61), width,ss) ; } - else + else if ((rect.width() < bounding.width()) || !displayText) { // calculate progress value int preWidth = static_cast((rect.width() - 1 - hSpan)*(_pinfo.progress/100.0f)); @@ -318,9 +320,8 @@ void xProgressBar::paint() // paint text? - if (displayText) + if (displayText && (rect.width() >= bounding.width())) { - QRect bounding = painter->boundingRect(rect, Qt::AlignCenter, QLocale().toString(_pinfo.progress, 'f', 2) + "%"); QColor color (255-textColor.red(), 255-textColor.green(), 255-textColor.blue(), 125); painter->setPen(color); painter->setBrush(QBrush(color)); From e1482dd5e4777114aca818b21199e04b0ac90dca Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 17 Mar 2018 00:00:05 +0100 Subject: [PATCH 3/3] Add Rounded and Gradient Background to xprogressbar text. --- .../src/gui/FileTransfer/xprogressbar.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp b/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp index 003904b30..f1eb7f3f2 100644 --- a/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp +++ b/retroshare-gui/src/gui/FileTransfer/xprogressbar.cpp @@ -322,10 +322,15 @@ void xProgressBar::paint() // paint text? if (displayText && (rect.width() >= bounding.width())) { - QColor color (255-textColor.red(), 255-textColor.green(), 255-textColor.blue(), 125); - painter->setPen(color); - painter->setBrush(QBrush(color)); - painter->drawRect(bounding.adjusted(2,2,-4,-4)); + QColor colorInt (255-textColor.red(), 255-textColor.green(), 255-textColor.blue(), 127); + QColor colorBor (255-textColor.red(), 255-textColor.green(), 255-textColor.blue(), 63); + QRadialGradient radialGrad(bounding.x()+(bounding.width()/2), bounding.y()+(bounding.height()/2),bounding.width()/2); + radialGrad.setColorAt(0.0, colorInt); + radialGrad.setColorAt(1.0, colorBor); + radialGrad.setSpread(QGradient::ReflectSpread); + painter->setPen(colorBor); + painter->setBrush(radialGrad); + painter->drawRoundedRect(bounding.adjusted(-2,2,2,-3),4.0,4.0); painter->setPen(textColor); painter->drawText(rect, Qt::AlignCenter, QLocale().toString(_pinfo.progress, 'f', 2) + "%");