forked from qt-creator/qt-creator
Utils: Fix missing DetailsWidget outline
On some systems, QPalette::Midlight can have the same color as the background color. So instead of using QPalette::Midlight on non-macOS, mix our own color with 15% text color intensity, to visually match what Qt Creator < 9.0 did. Change-Id: I40848b5e16344c07f42c20415194f893641d5f70 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/icon.h>
|
||||
#include <utils/stylehelper.h>
|
||||
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QGuiApplication>
|
||||
@@ -81,6 +82,14 @@ QSize DetailsButton::sizeHint() const
|
||||
spacing + fontMetrics().height() + spacing);
|
||||
}
|
||||
|
||||
QColor DetailsButton::outlineColor()
|
||||
{
|
||||
return HostOsInfo::isMacHost()
|
||||
? QGuiApplication::palette().color(QPalette::Mid)
|
||||
: StyleHelper::mergedColors(creatorTheme()->color(Theme::TextColorNormal),
|
||||
creatorTheme()->color(Theme::BackgroundColorNormal), 15);
|
||||
}
|
||||
|
||||
void DetailsButton::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
@@ -93,11 +102,8 @@ void DetailsButton::paintEvent(QPaintEvent *e)
|
||||
p.restore();
|
||||
}
|
||||
|
||||
if (!creatorTheme()->flag(Theme::FlatProjectsMode)) {
|
||||
const QColor outlineColor = palette().color(HostOsInfo::isMacHost() ? QPalette::Mid
|
||||
: QPalette::Midlight);
|
||||
qDrawPlainRect(&p, rect(), outlineColor);
|
||||
}
|
||||
if (!creatorTheme()->flag(Theme::FlatProjectsMode))
|
||||
qDrawPlainRect(&p, rect(), outlineColor());
|
||||
|
||||
const QRect textRect(spacing + 3, 0, width(), height());
|
||||
p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text());
|
||||
|
@@ -49,6 +49,7 @@ class QTCREATOR_UTILS_EXPORT DetailsButton : public ExpandButton
|
||||
public:
|
||||
DetailsButton(QWidget *parent = nullptr);
|
||||
QSize sizeHint() const override;
|
||||
static QColor outlineColor();
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
@@ -227,11 +227,8 @@ void DetailsWidget::paintEvent(QPaintEvent *paintEvent)
|
||||
: palette().color(QPalette::Window);
|
||||
p.fillRect(rect(), bgColor);
|
||||
}
|
||||
if (!creatorTheme()->flag(Theme::FlatProjectsMode)) {
|
||||
const QColor outlineColor = palette().color(HostOsInfo::isMacHost() ? QPalette::Mid
|
||||
: QPalette::Midlight);
|
||||
qDrawPlainRect(&p, rect(), outlineColor);
|
||||
}
|
||||
if (!creatorTheme()->flag(Theme::FlatProjectsMode))
|
||||
qDrawPlainRect(&p, rect(), DetailsButton::outlineColor());
|
||||
}
|
||||
|
||||
void DetailsWidget::enterEvent(QEnterEvent *event)
|
||||
|
Reference in New Issue
Block a user