forked from qt-creator/qt-creator
ProgressBar: Make it really flat for flat themes
Change-Id: I3964492e4b07dcba594d5bebc1b74d9458578e88 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -91,7 +91,7 @@ PanelTextColorMid=ffa0a0a0
|
|||||||
PanelTextColorLight=text
|
PanelTextColorLight=text
|
||||||
ProgressBarColorError=error
|
ProgressBarColorError=error
|
||||||
ProgressBarColorFinished=ff5aaa3c
|
ProgressBarColorFinished=ff5aaa3c
|
||||||
ProgressBarColorNormal=hoverBackground
|
ProgressBarColorNormal=ff808080
|
||||||
ProgressBarTitleColor=text
|
ProgressBarTitleColor=text
|
||||||
SplitterColor=ff313131
|
SplitterColor=ff313131
|
||||||
TextColorDisabled=textDisabled
|
TextColorDisabled=textDisabled
|
||||||
@@ -168,7 +168,6 @@ ClangCodeModel_Warning_TextMarkColor=ffceff40
|
|||||||
ComboBoxDrawTextShadow=false
|
ComboBoxDrawTextShadow=false
|
||||||
DerivePaletteFromTheme=true
|
DerivePaletteFromTheme=true
|
||||||
DrawIndicatorBranch=true
|
DrawIndicatorBranch=true
|
||||||
DrawProgressBarSunken=false
|
|
||||||
DrawSearchResultWidgetFrame=false
|
DrawSearchResultWidgetFrame=false
|
||||||
DrawTargetSelectorBottom=false
|
DrawTargetSelectorBottom=false
|
||||||
DrawToolBarHighlights=true
|
DrawToolBarHighlights=true
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ PanelsWidgetSeparatorLineColor=0
|
|||||||
PanelTextColorDark=text
|
PanelTextColorDark=text
|
||||||
PanelTextColorMid=ff666666
|
PanelTextColorMid=ff666666
|
||||||
PanelTextColorLight=toolBarItem
|
PanelTextColorLight=toolBarItem
|
||||||
ProgressBarColorError=error
|
ProgressBarColorError=ffdb6f71
|
||||||
ProgressBarColorFinished=ff5aaa3c
|
ProgressBarColorFinished=dda4d576
|
||||||
ProgressBarColorNormal=hoverBackground
|
ProgressBarColorNormal=ff999999
|
||||||
ProgressBarTitleColor=toolBarItem
|
ProgressBarTitleColor=toolBarItem
|
||||||
SplitterColor=splitter
|
SplitterColor=splitter
|
||||||
TextColorDisabled=textDisabled
|
TextColorDisabled=textDisabled
|
||||||
@@ -170,7 +170,6 @@ ClangCodeModel_Warning_TextMarkColor=ffc6c132
|
|||||||
ComboBoxDrawTextShadow=false
|
ComboBoxDrawTextShadow=false
|
||||||
DerivePaletteFromTheme=false
|
DerivePaletteFromTheme=false
|
||||||
DrawIndicatorBranch=true
|
DrawIndicatorBranch=true
|
||||||
DrawProgressBarSunken=false
|
|
||||||
DrawSearchResultWidgetFrame=false
|
DrawSearchResultWidgetFrame=false
|
||||||
DrawTargetSelectorBottom=false
|
DrawTargetSelectorBottom=false
|
||||||
DrawToolBarHighlights=false
|
DrawToolBarHighlights=false
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ ClangCodeModel_Warning_TextMarkColor=ffc6c132
|
|||||||
ComboBoxDrawTextShadow=true
|
ComboBoxDrawTextShadow=true
|
||||||
DerivePaletteFromTheme=false
|
DerivePaletteFromTheme=false
|
||||||
DrawIndicatorBranch=false
|
DrawIndicatorBranch=false
|
||||||
DrawProgressBarSunken=true
|
|
||||||
DrawSearchResultWidgetFrame=true
|
DrawSearchResultWidgetFrame=true
|
||||||
DrawTargetSelectorBottom=true
|
DrawTargetSelectorBottom=true
|
||||||
DrawToolBarHighlights=true
|
DrawToolBarHighlights=true
|
||||||
|
|||||||
@@ -254,7 +254,6 @@ public:
|
|||||||
enum Flag {
|
enum Flag {
|
||||||
DrawTargetSelectorBottom,
|
DrawTargetSelectorBottom,
|
||||||
DrawSearchResultWidgetFrame,
|
DrawSearchResultWidgetFrame,
|
||||||
DrawProgressBarSunken,
|
|
||||||
DrawIndicatorBranch,
|
DrawIndicatorBranch,
|
||||||
DrawToolBarHighlights,
|
DrawToolBarHighlights,
|
||||||
ComboBoxDrawTextShadow,
|
ComboBoxDrawTextShadow,
|
||||||
|
|||||||
@@ -182,11 +182,11 @@ void ProgressBar::setError(bool on)
|
|||||||
QSize ProgressBar::sizeHint() const
|
QSize ProgressBar::sizeHint() const
|
||||||
{
|
{
|
||||||
int width = 50;
|
int width = 50;
|
||||||
int height = PROGRESSBAR_HEIGHT + 6;
|
int height = PROGRESSBAR_HEIGHT + 5;
|
||||||
if (m_titleVisible) {
|
if (m_titleVisible) {
|
||||||
QFontMetrics fm(titleFont());
|
QFontMetrics fm(titleFont());
|
||||||
width = qMax(width, fm.width(m_title) + 16);
|
width = qMax(width, fm.width(m_title) + 16);
|
||||||
height += fm.height() + 4;
|
height += fm.height() + 5;
|
||||||
}
|
}
|
||||||
if (m_separatorVisible)
|
if (m_separatorVisible)
|
||||||
height += SEPARATOR_HEIGHT;
|
height += SEPARATOR_HEIGHT;
|
||||||
@@ -226,12 +226,9 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
|||||||
// TODO move font into Utils::StyleHelper
|
// TODO move font into Utils::StyleHelper
|
||||||
// TODO use Utils::StyleHelper white
|
// TODO use Utils::StyleHelper white
|
||||||
|
|
||||||
if (bar.isNull())
|
|
||||||
bar.load(StyleHelper::dpiSpecificImageFile(QLatin1String(":/core/images/progressbar.png")));
|
|
||||||
|
|
||||||
double range = maximum() - minimum();
|
double range = maximum() - minimum();
|
||||||
double percent = 0.;
|
double percent = 0.;
|
||||||
if (range != 0)
|
if (!qFuzzyIsNull(range))
|
||||||
percent = (value() - minimum()) / range;
|
percent = (value() - minimum()) / range;
|
||||||
if (percent > 1)
|
if (percent > 1)
|
||||||
percent = 1;
|
percent = 1;
|
||||||
@@ -282,18 +279,13 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
|||||||
m_progressHeight = PROGRESSBAR_HEIGHT;
|
m_progressHeight = PROGRESSBAR_HEIGHT;
|
||||||
m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
|
m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
|
||||||
// draw outer rect
|
// draw outer rect
|
||||||
const QRect rect(INDENT - 1, titleHeight + separatorHeight + (m_titleVisible ? 4 : 3),
|
const QRect rect(INDENT - 1, titleHeight + separatorHeight + (m_titleVisible ? 5 : 4),
|
||||||
size().width() - 2 * INDENT + 1, m_progressHeight);
|
size().width() - 2 * INDENT + 1, m_progressHeight);
|
||||||
|
|
||||||
if (creatorTheme()->flag(Theme::DrawProgressBarSunken))
|
|
||||||
StyleHelper::drawCornerImage(bar, &p, rect, 3, 3, 3, 3);
|
|
||||||
|
|
||||||
// draw inner rect
|
|
||||||
QColor c = creatorTheme()->color(Theme::ProgressBarColorNormal);
|
|
||||||
p.setPen(Qt::NoPen);
|
|
||||||
|
|
||||||
QRectF inner = rect.adjusted(2, 2, -2, -2);
|
QRectF inner = rect.adjusted(2, 2, -2, -2);
|
||||||
inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0);
|
inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0);
|
||||||
|
|
||||||
|
QColor c;
|
||||||
if (m_error) {
|
if (m_error) {
|
||||||
c = creatorTheme()->color(Theme::ProgressBarColorError);
|
c = creatorTheme()->color(Theme::ProgressBarColorError);
|
||||||
// avoid too small red bar
|
// avoid too small red bar
|
||||||
@@ -301,25 +293,33 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
|||||||
inner.adjust(0, 0, 10 - inner.width(), 0);
|
inner.adjust(0, 0, 10 - inner.width(), 0);
|
||||||
} else if (m_finished) {
|
} else if (m_finished) {
|
||||||
c = creatorTheme()->color(Theme::ProgressBarColorFinished);
|
c = creatorTheme()->color(Theme::ProgressBarColorFinished);
|
||||||
|
} else {
|
||||||
|
c = creatorTheme()->color(Theme::ProgressBarColorNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//draw the progress bar
|
||||||
|
if (creatorTheme()->widgetStyle() == Theme::StyleFlat) {
|
||||||
|
p.fillRect(rect.adjusted(2, 2, -2, -2),
|
||||||
|
creatorTheme()->color(Theme::FancyToolButtonHoverColor));
|
||||||
|
p.fillRect(inner, c);
|
||||||
|
} else {
|
||||||
|
const static QImage bar(StyleHelper::dpiSpecificImageFile(
|
||||||
|
QLatin1String(":/core/images/progressbar.png")));
|
||||||
|
StyleHelper::drawCornerImage(bar, &p, rect, 3, 3, 3, 3);
|
||||||
|
|
||||||
// Draw line and shadow after the gradient fill
|
// Draw line and shadow after the gradient fill
|
||||||
if (value() > 0 && value() < maximum()) {
|
if (value() > 0 && value() < maximum()) {
|
||||||
p.fillRect(QRect(inner.right(), inner.top(), 2, inner.height()), QColor(0, 0, 0, 20));
|
p.fillRect(QRect(inner.right(), inner.top(), 2, inner.height()), QColor(0, 0, 0, 20));
|
||||||
p.fillRect(QRect(inner.right(), inner.top(), 1, inner.height()), QColor(0, 0, 0, 60));
|
p.fillRect(QRect(inner.right(), inner.top(), 1, inner.height()), QColor(0, 0, 0, 60));
|
||||||
}
|
}
|
||||||
p.setPen(Qt::NoPen);
|
|
||||||
if (creatorTheme()->widgetStyle() == Theme::StyleFlat) {
|
|
||||||
//draw the progress bar
|
|
||||||
p.setBrush (c);
|
|
||||||
} else {
|
|
||||||
QLinearGradient grad(inner.topLeft(), inner.bottomLeft());
|
QLinearGradient grad(inner.topLeft(), inner.bottomLeft());
|
||||||
grad.setColorAt(0, c.lighter(130));
|
grad.setColorAt(0, c.lighter(130));
|
||||||
grad.setColorAt(0.4, c.lighter(106));
|
grad.setColorAt(0.4, c.lighter(106));
|
||||||
grad.setColorAt(0.41, c.darker(106));
|
grad.setColorAt(0.41, c.darker(106));
|
||||||
grad.setColorAt(1, c.darker(130));
|
grad.setColorAt(1, c.darker(130));
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
p.setBrush(grad);
|
p.setBrush(grad);
|
||||||
}
|
|
||||||
p.drawRect(inner);
|
p.drawRect(inner);
|
||||||
p.setBrush(Qt::NoBrush);
|
p.setBrush(Qt::NoBrush);
|
||||||
p.setPen(QPen(QColor(0, 0, 0, 30), 1));
|
p.setPen(QPen(QColor(0, 0, 0, 30), 1));
|
||||||
@@ -328,6 +328,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
|||||||
p.drawLine(inner.topLeft() + QPointF(0.5, 0.5), inner.bottomLeft() + QPointF(0.5, -0.5));
|
p.drawLine(inner.topLeft() + QPointF(0.5, 0.5), inner.bottomLeft() + QPointF(0.5, -0.5));
|
||||||
p.drawLine(inner.topRight() + QPointF(-0.5, 0.5), inner.bottomRight() + QPointF(-0.5, -0.5));
|
p.drawLine(inner.topRight() + QPointF(-0.5, 0.5), inner.bottomRight() + QPointF(-0.5, -0.5));
|
||||||
p.drawLine(inner.bottomLeft() + QPointF(0.5, -0.5), inner.bottomRight() + QPointF(-0.5, -0.5));
|
p.drawLine(inner.bottomLeft() + QPointF(0.5, -0.5), inner.bottomRight() + QPointF(-0.5, -0.5));
|
||||||
|
}
|
||||||
|
|
||||||
if (m_cancelEnabled) {
|
if (m_cancelEnabled) {
|
||||||
// Draw cancel button
|
// Draw cancel button
|
||||||
@@ -337,8 +338,9 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
|||||||
m_cancelRect = QRect(rect.adjusted(rect.width() - CANCELBUTTON_WIDTH + 2, 1, 0, 0));
|
m_cancelRect = QRect(rect.adjusted(rect.width() - CANCELBUTTON_WIDTH + 2, 1, 0, 0));
|
||||||
const bool hover = m_cancelRect.contains(mapFromGlobal(QCursor::pos()));
|
const bool hover = m_cancelRect.contains(mapFromGlobal(QCursor::pos()));
|
||||||
const QRectF cancelVisualRect(m_cancelRect.adjusted(0, 1, -2, -2));
|
const QRectF cancelVisualRect(m_cancelRect.adjusted(0, 1, -2, -2));
|
||||||
QLinearGradient grad(cancelVisualRect.topLeft(), cancelVisualRect.bottomLeft());
|
|
||||||
int intensity = hover ? 90 : 70;
|
int intensity = hover ? 90 : 70;
|
||||||
|
if (creatorTheme()->widgetStyle() != Theme::StyleFlat) {
|
||||||
|
QLinearGradient grad(cancelVisualRect.topLeft(), cancelVisualRect.bottomLeft());
|
||||||
QColor buttonColor(intensity, intensity, intensity, 255);
|
QColor buttonColor(intensity, intensity, intensity, 255);
|
||||||
grad.setColorAt(0, buttonColor.lighter(130));
|
grad.setColorAt(0, buttonColor.lighter(130));
|
||||||
grad.setColorAt(1, buttonColor.darker(130));
|
grad.setColorAt(1, buttonColor.darker(130));
|
||||||
@@ -352,6 +354,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
|||||||
p.drawLine(cancelVisualRect.topLeft() + QPointF(0.5, 0.5), cancelVisualRect.bottomLeft() + QPointF(0.5, -0.5));
|
p.drawLine(cancelVisualRect.topLeft() + QPointF(0.5, 0.5), cancelVisualRect.bottomLeft() + QPointF(0.5, -0.5));
|
||||||
p.setPen(QPen(QColor(255, 255, 255, 30)));
|
p.setPen(QPen(QColor(255, 255, 255, 30)));
|
||||||
p.drawLine(cancelVisualRect.topLeft() + QPointF(1.5, 0.5), cancelVisualRect.bottomLeft() + QPointF(1.5, -0.5));
|
p.drawLine(cancelVisualRect.topLeft() + QPointF(1.5, 0.5), cancelVisualRect.bottomLeft() + QPointF(1.5, -0.5));
|
||||||
|
}
|
||||||
p.setPen(QPen(hover ? StyleHelper::panelTextColor() : QColor(180, 180, 180), 1.2, Qt::SolidLine, Qt::FlatCap));
|
p.setPen(QPen(hover ? StyleHelper::panelTextColor() : QColor(180, 180, 180), 1.2, Qt::SolidLine, Qt::FlatCap));
|
||||||
p.setRenderHint(QPainter::Antialiasing, true);
|
p.setRenderHint(QPainter::Antialiasing, true);
|
||||||
p.drawLine(cancelVisualRect.topLeft() + QPointF(4.0, 2.0), cancelVisualRect.bottomRight() + QPointF(-3.0, -2.0));
|
p.drawLine(cancelVisualRect.topLeft() + QPointF(4.0, 2.0), cancelVisualRect.bottomRight() + QPointF(-3.0, -2.0));
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
QFont titleFont() const;
|
QFont titleFont() const;
|
||||||
|
|
||||||
QImage bar;
|
|
||||||
QString m_text;
|
QString m_text;
|
||||||
QString m_title;
|
QString m_title;
|
||||||
bool m_titleVisible;
|
bool m_titleVisible;
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ void ProgressManagerPrivate::init()
|
|||||||
m_summaryProgressWidget->setVisible(!m_progressViewPinned);
|
m_summaryProgressWidget->setVisible(!m_progressViewPinned);
|
||||||
m_summaryProgressWidget->setGraphicsEffect(m_opacityEffect);
|
m_summaryProgressWidget->setGraphicsEffect(m_opacityEffect);
|
||||||
m_summaryProgressLayout = new QHBoxLayout(m_summaryProgressWidget);
|
m_summaryProgressLayout = new QHBoxLayout(m_summaryProgressWidget);
|
||||||
m_summaryProgressLayout->setContentsMargins(0, 0, 0, 0);
|
m_summaryProgressLayout->setContentsMargins(0, 0, 0, 2);
|
||||||
m_summaryProgressLayout->setSpacing(0);
|
m_summaryProgressLayout->setSpacing(0);
|
||||||
m_summaryProgressWidget->setLayout(m_summaryProgressLayout);
|
m_summaryProgressWidget->setLayout(m_summaryProgressLayout);
|
||||||
m_summaryProgressBar = new ProgressBar(m_summaryProgressWidget);
|
m_summaryProgressBar = new ProgressBar(m_summaryProgressWidget);
|
||||||
|
|||||||
Reference in New Issue
Block a user