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.
This commit is contained in:
Phenom 2018-03-05 20:31:39 +01:00
parent 311b190f67
commit 7da73b35a9

View File

@ -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<int>((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));