Skip to content

Commit a06a14d

Browse files
Merge pull request #15 from skartashev/master
Qt 5.5.1 (ubuntu 16.04) compatibility buildfixes
2 parents b8ad2f7 + 88d4bea commit a06a14d

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
lines changed

demo/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
3636
int main(int argc, char *argv[])
3737
{
3838
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
39+
#if QT_VERSION >= 0x050600
3940
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
41+
#endif
4042
std::shared_ptr<int> b;
4143
QApplication a(argc, argv);
4244
a.setQuitOnLastWindowClosed(true);

src/DockContainerWidget.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,32 @@
4949

5050
#include <iostream>
5151

52+
#if QT_VERSION < 0x050900
53+
54+
inline char toHexLower(uint value)
55+
{
56+
return "0123456789abcdef"[value & 0xF];
57+
}
58+
59+
QByteArray qByteArrayToHex(const QByteArray& src, char separator)
60+
{
61+
if(src.size() == 0)
62+
return QByteArray();
63+
64+
const int length = separator ? (src.size() * 3 - 1) : (src.size() * 2);
65+
QByteArray hex(length, Qt::Uninitialized);
66+
char *hexData = hex.data();
67+
const uchar *data = (const uchar *)src.data();
68+
for (int i = 0, o = 0; i < src.size(); ++i) {
69+
hexData[o++] = toHexLower(data[i] >> 4);
70+
hexData[o++] = toHexLower(data[i] & 0xf);
71+
72+
if ((separator) && (o < length))
73+
hexData[o++] = separator;
74+
}
75+
return hex;
76+
}
77+
#endif
5278

5379
namespace ads
5480
{
@@ -1226,7 +1252,11 @@ void CDockContainerWidget::saveState(QXmlStreamWriter& s) const
12261252
{
12271253
CFloatingDockContainer* FloatingWidget = floatingWidget();
12281254
QByteArray Geometry = FloatingWidget->saveGeometry();
1255+
#if QT_VERSION < 0x050900
1256+
s.writeTextElement("Geometry", qByteArrayToHex(Geometry, ' '));
1257+
#else
12291258
s.writeTextElement("Geometry", Geometry.toHex(' '));
1259+
#endif
12301260
}
12311261
d->saveChildNodesState(s, d->RootSplitter);
12321262
s.writeEndElement();

src/DockOverlay.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ struct DockOverlayCrossPrivate
168168
QColor borderColor = iconColor(CDockOverlayCross::FrameColor);
169169
QColor backgroundColor = iconColor(CDockOverlayCross::WindowBackgroundColor);
170170

171+
#if QT_VERSION >= 0x050600
171172
double DevicePixelRatio = _this->window()->devicePixelRatioF();
173+
#else
174+
double DevicePixelRatio = _this->window()->devicePixelRatio();
175+
#endif
172176
QSizeF PixmapSize = size * DevicePixelRatio;
173177
QPixmap pm(PixmapSize.toSize());
174178
pm.fill(QColor(0, 0, 0, 0));
@@ -577,8 +581,11 @@ void CDockOverlayCross::setupOverlayCross(CDockOverlay::eMode Mode)
577581
areaWidgets.insert(BottomDockWidgetArea, d->createDropIndicatorWidget(BottomDockWidgetArea, Mode));
578582
areaWidgets.insert(LeftDockWidgetArea, d->createDropIndicatorWidget(LeftDockWidgetArea, Mode));
579583
areaWidgets.insert(CenterDockWidgetArea, d->createDropIndicatorWidget(CenterDockWidgetArea, Mode));
584+
#if QT_VERSION >= 0x050600
580585
d->LastDevicePixelRatio = devicePixelRatioF();
581-
586+
#else
587+
d->LastDevicePixelRatio = devicePixelRatio();
588+
#endif
582589
setAreaWidgets(areaWidgets);
583590
d->UpdateRequired = false;
584591
}
@@ -596,7 +603,11 @@ void CDockOverlayCross::updateOverlayIcons()
596603
{
597604
d->updateDropIndicatorIcon(Widget);
598605
}
606+
#if QT_VESION >= 0x050600
599607
d->LastDevicePixelRatio = devicePixelRatioF();
608+
#else
609+
d->LastDevicePixelRatio = devicePixelRatio();
610+
#endif
600611
}
601612

602613

src/DockWidget.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
214214
setObjectName(title);
215215

216216
d->TabWidget = new CDockWidgetTab(this);
217-
d->ToggleViewAction = new QAction(title);
217+
d->ToggleViewAction = new QAction(title, nullptr);
218218
d->ToggleViewAction->setCheckable(true);
219219
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
220220
SLOT(toggleView(bool)));
@@ -282,7 +282,18 @@ void CDockWidget::setFeatures(DockWidgetFeatures features)
282282
//============================================================================
283283
void CDockWidget::setFeature(DockWidgetFeature flag, bool on)
284284
{
285+
#if QT_VERSION >= 0x050700
285286
d->Features.setFlag(flag, on);
287+
#else
288+
if(on)
289+
{
290+
d->Features |= flag;
291+
}
292+
else
293+
{
294+
d->Features &= ~flag;
295+
}
296+
#endif
286297
}
287298

288299

src/src.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ windows {
2828
}
2929
}
3030

31+
unix {
32+
CONFIG += c++11
33+
}
34+
3135
RESOURCES += ads.qrc
3236

3337
HEADERS += \

0 commit comments

Comments
 (0)