From d04c386948534864efc305d520399ed316a0aa21 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Thu, 11 Jun 2020 07:43:06 +0200 Subject: [PATCH] Splitted stylesheets into default and focus_highlighting to properly support both use cases --- src/DockManager.cpp | 9 +- src/ads.qrc | 2 + src/stylesheets/default.css | 72 +-------- src/stylesheets/default_linux.css | 70 +-------- src/stylesheets/focus_highlighting.css | 150 ++++++++++++++++++ src/stylesheets/focus_highlighting_linux.css | 156 +++++++++++++++++++ 6 files changed, 325 insertions(+), 134 deletions(-) create mode 100644 src/stylesheets/focus_highlighting.css create mode 100644 src/stylesheets/focus_highlighting_linux.css diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 84b97f2..edead23 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -181,11 +181,14 @@ void DockManagerPrivate::loadStylesheet() { initResource(); QString Result; + QString FileName = ":ads/stylesheets/"; + FileName += CDockManager::testConfigFlag(CDockManager::FocusHighlighting) + ? "focus_highlighting" : "default"; #ifdef Q_OS_LINUX - QFile StyleSheetFile(":ads/stylesheets/default_linux.css"); -#else - QFile StyleSheetFile(":ads/stylesheets/default.css"); + FileName += "_linux"; #endif + FileName += ".css"; + QFile StyleSheetFile(FileName); StyleSheetFile.open(QIODevice::ReadOnly); QTextStream StyleSheetStream(&StyleSheetFile); Result = StyleSheetStream.readAll(); diff --git a/src/ads.qrc b/src/ads.qrc index 33157a2..7085b99 100644 --- a/src/ads.qrc +++ b/src/ads.qrc @@ -5,5 +5,7 @@ images/close-button-disabled.svg stylesheets/default_linux.css images/close-button-focused.svg + stylesheets/focus_highlighting.css + stylesheets/focus_highlighting_linux.css diff --git a/src/stylesheets/default.css b/src/stylesheets/default.css index c513397..139d9cd 100644 --- a/src/stylesheets/default.css +++ b/src/stylesheets/default.css @@ -1,7 +1,6 @@ /* * Default style sheet on Windows Platforms - * Note: Always use CSS-classes with and without "ads--" namespace to support Qt4 & Qt5 */ ads--CDockContainerWidget @@ -9,6 +8,10 @@ ads--CDockContainerWidget background: palette(dark); } +ads--CDockContainerWidget QSplitter::handle +{ + background: palette(dark); +} ads--CDockAreaWidget { @@ -78,74 +81,13 @@ QScrollArea#dockWidgetScrollArea #tabCloseButton:hover { - /*border: 1px solid rgba(0, 0, 0, 32);*/ - background: rgba(0, 0, 0, 24); + border: 1px solid rgba(0, 0, 0, 32); + background: rgba(0, 0, 0, 16); } #tabCloseButton:pressed { - background: rgba(0, 0, 0, 48); -} - -#tabCloseButton -{ - qproperty-icon: url(:/ads/images/close-button.svg); - qproperty-iconSize: 16px; + background: rgba(0, 0, 0, 32); } -ads--CDockSplitter::handle -{ - background-color: palette(dark); - /* uncomment the following line if you would like to change the size of - the splitter handles */ - /* height: 1px; */ -} - - -/* Focus related styling */ -ads--CDockWidgetTab[focused="true"] -{ - background: palette(highlight); - border-color: palette(highlight); -} - -ads--CDockWidgetTab[focused="true"] > #tabCloseButton -{ - qproperty-icon: url(:/ads/images/close-button-focused.svg) -} - - - -ads--CDockWidgetTab[focused="true"] > #tabCloseButton:hover -{ - background: rgba(255, 255, 255, 48); -} - - -ads--CDockWidgetTab[focused="true"] > #tabCloseButton:pressed -{ - background: rgba(255, 255, 255, 92); -} - - -ads--CDockWidgetTab[focused="true"] QLabel -{ - color: palette(light); -} - - -ads--CDockAreaTitleBar -{ - background: transparent; - border-bottom: 2px solid palette(light); - padding-bottom: 0px; -} - -ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar -{ - background: transparent; - border-bottom: 2px solid palette(highlight); - padding-bottom: 0px; -} - diff --git a/src/stylesheets/default_linux.css b/src/stylesheets/default_linux.css index 0eb6717..64f1466 100644 --- a/src/stylesheets/default_linux.css +++ b/src/stylesheets/default_linux.css @@ -1,7 +1,6 @@ /* - * Default style sheet on Windows Platforms - * Note: Always use CSS-classes with and without "ads--" namespace to support Qt4 & Qt5 + * Default style sheet on Linux Platforms */ ads--CDockContainerWidget @@ -84,74 +83,13 @@ QScrollArea#dockWidgetScrollArea #tabCloseButton:hover { - /*border: 1px solid rgba(0, 0, 0, 32);*/ - background: rgba(0, 0, 0, 24); + border: 1px solid rgba(0, 0, 0, 32); + background: rgba(0, 0, 0, 16); } #tabCloseButton:pressed { - background: rgba(0, 0, 0, 48); -} - -#tabCloseButton -{ - qproperty-icon: url(:/ads/images/close-button.svg); - qproperty-iconSize: 16px; -} - -/* Focus related styling */ -ads--CDockWidgetTab[focused="true"] -{ - background: palette(highlight); - border-color: palette(highlight); -} - -ads--CDockWidgetTab[focused="true"] > #tabCloseButton -{ - qproperty-icon: url(:/ads/images/close-button-focused.svg) + background: rgba(0, 0, 0, 32); } - -ads--CDockWidgetTab[focused="true"] > #tabCloseButton:hover -{ - background: rgba(255, 255, 255, 48); -} - - -ads--CDockWidgetTab[focused="true"] > #tabCloseButton:pressed -{ - background: rgba(255, 255, 255, 92); -} - -ads--CDockWidgetTab[focused="true"] QLabel -{ - color: palette(light); -} - - -ads--CDockAreaTitleBar -{ - background: transparent; - border-bottom: 2px solid palette(light); - padding-bottom: 0px; -} - -ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar -{ - background: transparent; - border-bottom: 2px solid palette(highlight); - padding-bottom: 0px; -} - - -ads--CFloatingDockContainer[isActiveWindow="true"] ads--CFloatingWidgetTitleBar -{ - background: palette(highlight); -} - - -ads--CFloatingDockContainer[isActiveWindow="true"] ads--CFloatingWidgetTitleBar > QLabel -{ - color: palette(light); -} diff --git a/src/stylesheets/focus_highlighting.css b/src/stylesheets/focus_highlighting.css new file mode 100644 index 0000000..5225593 --- /dev/null +++ b/src/stylesheets/focus_highlighting.css @@ -0,0 +1,150 @@ + +/* + * Default style sheet on Windows Platforms with focus highlighting flag enabled + */ + +ads--CDockContainerWidget +{ + background: palette(dark); +} + + +ads--CDockAreaWidget +{ + background: palette(window); + border: 1px solid white; +} + +ads--CDockAreaWidget #tabsMenuButton::menu-indicator +{ + image: none; +} + + +ads--CDockWidgetTab +{ + background: palette(window); + border-color: palette(light); + border-style: solid; + border-width: 0 1px 0 0; + padding: 0 0px; +} + +ads--CDockWidgetTab[activeTab="true"] +{ + background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:0.5, stop:0 palette(window), stop:1 palette(light)); + /*background: palette(highlight);*/ +} + +ads--CDockWidgetTab QLabel +{ + color: palette(dark); +} + +ads--CDockWidgetTab[activeTab="true"] QLabel +{ + color: palette(foreground); +} + +ads--CDockWidget +{ + background: palette(light); + border-color: palette(light); + border-style: solid; + border-width: 1px 0 0 0; +} + +ads--CTitleBarButton +{ + padding: 0px 0px; +} + + +QScrollArea#dockWidgetScrollArea +{ + padding: 0px; + border: none; +} + + +#tabCloseButton +{ + margin-top: 2px; + background: none; + border: none; + padding: 0px -2px; +} + +#tabCloseButton:hover +{ + /*border: 1px solid rgba(0, 0, 0, 32);*/ + background: rgba(0, 0, 0, 24); +} + +#tabCloseButton:pressed +{ + background: rgba(0, 0, 0, 48); +} + +#tabCloseButton +{ + qproperty-icon: url(:/ads/images/close-button.svg); + qproperty-iconSize: 16px; +} + + +ads--CDockSplitter::handle +{ + background-color: palette(dark); + /* uncomment the following line if you would like to change the size of + the splitter handles */ + /* height: 1px; */ +} + + +/* Focus related styling */ +ads--CDockWidgetTab[focused="true"] +{ + background: palette(highlight); + border-color: palette(highlight); +} + +ads--CDockWidgetTab[focused="true"] > #tabCloseButton +{ + qproperty-icon: url(:/ads/images/close-button-focused.svg) +} + + + +ads--CDockWidgetTab[focused="true"] > #tabCloseButton:hover +{ + background: rgba(255, 255, 255, 48); +} + + +ads--CDockWidgetTab[focused="true"] > #tabCloseButton:pressed +{ + background: rgba(255, 255, 255, 92); +} + + +ads--CDockWidgetTab[focused="true"] QLabel +{ + color: palette(light); +} + + +ads--CDockAreaTitleBar +{ + background: transparent; + border-bottom: 2px solid palette(light); + padding-bottom: 0px; +} + +ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar +{ + background: transparent; + border-bottom: 2px solid palette(highlight); + padding-bottom: 0px; +} + diff --git a/src/stylesheets/focus_highlighting_linux.css b/src/stylesheets/focus_highlighting_linux.css new file mode 100644 index 0000000..5177c93 --- /dev/null +++ b/src/stylesheets/focus_highlighting_linux.css @@ -0,0 +1,156 @@ + +/* + * Default style sheet on Linux Platforms with focus highlighting flag enabled + */ + +ads--CDockContainerWidget +{ + background: palette(dark); +} + +ads--CDockContainerWidget QSplitter::handle +{ + background: palette(dark); +} + +ads--CDockAreaWidget +{ + background: palette(window); + border: 1px solid white; +} + +ads--CDockAreaWidget #tabsMenuButton::menu-indicator +{ + image: none; +} + + +ads--CDockWidgetTab +{ + background: palette(window); + border-color: palette(light); + border-style: solid; + border-width: 0 1px 0 0; + padding: 0 0px; +} + +ads--CDockWidgetTab[activeTab="true"] +{ + background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:0.5, stop:0 palette(window), stop:1 palette(light)); + /*background: palette(highlight);*/ +} + +ads--CDockWidgetTab QLabel +{ + color: palette(dark); +} + +ads--CDockWidgetTab[activeTab="true"] QLabel +{ + color: palette(foreground); +} + +ads--CDockWidget +{ + background: palette(light); + border-color: palette(light); + border-style: solid; + border-width: 1px 0 0 0; +} + + +ads--CTitleBarButton +{ + padding: 0px 0px; +} + + + +QScrollArea#dockWidgetScrollArea +{ + padding: 0px; + border: none; +} + + +#tabCloseButton +{ + margin-top: 2px; + background: none; + border: none; + padding: 0px -2px; +} + +#tabCloseButton:hover +{ + /*border: 1px solid rgba(0, 0, 0, 32);*/ + background: rgba(0, 0, 0, 24); +} + +#tabCloseButton:pressed +{ + background: rgba(0, 0, 0, 48); +} + +#tabCloseButton +{ + qproperty-icon: url(:/ads/images/close-button.svg); + qproperty-iconSize: 16px; +} + +/* Focus related styling */ +ads--CDockWidgetTab[focused="true"] +{ + background: palette(highlight); + border-color: palette(highlight); +} + +ads--CDockWidgetTab[focused="true"] > #tabCloseButton +{ + qproperty-icon: url(:/ads/images/close-button-focused.svg) +} + + + +ads--CDockWidgetTab[focused="true"] > #tabCloseButton:hover +{ + background: rgba(255, 255, 255, 48); +} + + +ads--CDockWidgetTab[focused="true"] > #tabCloseButton:pressed +{ + background: rgba(255, 255, 255, 92); +} + +ads--CDockWidgetTab[focused="true"] QLabel +{ + color: palette(light); +} + + +ads--CDockAreaTitleBar +{ + background: transparent; + border-bottom: 2px solid palette(light); + padding-bottom: 0px; +} + +ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar +{ + background: transparent; + border-bottom: 2px solid palette(highlight); + padding-bottom: 0px; +} + + +ads--CFloatingDockContainer[isActiveWindow="true"] ads--CFloatingWidgetTitleBar +{ + background: palette(highlight); +} + + +ads--CFloatingDockContainer[isActiveWindow="true"] ads--CFloatingWidgetTitleBar > QLabel +{ + color: palette(light); +}