auto optionsButtonVisualRect = optionsButtonRect(option.rect, option.direction);
- QPixmap pm = statusIcon.pixmap(iconSize, iconSize, syncEnabled ? QIcon::Normal : QIcon::Disabled);
- painter->drawPixmap(QStyle::visualRect(option.direction, option.rect, iconRect).left(),
- iconRect.top(), pm);
+ const auto statusPixmap = statusIcon.pixmap(iconSize, iconSize, syncEnabled ? QIcon::Normal : QIcon::Disabled);
+ painter->drawPixmap(QStyle::visualRect(option.direction, option.rect, iconRect).left(), iconRect.top(), statusPixmap);
// only show the warning icon if the sync is running. Otherwise its
// encoded in the status icon.
warnRect.setHeight(16);
QIcon warnIcon(":/client/theme/warning");
- const auto pm = warnIcon.pixmap(16, 16, syncEnabled ? QIcon::Normal : QIcon::Disabled);
+ const auto warnPixmap = warnIcon.pixmap(16, 16, syncEnabled ? QIcon::Normal : QIcon::Disabled);
warnRect = QStyle::visualRect(option.direction, option.rect, warnRect);
- painter->drawPixmap(QPoint(warnRect.left(), warnRect.top()), pm);
+ painter->drawPixmap(QPoint(warnRect.left(), warnRect.top()), warnPixmap);
}
auto palette = option.palette;
- auto cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
- if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
- cg = QPalette::Inactive;
+ auto colourGroup = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
+ if (colourGroup == QPalette::Normal && !(option.state & QStyle::State_Active)) {
+ colourGroup = QPalette::Inactive;
}
if (option.state & QStyle::State_Selected) {
- painter->setPen(palette.color(cg, QPalette::HighlightedText));
+ painter->setPen(palette.color(colourGroup, QPalette::HighlightedText));
} else {
- painter->setPen(palette.color(cg, QPalette::Text));
+ painter->setPen(palette.color(colourGroup, QPalette::Text));
}
const auto elidedAlias = aliasFm.elidedText(aliasText, Qt::ElideRight, aliasRect.width());
painter->drawText(QStyle::visualRect(option.direction, option.rect, localPathRect), textAlign, elidedPathText);
}
- auto h = iconRect.bottom() + margin;
+ auto textBoxTop = iconRect.bottom() + margin;
// paint an error overlay if there is an error string or conflict string
auto drawTextBox = [&](const QStringList &texts, QColor color) {
auto rect = localPathRect;
rect.setLeft(iconRect.left());
- rect.setTop(h);
+ rect.setTop(textBoxTop);
rect.setHeight(texts.count() * subFm.height() + 2 * margin);
rect.setRight(option.rect.right() - margin);
rect.width() - 2 * margin,
subFm.height());
- foreach (QString eText, texts) {
- painter->drawText(QStyle::visualRect(option.direction, option.rect, textRect), textAlign,
- subFm.elidedText(eText, Qt::ElideLeft, textRect.width()));
+ for (const auto &eText : texts) {
+ painter->drawText(QStyle::visualRect(option.direction, option.rect, textRect), textAlign, subFm.elidedText(eText, Qt::ElideLeft, textRect.width()));
textRect.translate(0, textRect.height());
}
// restore previous state
painter->restore();
- h = rect.bottom() + margin;
+ textBoxTop = rect.bottom() + margin;
};
if (!conflictTexts.isEmpty()) {
painter->save();
// Overall Progress Bar.
- QRect pBRect;
- pBRect.setTop(remotePathRect.top());
- pBRect.setLeft(nextToIcon);
- pBRect.setHeight(barHeight);
- pBRect.setWidth(overallWidth - 2 * margin);
+ QRect progressBarRect;
+ progressBarRect.setTop(remotePathRect.top());
+ progressBarRect.setLeft(nextToIcon);
+ progressBarRect.setHeight(barHeight);
+ progressBarRect.setWidth(overallWidth - 2 * margin);
- QStyleOptionProgressBar pBarOpt;
+ QStyleOptionProgressBar progressBarOpt;
- pBarOpt.state = option.state | QStyle::State_Horizontal;
- pBarOpt.minimum = 0;
- pBarOpt.maximum = 100;
- pBarOpt.progress = overallPercent;
- pBarOpt.orientation = Qt::Horizontal;
- pBarOpt.rect = QStyle::visualRect(option.direction, option.rect, pBRect);
- QApplication::style()->drawControl(QStyle::CE_ProgressBar, &pBarOpt, painter, option.widget);
+ progressBarOpt.state = option.state | QStyle::State_Horizontal;
+ progressBarOpt.minimum = 0;
+ progressBarOpt.maximum = 100;
+ progressBarOpt.progress = overallPercent;
+ progressBarOpt.orientation = Qt::Horizontal;
+ progressBarOpt.rect = QStyle::visualRect(option.direction, option.rect, progressBarRect);
+ QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOpt, painter, option.widget);
// Overall Progress Text
QRect overallProgressRect;
- overallProgressRect.setTop(pBRect.bottom() + margin);
+ overallProgressRect.setTop(progressBarRect.bottom() + margin);
overallProgressRect.setHeight(fileNameTextHeight);
- overallProgressRect.setLeft(pBRect.left());
- overallProgressRect.setWidth(pBRect.width());
+ overallProgressRect.setLeft(progressBarRect.left());
+ overallProgressRect.setWidth(progressBarRect.width());
painter->setFont(progressFont);
- painter->drawText(QStyle::visualRect(option.direction, option.rect, overallProgressRect),
- Qt::AlignLeft | Qt::AlignVCenter, overallString);
- // painter->drawRect(overallProgressRect);
-
+ painter->drawText(QStyle::visualRect(option.direction, option.rect, overallProgressRect), Qt::AlignLeft | Qt::AlignVCenter, overallString);
painter->restore();
}
btnOpt.subControls = QStyle::SC_ToolButton;
btnOpt.rect = optionsButtonVisualRect;
btnOpt.icon = _iconMore;
- const auto e = QApplication::style()->pixelMetric(QStyle::PM_ButtonIconSize);
- btnOpt.iconSize = QSize(e,e);
+ const auto buttonSize = QApplication::style()->pixelMetric(QStyle::PM_ButtonIconSize);
+ btnOpt.iconSize = QSize(buttonSize, buttonSize);
QApplication::style()->drawComplexControl(QStyle::CC_ToolButton, &btnOpt, painter);
}
}