Hello community, here is the log from the commit of package adwaita-qt for openSUSE:Factory checked in at 2020-08-03 14:15:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/adwaita-qt (Old) and /work/SRC/openSUSE:Factory/.adwaita-qt.new.3592 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "adwaita-qt" Mon Aug 3 14:15:43 2020 rev:6 rq:823597 version:1.1.4 Changes: -------- --- /work/SRC/openSUSE:Factory/adwaita-qt/adwaita-qt.changes 2020-02-04 19:56:43.825439784 +0100 +++ /work/SRC/openSUSE:Factory/.adwaita-qt.new.3592/adwaita-qt.changes 2020-08-03 14:16:43.456579608 +0200 @@ -1,0 +2,17 @@ +Wed Jul 29 22:11:22 UTC 2020 - Matthias Eliasson <[email protected]> + +- Update to 1.1.4 + * Do not set color to views which don't use our palette +- Update to 1.1.3 + * Fix crash when accessing already deleted widget (qutebrowser/qutebrowser#5435) +- Update to 1.1.2 + * Correctly set Light, Midlight, Mid and Dark colors + * Specify XCB types correctly to avoid crash on 32-bit systems + * QMenu: allow icons + * QMenu: move text in submenus to avoid having arrow ipainted over accelerator + * QTreeView: don't use different colors for unfocused views + * QCheckBox/QRadioButton: update colors to match latest adwaita changes + * Implement standardPalette() which might be used by some applications +- Run spec-cleaner + +------------------------------------------------------------------- Old: ---- adwaita-qt-1.1.1.tar.gz New: ---- adwaita-qt-1.1.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ adwaita-qt.spec ++++++ --- /var/tmp/diff_new_pack.FWv1nH/_old 2020-08-03 14:16:45.816581974 +0200 +++ /var/tmp/diff_new_pack.FWv1nH/_new 2020-08-03 14:16:45.816581974 +0200 @@ -1,7 +1,7 @@ # # spec file for package adwaita-qt # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # Copyright (c) 2015 Bjørn Lie, Bryne, Norway. # # All modifications and additions to the file contributed by third parties @@ -23,14 +23,12 @@ %bcond_with qt4 %endif Name: adwaita-qt -Version: 1.1.1 +Version: 1.1.4 Release: 0 Summary: Adwaita theme for Qt-based applications License: GPL-2.0-or-later AND LGPL-2.1-or-later -Group: System/GUI/GNOME URL: https://github.com/FedoraQt/adwaita-qt Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz - BuildRequires: cmake BuildRequires: fdupes BuildRequires: libqt5-qtbase-devel @@ -43,7 +41,6 @@ %package -n adwaita-qt4 Summary: Adwaita Qt4 theme -Group: System/GUI/GNOME Supplements: (libqt4 and gnome-session) %description -n adwaita-qt4 @@ -51,7 +48,6 @@ %package -n adwaita-qt5 Summary: Adwaita Qt5 theme -Group: System/GUI/GNOME Supplements: (libQt5Core5 and gnome-session) %description -n adwaita-qt5 ++++++ adwaita-qt-1.1.1.tar.gz -> adwaita-qt-1.1.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/adwaita-qt-1.1.1/style/adwaita.h new/adwaita-qt-1.1.4/style/adwaita.h --- old/adwaita-qt-1.1.1/style/adwaita.h 2019-11-04 10:22:05.000000000 +0100 +++ new/adwaita-qt-1.1.4/style/adwaita.h 2020-05-18 12:53:04.000000000 +0200 @@ -56,7 +56,7 @@ const bool SingleClick { true }; const bool ShowIconsOnPushButtons { true }; const int ToolButtonStyle { Qt::ToolButtonTextBesideIcon }; - const bool ShowIconsInMenuItems { false }; + const bool ShowIconsInMenuItems { true }; } enum EnumMnemonicsMode { @@ -179,9 +179,9 @@ ToolButton_InlineIndicatorWidth = 12, // checkboxes and radio buttons - CheckBox_Size = 20, + CheckBox_Size = 22, CheckBox_FocusMarginWidth = 3, - CheckBox_ItemSpacing = 4, + CheckBox_ItemSpacing = 8, // menubar items MenuBarItem_MarginWidth = 8, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/adwaita-qt-1.1.1/style/adwaitahelper.cpp new/adwaita-qt-1.1.4/style/adwaitahelper.cpp --- old/adwaita-qt-1.1.1/style/adwaitahelper.cpp 2019-11-04 10:22:05.000000000 +0100 +++ new/adwaita-qt-1.1.4/style/adwaitahelper.cpp 2020-05-18 12:53:04.000000000 +0200 @@ -51,19 +51,216 @@ } #endif +// +QPalette Helper::palette(bool dark) const +{ + QPalette palette; + + if (dark) { + // Colors defined in GTK adwaita style in _colors.scss + QColor base_color = lighten(desaturate(QColor("#241f31"), 1.0), 0.02); + QColor text_color = QColor("white"); + QColor bg_color = darken(desaturate(QColor("#3d3846"), 1.0), 0.04); + QColor fg_color = QColor("#eeeeec"); + QColor selected_bg_color = darken(QColor("#3584e4"), 0.2); + QColor selected_fg_color = QColor("white"); + QColor osd_text_color = QColor("white"); + QColor osd_bg_color = QColor("black"); + QColor shadow = transparentize(QColor("black"), 0.9); + + QColor backdrop_fg_color = mix(fg_color, bg_color); + QColor backdrop_base_color = lighten(base_color, 0.01); + QColor backdrop_selected_fg_color = mix(text_color, backdrop_base_color, 0.2); + + // This is the color we use as initial color for the gradient in normal state + // Defined in _drawing.scss button(normal) + QColor button_base_color = darken(bg_color, 0.01); + + QColor link_color = lighten(selected_bg_color, 0.2); + QColor link_visited_color = lighten(selected_bg_color, 0.1); + + palette.setColor(QPalette::All, QPalette::Window, bg_color); + palette.setColor(QPalette::All, QPalette::WindowText, fg_color); + palette.setColor(QPalette::All, QPalette::Base, base_color); + palette.setColor(QPalette::All, QPalette::AlternateBase, base_color); + palette.setColor(QPalette::All, QPalette::ToolTipBase, osd_bg_color); + palette.setColor(QPalette::All, QPalette::ToolTipText, osd_text_color); + palette.setColor(QPalette::All, QPalette::Text, fg_color); + palette.setColor(QPalette::All, QPalette::Button, button_base_color); + palette.setColor(QPalette::All, QPalette::ButtonText, fg_color); + palette.setColor(QPalette::All, QPalette::BrightText, text_color); + + palette.setColor(QPalette::All, QPalette::Light, lighten(button_base_color)); + palette.setColor(QPalette::All, QPalette::Midlight, mix(lighten(button_base_color), button_base_color)); + palette.setColor(QPalette::All, QPalette::Mid, mix(darken(button_base_color), button_base_color)); + palette.setColor(QPalette::All, QPalette::Dark, darken(button_base_color)); + palette.setColor(QPalette::All, QPalette::Shadow, shadow); + + palette.setColor(QPalette::All, QPalette::Highlight, selected_bg_color); + palette.setColor(QPalette::All, QPalette::HighlightedText, selected_fg_color); + + palette.setColor(QPalette::All, QPalette::Link, link_color); + palette.setColor(QPalette::All, QPalette::LinkVisited, link_visited_color); + + + QColor insensitive_fg_color = mix(fg_color, bg_color); + QColor insensitive_bg_color = mix(bg_color, base_color, 0.4); + + palette.setColor(QPalette::Disabled, QPalette::Window, insensitive_bg_color); + palette.setColor(QPalette::Disabled, QPalette::WindowText, insensitive_fg_color); + palette.setColor(QPalette::Disabled, QPalette::Base, base_color); + palette.setColor(QPalette::Disabled, QPalette::AlternateBase, base_color); + palette.setColor(QPalette::Disabled, QPalette::Text, insensitive_fg_color); + palette.setColor(QPalette::Disabled, QPalette::Button, insensitive_bg_color); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, insensitive_fg_color); + palette.setColor(QPalette::Disabled, QPalette::BrightText, text_color); + + palette.setColor(QPalette::Disabled, QPalette::Light, lighten(insensitive_bg_color)); + palette.setColor(QPalette::Disabled, QPalette::Midlight, mix(lighten(insensitive_bg_color), insensitive_bg_color)); + palette.setColor(QPalette::Disabled, QPalette::Mid, mix(darken(insensitive_bg_color), insensitive_bg_color)); + palette.setColor(QPalette::Disabled, QPalette::Dark, darken(insensitive_bg_color)); + palette.setColor(QPalette::Disabled, QPalette::Shadow, shadow); + + palette.setColor(QPalette::Disabled, QPalette::Highlight, selected_bg_color); + palette.setColor(QPalette::Disabled, QPalette::HighlightedText, selected_fg_color); + + palette.setColor(QPalette::Disabled, QPalette::Link, link_color); + palette.setColor(QPalette::Disabled, QPalette::LinkVisited, link_visited_color); + + + palette.setColor(QPalette::Inactive, QPalette::Window, bg_color); + palette.setColor(QPalette::Inactive, QPalette::WindowText, backdrop_fg_color); + palette.setColor(QPalette::Inactive, QPalette::Base, backdrop_base_color); + palette.setColor(QPalette::Inactive, QPalette::AlternateBase, backdrop_base_color); + palette.setColor(QPalette::Inactive, QPalette::Text, backdrop_fg_color); + palette.setColor(QPalette::Inactive, QPalette::Button, button_base_color); + palette.setColor(QPalette::Inactive, QPalette::ButtonText, backdrop_fg_color); + palette.setColor(QPalette::Inactive, QPalette::BrightText, text_color); + + palette.setColor(QPalette::Inactive, QPalette::Light, lighten(insensitive_bg_color)); + palette.setColor(QPalette::Inactive, QPalette::Midlight, mix(lighten(insensitive_bg_color), insensitive_bg_color)); + palette.setColor(QPalette::Inactive, QPalette::Mid, mix(darken(insensitive_bg_color), insensitive_bg_color)); + palette.setColor(QPalette::Inactive, QPalette::Dark, darken(insensitive_bg_color)); + palette.setColor(QPalette::Inactive, QPalette::Shadow, shadow); + + palette.setColor(QPalette::Inactive, QPalette::Highlight, selected_bg_color); + palette.setColor(QPalette::Inactive, QPalette::HighlightedText, backdrop_selected_fg_color); + + palette.setColor(QPalette::Inactive, QPalette::Link, link_color); + palette.setColor(QPalette::Inactive, QPalette::LinkVisited, link_visited_color); + } else { + // Colors defined in GTK adwaita style in _colors.scss + QColor base_color = QColor("white"); + QColor text_color = QColor("black"); + QColor bg_color = QColor("#f6f5f4"); + QColor fg_color = QColor("#2e3436"); + QColor selected_bg_color = QColor("#3584e4"); + QColor selected_fg_color = QColor("white"); + QColor osd_text_color = QColor("white"); + QColor osd_bg_color = QColor("black"); + QColor shadow = transparentize(QColor("black"), 0.9); + + QColor backdrop_fg_color = mix(fg_color, bg_color); + QColor backdrop_base_color = darken(base_color, 0.01); + QColor backdrop_selected_fg_color = backdrop_base_color; + + // This is the color we use as initial color for the gradient in normal state + // Defined in _drawing.scss button(normal) + QColor button_base_color = darken(bg_color, 0.04); + + QColor link_color = darken(selected_bg_color, 0.1); + QColor link_visited_color = darken(selected_bg_color, 0.2); + + palette.setColor(QPalette::All, QPalette::Window, bg_color); + palette.setColor(QPalette::All, QPalette::WindowText, fg_color); + palette.setColor(QPalette::All, QPalette::Base, base_color); + palette.setColor(QPalette::All, QPalette::AlternateBase, base_color); + palette.setColor(QPalette::All, QPalette::ToolTipBase, osd_bg_color); + palette.setColor(QPalette::All, QPalette::ToolTipText, osd_text_color); + palette.setColor(QPalette::All, QPalette::Text, fg_color); + palette.setColor(QPalette::All, QPalette::Button, button_base_color); + palette.setColor(QPalette::All, QPalette::ButtonText, fg_color); + palette.setColor(QPalette::All, QPalette::BrightText, text_color); + + palette.setColor(QPalette::All, QPalette::Light, lighten(button_base_color)); + palette.setColor(QPalette::All, QPalette::Midlight, mix(lighten(button_base_color), button_base_color)); + palette.setColor(QPalette::All, QPalette::Mid, mix(darken(button_base_color), button_base_color)); + palette.setColor(QPalette::All, QPalette::Dark, darken(button_base_color)); + palette.setColor(QPalette::All, QPalette::Shadow, shadow); + + palette.setColor(QPalette::All, QPalette::Highlight, selected_bg_color); + palette.setColor(QPalette::All, QPalette::HighlightedText, selected_fg_color); + + palette.setColor(QPalette::All, QPalette::Link, link_color); + palette.setColor(QPalette::All, QPalette::LinkVisited, link_visited_color); + + QColor insensitive_fg_color = mix(fg_color, bg_color); + QColor insensitive_bg_color = mix(bg_color, base_color, 0.4); + + palette.setColor(QPalette::Disabled, QPalette::Window, insensitive_bg_color); + palette.setColor(QPalette::Disabled, QPalette::WindowText, insensitive_fg_color); + palette.setColor(QPalette::Disabled, QPalette::Base, base_color); + palette.setColor(QPalette::Disabled, QPalette::AlternateBase, base_color); + palette.setColor(QPalette::Disabled, QPalette::Text, insensitive_fg_color); + palette.setColor(QPalette::Disabled, QPalette::Button, insensitive_bg_color); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, insensitive_fg_color); + palette.setColor(QPalette::Disabled, QPalette::BrightText, text_color); + + palette.setColor(QPalette::Disabled, QPalette::Light, lighten(insensitive_bg_color)); + palette.setColor(QPalette::Disabled, QPalette::Midlight, mix(lighten(insensitive_bg_color), insensitive_bg_color)); + palette.setColor(QPalette::Disabled, QPalette::Mid, mix(darken(insensitive_bg_color), insensitive_bg_color)); + palette.setColor(QPalette::Disabled, QPalette::Dark, darken(insensitive_bg_color)); + palette.setColor(QPalette::Disabled, QPalette::Shadow, shadow); + + palette.setColor(QPalette::Disabled, QPalette::Highlight, selected_bg_color); + palette.setColor(QPalette::Disabled, QPalette::HighlightedText, selected_fg_color); + + palette.setColor(QPalette::Disabled, QPalette::Link, link_color); + palette.setColor(QPalette::Disabled, QPalette::LinkVisited, link_visited_color); + + + palette.setColor(QPalette::Inactive, QPalette::Window, bg_color); + palette.setColor(QPalette::Inactive, QPalette::WindowText, backdrop_fg_color); + palette.setColor(QPalette::Inactive, QPalette::Base, backdrop_base_color); + palette.setColor(QPalette::Inactive, QPalette::AlternateBase, backdrop_base_color); + palette.setColor(QPalette::Inactive, QPalette::Text, backdrop_fg_color); + palette.setColor(QPalette::Inactive, QPalette::Button, button_base_color); + palette.setColor(QPalette::Inactive, QPalette::ButtonText, backdrop_fg_color); + palette.setColor(QPalette::Inactive, QPalette::BrightText, text_color); + + palette.setColor(QPalette::Inactive, QPalette::Light, lighten(insensitive_bg_color)); + palette.setColor(QPalette::Inactive, QPalette::Midlight, mix(lighten(insensitive_bg_color), insensitive_bg_color)); + palette.setColor(QPalette::Inactive, QPalette::Mid, mix(darken(insensitive_bg_color), insensitive_bg_color)); + palette.setColor(QPalette::Inactive, QPalette::Dark, darken(insensitive_bg_color)); + palette.setColor(QPalette::Inactive, QPalette::Shadow, shadow); + + palette.setColor(QPalette::Inactive, QPalette::Highlight, selected_bg_color); + palette.setColor(QPalette::Inactive, QPalette::HighlightedText, backdrop_selected_fg_color); + + palette.setColor(QPalette::Inactive, QPalette::Link, link_color); + palette.setColor(QPalette::Inactive, QPalette::LinkVisited, link_visited_color); + } + + return palette; +} + //____________________________________________________________________ -QColor Helper::indicatorOutlineColor(const QPalette &palette, bool mouseOver, bool hasFocus, qreal opacity, AnimationMode mode, bool darkMode) const +QColor Helper::indicatorOutlineColor(const QPalette &palette, bool mouseOver, bool hasFocus, qreal opacity, AnimationMode mode, CheckBoxState state, bool darkMode, bool inMenu) const { bool isDisabled = palette.currentColorGroup() == QPalette::Disabled; + if (inMenu || state == CheckBoxState::CheckOff) { - if (isDisabled) { - return buttonOutlineColor(palette, mouseOver, hasFocus, opacity, mode, darkMode); - } + if (isDisabled) { + return buttonOutlineColor(palette, mouseOver, hasFocus, opacity, mode, darkMode); + } - if (darkMode) { - return darken(palette.color(QPalette::Window), 0.18); + if (darkMode) { + return darken(palette.color(QPalette::Window), 0.18); + } else { + return darken(palette.color(QPalette::Window), 0.24); + } } else { - return darken(palette.color(QPalette::Window), 0.24); + return palette.color(QPalette::Highlight); } } @@ -196,50 +393,59 @@ } // -QColor Helper::indicatorBackgroundColor(const QPalette &palette, bool mouseOver, bool hasFocus, bool sunken, qreal opacity, AnimationMode mode, bool darkMode) const +QColor Helper::indicatorBackgroundColor(const QPalette &palette, bool mouseOver, bool hasFocus, bool sunken, qreal opacity, AnimationMode mode, CheckBoxState state, bool darkMode, bool inMenu) const { bool isDisabled = palette.currentColorGroup() == QPalette::Disabled; QColor background(palette.color(QPalette::Window)); // Normal-alt button for dark mode is darken(bg_color, 0.03) // Normal-alt button for normal mode is lighten(bg_color, 0.05) QColor indicatorColor(darkMode ? darken(background, 0.03) : lighten(background, 0.05)); - if (isDisabled) { - // Defined in drawing.css - insensitive button - // $insensitive_bg_color: mix($bg_color, $base_color, 60%); - return mix(palette.color(QPalette::Active, QPalette::Window), palette.color(QPalette::Active, QPalette::Base), 0.6); - } - if (mode == AnimationPressed) { - if (darkMode) { - // Active button for dark mode is darken(bg_color, 0.09) - return mix(background, darken(background, 0.09), opacity); - } else { - // Active button for normal mode is darken(bg_color, 0.14) - return mix(lighten(background, 0.0), darken(background, 0.14), opacity); - } - } else if (sunken) { - if (darkMode) { - // Active button for dark mode is darken(bg_color, 0.09) - return darken(background, 0.09); - } else { - // Active button for normal mode is darken(bg_color, 0.14) - return darken(background, 0.14); + if (inMenu || state == CheckOff) { + if (isDisabled) { + // Defined in drawing.css - insensitive button + // $insensitive_bg_color: mix($bg_color, $base_color, 60%); + return mix(palette.color(QPalette::Active, QPalette::Window), palette.color(QPalette::Active, QPalette::Base), 0.6); } - } else if (mode == AnimationHover) { - if (darkMode) { - // Hovered-alt button for dark mode is bg_color - return mix(indicatorColor, background, opacity); - } else { - // Hovered-alt button for normal mode is lighten(bg_color, 0.09) - return mix(indicatorColor, lighten(background, 0.09), opacity); + + if (mode == AnimationPressed) { + if (darkMode) { + // Active button for dark mode is darken(bg_color, 0.09) + return mix(background, darken(background, 0.09), opacity); + } else { + // Active button for normal mode is darken(bg_color, 0.14) + return mix(lighten(background, 0.0), darken(background, 0.14), opacity); + } + } else if (sunken) { + if (darkMode) { + // Active button for dark mode is darken(bg_color, 0.09) + return darken(background, 0.09); + } else { + // Active button for normal mode is darken(bg_color, 0.14) + return darken(background, 0.14); + } + } else if (mode == AnimationHover) { + if (darkMode) { + // Hovered-alt button for dark mode is bg_color + return mix(indicatorColor, background, opacity); + } else { + // Hovered-alt button for normal mode is lighten(bg_color, 0.09) + return mix(indicatorColor, lighten(background, 0.09), opacity); + } + } else if (mouseOver) { + if (darkMode) { + // Hovered-alt button for dark mode is bg_color + return background; + } else { + // Hovered-alt button for normal mode is lighten(bg_color, 0.09) + return lighten(background, 0.09); + } } - } else if (mouseOver) { + } else { if (darkMode) { - // Hovered-alt button for dark mode is bg_color - return background; + return lighten(palette.color(QPalette::Highlight)); } else { - // Hovered-alt button for normal mode is lighten(bg_color, 0.09) - return lighten(background, 0.09); + return palette.color(QPalette::Highlight); } } @@ -308,13 +514,22 @@ } //______________________________________________________________________________ -QColor Helper::checkBoxIndicatorColor(const QPalette &palette, bool mouseOver, bool active, qreal opacity, AnimationMode mode) const +QColor Helper::checkBoxIndicatorColor(const QPalette &palette, bool mouseOver, bool active, qreal opacity, AnimationMode mode, bool darkMode, bool inMenu) const { Q_UNUSED(mouseOver); Q_UNUSED(active); Q_UNUSED(opacity); Q_UNUSED(mode); - return palette.text().color(); + + if (inMenu) { + return palette.color(QPalette::Text); + } else { + if (active) { + return palette.color(QPalette::HighlightedText); + } else { + return transparentize(palette.color(QPalette::ToolTipText), 0.2); + } + } } //______________________________________________________________________________ @@ -609,15 +824,9 @@ if (color.isValid() && active) { QLinearGradient gradient(frameRect.bottomLeft(), frameRect.topLeft()); if (sunken) { - // Pressed button in dark mode is not a gradient, just an image consting from same $color - if (darkMode) { - gradient.setColorAt(0, color); - gradient.setColorAt(1, color); - } else { - // Pressed button in normal mode is not a gradient, just an image consting from same $color - gradient.setColorAt(0, color); - gradient.setColorAt(1, color); - } + // Pressed button in normal and dark mode is not a gradient, just an image consting from same $color + gradient.setColorAt(0, color); + gradient.setColorAt(1, color); } else if (mouseOver) { if (darkMode) { QColor baseColor = lighten(color, 0.01); @@ -663,7 +872,7 @@ //______________________________________________________________________________ void Helper::renderCheckBoxFrame(QPainter *painter, const QRect &rect, const QColor &color, const QColor &outline, const QColor &shadow, - bool hasFocus, bool sunken, bool mouseOver, bool active, bool darkMode) const + bool hasFocus, bool sunken, bool mouseOver, bool active, CheckBoxState state, bool darkMode, bool inMenu) const { // setup painter painter->setRenderHint(QPainter::Antialiasing, true); @@ -681,60 +890,64 @@ } else painter->setPen(Qt::NoPen); - // content - if (color.isValid() && active) { - QLinearGradient gradient(frameRect.bottomLeft(), frameRect.topLeft()); - if (sunken) { - // Pressed-alt button in dark mode is not a gradient, just an image consting from same $color - if (darkMode) { - gradient.setColorAt(0, color); - gradient.setColorAt(1, color); - } else { - // Pressed-alt button in normal mode is not a gradient, just an image consting from same $color - gradient.setColorAt(0, color); - gradient.setColorAt(1, color); - } - } else if (mouseOver) { - if (darkMode) { - QColor baseColor = color; - // Hovered-alt button in dark mode is a gradient from $color to darken(bg_color, 0.04) - gradient.setColorAt(0, darken(baseColor, 0.04)); - gradient.setColorAt(1, color); + if (inMenu || state == CheckOff) { + // content + if (color.isValid() && active) { + QLinearGradient gradient(frameRect.bottomLeft(), frameRect.topLeft()); + if (sunken) { + // Pressed-alt button in dark mode is not a gradient, just an image consting from same $color + if (darkMode) { + gradient.setColorAt(0, color); + gradient.setColorAt(1, color); + } else { + // Pressed-alt button in normal mode is not a gradient, just an image consting from same $color + gradient.setColorAt(0, color); + gradient.setColorAt(1, color); + } + } else if (mouseOver) { + if (darkMode) { + QColor baseColor = color; + // Hovered-alt button in dark mode is a gradient from $color to darken(bg_color, 0.04) + gradient.setColorAt(0, darken(baseColor, 0.04)); + gradient.setColorAt(1, color); + } else { + QColor baseColor = darken(color, 0.09); + // Hovered-alt button in normal mode is a gradient from $color to lighten(bg_color, 0.04) + gradient.setColorAt(0, color); // FIXME: + gradient.setColorAt(1, lighten(baseColor, 0.04)); // should be vice-versa, but this way it seems to be more accurate + } } else { - QColor baseColor = darken(color, 0.09); - // Hovered-alt button in normal mode is a gradient from $color to lighten(bg_color, 0.04) - gradient.setColorAt(0, color); // FIXME: - gradient.setColorAt(1, lighten(baseColor, 0.04)); // should be vice-versa, but this way it seems to be more accurate + if (darkMode) { + QColor baseColor = lighten(color, 0.03); + // Normal-alt button in dark mode is a gradient from $color to darken(bg_color, 0.06) + gradient.setColorAt(0, darken(baseColor, 0.06)); + gradient.setColorAt(1, color); + } else { + QColor baseColor = darken(color, 0.05); + // Normal-alt button in normal mode is a gradient from $color to bg_color + gradient.setColorAt(0, baseColor); + gradient.setColorAt(1, color); + } } + painter->setBrush(gradient); + } else if (!active) { + painter->setBrush(color); } else { - if (darkMode) { - QColor baseColor = lighten(color, 0.03); - // Normal-alt button in dark mode is a gradient from $color to darken(bg_color, 0.06) - gradient.setColorAt(0, darken(baseColor, 0.06)); - gradient.setColorAt(1, color); - } else { - QColor baseColor = darken(color, 0.05); - // Normal-alt button in normal mode is a gradient from $color to bg_color - gradient.setColorAt(0, baseColor); - gradient.setColorAt(1, color); - } + painter->setBrush(Qt::NoBrush); } - painter->setBrush(gradient); - } else if (!active) { - painter->setBrush(color); } else { - painter->setBrush(Qt::NoBrush); + if (color.isValid()) { + QLinearGradient gradient(frameRect.bottomLeft(), frameRect.topLeft()); + gradient.setColorAt(0, color); + gradient.setColorAt(1, lighten(color, 0.04)); + painter->setBrush(gradient); + } else { + painter->setBrush(Qt::NoBrush); + } } // render painter->drawRoundedRect(frameRect, radius, radius); - - if (!sunken && active && color.isValid()) { - painter->setPen(color.lighter(140)); - painter->drawLine(frameRect.topLeft() + QPoint(3, 1), frameRect.topRight() + QPoint(-3, 1)); - painter->setPen(outline.darker(114)); - painter->drawLine(frameRect.bottomLeft() + QPointF(2.7, 0), frameRect.bottomRight() + QPointF(-2.7, 0)); - } } //______________________________________________________________________________ @@ -940,7 +1153,7 @@ //______________________________________________________________________________ void Helper::renderCheckBox(QPainter *painter, const QRect &rect, const QColor &background, const QColor &outline, const QColor &tickColor, - bool sunken, CheckBoxState state, bool mouseOver, qreal animation, bool active, bool darkMode) const + bool sunken, CheckBoxState state, bool mouseOver, qreal animation, bool active, bool darkMode, bool inMenu) const { // setup painter painter->save(); @@ -953,7 +1166,7 @@ // content { - renderCheckBoxFrame(painter, rect, background, outline, Qt::transparent, false, sunken, mouseOver, active, darkMode); + renderCheckBoxFrame(painter, rect, background, outline, Qt::transparent, false, sunken, mouseOver, active, state, darkMode, inMenu); } // mark @@ -968,9 +1181,9 @@ QRectF markerRect(frameRect); QPainterPath path; - path.moveTo(markerRect.right(), markerRect.top() + markerRect.height() / 4); + path.moveTo(markerRect.right() - markerRect.width() / 4, markerRect.top() + markerRect.height() / 3); path.lineTo(markerRect.center().x(), markerRect.bottom() - markerRect.height() / 3.0); - path.lineTo(markerRect.left() + markerRect.width() / 3.0, markerRect.center().y()); + path.lineTo(markerRect.left() + markerRect.width() / 4, markerRect.center().y()); painter->setClipRect(markerRect); painter->drawPath(path); @@ -994,9 +1207,9 @@ QRectF markerRect(frameRect); QPainterPath path; - path.moveTo(markerRect.right(), markerRect.top() + markerRect.height() / 4); + path.moveTo(markerRect.right() - markerRect.width() / 4, markerRect.top() + markerRect.height() / 3); path.lineTo(markerRect.center().x(), markerRect.bottom() - markerRect.height() / 3.0); - path.lineTo(markerRect.left() + markerRect.width() / 3.0, markerRect.center().y()); + path.lineTo(markerRect.left() + markerRect.width() / 4, markerRect.center().y()); path.translate(-markerRect.right(), -markerRect.top()); painter->setClipRect(markerRect.adjusted(1, 1, -1, -1)); @@ -1028,7 +1241,7 @@ //______________________________________________________________________________ void Helper::renderRadioButton(QPainter *painter, const QRect &rect, const QColor &background, const QColor &outline, const QColor &tickColor, - bool sunken, bool enabled, RadioButtonState state, qreal animation, bool mouseOver, bool darkMode) const + bool sunken, bool enabled, RadioButtonState state, qreal animation, bool mouseOver, bool darkMode, bool inMenu) const { // setup painter painter->setRenderHint(QPainter::Antialiasing, true); @@ -1037,20 +1250,13 @@ QRectF frameRect(rect); frameRect.adjust(2, 2, -2, -2); - // content - { + if (inMenu || state == RadioOff) { if (background.isValid() && enabled) { QLinearGradient gradient(frameRect.bottomLeft(), frameRect.topLeft()); if (sunken) { - // Pressed-alt button in dark mode is not a gradient, just an image consting from same $background - if (darkMode) { - gradient.setColorAt(0, background); - gradient.setColorAt(1, background); - } else { - // Pressed-alt button in normal mode is not a gradient, just an image consting from same $background - gradient.setColorAt(0, background); - gradient.setColorAt(1, background); - } + // Pressed-alt button in normal and dark mode is not a gradient, just an image consting from same $background + gradient.setColorAt(0, background); + gradient.setColorAt(1, background); } else if (mouseOver) { if (darkMode) { QColor baseColor = background; @@ -1087,6 +1293,20 @@ QRectF contentRect(frameRect.adjusted(0.5, 0.5, -0.5, -0.5)); painter->drawEllipse(contentRect); + } else { + if (background.isValid()) { + QLinearGradient gradient(frameRect.bottomLeft(), frameRect.topLeft()); + gradient.setColorAt(0, background); + gradient.setColorAt(1, lighten(background, 0.04)); + painter->setBrush(gradient); + } else { + painter->setBrush(Qt::NoBrush); + } + + painter->setPen(QPen(outline, 1)); + + QRectF contentRect(frameRect.adjusted(0.5, 0.5, -0.5, -0.5)); + painter->drawEllipse(contentRect); } // mark @@ -1204,15 +1424,9 @@ if (color.isValid() && enabled) { QLinearGradient gradient(frameRect.bottomLeft(), frameRect.topLeft()); if (sunken) { - // Pressed-alt button in dark mode is not a gradient, just an image consting from same $background - if (darkMode) { - gradient.setColorAt(0, color); - gradient.setColorAt(1, color); - } else { - // Pressed-alt button in normal mode is not a gradient, just an image consting from same $color - gradient.setColorAt(0, color); - gradient.setColorAt(1, color); - } + // Pressed-alt button in normal and dark mode is not a gradient, just an image consting from same $background + gradient.setColorAt(0, color); + gradient.setColorAt(1, color); } else { if (darkMode) { QColor baseColor = lighten(color, 0.03); @@ -1694,10 +1908,14 @@ XcbAtom atom; }; - typedef void *(*XcbConnectFn)(int, int); - typedef XcbInternAtomCookie(*XcbInternAtomFn)(void *, int, int, const char *); - typedef XcbInternAtomReply * (*XcbInternAtomReplyFn)(void *, XcbInternAtomCookie, int); - typedef int (*XcbChangePropertyFn)(void *, int, int, XcbAtom, XcbAtom, int, int, const void *); + struct XcbVoidCookie { + unsigned int sequence; + }; + + typedef void *(*XcbConnectFn)(const char *, int *); + typedef XcbInternAtomCookie(*XcbInternAtomFn)(void *, quint8, quint16, const char *); + typedef XcbInternAtomReply * (*XcbInternAtomReplyFn)(void *, XcbInternAtomCookie, void *); + typedef XcbVoidCookie (*XcbChangePropertyFn)(void *, quint8, quint32, XcbAtom, XcbAtom, quint8, quint32, const void *); typedef int (*XcbFlushFn)(void *); static QLibrary *lib = 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/adwaita-qt-1.1.1/style/adwaitahelper.h new/adwaita-qt-1.1.4/style/adwaitahelper.h --- old/adwaita-qt-1.1.1/style/adwaitahelper.h 2019-11-04 10:22:05.000000000 +0100 +++ new/adwaita-qt-1.1.4/style/adwaitahelper.h 2020-05-18 12:53:04.000000000 +0200 @@ -27,8 +27,12 @@ #include "config-adwaita.h" #include <QPainterPath> -#include <QWidget> #include <QStyle> +#include <QWidget> + +#if QT_VERSION > 0x050000 +#include <QWindow> +#endif #if ADWAITA_HAVE_X11 #include <QX11Info> @@ -58,6 +62,17 @@ virtual ~Helper() {} +#if QT_VERSION > 0x050000 + static bool isWindowActive(const QWidget *widget) + { + const QWindow *win = widget ? widget->window()->windowHandle() : nullptr; + if (win) { + return win->isActive(); + } + return false; + } +#endif + //*@name color utilities //@{ @@ -128,11 +143,12 @@ return QColor::fromHslF(h, s, l, alpha); } + //* returns adwaita color palette + QPalette palette(bool dark) const; + //* add alpha channel multiplier to color QColor alphaColor(QColor color, qreal alpha) const; - // ADWAITA TODO - //* mouse over color QColor hoverColor(const QPalette &palette) const { @@ -172,7 +188,7 @@ } //* indicator outline color - QColor indicatorOutlineColor(const QPalette &palette, bool mouseOver = false, bool hasFocus = false, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone, bool darkMode = false) const; + QColor indicatorOutlineColor(const QPalette &palette, bool mouseOver = false, bool hasFocus = false, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone, CheckBoxState state = CheckOff, bool darkMode = false, bool inMenu = false) const; //* frame outline color, using animations QColor frameOutlineColor(const QPalette &palette, bool mouseOver = false, bool hasFocus = false, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone, bool darkMode = false) const; @@ -211,7 +227,7 @@ QColor buttonBackgroundColor(const QPalette &palette, bool mouseOver, bool hasFocus, bool sunken, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone, bool darkMode = false) const; //* checkbox/radiobutton color, using animations - QColor indicatorBackgroundColor(const QPalette &palette, bool mouseOver, bool hasFocus, bool sunken, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone, bool darkMode = false) const; + QColor indicatorBackgroundColor(const QPalette &palette, bool mouseOver, bool hasFocus, bool sunken, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone, CheckBoxState state = CheckOff, bool darkMode = false, bool inMenu = false) const; //* tool button color QColor toolButtonColor(const QPalette &palette, bool mouseOver, bool hasFocus, bool sunken, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone) const; @@ -223,7 +239,7 @@ QColor scrollBarHandleColor(const QPalette &palette, bool mouseOver, bool hasFocus, bool sunken, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone, bool darkMode = false) const; //* checkbox indicator, using animations - QColor checkBoxIndicatorColor(const QPalette &palette, bool mouseOver, bool active, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone) const; + QColor checkBoxIndicatorColor(const QPalette &palette, bool mouseOver, bool active, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone, bool darkMode = false, bool inMenu = false) const; //* separator color QColor separatorColor(const QPalette &palette, bool darkMode = false) const; @@ -270,7 +286,7 @@ void renderButtonFrame(QPainter *painter, const QRect &rect, const QColor &color, const QColor &outline, const QColor &shadow, bool focus, bool sunken, bool mouseOver, bool active, bool darkMode = false) const; //* checkbox frame - void renderCheckBoxFrame(QPainter *painter, const QRect &rect, const QColor &color, const QColor &outline, const QColor &shadow, bool focus, bool sunken, bool mouseOver, bool active, bool darkMode = false) const; + void renderCheckBoxFrame(QPainter *painter, const QRect &rect, const QColor &color, const QColor &outline, const QColor &shadow, bool focus, bool sunken, bool mouseOver, bool active, CheckBoxState state = CheckOff, bool darkMode = false, bool inMenu = false) const; //* button frame void renderFlatButtonFrame(QPainter *painter, const QRect &rect, const QColor &color, const QColor &outline, const QColor &shadow, bool focus, bool sunken, bool mouseOver, bool active) const; @@ -294,13 +310,13 @@ void renderCheckBoxBackground(QPainter *painter, const QRect &rect, const QColor &color, const QColor &outline, bool sunken) const; //* checkbox - void renderCheckBox(QPainter *painter, const QRect &rect, const QColor &background, const QColor &outline, const QColor &tickColor, bool sunken, CheckBoxState state, bool mouseOver, qreal animation = AnimationData::OpacityInvalid, bool active = true, bool darkMode = false) const; + void renderCheckBox(QPainter *painter, const QRect &rect, const QColor &background, const QColor &outline, const QColor &tickColor, bool sunken, CheckBoxState state, bool mouseOver, qreal animation = AnimationData::OpacityInvalid, bool active = true, bool darkMode = false, bool inMenu = false) const; //* radio button void renderRadioButtonBackground(QPainter *painter, const QRect &rect, const QColor &color, const QColor &outline, bool sunken) const; //* radio button - void renderRadioButton(QPainter *painter, const QRect &rect, const QColor &background, const QColor &outline, const QColor &tickColor, bool sunken, bool enabled, RadioButtonState state, qreal animation = AnimationData::OpacityInvalid, bool mouseOver = false, bool darkMode = false) const; + void renderRadioButton(QPainter *painter, const QRect &rect, const QColor &background, const QColor &outline, const QColor &tickColor, bool sunken, bool enabled, RadioButtonState state, qreal animation = AnimationData::OpacityInvalid, bool mouseOver = false, bool darkMode = false, bool inMenu = false) const; //* slider groove void renderSliderGroove(QPainter *painter, const QRect &rect, const QColor &) const; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/adwaita-qt-1.1.1/style/adwaitastyle.cpp new/adwaita-qt-1.1.4/style/adwaitastyle.cpp --- old/adwaita-qt-1.1.1/style/adwaitastyle.cpp 2019-11-04 10:22:05.000000000 +0100 +++ new/adwaita-qt-1.1.4/style/adwaitastyle.cpp 2020-05-18 12:53:04.000000000 +0200 @@ -407,6 +407,24 @@ } } +#if QT_VERSION > 0x050000 + // HACK to avoid different text color in unfocused views + // This has a side effect that the view will never grey out, but it's still better then having + // views greyed out when the application is active + if (QPointer<QAbstractItemView> view = qobject_cast<QAbstractItemView *>(widget)) { + QPalette pal = view->palette(); + // TODO keep synced with the standard palette + const QColor activeTextColor = _dark ? QColor("#eeeeec") : QColor("#2e3436"); + const QColor inactiveTextColor = _dark ? _helper->mix(QColor("#eeeeec"), _helper->darken(_helper->desaturate(QColor("#3d3846"), 1.0), 0.04)) : + _helper->mix(QColor("#2e3436"), QColor("#f6f5f4")); + // No custom text color used, we can do our HACK + if (inactiveTextColor == pal.color(QPalette::Inactive, QPalette::Text) && activeTextColor == pal.color(QPalette::Active, QPalette::Text)) { + pal.setColor(QPalette::Inactive, QPalette::Text, pal.color(QPalette::Active, QPalette::Text)); + view->setPalette(pal); + } + } +#endif + if (!widget->parent() || !qobject_cast<QWidget *>(widget->parent()) || qobject_cast<QDialog *>(widget) || qobject_cast<QMainWindow *>(widget)) { addEventFilter(widget); } @@ -504,190 +522,12 @@ void Style::polish(QPalette &palette) { - if (_dark) { - // Colors defined in GTK adwaita style in _colors.scss - QColor base_color = _helper->lighten(_helper->desaturate(QColor("#241f31"), 1.0), 0.02); - QColor text_color = QColor("white"); - QColor bg_color = _helper->darken(_helper->desaturate(QColor("#3d3846"), 1.0), 0.04); - QColor fg_color = QColor("#eeeeec"); - QColor selected_bg_color = _helper->darken(QColor("#3584e4"), 0.2); - QColor selected_fg_color = QColor("white"); - QColor osd_text_color = QColor("white"); - QColor osd_bg_color = QColor("black"); - QColor shadow = _helper->transparentize(QColor("black"), 0.9); - - QColor backdrop_fg_color = _helper->mix(fg_color, bg_color); - QColor backdrop_base_color = _helper->lighten(base_color, 0.01); - QColor backdrop_selected_fg_color = _helper->mix(text_color, backdrop_base_color, 0.2); - - // This is the color we use as initial color for the gradient in normal state - // Defined in _drawing.scss button(normal) - QColor button_base_color = _helper->darken(bg_color, 0.01); - - QColor link_color = _helper->lighten(selected_bg_color, 0.2); - QColor link_visited_color = _helper->lighten(selected_bg_color, 0.1); - - palette.setColor(QPalette::All, QPalette::Window, bg_color); - palette.setColor(QPalette::All, QPalette::WindowText, fg_color); - palette.setColor(QPalette::All, QPalette::Base, base_color); - palette.setColor(QPalette::All, QPalette::AlternateBase, base_color); - palette.setColor(QPalette::All, QPalette::ToolTipBase, osd_bg_color); - palette.setColor(QPalette::All, QPalette::ToolTipText, osd_text_color); - palette.setColor(QPalette::All, QPalette::Text, fg_color); - palette.setColor(QPalette::All, QPalette::Button, button_base_color); - palette.setColor(QPalette::All, QPalette::ButtonText, fg_color); - palette.setColor(QPalette::All, QPalette::BrightText, text_color); - - palette.setColor(QPalette::All, QPalette::Light, QColor("white")); - palette.setColor(QPalette::All, QPalette::Midlight, QColor("#d7d7d7")); - palette.setColor(QPalette::All, QPalette::Mid, QColor("#b4b4b4")); - palette.setColor(QPalette::All, QPalette::Dark, QColor("#1a1a1a")); - palette.setColor(QPalette::All, QPalette::Shadow, shadow); - - palette.setColor(QPalette::All, QPalette::Highlight, selected_bg_color); - palette.setColor(QPalette::All, QPalette::HighlightedText, selected_fg_color); - - palette.setColor(QPalette::All, QPalette::Link, link_color); - palette.setColor(QPalette::All, QPalette::LinkVisited, link_visited_color); - - - QColor insensitive_fg_color = _helper->mix(fg_color, bg_color); - QColor insensitive_bg_color = _helper->mix(bg_color, base_color, 0.4); - - palette.setColor(QPalette::Disabled, QPalette::Window, insensitive_bg_color); - palette.setColor(QPalette::Disabled, QPalette::WindowText, insensitive_fg_color); - palette.setColor(QPalette::Disabled, QPalette::Base, base_color); - palette.setColor(QPalette::Disabled, QPalette::AlternateBase, base_color); - palette.setColor(QPalette::Disabled, QPalette::Text, insensitive_fg_color); - palette.setColor(QPalette::Disabled, QPalette::Button, insensitive_bg_color); - palette.setColor(QPalette::Disabled, QPalette::ButtonText, insensitive_fg_color); - palette.setColor(QPalette::Disabled, QPalette::BrightText, text_color); - - palette.setColor(QPalette::Disabled, QPalette::Light, QColor("#f4f4f4")); - palette.setColor(QPalette::Disabled, QPalette::Midlight, QColor("#f4f4f4")); - palette.setColor(QPalette::Disabled, QPalette::Dark, QColor("#f4f4f4")); - palette.setColor(QPalette::Disabled, QPalette::Mid, QColor("#c3c3c3")); - palette.setColor(QPalette::Disabled, QPalette::Shadow, shadow); - - palette.setColor(QPalette::Disabled, QPalette::Highlight, selected_bg_color); - palette.setColor(QPalette::Disabled, QPalette::HighlightedText, selected_fg_color); - - palette.setColor(QPalette::Disabled, QPalette::Link, link_color); - palette.setColor(QPalette::Disabled, QPalette::LinkVisited, link_visited_color); - - - palette.setColor(QPalette::Inactive, QPalette::Window, bg_color); - palette.setColor(QPalette::Inactive, QPalette::WindowText, backdrop_fg_color); - palette.setColor(QPalette::Inactive, QPalette::Base, backdrop_base_color); - palette.setColor(QPalette::Inactive, QPalette::AlternateBase, backdrop_base_color); - palette.setColor(QPalette::Inactive, QPalette::Text, backdrop_fg_color); - palette.setColor(QPalette::Inactive, QPalette::Button, button_base_color); - palette.setColor(QPalette::Inactive, QPalette::ButtonText, backdrop_fg_color); - palette.setColor(QPalette::Inactive, QPalette::BrightText, text_color); - - palette.setColor(QPalette::Inactive, QPalette::Light, QColor("white")); - palette.setColor(QPalette::Inactive, QPalette::Midlight, QColor("#d7d7d7")); - palette.setColor(QPalette::Inactive, QPalette::Mid, QColor("#b4b4b4")); - palette.setColor(QPalette::Inactive, QPalette::Dark, QColor("#33393b")); - palette.setColor(QPalette::Inactive, QPalette::Shadow, shadow); - - palette.setColor(QPalette::Inactive, QPalette::Highlight, selected_bg_color); - palette.setColor(QPalette::Inactive, QPalette::HighlightedText, backdrop_selected_fg_color); - - palette.setColor(QPalette::Inactive, QPalette::Link, link_color); - palette.setColor(QPalette::Inactive, QPalette::LinkVisited, link_visited_color); - } else { - // Colors defined in GTK adwaita style in _colors.scss - QColor base_color = QColor("white"); - QColor text_color = QColor("black"); - QColor bg_color = QColor("#f6f5f4"); - QColor fg_color = QColor("#2e3436"); - QColor selected_bg_color = QColor("#3584e4"); - QColor selected_fg_color = QColor("white"); - QColor osd_text_color = QColor("white"); - QColor osd_bg_color = QColor("black"); - QColor shadow = _helper->transparentize(QColor("black"), 0.9); - - QColor backdrop_fg_color = _helper->mix(fg_color, bg_color); - QColor backdrop_base_color = _helper->darken(base_color, 0.01); - QColor backdrop_selected_fg_color = backdrop_base_color; - - // This is the color we use as initial color for the gradient in normal state - // Defined in _drawing.scss button(normal) - QColor button_base_color = _helper->darken(bg_color, 0.04); - - QColor link_color = _helper->darken(selected_bg_color, 0.1); - QColor link_visited_color = _helper->darken(selected_bg_color, 0.2); - - palette.setColor(QPalette::All, QPalette::Window, bg_color); - palette.setColor(QPalette::All, QPalette::WindowText, fg_color); - palette.setColor(QPalette::All, QPalette::Base, base_color); - palette.setColor(QPalette::All, QPalette::AlternateBase, base_color); - palette.setColor(QPalette::All, QPalette::ToolTipBase, osd_bg_color); - palette.setColor(QPalette::All, QPalette::ToolTipText, osd_text_color); - palette.setColor(QPalette::All, QPalette::Text, fg_color); - palette.setColor(QPalette::All, QPalette::Button, button_base_color); - palette.setColor(QPalette::All, QPalette::ButtonText, fg_color); - palette.setColor(QPalette::All, QPalette::BrightText, text_color); - - palette.setColor(QPalette::All, QPalette::Light, QColor("white")); - palette.setColor(QPalette::All, QPalette::Midlight, QColor("#d7d7d7")); - palette.setColor(QPalette::All, QPalette::Mid, QColor("#b4b4b4")); - palette.setColor(QPalette::All, QPalette::Dark, QColor("#1a1a1a")); - palette.setColor(QPalette::All, QPalette::Shadow, shadow); - - palette.setColor(QPalette::All, QPalette::Highlight, selected_bg_color); - palette.setColor(QPalette::All, QPalette::HighlightedText, selected_fg_color); - - palette.setColor(QPalette::All, QPalette::Link, link_color); - palette.setColor(QPalette::All, QPalette::LinkVisited, link_visited_color); - - QColor insensitive_fg_color = _helper->mix(fg_color, bg_color); - QColor insensitive_bg_color = _helper->mix(bg_color, base_color, 0.4); - - palette.setColor(QPalette::Disabled, QPalette::Window, insensitive_bg_color); - palette.setColor(QPalette::Disabled, QPalette::WindowText, insensitive_fg_color); - palette.setColor(QPalette::Disabled, QPalette::Base, base_color); - palette.setColor(QPalette::Disabled, QPalette::AlternateBase, base_color); - palette.setColor(QPalette::Disabled, QPalette::Text, insensitive_fg_color); - palette.setColor(QPalette::Disabled, QPalette::Button, insensitive_bg_color); - palette.setColor(QPalette::Disabled, QPalette::ButtonText, insensitive_fg_color); - palette.setColor(QPalette::Disabled, QPalette::BrightText, text_color); - - palette.setColor(QPalette::Disabled, QPalette::Light, QColor("#f4f4f4")); - palette.setColor(QPalette::Disabled, QPalette::Midlight, QColor("#f4f4f4")); - palette.setColor(QPalette::Disabled, QPalette::Dark, QColor("#f4f4f4")); - palette.setColor(QPalette::Disabled, QPalette::Mid, QColor("#c3c3c3")); - palette.setColor(QPalette::Disabled, QPalette::Shadow, shadow); - - palette.setColor(QPalette::Disabled, QPalette::Highlight, selected_bg_color); - palette.setColor(QPalette::Disabled, QPalette::HighlightedText, selected_fg_color); - - palette.setColor(QPalette::Disabled, QPalette::Link, link_color); - palette.setColor(QPalette::Disabled, QPalette::LinkVisited, link_visited_color); - - - palette.setColor(QPalette::Inactive, QPalette::Window, bg_color); - palette.setColor(QPalette::Inactive, QPalette::WindowText, backdrop_fg_color); - palette.setColor(QPalette::Inactive, QPalette::Base, backdrop_base_color); - palette.setColor(QPalette::Inactive, QPalette::AlternateBase, backdrop_base_color); - palette.setColor(QPalette::Inactive, QPalette::Text, backdrop_fg_color); - palette.setColor(QPalette::Inactive, QPalette::Button, button_base_color); - palette.setColor(QPalette::Inactive, QPalette::ButtonText, backdrop_fg_color); - palette.setColor(QPalette::Inactive, QPalette::BrightText, text_color); - - palette.setColor(QPalette::Inactive, QPalette::Light, QColor("white")); - palette.setColor(QPalette::Inactive, QPalette::Midlight, QColor("#d7d7d7")); - palette.setColor(QPalette::Inactive, QPalette::Mid, QColor("#b4b4b4")); - palette.setColor(QPalette::Inactive, QPalette::Dark, QColor("#33393b")); - palette.setColor(QPalette::Inactive, QPalette::Shadow, shadow); - - palette.setColor(QPalette::Inactive, QPalette::Highlight, selected_bg_color); - palette.setColor(QPalette::Inactive, QPalette::HighlightedText, backdrop_selected_fg_color); + palette = _helper->palette(_dark); +} - palette.setColor(QPalette::Inactive, QPalette::Link, link_color); - palette.setColor(QPalette::Inactive, QPalette::LinkVisited, link_visited_color); - } +QPalette Style::standardPalette() const +{ + return _helper->palette(_dark); } //______________________________________________________________ @@ -1850,7 +1690,7 @@ //___________________________________________________________________________________________________________________ QRect Style::checkBoxContentsRect(const QStyleOption *option, const QWidget *) const { - return visualRect(option, option->rect.adjusted(Metrics::CheckBox_Size + 2 * Metrics::CheckBox_ItemSpacing, 0, 0, 0)); + return visualRect(option, option->rect.adjusted(Metrics::CheckBox_Size + Metrics::CheckBox_ItemSpacing, 0, 0, 0)); } //___________________________________________________________________________________________________________________ @@ -3999,8 +3839,6 @@ bool active((state & (State_On | State_NoChange))); bool windowActive(state & State_Active); - const QColor &outline(_helper->indicatorOutlineColor(palette, mouseOver, false, AnimationData::OpacityInvalid, AnimationNone, _dark)); - const QColor &background(_helper->indicatorBackgroundColor(palette, mouseOver, false, sunken, AnimationData::OpacityInvalid, AnimationNone, _dark)); // checkbox state CheckBoxState checkBoxState(CheckOff); @@ -4009,6 +3847,9 @@ else if (state & State_On) checkBoxState = CheckOn; + const QColor &outline(_helper->indicatorOutlineColor(palette, mouseOver, false, AnimationData::OpacityInvalid, AnimationNone, checkBoxState, _dark)); + const QColor &background(_helper->indicatorBackgroundColor(palette, mouseOver, false, sunken, AnimationData::OpacityInvalid, AnimationNone, checkBoxState, _dark)); + // detect checkboxes in lists bool isSelectedItem(this->isSelectedItem(widget, rect.center())); @@ -4016,7 +3857,7 @@ _animations->widgetStateEngine().updateState(widget, AnimationHover, mouseOver); if (checkBoxState != CheckPartial) { _animations->widgetStateEngine().updateState(widget, AnimationPressed, checkBoxState != CheckOff); - if (_animations->widgetStateEngine().isAnimated(widget, AnimationPressed)) + if (_animations->widgetStateEngine().isAnimated(widget, AnimationPressed) && checkBoxState == CheckOn) checkBoxState = CheckAnimated; } qreal animation(_animations->widgetStateEngine().opacity(widget, AnimationPressed)); @@ -4052,8 +3893,8 @@ bool checked(state & State_On); bool windowActive(state & State_Active); - const QColor &outline(_helper->indicatorOutlineColor(palette, mouseOver, false, AnimationData::OpacityInvalid, AnimationNone, _dark)); - const QColor &background(_helper->indicatorBackgroundColor(palette, mouseOver, false, sunken, AnimationData::OpacityInvalid, AnimationNone, _dark)); + const QColor &outline(_helper->indicatorOutlineColor(palette, mouseOver, false, AnimationData::OpacityInvalid, AnimationNone, checked ? CheckOn : CheckOff, _dark)); + const QColor &background(_helper->indicatorBackgroundColor(palette, mouseOver, false, sunken, AnimationData::OpacityInvalid, AnimationNone, checked ? CheckOn : CheckOff,_dark)); // radio button state RadioButtonState radioButtonState(state & State_On ? RadioOn : RadioOff); @@ -4081,7 +3922,7 @@ } // render - _helper->renderRadioButton(painter, rect, background, outline, tickColor, sunken, enabled && windowActive, radioButtonState, animation, mouseOver, _dark); + _helper->renderRadioButton(painter, rect, background, outline, tickColor, sunken, enabled && windowActive, radioButtonState, animation, mouseOver, _dark, false); return true; } @@ -4407,15 +4248,16 @@ // color role QPalette::ColorRole textRole; if (flat) { - if (hasFocus && sunken) + if (hasFocus && sunken) { textRole = QPalette::ButtonText; - else + } else { textRole = QPalette::WindowText; - - } else if - (hasFocus) textRole = QPalette::ButtonText; - else + } + } else if (hasFocus) { textRole = QPalette::ButtonText; + } else { + textRole = QPalette::ButtonText; + } // menu arrow if (buttonOption->features & QStyleOptionButton::HasMenu) { @@ -4772,13 +4614,19 @@ #else QStyleOptionViewItemV4 op(*vopt); #endif - QPalette palette = op.palette; - if ((vopt->state & QStyle::State_Enabled) && !(vopt->state & QStyle::State_Active)) { - palette.setColor(QPalette::Inactive, QPalette::Text, palette.color(QPalette::Active, QPalette::Text)); +#if QT_VERSION > 0x050000 + if (_helper->isWindowActive(widget)) { + const QColor activeTextColor = _dark ? QColor("#eeeeec") : QColor("#2e3436"); + const QColor inactiveTextColor = _dark ? _helper->mix(QColor("#eeeeec"), _helper->darken(_helper->desaturate(QColor("#3d3846"), 1.0), 0.04)) : + _helper->mix(QColor("#2e3436"), QColor("#f6f5f4")); + // No custom text color used, we can do our HACK + QPalette palette = op.palette; + if (inactiveTextColor == palette.color(QPalette::Inactive, QPalette::Text) && activeTextColor == palette.color(QPalette::Active, QPalette::Text)) { + palette.setColor(QPalette::Inactive, QPalette::Text, palette.color(QPalette::Active, QPalette::Text)); + op.palette = palette; + } } - - op.palette = palette; - +#endif ParentStyleClass::drawControl(CE_ItemViewItem, &op, painter, widget); return true; @@ -4910,15 +4758,15 @@ // checkbox QRect checkBoxRect; if (menuItemOption->menuHasCheckableItems) { - checkBoxRect = QRect(contentsRect.left(), contentsRect.top() + (contentsRect.height() - Metrics::CheckBox_Size) / 2, Metrics::CheckBox_Size, Metrics::CheckBox_Size); + checkBoxRect = QRect(contentsRect.left(), contentsRect.top() + (contentsRect.height() - Metrics::CheckBox_Size) / 2, Metrics::CheckBox_Size, Metrics::CheckBox_Size).adjusted(1, 1, -1, -1); } // We want to always to keep the space for checkbox contentsRect.setLeft(Metrics::CheckBox_Size + Metrics::MenuItem_ItemSpacing); + CheckBoxState checkState(menuItemOption->checked ? CheckOn : CheckOff); const QColor &outline(palette.foreground().color()); - const QColor &indicatorBackground(_helper->indicatorBackgroundColor(palette, mouseOver, false, false, AnimationData::OpacityInvalid, AnimationNone, _dark)); - + const QColor &indicatorBackground(_helper->indicatorBackgroundColor(palette, mouseOver, false, false, AnimationData::OpacityInvalid, AnimationNone, checkState, _dark, true)); // render checkbox indicator if (menuItemOption->checkType == QStyleOptionMenuItem::NonExclusive) { checkBoxRect = visualRect(option, checkBoxRect); @@ -4933,9 +4781,8 @@ bool active(menuItemOption->checked); AnimationMode mode(_animations->widgetStateEngine().isAnimated(widget, AnimationHover) ? AnimationHover : AnimationNone); qreal opacity(_animations->widgetStateEngine().opacity(widget, AnimationHover)); - QColor tickColor = _helper->checkBoxIndicatorColor(palette, mouseOver, enabled && active, opacity, mode); - CheckBoxState state(menuItemOption->checked ? CheckOn : CheckOff); - _helper->renderCheckBox(painter, checkBoxRect, indicatorBackground, outline, tickColor, false, state, mouseOver, enabled && windowActive, _dark); + QColor tickColor = _helper->checkBoxIndicatorColor(palette, mouseOver, enabled && active, opacity, mode, _dark, true); + _helper->renderCheckBox(painter, checkBoxRect, indicatorBackground, outline, tickColor, false, checkState, mouseOver, enabled && windowActive, _dark, true); } else if (menuItemOption->checkType == QStyleOptionMenuItem::Exclusive) { checkBoxRect = visualRect(option, checkBoxRect); @@ -4947,9 +4794,8 @@ bool active(menuItemOption->checked); AnimationMode mode(_animations->widgetStateEngine().isAnimated(widget, AnimationHover) ? AnimationHover : AnimationNone); qreal opacity(_animations->widgetStateEngine().opacity(widget, AnimationHover)); - QColor tickColor = _helper->checkBoxIndicatorColor(palette, mouseOver, enabled && active, opacity, mode); - CheckBoxState state(menuItemOption->checked ? CheckOn : CheckOff); - _helper->renderRadioButton(painter, checkBoxRect, indicatorBackground, outline, tickColor, false, enabled && windowActive, active ? RadioOn : RadioOff); + QColor tickColor = _helper->checkBoxIndicatorColor(palette, mouseOver, enabled && active, opacity, mode, _dark, true); + _helper->renderRadioButton(painter, checkBoxRect, indicatorBackground, outline, tickColor, false, enabled && windowActive, active ? RadioOn : RadioOff, _dark, true); } // icon @@ -5013,10 +4859,12 @@ if (!menuItemOption->text.isEmpty()) { // adjust textRect QString text = menuItemOption->text; + textRect = centerRect(textRect, textRect.width(), option->fontMetrics.size(_mnemonics->textFlags(), text).height()); textRect = visualRect(option, textRect); - textRect.setRight(textRect.right() - Metrics::MenuItem_MarginWidth); + const int arrowWidth = menuItemOption->menuItemType == QStyleOptionMenuItem::SubMenu ? Metrics::MenuButton_IndicatorWidth : 0; + textRect.setRight(textRect.right() - Metrics::MenuItem_MarginWidth - arrowWidth); // set font painter->setFont(menuItemOption->font); @@ -6500,8 +6348,8 @@ qreal opacity(_animations->widgetStateEngine().buttonOpacity(widget)); // define colors - QColor background(_helper->indicatorBackgroundColor(palette, mouseOver, false, false, opacity, AnimationNone, _dark)); - QColor outline(_helper->indicatorOutlineColor(palette, handleActive && mouseOver, hasFocus, opacity, mode, _dark)); + QColor background(_helper->indicatorBackgroundColor(palette, mouseOver, false, false, opacity, AnimationNone, CheckOff, _dark, true)); + QColor outline(_helper->indicatorOutlineColor(palette, handleActive && mouseOver, hasFocus, opacity, mode, CheckOff, _dark, true)); QColor shadow(_helper->shadowColor(palette)); // render diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/adwaita-qt-1.1.1/style/adwaitastyle.h new/adwaita-qt-1.1.4/style/adwaitastyle.h --- old/adwaita-qt-1.1.1/style/adwaitastyle.h 2019-11-04 10:22:05.000000000 +0100 +++ new/adwaita-qt-1.1.4/style/adwaitastyle.h 2020-05-18 12:53:04.000000000 +0200 @@ -94,6 +94,8 @@ //* palette polishing virtual void polish(QPalette &palette); + virtual QPalette standardPalette() const; + //* polish scrollarea void polishScrollArea(QAbstractScrollArea *scrollArea);
