From 88d4bea2c11cc7b075fb80678a6056380a2406b1 Mon Sep 17 00:00:00 2001 From: Sergey Kartashev Date: Mon, 14 Jan 2019 10:59:37 +0300 Subject: [PATCH] Qt 5.5.1 (ubuntu 16.04) compatibility buildfixes --- demo/main.cpp | 2 ++ src/DockContainerWidget.cpp | 30 ++++++++++++++++++++++++++++++ src/DockOverlay.cpp | 13 ++++++++++++- src/DockWidget.cpp | 13 ++++++++++++- src/src.pro | 4 ++++ 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/demo/main.cpp b/demo/main.cpp index 1a2bd47..b1f2e9c 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -38,7 +38,9 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#if QT_VERSION >= 0x050600 QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif std::shared_ptr b; QApplication a(argc, argv); a.setQuitOnLastWindowClosed(true); diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 8292cb9..3cbfefd 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -49,6 +49,32 @@ #include +#if QT_VERSION < 0x050900 + +inline char toHexLower(uint value) +{ + return "0123456789abcdef"[value & 0xF]; +} + +QByteArray qByteArrayToHex(const QByteArray& src, char separator) +{ + if(src.size() == 0) + return QByteArray(); + + const int length = separator ? (src.size() * 3 - 1) : (src.size() * 2); + QByteArray hex(length, Qt::Uninitialized); + char *hexData = hex.data(); + const uchar *data = (const uchar *)src.data(); + for (int i = 0, o = 0; i < src.size(); ++i) { + hexData[o++] = toHexLower(data[i] >> 4); + hexData[o++] = toHexLower(data[i] & 0xf); + + if ((separator) && (o < length)) + hexData[o++] = separator; + } + return hex; +} +#endif namespace ads { @@ -1182,7 +1208,11 @@ void CDockContainerWidget::saveState(QXmlStreamWriter& s) const { CFloatingDockContainer* FloatingWidget = floatingWidget(); QByteArray Geometry = FloatingWidget->saveGeometry(); +#if QT_VERSION < 0x050900 + s.writeTextElement("Geometry", qByteArrayToHex(Geometry, ' ')); +#else s.writeTextElement("Geometry", Geometry.toHex(' ')); +#endif } d->saveChildNodesState(s, d->RootSplitter); s.writeEndElement(); diff --git a/src/DockOverlay.cpp b/src/DockOverlay.cpp index bf0ce3e..b1cb4f7 100644 --- a/src/DockOverlay.cpp +++ b/src/DockOverlay.cpp @@ -168,7 +168,11 @@ struct DockOverlayCrossPrivate QColor borderColor = iconColor(CDockOverlayCross::FrameColor); QColor backgroundColor = iconColor(CDockOverlayCross::WindowBackgroundColor); +#if QT_VERSION >= 0x050600 double DevicePixelRatio = _this->window()->devicePixelRatioF(); +#else + double DevicePixelRatio = _this->window()->devicePixelRatio(); +#endif QSizeF PixmapSize = size * DevicePixelRatio; QPixmap pm(PixmapSize.toSize()); pm.fill(QColor(0, 0, 0, 0)); @@ -577,8 +581,11 @@ void CDockOverlayCross::setupOverlayCross(CDockOverlay::eMode Mode) areaWidgets.insert(BottomDockWidgetArea, d->createDropIndicatorWidget(BottomDockWidgetArea, Mode)); areaWidgets.insert(LeftDockWidgetArea, d->createDropIndicatorWidget(LeftDockWidgetArea, Mode)); areaWidgets.insert(CenterDockWidgetArea, d->createDropIndicatorWidget(CenterDockWidgetArea, Mode)); +#if QT_VERSION >= 0x050600 d->LastDevicePixelRatio = devicePixelRatioF(); - +#else + d->LastDevicePixelRatio = devicePixelRatio(); +#endif setAreaWidgets(areaWidgets); d->UpdateRequired = false; } @@ -596,7 +603,11 @@ void CDockOverlayCross::updateOverlayIcons() { d->updateDropIndicatorIcon(Widget); } +#if QT_VESION >= 0x050600 d->LastDevicePixelRatio = devicePixelRatioF(); +#else + d->LastDevicePixelRatio = devicePixelRatio(); +#endif } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 0333d57..559a1d5 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -214,7 +214,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) : setObjectName(title); d->TabWidget = new CDockWidgetTab(this); - d->ToggleViewAction = new QAction(title); + d->ToggleViewAction = new QAction(title, nullptr); d->ToggleViewAction->setCheckable(true); connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this, SLOT(toggleView(bool))); @@ -282,7 +282,18 @@ void CDockWidget::setFeatures(DockWidgetFeatures features) //============================================================================ void CDockWidget::setFeature(DockWidgetFeature flag, bool on) { +#if QT_VERSION >= 0x050700 d->Features.setFlag(flag, on); +#else + if(on) + { + d->Features |= flag; + } + else + { + d->Features &= ~flag; + } +#endif } diff --git a/src/src.pro b/src/src.pro index 279bd7f..2f4ea7d 100644 --- a/src/src.pro +++ b/src/src.pro @@ -28,6 +28,10 @@ windows { } } +unix { + CONFIG += c++11 +} + RESOURCES += ads.qrc HEADERS += \