diff --git a/CMakeLists.txt b/CMakeLists.txt index 08824db..661e795 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,7 @@ set(GTA5VIEW_SOURCES set(GTA5VIEW_HEADERS config.h + wrapper.h AboutDialog.h AppEnv.h CrewDatabase.h diff --git a/MapLocationDialog.cpp b/MapLocationDialog.cpp index 34ed1bb..7351234 100644 --- a/MapLocationDialog.cpp +++ b/MapLocationDialog.cpp @@ -240,8 +240,19 @@ void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev) void MapLocationDialog::wheelEvent(QWheelEvent *ev) { +#if QT_VERSION >= 0x050000 const QPoint numPixels = ev->pixelDelta(); const QPoint numDegrees = ev->angleDelta(); +#else + QPoint numDegrees; + if (ev->orientation() == Qt::Horizontal) { + numDegrees.setX(ev->delta()); + } + else { + numDegrees.setY(ev->delta()); + } +#endif +#if QT_VERSION >= 0x050000 if (!numPixels.isNull()) { if (numPixels.y() < 0 && zoomPercent != 100) { zoomPercent = zoomPercent - 10; @@ -251,8 +262,10 @@ void MapLocationDialog::wheelEvent(QWheelEvent *ev) zoomPercent = zoomPercent + 10; repaint(); } + return; } - else if (!numDegrees.isNull()) { +#endif + if (!numDegrees.isNull()) { if (numDegrees.y() < 0 && zoomPercent != 100) { zoomPercent = zoomPercent - 10; repaint(); diff --git a/ProfileLoader.cpp b/ProfileLoader.cpp index bc1edc1..4f2edcd 100644 --- a/ProfileLoader.cpp +++ b/ProfileLoader.cpp @@ -20,6 +20,7 @@ #include "SnapmaticPicture.h" #include "SavegameData.h" #include "CrewDatabase.h" +#include "wrapper.h" #include #include #include diff --git a/RagePhoto.cpp b/RagePhoto.cpp index a7f2c21..b4e5ff8 100644 --- a/RagePhoto.cpp +++ b/RagePhoto.cpp @@ -837,8 +837,7 @@ void RagePhoto::uInt32ToCharLE(quint32 x, char *y) const QByteArray RagePhoto::stringToUtf16LE(const QString &string) { #if QT_VERSION >= 0x060000 - QStringEncoder stringEncoder = QStringEncoder(QStringEncoder::Utf16LE); - return stringEncoder(string); + return QStringEncoder(QStringEncoder::Utf16LE)(string); #else return QTextCodec::codecForName("UTF-16LE")->fromUnicode(string); #endif @@ -847,8 +846,7 @@ const QByteArray RagePhoto::stringToUtf16LE(const QString &string) const QString RagePhoto::utf16LEToString(const QByteArray &data) { #if QT_VERSION >= 0x060000 - QStringDecoder stringDecoder = QStringDecoder(QStringDecoder::Utf16LE); - return stringDecoder(data); + return QStringDecoder(QStringDecoder::Utf16LE)(data); #else return QTextCodec::codecForName("UTF-16LE")->toUnicode(data); #endif @@ -857,8 +855,7 @@ const QString RagePhoto::utf16LEToString(const QByteArray &data) const QString RagePhoto::utf16LEToString(const char *data, int size) { #if QT_VERSION >= 0x060000 - QStringDecoder stringDecoder = QStringDecoder(QStringDecoder::Utf16LE); - return stringDecoder(QByteArray::fromRawData(data, size)); + return QStringDecoder(QStringDecoder::Utf16LE)(QByteArray::fromRawData(data, size)); #else return QTextCodec::codecForName("UTF-16LE")->toUnicode(data, size); #endif diff --git a/SnapmaticEditor.cpp b/SnapmaticEditor.cpp index 10414c5..f07346e 100644 --- a/SnapmaticEditor.cpp +++ b/SnapmaticEditor.cpp @@ -21,6 +21,7 @@ #include "SnapmaticPicture.h" #include "PlayerListDialog.h" #include "StringParser.h" +#include "wrapper.h" #include "AppEnv.h" #include "config.h" #include @@ -405,7 +406,7 @@ void SnapmaticEditor::on_labCrew_linkActivated(const QString &link) newCrew = newCrew.split(" ").at(0); if (newCrew.length() > 10) return; - for (const QChar &crewChar : newCrew) { + for (const QChar &crewChar : qAsConst(newCrew)) { if (!crewChar.isNumber()) { return; } diff --git a/gta5view.pro b/gta5view.pro index 679cb3d..a9c9f91 100644 --- a/gta5view.pro +++ b/gta5view.pro @@ -25,7 +25,8 @@ DEPLOYMENT.display_name = gta5view TARGET = gta5view TEMPLATE = app -HEADERS += config.h +HEADERS += config.h \ + wrapper.h PRECOMPILED_HEADER += config.h SOURCES += main.cpp \ diff --git a/wrapper.h b/wrapper.h new file mode 100644 index 0000000..9ea0443 --- /dev/null +++ b/wrapper.h @@ -0,0 +1,30 @@ +/***************************************************************************** +* gta5view Grand Theft Auto V Profile Viewer +* Copyright (C) 2021 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef WRAPPER_H +#define WRAPPER_H + +#if QT_VERSION < 0x050700 +#if __cplusplus > 201703L +#define qAsConst(x) std::as_const(x) +#else +#define qAsConst +#endif +#endif + +#endif // WRAPPER_H