From c6595563afb5955e13ea3c9f26bc280146a944d1 Mon Sep 17 00:00:00 2001 From: Murmele Date: Sun, 16 Apr 2023 11:32:45 +0200 Subject: [PATCH 1/2] if QT_VERSION_MAJOR is defined, use this version instead of searching again. Labplot does not support Qt6 yet and therefore the version is set manually in the project. If Qt5 and Qt6 are installed, QAd overwrites the Qt5 requirement and then the configuration of the project does not work (#504) --- src/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ec56aa..8224644 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,11 @@ cmake_minimum_required(VERSION 3.5) project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT}) -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) +if (${QT_VERSION_MAJOR}) + message(STATUS "Forced to use Qt version ${QT_VERSION_MAJOR}") + find_package(QT NAMES Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) +else() + find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) +endif() find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets REQUIRED) if (UNIX AND NOT APPLE) include_directories(${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS}) From a940fc29c6d1fbcb5ee1e2fecf86f20bb86a7fb6 Mon Sep 17 00:00:00 2001 From: Murmele Date: Tue, 18 Apr 2023 19:17:10 +0200 Subject: [PATCH 2/2] Use code also for other unix systems like BSD (#507) --- src/DockFocusController.cpp | 10 +++++----- src/DockManager.cpp | 8 ++++---- src/DockManager.h | 2 +- src/DockOverlay.cpp | 6 +++--- src/FloatingDockContainer.cpp | 22 +++++++++++----------- src/FloatingDockContainer.h | 10 ++++------ src/FloatingDragPreview.cpp | 2 +- src/ads_globals.cpp | 6 +++--- src/ads_globals.h | 4 ++-- 9 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/DockFocusController.cpp b/src/DockFocusController.cpp index 322ff29..a85d010 100644 --- a/src/DockFocusController.cpp +++ b/src/DockFocusController.cpp @@ -27,7 +27,7 @@ #include "DockManager.h" #include "DockAreaTitleBar.h" -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) #include "linux/FloatingWidgetTitleBar.h" #endif @@ -44,7 +44,7 @@ struct DockFocusControllerPrivate QPointer FocusedDockWidget = nullptr; QPointer FocusedArea = nullptr; QPointer OldFocusedDockWidget = nullptr; -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) QPointer FloatingWidget = nullptr; #endif CDockManager* DockManager; @@ -84,7 +84,7 @@ static void updateDockAreaFocusStyle(CDockAreaWidget* DockArea, bool Focused) //=========================================================================== -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) static void updateFloatingWidgetFocusStyle(CFloatingDockContainer* FloatingWidget, bool Focused) { if (FloatingWidget->hasNativeTitleBar()) @@ -168,7 +168,7 @@ void DockFocusControllerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget) } -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) // This code is required for styling the floating widget titlebar for linux // depending on the current focus state if (FloatingWidget != NewFloatingWidget) @@ -285,7 +285,7 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge DockWidget = internal::findParent(focusedNow); } -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) if (!DockWidget) { return; diff --git a/src/DockManager.cpp b/src/DockManager.cpp index bebe619..5c7dd4d 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -59,7 +59,7 @@ #include "DockFocusController.h" #include "DockSplitter.h" -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) #include "linux/FloatingWidgetTitleBar.h" #endif @@ -192,7 +192,7 @@ void DockManagerPrivate::loadStylesheet() QString FileName = ":ads/stylesheets/"; FileName += CDockManager::testConfigFlag(CDockManager::FocusHighlighting) ? "focus_highlighting" : "default"; -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) FileName += "_linux"; #endif FileName += ".css"; @@ -510,7 +510,7 @@ CDockManager::CDockManager(QWidget *parent) : d->FocusController = new CDockFocusController(this); } -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) window()->installEventFilter(this); connect(qApp, &QApplication::focusWindowChanged, [](QWindow* focusWindow) @@ -552,7 +552,7 @@ CDockManager::~CDockManager() } //============================================================================ -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) bool CDockManager::eventFilter(QObject *obj, QEvent *e) { // Emulate Qt:Tool behaviour. diff --git a/src/DockManager.h b/src/DockManager.h index db215e3..bdb8c72 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -560,7 +560,7 @@ public: widget->setFocus(Qt::OtherFocusReason); } -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) bool eventFilter(QObject *obj, QEvent *e) override; #endif diff --git a/src/DockOverlay.cpp b/src/DockOverlay.cpp index 433974f..afefa26 100644 --- a/src/DockOverlay.cpp +++ b/src/DockOverlay.cpp @@ -139,7 +139,7 @@ struct DockOverlayCrossPrivate */ qreal dropIndicatiorWidth(QLabel* l) const { - #ifdef Q_OS_LINUX + #if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) Q_UNUSED(l) return 40; #else @@ -333,7 +333,7 @@ CDockOverlay::CDockOverlay(QWidget* parent, eMode Mode) : { d->Mode = Mode; d->Cross = new CDockOverlayCross(this); -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); #else setWindowFlags(Qt::Tool | Qt::FramelessWindowHint); @@ -595,7 +595,7 @@ CDockOverlayCross::CDockOverlayCross(CDockOverlay* overlay) : d(new DockOverlayCrossPrivate(this)) { d->DockOverlay = overlay; -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); #else setWindowFlags(Qt::Tool | Qt::FramelessWindowHint); diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index bd1e291..80f39d3 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -52,7 +52,7 @@ #pragma comment(lib, "User32.lib") #endif #endif -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) #include "linux/FloatingWidgetTitleBar.h" #include #endif @@ -374,7 +374,7 @@ struct FloatingDockContainerPrivate QPoint DragStartPos; bool Hiding = false; bool AutoHideChildren = true; -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) QWidget* MouseEventHandler = nullptr; CFloatingWidgetTitleBar* TitleBar = nullptr; bool IsResizing = false; @@ -424,7 +424,7 @@ struct FloatingDockContainerPrivate void setWindowTitle(const QString &Text) { -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) if (TitleBar) { TitleBar->setTitle(Text); @@ -540,7 +540,7 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint &GlobalPos) return; } -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) // Prevent display of drop overlays and docking as long as a model dialog // is active if (qApp->activeModalWidget()) @@ -641,7 +641,7 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager *DockManager) : connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this, SLOT(onDockAreasAddedOrRemoved())); -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) QDockWidget::setWidget(d->DockContainer); QDockWidget::setFloating(true); QDockWidget::setFeatures(QDockWidget::DockWidgetClosable @@ -768,7 +768,7 @@ void CFloatingDockContainer::changeEvent(QEvent *event) ADS_PRINT("FloatingWidget::changeEvent QEvent::ActivationChange "); d->zOrderIndex = ++zOrderCounter; -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) if (d->DraggingState == DraggingFloatingWidget) { d->titleMouseReleaseEvent(); @@ -920,7 +920,7 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event) void CFloatingDockContainer::showEvent(QShowEvent *event) { Super::showEvent(event); -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting)) { this->window()->activateWindow(); @@ -933,7 +933,7 @@ void CFloatingDockContainer::showEvent(QShowEvent *event) void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos, const QSize &Size, eDragState DragState, QWidget *MouseEventHandler) { -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) if (!isMaximized()) { resize(Size); @@ -1070,7 +1070,7 @@ bool CFloatingDockContainer::restoreState(CDockingStateReader &Stream, return false; } onDockAreasAddedOrRemoved(); -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) if(d->TitleBar) { d->TitleBar->setMaximizedIcon(windowState() == Qt::WindowMaximized); @@ -1114,7 +1114,7 @@ void CFloatingDockContainer::hideAndDeleteLater() void CFloatingDockContainer::finishDragging() { ADS_PRINT("CFloatingDockContainer::finishDragging"); -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) setWindowOpacity(1); activateWindow(); if (d->MouseEventHandler) @@ -1229,7 +1229,7 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event) #endif -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) //============================================================================ void CFloatingDockContainer::onMaximizeRequest() { diff --git a/src/FloatingDockContainer.h b/src/FloatingDockContainer.h index f91fe61..c640e54 100644 --- a/src/FloatingDockContainer.h +++ b/src/FloatingDockContainer.h @@ -33,7 +33,7 @@ #include -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) #include #define tFloatingWidgetBase QDockWidget #else @@ -182,10 +182,8 @@ protected: // reimplements QWidget #ifdef Q_OS_MACOS virtual bool event(QEvent *e) override; - virtual void moveEvent(QMoveEvent *event) override; -#endif - -#ifdef Q_OS_LINUX + virtual void moveEvent(QMoveEvent *event) override; +#elif defined(Q_OS_UNIX) virtual void moveEvent(QMoveEvent *event) override; virtual void resizeEvent(QResizeEvent *event) override; virtual bool event(QEvent *e) override; @@ -264,7 +262,7 @@ public: */ void hideAndDeleteLater(); -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) /** * This is a function that responds to FloatingWidgetTitleBar::maximizeRequest() * Maximize or normalize the container size. diff --git a/src/FloatingDragPreview.cpp b/src/FloatingDragPreview.cpp index 9f98bd9..8ee3b8e 100644 --- a/src/FloatingDragPreview.cpp +++ b/src/FloatingDragPreview.cpp @@ -262,7 +262,7 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) : setAttribute(Qt::WA_TranslucentBackground); } -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) auto Flags = windowFlags(); Flags |= Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint; setWindowFlags(Flags); diff --git a/src/ads_globals.cpp b/src/ads_globals.cpp index c096188..2afb675 100644 --- a/src/ads_globals.cpp +++ b/src/ads_globals.cpp @@ -38,7 +38,7 @@ #include "IconProvider.h" #include "ads_globals.h" -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) #include #include #include @@ -52,7 +52,7 @@ namespace internal { const int FloatingWidgetDragStartEvent = QEvent::registerEventType(); const int DockedWidgetDragStartEvent = QEvent::registerEventType(); -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) static QString _window_manager; static QHash _xcb_atom_cache; @@ -371,7 +371,7 @@ void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap return; } -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) Button->setIcon(Button->style()->standardIcon(StandarPixmap)); #else // The standard icons does not look good on high DPI screens so we create diff --git a/src/ads_globals.h b/src/ads_globals.h index 135fc37..aff8667 100644 --- a/src/ads_globals.h +++ b/src/ads_globals.h @@ -40,7 +40,7 @@ #include -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) #include #endif @@ -156,7 +156,7 @@ static const char* const DirtyProperty = "dirty"; extern const int FloatingWidgetDragStartEvent; extern const int DockedWidgetDragStartEvent; -#ifdef Q_OS_LINUX +#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) // Utils to directly communicate with the X server /** * Get atom from cache or request it from the XServer.