From 0c88457037b11b9958d2e95fc79b0106dd1cc4b3 Mon Sep 17 00:00:00 2001 From: Christian Seiler Date: Wed, 21 Oct 2020 22:05:36 +0200 Subject: [PATCH 1/4] Fix CMake build on macOS (don't try to link against Qt's X11Extras) (#267) macOS is identified as UNIX by CMake, but Qt doesn't actually use X11 there (and X11 support is not available by default anyway). Change the condition that includes X11Extras to if (UNIX AND NOT APPLE) instead of just if (UNIX) to mitigate that. This makes the build on macOS work with CMake. Co-authored-by: Christian Seiler --- adsConfig.cmake | 4 +++- src/CMakeLists.txt | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/adsConfig.cmake b/adsConfig.cmake index d006a3f..9f9b307 100644 --- a/adsConfig.cmake +++ b/adsConfig.cmake @@ -2,5 +2,7 @@ include(CMakeFindDependencyMacro) find_dependency(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED) find_dependency(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED) find_dependency(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED) -find_dependency(Qt5X11Extras ${REQUIRED_QT_VERSION} REQUIRED) +if(UNIX AND NOT APPLE) + find_dependency(Qt5X11Extras ${REQUIRED_QT_VERSION} REQUIRED) +endif() include("${CMAKE_CURRENT_LIST_DIR}/adsTargets.cmake") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0bd721d..b0ca9ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT}) find_package(Qt5 5.5 COMPONENTS Core Gui Widgets REQUIRED) -if (UNIX) +if (UNIX AND NOT APPLE) find_package(Qt5 5.5 COMPONENTS X11Extras REQUIRED) endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -48,7 +48,7 @@ set(ads_HEADERS IconProvider.h DockComponentsFactory.h ) -if (UNIX) +if (UNIX AND NOT APPLE) set(ads_SRCS linux/FloatingWidgetTitleBar.cpp ${ads_SRCS}) set(ads_HEADERS linux/FloatingWidgetTitleBar.h ${ads_HEADERS}) endif() @@ -60,7 +60,7 @@ else() target_compile_definitions(qtadvanceddocking PRIVATE ADS_SHARED_EXPORT) endif() target_link_libraries(qtadvanceddocking PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets) -if (UNIX) +if (UNIX AND NOT APPLE) target_link_libraries(qtadvanceddocking PUBLIC Qt5::X11Extras) endif() set_target_properties(qtadvanceddocking PROPERTIES From 3a5c96530621aa1726f89dcc1c3b9e91a5b2f9f2 Mon Sep 17 00:00:00 2001 From: Christian Seiler Date: Wed, 21 Oct 2020 22:07:41 +0200 Subject: [PATCH 2/4] Ensure that the stylesheet doesn't affect all QSplitter instances (#265) The stylesheet should only change the style of ads::CDockSplitter instances, but not all QSplitter instances. Otherwise all splitters within any dock widget will also be affected and look different from the default Qt style. Co-authored-by: Christian Seiler --- src/stylesheets/default.css | 2 +- src/stylesheets/default_linux.css | 2 +- src/stylesheets/focus_highlighting_linux.css | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stylesheets/default.css b/src/stylesheets/default.css index f5cd680..6ae011a 100644 --- a/src/stylesheets/default.css +++ b/src/stylesheets/default.css @@ -5,7 +5,7 @@ ads--CDockContainerWidget { background: palette(dark); } -ads--CDockContainerWidget QSplitter::handle { +ads--CDockContainerWidget ads--CDockSplitter::handle { background: palette(dark); } diff --git a/src/stylesheets/default_linux.css b/src/stylesheets/default_linux.css index 51e52ac..bf7f336 100644 --- a/src/stylesheets/default_linux.css +++ b/src/stylesheets/default_linux.css @@ -5,7 +5,7 @@ ads--CDockContainerWidget { background: palette(dark); } -ads--CDockContainerWidget QSplitter::handle { +ads--CDockContainerWidget ads--CDockSplitter::handle { background: palette(dark); } diff --git a/src/stylesheets/focus_highlighting_linux.css b/src/stylesheets/focus_highlighting_linux.css index bea52d0..888092f 100644 --- a/src/stylesheets/focus_highlighting_linux.css +++ b/src/stylesheets/focus_highlighting_linux.css @@ -5,7 +5,7 @@ ads--CDockContainerWidget { background: palette(dark); } -ads--CDockContainerWidget QSplitter::handle { +ads--CDockContainerWidget ads--CDockSplitter::handle { background: palette(dark); } @@ -192,3 +192,4 @@ ads--CFloatingDockContainer[isActiveWindow="true"] #floatingTitleMaximizeButton: background: rgba(255, 255, 255, 92); } */ + From 0e3c3bab456732b5803eaa4dc753a03e7bb60f6c Mon Sep 17 00:00:00 2001 From: Christian Seiler Date: Fri, 23 Oct 2020 20:59:50 +0200 Subject: [PATCH 3/4] DockManager: add the ability to programmatically update splitter sizes (#266) Add the ability to programmatically update splitter sizes. The user must specify the dock area that is contained in a splitter and a list of sizes. The list of sizes will be passed to the splitter that immediately contains the specified dock area. If the dock area is not part of a splitter the method will have no effect. Co-authored-by: Christian Seiler --- src/DockManager.cpp | 29 +++++++++++++++++++++++++++++ src/DockManager.h | 19 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 16b2d01..a7b0ddb 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -55,6 +55,7 @@ #include "DockingStateReader.h" #include "DockAreaTitleBar.h" #include "DockFocusController.h" +#include "DockSplitter.h" #ifdef Q_OS_LINUX #include "linux/FloatingWidgetTitleBar.h" @@ -1093,6 +1094,34 @@ CDockWidget* CDockManager::focusedDockWidget() const } } +//=========================================================================== +QList CDockManager::splitterSizes(CDockAreaWidget *ContainedArea) const +{ + if (ContainedArea) + { + auto Splitter = internal::findParent(ContainedArea); + if (Splitter) + { + return Splitter->sizes(); + } + } + return QList(); +} + +//=========================================================================== +void CDockManager::setSplitterSizes(CDockAreaWidget *ContainedArea, const QList& sizes) +{ + if (!ContainedArea) + { + return; + } + + auto Splitter = internal::findParent(ContainedArea); + if (Splitter && Splitter->count() == sizes.count()) + { + Splitter->setSizes(sizes); + } +} } // namespace ads diff --git a/src/DockManager.h b/src/DockManager.h index 8832415..c3924d3 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -487,6 +487,25 @@ public: */ CDockWidget* focusedDockWidget() const; + /** + * Returns the sizes of the splitter that contains the dock area. + * + * If there is no splitter that contains the area, an empty list will be + * returned. + */ + QList splitterSizes(CDockAreaWidget *ContainedArea) const; + + /** + * Update the sizes of a splitter + * Programmatically updates the sizes of a given splitter by calling + * QSplitter::setSizes(). The splitter will be the splitter that + * contains the supplied dock area widget. If there is not splitter + * that contains the dock area, or the sizes supplied does not match + * the number of children of the splitter, this method will have no + * effect. + */ + void setSplitterSizes(CDockAreaWidget *ContainedArea, const QList& sizes); + public slots: /** * Opens the perspective with the given name. From 8f95447108cd7b3a041f0c5e991d6e0181bbebc7 Mon Sep 17 00:00:00 2001 From: Nick D'Ademo Date: Sat, 24 Oct 2020 03:00:33 +0800 Subject: [PATCH 4/4] Fix. (#264) --- src/DockFocusController.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/DockFocusController.cpp b/src/DockFocusController.cpp index 77e73c1..6f3318a 100644 --- a/src/DockFocusController.cpp +++ b/src/DockFocusController.cpp @@ -240,7 +240,11 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge auto OtherDockWidgetTab = internal::findParent(focusedNow); if (OtherDockWidgetTab && focusedOld) { - focusedOld->setFocus(); + auto OldFocusedDockWidget = internal::findParent(focusedOld); + if (OldFocusedDockWidget) + { + focusedOld->setFocus(); + } return; } }