- QPainter painter(this);
- const int barWidth = width();
- const int barTop = 1;
- const int barHeight = height() - 5;
-
- QString text;
-
- const int widthDec = 3; // visual decrement for the available width
-
- QColor frameColor = palette().brush(QPalette::Background).color();
- frameColor.setAlpha(128);
- painter.setPen(frameColor);
-
- const QColor backgrColor = KGlobalSettings::baseColor();
- painter.setBrush(backgrColor);
-
- painter.drawRect(QRect(0, barTop + 1 , barWidth - widthDec, barHeight));
-
- if ((m_kBSize > 0) && (m_kBAvailable > 0)) {
- // draw 'used size' bar
- painter.setPen(Qt::NoPen);
- painter.setBrush(progressColor(backgrColor));
- int usedWidth = barWidth - static_cast<int>((m_kBAvailable *
- static_cast<float>(barWidth)) / m_kBSize);
- const int left = 1;
- int right = usedWidth - widthDec;
- if (right < left) {
- right = left;
- }
- painter.drawRect(QRect(left, barTop + 2, right, barHeight - 1));
-
- text = i18n("%1 free", KIO::convertSizeFromKiB(m_kBAvailable));
- } else {
- if (m_gettingSize) {
- text = i18n("Getting size...");
- } else {
- text = QString();
- QTimer::singleShot(0, this, SLOT(hide()));
- }
- }
-
- // draw text
- painter.setPen(KGlobalSettings::textColor());
- painter.drawText(QRect(1, 1, barWidth - 2, barHeight + 6),
- Qt::AlignCenter | Qt::TextWordWrap,
- text);