This commit is contained in:
Uwe Kindler 2021-01-09 19:03:14 +01:00
commit 2a6bd306cb
24 changed files with 154 additions and 163 deletions

View File

@ -15,6 +15,9 @@ integrated development environments (IDEs) such as Visual Studio.
## New and Noteworthy ## New and Noteworthy
The [release 3.7.0](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/tag/3.7.0)
adds support for Qt6.
The [release 3.6.0](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/tag/3.6.0) The [release 3.6.0](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/tag/3.6.0)
adds some nice new features: adds some nice new features:
@ -56,6 +59,7 @@ know it from Visual Studio.
- [Supports deletion of dynamically created dock widgets](#supports-deletion-of-dynamically-created-dock-widgets) - [Supports deletion of dynamically created dock widgets](#supports-deletion-of-dynamically-created-dock-widgets)
- [Python PyQt5 Bindings](#python-pyqt5-bindings) - [Python PyQt5 Bindings](#python-pyqt5-bindings)
- [Tested Compatible Environments](#tested-compatible-environments) - [Tested Compatible Environments](#tested-compatible-environments)
- [Supported Qt Versions](#supported-qt-versions)
- [Windows](#windows) - [Windows](#windows)
- [macOS](#macos) - [macOS](#macos)
- [Linux](#linux) - [Linux](#linux)
@ -81,8 +85,8 @@ There is no central widget like in the Qt docking system. You can dock on every
border of the main window or you can dock into each dock area - so you are border of the main window or you can dock into each dock area - so you are
free to dock almost everywhere. free to dock almost everywhere.
![Dropping widgets](doc/preview-dragndrop.png)\ ![Dropping widgets](doc/preview-dragndrop.png)
\
![Dropping widgets](doc/preview-dragndrop_dark.png) ![Dropping widgets](doc/preview-dragndrop_dark.png)
### Docking inside floating windows ### Docking inside floating windows
@ -90,8 +94,8 @@ free to dock almost everywhere.
There is no difference between the main window and a floating window. Docking There is no difference between the main window and a floating window. Docking
into floating windows is supported. into floating windows is supported.
![Docking inside floating windows](doc/floating-widget-dragndrop.png)\ ![Docking inside floating windows](doc/floating-widget-dragndrop.png)
\
![Docking inside floating windows](doc/floating-widget-dragndrop_dark.png) ![Docking inside floating windows](doc/floating-widget-dragndrop_dark.png)
### Grouped dragging ### Grouped dragging
@ -100,8 +104,8 @@ When dragging the titlebar of a dock, all the tabs that are tabbed with it are
going to be dragged. So you can move complete groups of tabbed widgets into going to be dragged. So you can move complete groups of tabbed widgets into
a floating widget or from one dock area to another one. a floating widget or from one dock area to another one.
![Grouped dragging](doc/grouped-dragging.gif)\ ![Grouped dragging](doc/grouped-dragging.gif)
\
![Grouped dragging](doc/grouped-dragging_dark.png) ![Grouped dragging](doc/grouped-dragging_dark.png)
### Perspectives for fast switching of the complete main window layout ### Perspectives for fast switching of the complete main window layout
@ -112,13 +116,13 @@ perspective to make your own custom perspective. Later you can simply
select a perspective from the perspective list to quickly switch the complete select a perspective from the perspective list to quickly switch the complete
main window layout. main window layout.
![Perspective](doc/perspectives.gif)\ ![Perspective](doc/perspectives.gif)
\
![Perspective](doc/perspectives_dark.png) ![Perspective](doc/perspectives_dark.png)
### Opaque and non-opaque splitter resizing ### Opaque and non-opaque splitter resizing
The advanced docking system uses standard QSplitters as resize separators and thus supports opaque and non-opaque resizing functionality of QSplitter. In some rare cases, for very complex widgets or on slow machines resizing via separator on the fly may cause flicking and glaring of rendered content inside a widget. The global dock manager flag `OpaqueSplitterResize` configures the resizing behaviour of the splitters. If this flag is set, then widgets are resized dynamically (opaquely) while interactively moving the splitters. The advanced docking system uses standard QSplitters as resize separators and thus supports opaque and non-opaque resizing functionality of QSplitter. In some rare cases, for very complex widgets or on slow machines resizing via separator on the fly may cause flicking and glaring of rendered content inside a widget. The global dock manager flag `OpaqueSplitterResize` configures the resizing behaviour of the splitters. If this flag is set, then widgets are resized dynamically (opaquely) while interactively moving the splitters.
![Opaque resizing](doc/opaque_resizing.gif) ![Opaque resizing](doc/opaque_resizing.gif)
@ -171,6 +175,10 @@ Latest working version: [3.5.2](https://github.com/githubuser0xFFFF/Qt-Advanced-
## Tested Compatible Environments ## Tested Compatible Environments
### Supported Qt Versions
The library supports **Qt5** and **Qt6**.
### Windows ### Windows
Windows 10 [![Build status](https://ci.appveyor.com/api/projects/status/qcfb3cy932jw9mpy/branch/master?svg=true)](https://ci.appveyor.com/project/githubuser0xFFFF/qt-advanced-docking-system/branch/master) Windows 10 [![Build status](https://ci.appveyor.com/api/projects/status/qcfb3cy932jw9mpy/branch/master?svg=true)](https://ci.appveyor.com/project/githubuser0xFFFF/qt-advanced-docking-system/branch/master)
@ -187,15 +195,23 @@ The application can be compiled for macOS. A user reported, that the library wor
### Linux ### Linux
Ubuntu [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System) [![Build Status](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
[![Build status](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/workflows/linux-builds/badge.svg)](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/actions?query=workflow%3Alinux-builds) [![Build status](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/workflows/linux-builds/badge.svg)](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/actions?query=workflow%3Alinux-builds)
The application can be compiled for Linux and has been developed and tested with **Kubuntu 18.04** and **Kubuntu 19.10**. Unfortunately, there is no such thing as a Linux operating system. Linux is a heterogeneous environment with a variety of different distributions. So it is not possible to support "Linux" like this is possible for Windows. It is only possible to support and test a small subset of Linux distributions. The library can be compiled for and has been developed and tested with the following Linux distributions:
- **Kubuntu 18.04 and 19.10**
- **Ubuntu 18.04, 19.10 and 20.04**
There are some requirements for the Linux distribution that have to be met:
- an X server that supports ARGB visuals and a compositing window manager. This is required to display the translucent dock overlays ([https://doc.qt.io/qt-5/qwidget.html#creating-translucent-windows](https://doc.qt.io/qt-5/qwidget.html#creating-translucent-windows)). If your Linux distribution does not support this, or if you disable this feature, you will very likely see issue [#95](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/95).
- Wayland is not properly supported by Qt yet. If you use Wayland, then you should set the session type to x11: `XDG_SESSION_TYPE=x11 ./AdvancedDockingSystemDemo`. You will find more details about this in issue [#288](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/288).
Screenshot Kubuntu:
![Advanced Docking on Kubuntu Linux](doc/linux_kubuntu_1804.png) ![Advanced Docking on Kubuntu Linux](doc/linux_kubuntu_1804.png)
and with **Ubuntu 19.10** Screenshot Ubuntu:
![Advanced Docking on Ubuntu Linux](doc/linux_ubuntu_1910.png) ![Advanced Docking on Ubuntu Linux](doc/linux_ubuntu_1910.png)
## Build ## Build

28
ads.pri Normal file
View File

@ -0,0 +1,28 @@
lessThan(QT_MAJOR_VERSION, 6) {
CONFIG(debug, debug|release){
win32 {
LIBS += -lqtadvanceddockingd
}
else:mac {
LIBS += -lqtadvanceddocking_debug
}
else {
LIBS += -lqtadvanceddocking
}
}
else{
LIBS += -lqtadvanceddocking
}
}
else {
# qt$$qtLibraryTarget(qtadvanceddocking) does not produce an advanceddockingd.dll file on Windows
# for Qt6 - I don't know if this is a bug and I have to investigate
LIBS += -lqtadvanceddocking
}
unix:!macx {
LIBS += -lxcb
QT += x11extras
}

View File

@ -58,12 +58,15 @@
#include <QMessageBox> #include <QMessageBox>
#include <QMenu> #include <QMenu>
#include <QToolButton> #include <QToolButton>
#include <QToolBar>
#include <QPointer> #include <QPointer>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QAxWidget> #include <QAxWidget>
#endif #endif
#endif
#include <QMap> #include <QMap>
#include <QElapsedTimer> #include <QElapsedTimer>
@ -355,6 +358,7 @@ struct MainWindowPrivate
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
/** /**
* Creates an ActiveX widget on windows * Creates an ActiveX widget on windows
*/ */
@ -368,6 +372,7 @@ struct MainWindowPrivate
return DockWidget; return DockWidget;
} }
#endif #endif
#endif
}; };
@ -446,10 +451,12 @@ void MainWindowPrivate::createContent()
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(raise())); DockWidget->connect(Action, SIGNAL(triggered()), SLOT(raise()));
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (!ads::CDockManager::testConfigFlag(ads::CDockManager::OpaqueUndocking)) if (!ads::CDockManager::testConfigFlag(ads::CDockManager::OpaqueUndocking))
{ {
DockManager->addDockWidget(ads::CenterDockWidgetArea, createActiveXWidget(), RighDockArea); DockManager->addDockWidget(ads::CenterDockWidgetArea, createActiveXWidget(), RighDockArea);
} }
#endif
#endif #endif
for (auto DockWidget : DockManager->dockWidgetsMap()) for (auto DockWidget : DockManager->dockWidgetsMap())
@ -610,8 +617,13 @@ CMainWindow::CMainWindow(QWidget *parent) :
// Now create the dock manager and its content // Now create the dock manager and its content
d->DockManager = new CDockManager(this); d->DockManager = new CDockManager(this);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
connect(d->PerspectiveComboBox, SIGNAL(activated(const QString&)), connect(d->PerspectiveComboBox, SIGNAL(activated(const QString&)),
d->DockManager, SLOT(openPerspective(const QString&))); d->DockManager, SLOT(openPerspective(const QString&)));
#else
connect(d->PerspectiveComboBox, SIGNAL(textActivated(const QString&)),
d->DockManager, SLOT(openPerspective(const QString&)));
#endif
d->createContent(); d->createContent();
// Default window geometry - center on screen // Default window geometry - center on screen

View File

@ -4,8 +4,12 @@ TARGET = AdvancedDockingSystemDemo
DESTDIR = $${ADS_OUT_ROOT}/lib DESTDIR = $${ADS_OUT_ROOT}/lib
QT += core gui widgets QT += core gui widgets
win32 { include(../ads.pri)
QT += axcontainer
lessThan(QT_MAJOR_VERSION, 6) {
win32 {
QT += axcontainer
}
} }
CONFIG += c++14 CONFIG += c++14
@ -35,26 +39,5 @@ RESOURCES += demo.qrc
LIBS += -L$${ADS_OUT_ROOT}/lib LIBS += -L$${ADS_OUT_ROOT}/lib
# Dependency: AdvancedDockingSystem (shared)
CONFIG(debug, debug|release){
win32 {
LIBS += -lqtadvanceddockingd
}
else:mac {
LIBS += -lqtadvanceddocking_debug
}
else {
LIBS += -lqtadvanceddocking
}
}
else{
LIBS += -lqtadvanceddocking
}
unix:!macx {
LIBS += -lxcb
QT += x11extras
}
INCLUDEPATH += ../src INCLUDEPATH += ../src
DEPENDPATH += ../src DEPENDPATH += ../src

View File

@ -359,6 +359,7 @@ class MainWindow(MainWindowUI, MainWindowBase):
floating = sender.property("Floating") floating = sender.property("Floating")
dock_widget = self.create_editor_widget() dock_widget = self.create_editor_widget()
dock_widget.setFeature(QtAds.CDockWidget.DockWidgetDeleteOnClose, True) dock_widget.setFeature(QtAds.CDockWidget.DockWidgetDeleteOnClose, True)
dock_widget.setFeature(QtAds.CDockWidget.DockWidgetForceCloseWithArea, True)
dock_widget.closeRequested.connect(self.on_editor_close_requested) dock_widget.closeRequested.connect(self.on_editor_close_requested)
if floating: if floating:

View File

@ -35,9 +35,11 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#if QT_VERSION >= 0x050600 #if QT_VERSION >= 0x050600
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#endif #endif
std::shared_ptr<int> b; std::shared_ptr<int> b;
QApplication a(argc, argv); QApplication a(argc, argv);

View File

@ -106,6 +106,11 @@ class MainWindow(MainWindowUI, MainWindowBase):
self.perspective_combobox.clear() self.perspective_combobox.clear()
self.perspective_combobox.addItems(self.dock_manager.perspectiveNames()) self.perspective_combobox.addItems(self.dock_manager.perspectiveNames())
self.perspective_combobox.setCurrentText(perspective_name) self.perspective_combobox.setCurrentText(perspective_name)
def closeEvent(self, event: QCloseEvent):
self.dock_manager.deleteLater()
super().closeEvent(event)
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication(sys.argv) app = QApplication(sys.argv)

View File

@ -28,28 +28,7 @@ FORMS += \
mainwindow.ui mainwindow.ui
LIBS += -L$${ADS_OUT_ROOT}/lib LIBS += -L$${ADS_OUT_ROOT}/lib
include(../../ads.pri)
# Dependency: AdvancedDockingSystem (shared)
CONFIG(debug, debug|release){
win32 {
LIBS += -lqtadvanceddockingd
}
else:mac {
LIBS += -lqtadvanceddocking_debug
}
else {
LIBS += -lqtadvanceddocking
}
}
else{
LIBS += -lqtadvanceddocking
}
unix:!macx {
LIBS += -lxcb
QT += x11extras
}
INCLUDEPATH += ../../src INCLUDEPATH += ../../src
DEPENDPATH += ../../src DEPENDPATH += ../../src

View File

@ -26,17 +26,6 @@
using namespace ads; using namespace ads;
/**
* Helper function to create an SVG icon
*/
static QIcon svgIcon(const QString& File)
{
// This is a workaround, because in item views SVG icons are not
// properly scaled and look blurry or pixelate
QIcon SvgIcon(File);
SvgIcon.addPixmap(SvgIcon.pixmap(92));
return SvgIcon;
}
CMainWindow::CMainWindow(QWidget *parent) CMainWindow::CMainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
@ -104,7 +93,6 @@ CMainWindow::~CMainWindow()
void CMainWindow::createPerspectiveUi() void CMainWindow::createPerspectiveUi()
{ {
SavePerspectiveAction = new QAction("Create Perspective", this); SavePerspectiveAction = new QAction("Create Perspective", this);
SavePerspectiveAction->setIcon(svgIcon(":/adsdemo/images/picture_in_picture.svg"));
connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective())); connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective()));
PerspectiveListAction = new QWidgetAction(this); PerspectiveListAction = new QWidgetAction(this);
PerspectiveComboBox = new QComboBox(this); PerspectiveComboBox = new QComboBox(this);

View File

@ -17,28 +17,7 @@ SOURCES += main.cpp
LIBS += -L$${ADS_OUT_ROOT}/lib LIBS += -L$${ADS_OUT_ROOT}/lib
include(../../ads.pri)
# Dependency: AdvancedDockingSystem (shared)
CONFIG(debug, debug|release){
win32 {
LIBS += -lqtadvanceddockingd
}
else:mac {
LIBS += -lqtadvanceddocking_debug
}
else {
LIBS += -lqtadvanceddocking
}
}
else{
LIBS += -lqtadvanceddocking
}
unix:!macx {
LIBS += -lxcb
QT += x11extras
}
INCLUDEPATH += ../../src INCLUDEPATH += ../../src
DEPENDPATH += ../../src DEPENDPATH += ../../src

View File

@ -25,28 +25,7 @@ FORMS += \
LIBS += -L$${ADS_OUT_ROOT}/lib LIBS += -L$${ADS_OUT_ROOT}/lib
include(../../ads.pri)
# Dependency: AdvancedDockingSystem (shared)
CONFIG(debug, debug|release){
win32 {
LIBS += -lqtadvanceddockingd
}
else:mac {
LIBS += -lqtadvanceddocking_debug
}
else {
LIBS += -lqtadvanceddocking
}
}
else{
LIBS += -lqtadvanceddocking
}
unix:!macx {
LIBS += -lxcb
QT += x11extras
}
INCLUDEPATH += ../../src INCLUDEPATH += ../../src
DEPENDPATH += ../../src DEPENDPATH += ../../src

View File

@ -25,28 +25,7 @@ FORMS += \
LIBS += -L$${ADS_OUT_ROOT}/lib LIBS += -L$${ADS_OUT_ROOT}/lib
include(../../ads.pri)
# Dependency: AdvancedDockingSystem (shared)
CONFIG(debug, debug|release){
win32 {
LIBS += -lqtadvanceddockingd
}
else:mac {
LIBS += -lqtadvanceddocking_debug
}
else {
LIBS += -lqtadvanceddocking
}
}
else{
LIBS += -lqtadvanceddocking
}
unix:!macx {
LIBS += -lxcb
QT += x11extras
}
INCLUDEPATH += ../../src INCLUDEPATH += ../../src
DEPENDPATH += ../../src DEPENDPATH += ../../src

View File

@ -135,7 +135,6 @@ protected:
ads::CDockOverlay* dockAreaOverlay() const; ads::CDockOverlay* dockAreaOverlay() const;
void notifyWidgetOrAreaRelocation(QWidget* RelocatedWidget); void notifyWidgetOrAreaRelocation(QWidget* RelocatedWidget);
void notifyFloatingWidgetDrop(ads::CFloatingDockContainer* FloatingWidget); void notifyFloatingWidgetDrop(ads::CFloatingDockContainer* FloatingWidget);
ads::CDockWidget* focusedDockWidget() const;
virtual void showEvent(QShowEvent *event); virtual void showEvent(QShowEvent *event);
@ -217,6 +216,9 @@ public:
void setViewMenuInsertionOrder(ads::CDockManager::eViewMenuInsertionOrder Order); void setViewMenuInsertionOrder(ads::CDockManager::eViewMenuInsertionOrder Order);
bool isRestoringState() const; bool isRestoringState() const;
static int startDragDistance(); static int startDragDistance();
ads::CDockWidget* focusedDockWidget() const;
QList<int> splitterSizes(ads::CDockAreaWidget *ContainedArea) const;
void setSplitterSizes(ads::CDockAreaWidget *ContainedArea, const QList<int>& sizes);
public slots: public slots:
void openPerspective(const QString& PerspectiveName); void openPerspective(const QString& PerspectiveName);

View File

@ -35,6 +35,8 @@ public:
virtual bool event(QEvent *e); virtual bool event(QEvent *e);
void setElideMode(Qt::TextElideMode mode); void setElideMode(Qt::TextElideMode mode);
void updateStyle(); void updateStyle();
QSize iconSize() const;
void setIconSize(const QSize& Size);
public slots: public slots:
virtual void setVisible(bool visible); virtual void setVisible(bool visible);

View File

@ -917,15 +917,15 @@ bool DockContainerWidgetPrivate::restoreSplitter(CDockingStateReader& s,
{ {
QWidget* ChildNode = nullptr; QWidget* ChildNode = nullptr;
bool Result = true; bool Result = true;
if (s.name() == "Splitter") if (s.name() == QLatin1String("Splitter"))
{ {
Result = restoreSplitter(s, ChildNode, Testing); Result = restoreSplitter(s, ChildNode, Testing);
} }
else if (s.name() == "Area") else if (s.name() == QLatin1String("Area"))
{ {
Result = restoreDockArea(s, ChildNode, Testing); Result = restoreDockArea(s, ChildNode, Testing);
} }
else if (s.name() == "Sizes") else if (s.name() == QLatin1String("Sizes"))
{ {
QString sSizes = s.readElementText().trimmed(); QString sSizes = s.readElementText().trimmed();
ADS_PRINT("Sizes: " << sSizes); ADS_PRINT("Sizes: " << sSizes);
@ -1026,7 +1026,7 @@ bool DockContainerWidgetPrivate::restoreDockArea(CDockingStateReader& s,
while (s.readNextStartElement()) while (s.readNextStartElement())
{ {
if (s.name() != "Widget") if (s.name() != QLatin1String("Widget"))
{ {
continue; continue;
} }
@ -1089,12 +1089,12 @@ bool DockContainerWidgetPrivate::restoreChildNodes(CDockingStateReader& s,
bool Result = true; bool Result = true;
while (s.readNextStartElement()) while (s.readNextStartElement())
{ {
if (s.name() == "Splitter") if (s.name() == QLatin1String("Splitter"))
{ {
Result = restoreSplitter(s, CreatedWidget, Testing); Result = restoreSplitter(s, CreatedWidget, Testing);
ADS_PRINT("Splitter"); ADS_PRINT("Splitter");
} }
else if (s.name() == "Area") else if (s.name() == QLatin1String("Area"))
{ {
Result = restoreDockArea(s, CreatedWidget, Testing); Result = restoreDockArea(s, CreatedWidget, Testing);
ADS_PRINT("DockAreaWidget"); ADS_PRINT("DockAreaWidget");
@ -1664,7 +1664,7 @@ bool CDockContainerWidget::restoreState(CDockingStateReader& s, bool Testing)
if (IsFloating) if (IsFloating)
{ {
ADS_PRINT("Restore floating widget"); ADS_PRINT("Restore floating widget");
if (!s.readNextStartElement() || s.name() != "Geometry") if (!s.readNextStartElement() || s.name() != QLatin1String("Geometry"))
{ {
return false; return false;
} }

View File

@ -250,7 +250,7 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi
} }
CDockingStateReader s(state); CDockingStateReader s(state);
s.readNextStartElement(); s.readNextStartElement();
if (s.name() != "QtAdvancedDockingSystem") if (s.name() != QLatin1String("QtAdvancedDockingSystem"))
{ {
return false; return false;
} }
@ -304,7 +304,7 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi
int DockContainerCount = 0; int DockContainerCount = 0;
while (s.readNextStartElement()) while (s.readNextStartElement())
{ {
if (s.name() == "Container") if (s.name() == QLatin1String("Container"))
{ {
Result = restoreContainer(DockContainerCount, s, Testing); Result = restoreContainer(DockContainerCount, s, Testing);
if (!Result) if (!Result)

View File

@ -806,10 +806,15 @@ void CDockOverlayCross::setIconColors(const QString& Colors)
{"Arrow", CDockOverlayCross::ArrowColor}, {"Arrow", CDockOverlayCross::ArrowColor},
{"Shadow", CDockOverlayCross::ShadowColor}}; {"Shadow", CDockOverlayCross::ShadowColor}};
auto ColorList = Colors.split(' ', QString::SkipEmptyParts); #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
auto SkipEmptyParts = QString::SkipEmptyParts;
#else
auto SkipEmptyParts = Qt::SkipEmptyParts;
#endif
auto ColorList = Colors.split(' ', SkipEmptyParts);
for (const auto& ColorListEntry : ColorList) for (const auto& ColorListEntry : ColorList)
{ {
auto ComponentColor = ColorListEntry.split('=', QString::SkipEmptyParts); auto ComponentColor = ColorListEntry.split('=', SkipEmptyParts);
int Component = ColorCompenentStringMap.value(ComponentColor[0], -1); int Component = ColorCompenentStringMap.value(ComponentColor[0], -1);
if (Component < 0) if (Component < 0)
{ {

View File

@ -31,7 +31,7 @@
#include <QDebug> #include <QDebug>
#include <QChildEvent> #include <QChildEvent>
#include <QVariant>
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
namespace ads namespace ads
@ -52,7 +52,7 @@ CDockSplitter::CDockSplitter(QWidget *parent)
: QSplitter(parent), : QSplitter(parent),
d(new DockSplitterPrivate(this)) d(new DockSplitterPrivate(this))
{ {
setProperty("ads-splitter", true); setProperty("ads-splitter", QVariant(true));
setChildrenCollapsible(false); setChildrenCollapsible(false);
} }

View File

@ -259,7 +259,7 @@ void DockWidgetTabPrivate::createLayout()
void DockWidgetTabPrivate::moveTab(QMouseEvent* ev) void DockWidgetTabPrivate::moveTab(QMouseEvent* ev)
{ {
ev->accept(); ev->accept();
QPoint Distance = ev->globalPos() - GlobalDragStartMousePosition; QPoint Distance = internal::globalPositionOf(ev) - GlobalDragStartMousePosition;
Distance.setY(0); Distance.setY(0);
auto TargetPos = Distance + TabDragStartPosition; auto TargetPos = Distance + TabDragStartPosition;
TargetPos.rx() = qMax(TargetPos.x(), 0); TargetPos.rx() = qMax(TargetPos.x(), 0);
@ -351,7 +351,7 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
if (ev->button() == Qt::LeftButton) if (ev->button() == Qt::LeftButton)
{ {
ev->accept(); ev->accept();
d->saveDragStartMousePosition(ev->globalPos()); d->saveDragStartMousePosition(internal::globalPositionOf(ev));
d->DragState = DraggingMousePressed; d->DragState = DraggingMousePressed;
emit clicked(); emit clicked();
return; return;
@ -377,7 +377,7 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
// End of tab moving, emit signal // End of tab moving, emit signal
if (d->DockArea) if (d->DockArea)
{ {
emit moved(ev->globalPos()); emit moved(internal::globalPositionOf(ev));
} }
break; break;
@ -422,7 +422,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
auto MappedPos = mapToParent(ev->pos()); auto MappedPos = mapToParent(ev->pos());
bool MouseOutsideBar = (MappedPos.x() < 0) || (MappedPos.x() > parentWidget()->rect().right()); bool MouseOutsideBar = (MappedPos.x() < 0) || (MappedPos.x() > parentWidget()->rect().right());
// Maybe a fixed drag distance is better here ? // Maybe a fixed drag distance is better here ?
int DragDistanceY = qAbs(d->GlobalDragStartMousePosition.y() - ev->globalPos().y()); int DragDistanceY = qAbs(d->GlobalDragStartMousePosition.y() - internal::globalPositionOf(ev).y());
if (DragDistanceY >= CDockManager::startDragDistance() || MouseOutsideBar) if (DragDistanceY >= CDockManager::startDragDistance() || MouseOutsideBar)
{ {
// If this is the last dock area in a dock container with only // If this is the last dock area in a dock container with only
@ -454,7 +454,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
return; return;
} }
else if (d->DockArea->openDockWidgetsCount() > 1 else if (d->DockArea->openDockWidgetsCount() > 1
&& (ev->globalPos() - d->GlobalDragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving && (internal::globalPositionOf(ev) - d->GlobalDragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
{ {
// If we start dragging the tab, we save its inital position to // If we start dragging the tab, we save its inital position to
// restore it later // restore it later
@ -618,7 +618,7 @@ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
if ((!d->DockArea->dockContainer()->isFloating() || d->DockArea->dockWidgetsCount() > 1) if ((!d->DockArea->dockContainer()->isFloating() || d->DockArea->dockWidgetsCount() > 1)
&& d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable)) && d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
{ {
d->saveDragStartMousePosition(event->globalPos()); d->saveDragStartMousePosition(internal::globalPositionOf(event));
d->startFloating(DraggingInactive); d->startFloating(DraggingInactive);
} }

View File

@ -163,7 +163,12 @@ void CElidingLabel::resizeEvent(QResizeEvent *event)
//============================================================================ //============================================================================
QSize CElidingLabel::minimumSizeHint() const QSize CElidingLabel::minimumSizeHint() const
{ {
if (pixmap() != nullptr || d->isModeElideNone()) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
bool HasPixmap = !pixmap().isNull();
#else
bool HasPixmap = (pixmap() != nullptr);
#endif
if (HasPixmap || d->isModeElideNone())
{ {
return QLabel::minimumSizeHint(); return QLabel::minimumSizeHint();
} }
@ -180,7 +185,12 @@ QSize CElidingLabel::minimumSizeHint() const
//============================================================================ //============================================================================
QSize CElidingLabel::sizeHint() const QSize CElidingLabel::sizeHint() const
{ {
if (pixmap() != nullptr || d->isModeElideNone()) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
bool HasPixmap = !pixmap().isNull();
#else
bool HasPixmap = (pixmap() != nullptr);
#endif
if (HasPixmap || d->isModeElideNone())
{ {
return QLabel::sizeHint(); return QLabel::sizeHint();
} }

View File

@ -58,8 +58,8 @@ protected:
public: public:
using Super = QLabel; using Super = QLabel;
CElidingLabel(QWidget* parent = 0, Qt::WindowFlags f = 0); CElidingLabel(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags ());
CElidingLabel(const QString& text, QWidget* parent = 0, Qt::WindowFlags f = 0); CElidingLabel(const QString& text, QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags ());
virtual ~CElidingLabel(); virtual ~CElidingLabel();
/** /**

View File

@ -733,8 +733,11 @@ void CFloatingDockContainer::changeEvent(QEvent *event)
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
//============================================================================ #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *message, long *result) bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *message, long *result)
#else
bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *message, qintptr *result)
#endif
{ {
QWidget::nativeEvent(eventType, message, result); QWidget::nativeEvent(eventType, message, result);
MSG *msg = static_cast<MSG*>(message); MSG *msg = static_cast<MSG*>(message);

View File

@ -194,7 +194,11 @@ protected: // reimplements QWidget
/** /**
* Native event filter for handling WM_MOVING messages on Windows * Native event filter for handling WM_MOVING messages on Windows
*/ */
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
#else
virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
#endif
#endif #endif

View File

@ -36,6 +36,7 @@
#include <QWidget> #include <QWidget>
#include <QDebug> #include <QDebug>
#include <QStyle> #include <QStyle>
#include <QMouseEvent>
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
#include <xcb/xcb.h> #include <xcb/xcb.h>
@ -179,7 +180,7 @@ void hideEmptyParentSplitters(CDockSplitter* FirstParentSplitter);
class CDockInsertParam : public QPair<Qt::Orientation, bool> class CDockInsertParam : public QPair<Qt::Orientation, bool>
{ {
public: public:
using QPair::QPair; using QPair<Qt::Orientation, bool>::QPair;
Qt::Orientation orientation() const {return this->first;} Qt::Orientation orientation() const {return this->first;}
bool append() const {return this->second;} bool append() const {return this->second;}
int insertOffset() const {return append() ? 1 : 0;} int insertOffset() const {return append() ? 1 : 0;}
@ -260,6 +261,19 @@ void setToolTip(QObjectPtr obj, const QString &tip)
} }
/**
* Helper function for access to mouse event global position in Qt5 and
*/
inline QPoint globalPositionOf(QMouseEvent* ev)
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return ev->globalPosition().toPoint();
#else
return ev->globalPos();
#endif
}
/** /**
* Helper function to set the icon of a certain button. * Helper function to set the icon of a certain button.
* Use this function to set the icons for the dock area and dock widget buttons. * Use this function to set the icons for the dock area and dock widget buttons.