diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index 690c04b9df0..38a1b179319 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -455,6 +456,22 @@ void StyleHelper::drawMinimalArrow(QStyle::PrimitiveElement element, QPainter *p painter->drawPixmap(xOffset, yOffset, pixmap); } +void StyleHelper::drawPanelBgRect(QPainter *painter, const QRectF &rect, const QBrush &brush) +{ + if (toolbarStyle() == ToolbarStyleCompact) { + painter->fillRect(rect.toRect(), brush); + } else { + constexpr int margin = 2; + constexpr int radius = 5; + QPainterPath path; + path.addRoundedRect(rect.adjusted(margin, margin, -margin, -margin), radius, radius); + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); + painter->fillPath(path, brush); + painter->restore(); + } +} + void StyleHelper::menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect) { if (StyleHelper::usePixmapCache()) { diff --git a/src/libs/utils/stylehelper.h b/src/libs/utils/stylehelper.h index 11fa8a03890..8ee91978b7e 100644 --- a/src/libs/utils/stylehelper.h +++ b/src/libs/utils/stylehelper.h @@ -65,6 +65,8 @@ public: static void drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option); static void drawMinimalArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option); + static void drawPanelBgRect(QPainter *painter, const QRectF &rect, const QBrush &brush); + // Gradients used for panels static void horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false); static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false); diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index b8f24e6f709..59d633ee0fc 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -655,9 +655,15 @@ void ManhattanStyle::polish(QWidget *widget) widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true); // So that text isn't cutoff in line-edits, comboboxes... etc. const int height = qMax(StyleHelper::navigationWidgetHeight(), QApplication::fontMetrics().height()); - if (qobject_cast(widget) || qobject_cast(widget)) { + if (qobject_cast(widget)) { + widget->setMinimumWidth( + StyleHelper::toolbarStyle() == StyleHelper::ToolbarStyleCompact ? 24 : 28); widget->setAttribute(Qt::WA_Hover); widget->setMaximumHeight(height - 2); + } else if (qobject_cast(widget)) { + widget->setAttribute(Qt::WA_Hover); + widget->setFixedHeight(height - (StyleHelper::toolbarStyle() + == StyleHelper::ToolbarStyleCompact ? 1 : 3)); } else if (qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget)) { widget->setPalette(panelPalette(widget->palette(), lightColored(widget))); @@ -1046,22 +1052,22 @@ void ManhattanStyle::drawPrimitiveForPanelWidget(PrimitiveElement element, if (!animating && anim) { anim->paint(painter, option); } else { - bool pressed = option->state & State_Sunken || option->state & State_On; + const bool pressed = option->state & State_Sunken || option->state & State_On + || (widget && widget->property("highlightWidget").toBool()); painter->setPen(StyleHelper::sidebarShadow()); if (pressed) { - const QColor shade = creatorTheme()->color(Theme::FancyToolButtonSelectedColor); - painter->fillRect(rect, shade); - if (!creatorTheme()->flag(Theme::FlatToolBars)) { + StyleHelper::drawPanelBgRect( + painter, rect, creatorTheme()->color(Theme::FancyToolButtonSelectedColor)); + if (StyleHelper::toolbarStyle() == StyleHelper::ToolbarStyleCompact + && !creatorTheme()->flag(Theme::FlatToolBars)) { const QRectF borderRect = QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5); painter->drawLine(borderRect.topLeft() + QPointF(1, 0), borderRect.topRight() - QPointF(1, 0)); painter->drawLine(borderRect.topLeft(), borderRect.bottomLeft()); painter->drawLine(borderRect.topRight(), borderRect.bottomRight()); } } else if (option->state & State_Enabled && option->state & State_MouseOver) { - painter->fillRect(rect, creatorTheme()->color(Theme::FancyToolButtonHoverColor)); - } else if (widget && widget->property("highlightWidget").toBool()) { - QColor shade(0, 0, 0, 128); - painter->fillRect(rect, shade); + StyleHelper::drawPanelBgRect( + painter, rect, creatorTheme()->color(Theme::FancyToolButtonHoverColor)); } if (option->state & State_HasFocus && (option->state & State_KeyboardFocusChange)) { QColor highlight = option->palette.highlight().color(); diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index a249686f9e8..2e2da0d4bc0 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -803,6 +803,13 @@ QSize OutputPaneToggleButton::sizeHint() const return s; } +static QRect bgRect(const QRect &widgetRect) +{ + // Removes/compensates the left and right margins of StyleHelper::drawPanelBgRect + return StyleHelper::toolbarStyle() == StyleHelper::ToolbarStyleCompact + ? widgetRect : widgetRect.adjusted(-2, 0, 2, 0); +} + void OutputPaneToggleButton::paintEvent(QPaintEvent*) { const QFontMetrics fm = fontMetrics(); @@ -824,7 +831,7 @@ void OutputPaneToggleButton::paintEvent(QPaintEvent*) c = Theme::BackgroundColorSelected; if (c != Theme::BackgroundColorDark) - p.fillRect(rect(), creatorTheme()->color(c)); + StyleHelper::drawPanelBgRect(&p, bgRect(rect()), creatorTheme()->color(c)); } else { const QImage *image = nullptr; if (isDown()) { @@ -860,9 +867,10 @@ void OutputPaneToggleButton::paintEvent(QPaintEvent*) { QColor c = creatorTheme()->color(Theme::OutputPaneButtonFlashColor); c.setAlpha (m_flashTimer->currentFrame()); - QRect r = creatorTheme()->flag(Theme::FlatToolBars) - ? rect() : rect().adjusted(numberAreaWidth(), 1, -1, -1); - p.fillRect(r, c); + if (creatorTheme()->flag(Theme::FlatToolBars)) + StyleHelper::drawPanelBgRect(&p, bgRect(rect()), c); + else + p.fillRect(rect().adjusted(numberAreaWidth(), 1, -1, -1), c); } p.setFont(font());