From 018ce2001e93647e6af95df1033500e02f2fa1a3 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Sat, 2 Jan 2021 18:06:45 +0100 Subject: [PATCH] Fixed all Qt6 build issues --- demo/MainWindow.cpp | 7 +++++++ demo/demo.pro | 6 ++++-- src/DockContainerWidget.cpp | 14 +++++++------- src/DockManager.cpp | 4 ++-- src/DockOverlay.cpp | 9 +++++++-- src/DockSplitter.cpp | 4 ++-- src/ElidingLabel.cpp | 14 ++++++++++++-- src/ElidingLabel.h | 4 ++-- src/FloatingDockContainer.cpp | 5 ++++- src/FloatingDockContainer.h | 6 +++++- src/ads_globals.h | 2 +- 11 files changed, 53 insertions(+), 22 deletions(-) diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 289fba1..4223926 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -58,12 +58,15 @@ #include #include #include +#include #include #ifdef Q_OS_WIN +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #endif +#endif #include #include @@ -355,6 +358,7 @@ struct MainWindowPrivate #ifdef Q_OS_WIN +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) /** * Creates an ActiveX widget on windows */ @@ -368,6 +372,7 @@ struct MainWindowPrivate return DockWidget; } #endif +#endif }; @@ -446,10 +451,12 @@ void MainWindowPrivate::createContent() DockWidget->connect(Action, SIGNAL(triggered()), SLOT(raise())); #ifdef Q_OS_WIN +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (!ads::CDockManager::testConfigFlag(ads::CDockManager::OpaqueUndocking)) { DockManager->addDockWidget(ads::CenterDockWidgetArea, createActiveXWidget(), RighDockArea); } +#endif #endif for (auto DockWidget : DockManager->dockWidgetsMap()) diff --git a/demo/demo.pro b/demo/demo.pro index 24a2965..db33bbe 100644 --- a/demo/demo.pro +++ b/demo/demo.pro @@ -4,8 +4,10 @@ TARGET = AdvancedDockingSystemDemo DESTDIR = $${ADS_OUT_ROOT}/lib QT += core gui widgets -win32 { -QT += axcontainer +lessThan(QT_MAJOR_VERSION, 6) { + win32 { + QT += axcontainer + } } CONFIG += c++14 diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 0288ae9..107180c 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -917,15 +917,15 @@ bool DockContainerWidgetPrivate::restoreSplitter(CDockingStateReader& s, { QWidget* ChildNode = nullptr; bool Result = true; - if (s.name() == "Splitter") + if (s.name() == QLatin1String("Splitter")) { Result = restoreSplitter(s, ChildNode, Testing); } - else if (s.name() == "Area") + else if (s.name() == QLatin1String("Area")) { Result = restoreDockArea(s, ChildNode, Testing); } - else if (s.name() == "Sizes") + else if (s.name() == QLatin1String("Sizes")) { QString sSizes = s.readElementText().trimmed(); ADS_PRINT("Sizes: " << sSizes); @@ -1026,7 +1026,7 @@ bool DockContainerWidgetPrivate::restoreDockArea(CDockingStateReader& s, while (s.readNextStartElement()) { - if (s.name() != "Widget") + if (s.name() != QLatin1String("Widget")) { continue; } @@ -1089,12 +1089,12 @@ bool DockContainerWidgetPrivate::restoreChildNodes(CDockingStateReader& s, bool Result = true; while (s.readNextStartElement()) { - if (s.name() == "Splitter") + if (s.name() == QLatin1String("Splitter")) { Result = restoreSplitter(s, CreatedWidget, Testing); ADS_PRINT("Splitter"); } - else if (s.name() == "Area") + else if (s.name() == QLatin1String("Area")) { Result = restoreDockArea(s, CreatedWidget, Testing); ADS_PRINT("DockAreaWidget"); @@ -1664,7 +1664,7 @@ bool CDockContainerWidget::restoreState(CDockingStateReader& s, bool Testing) if (IsFloating) { ADS_PRINT("Restore floating widget"); - if (!s.readNextStartElement() || s.name() != "Geometry") + if (!s.readNextStartElement() || s.name() != QLatin1String("Geometry")) { return false; } diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 67cf210..9ef4a08 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -250,7 +250,7 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi } CDockingStateReader s(state); s.readNextStartElement(); - if (s.name() != "QtAdvancedDockingSystem") + if (s.name() != QLatin1String("QtAdvancedDockingSystem")) { return false; } @@ -304,7 +304,7 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi int DockContainerCount = 0; while (s.readNextStartElement()) { - if (s.name() == "Container") + if (s.name() == QLatin1String("Container")) { Result = restoreContainer(DockContainerCount, s, Testing); if (!Result) diff --git a/src/DockOverlay.cpp b/src/DockOverlay.cpp index f23a834..5fd92b3 100644 --- a/src/DockOverlay.cpp +++ b/src/DockOverlay.cpp @@ -806,10 +806,15 @@ void CDockOverlayCross::setIconColors(const QString& Colors) {"Arrow", CDockOverlayCross::ArrowColor}, {"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) { - auto ComponentColor = ColorListEntry.split('=', QString::SkipEmptyParts); + auto ComponentColor = ColorListEntry.split('=', SkipEmptyParts); int Component = ColorCompenentStringMap.value(ComponentColor[0], -1); if (Component < 0) { diff --git a/src/DockSplitter.cpp b/src/DockSplitter.cpp index 047f0f4..33f6172 100644 --- a/src/DockSplitter.cpp +++ b/src/DockSplitter.cpp @@ -31,7 +31,7 @@ #include #include - +#include #include "DockAreaWidget.h" namespace ads @@ -52,7 +52,7 @@ CDockSplitter::CDockSplitter(QWidget *parent) : QSplitter(parent), d(new DockSplitterPrivate(this)) { - setProperty("ads-splitter", true); + setProperty("ads-splitter", QVariant(true)); setChildrenCollapsible(false); } diff --git a/src/ElidingLabel.cpp b/src/ElidingLabel.cpp index 7725b9b..b95a7f6 100644 --- a/src/ElidingLabel.cpp +++ b/src/ElidingLabel.cpp @@ -163,7 +163,12 @@ void CElidingLabel::resizeEvent(QResizeEvent *event) //============================================================================ QSize CElidingLabel::minimumSizeHint() const { - if (pixmap() != nullptr || d->isModeElideNone()) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + bool NoPixmap = pixmap().isNull(); +#else + bool NoPixmap = (pixmap() == nullptr); +#endif + if (NoPixmap || d->isModeElideNone()) { return QLabel::minimumSizeHint(); } @@ -180,7 +185,12 @@ QSize CElidingLabel::minimumSizeHint() const //============================================================================ QSize CElidingLabel::sizeHint() const { - if (pixmap() != nullptr || d->isModeElideNone()) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + bool NoPixmap = pixmap().isNull(); +#else + bool NoPixmap = (pixmap() == nullptr); +#endif + if (NoPixmap || d->isModeElideNone()) { return QLabel::sizeHint(); } diff --git a/src/ElidingLabel.h b/src/ElidingLabel.h index 89a31e7..7db7de5 100644 --- a/src/ElidingLabel.h +++ b/src/ElidingLabel.h @@ -58,8 +58,8 @@ protected: public: using Super = QLabel; - CElidingLabel(QWidget* parent = 0, Qt::WindowFlags f = 0); - CElidingLabel(const QString& text, 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 = Qt::WindowFlags ()); virtual ~CElidingLabel(); /** diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index 55979f3..a60f1e2 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -733,8 +733,11 @@ void CFloatingDockContainer::changeEvent(QEvent *event) #ifdef Q_OS_WIN -//============================================================================ +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) 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); MSG *msg = static_cast(message); diff --git a/src/FloatingDockContainer.h b/src/FloatingDockContainer.h index a22d394..1265332 100644 --- a/src/FloatingDockContainer.h +++ b/src/FloatingDockContainer.h @@ -194,7 +194,11 @@ protected: // reimplements QWidget /** * 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 diff --git a/src/ads_globals.h b/src/ads_globals.h index c5fe28d..2a22c0e 100644 --- a/src/ads_globals.h +++ b/src/ads_globals.h @@ -179,7 +179,7 @@ void hideEmptyParentSplitters(CDockSplitter* FirstParentSplitter); class CDockInsertParam : public QPair { public: - using QPair::QPair; + using QPair::QPair; Qt::Orientation orientation() const {return this->first;} bool append() const {return this->second;} int insertOffset() const {return append() ? 1 : 0;}