forked from qt-creator/qt-creator
Core: Make FancyActionBar actions theme aware
The text in the FancyActionBar actions had hardcoded text colors, which by accidend looked OK with the current themes. But light themes require these texts to follow the theme. This patch removes the uncommon "shadows" under the text, instead of trying to make text shadows themable. Change-Id: Ie0e3a9673f24ead64dcdd8963319dc1908afb3aa Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
committed by
Alessandro Portale
parent
e2dab0cf07
commit
f556057924
@@ -206,23 +206,14 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
|
|||||||
QPoint textOffset = centerRect.center() - QPoint(iconRect.width()/2, iconRect.height()/2);
|
QPoint textOffset = centerRect.center() - QPoint(iconRect.width()/2, iconRect.height()/2);
|
||||||
textOffset = textOffset - QPoint(0, lineHeight + 4);
|
textOffset = textOffset - QPoint(0, lineHeight + 4);
|
||||||
QRectF r(0, textOffset.y(), rect().width(), lineHeight);
|
QRectF r(0, textOffset.y(), rect().width(), lineHeight);
|
||||||
QColor penColor;
|
painter.setPen(creatorTheme()->color(isEnabled()
|
||||||
if (isEnabled())
|
? Theme::PanelTextColorLight
|
||||||
penColor = Qt::white;
|
: Theme::IconsDisabledColor));
|
||||||
else
|
|
||||||
penColor = Qt::gray;
|
|
||||||
painter.setPen(penColor);
|
|
||||||
|
|
||||||
// draw project name
|
// draw project name
|
||||||
const int margin = 6;
|
const int margin = 6;
|
||||||
const qreal availableWidth = r.width() - margin;
|
const qreal availableWidth = r.width() - margin;
|
||||||
QString ellidedProjectName = fm.elidedText(projectName, Qt::ElideMiddle, availableWidth);
|
QString ellidedProjectName = fm.elidedText(projectName, Qt::ElideMiddle, availableWidth);
|
||||||
if (isEnabled()) {
|
|
||||||
const QRectF shadowR = r.translated(0, 1);
|
|
||||||
painter.setPen(QColor(30, 30, 30, 80));
|
|
||||||
painter.drawText(shadowR, textFlags, ellidedProjectName);
|
|
||||||
painter.setPen(penColor);
|
|
||||||
}
|
|
||||||
painter.drawText(r, textFlags, ellidedProjectName);
|
painter.drawText(r, textFlags, ellidedProjectName);
|
||||||
|
|
||||||
// draw build configuration name
|
// draw build configuration name
|
||||||
@@ -240,15 +231,12 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
|
|||||||
splitBuildConfiguration = splitInTwoLines(buildConfiguration, boldFm, availableWidth);
|
splitBuildConfiguration = splitInTwoLines(buildConfiguration, boldFm, availableWidth);
|
||||||
}
|
}
|
||||||
// draw the two lines for the build configuration
|
// draw the two lines for the build configuration
|
||||||
|
painter.setPen(creatorTheme()->color(isEnabled()
|
||||||
|
? Theme::FancyTabWidgetEnabledSelectedTextColor
|
||||||
|
: Theme::FancyTabWidgetDisabledSelectedTextColor));
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
if (splitBuildConfiguration[i].isEmpty())
|
if (splitBuildConfiguration[i].isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (isEnabled()) {
|
|
||||||
const QRectF shadowR = buildConfigRect[i].translated(0, 1);
|
|
||||||
painter.setPen(QColor(30, 30, 30, 80));
|
|
||||||
painter.drawText(shadowR, textFlags, splitBuildConfiguration[i]);
|
|
||||||
painter.setPen(penColor);
|
|
||||||
}
|
|
||||||
painter.drawText(buildConfigRect[i], textFlags, splitBuildConfiguration[i]);
|
painter.drawText(buildConfigRect[i], textFlags, splitBuildConfiguration[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user