forked from github_mirror/framelesshelper
Fix build on Qt versions below 5.14
QStringView introduced in Qt 5.10.0 qExchange() introduced in Qt 5.14.0 qSwap() is deprecated, use std::swap() instead Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
e85e3f891e
commit
485d9665ea
|
@ -10,7 +10,7 @@ RESOURCES += $$PWD/images.qrc
|
|||
win32 {
|
||||
CONFIG += windeployqt
|
||||
CONFIG -= embed_manifest_exe
|
||||
LIBS += -luser32 -lshell32
|
||||
LIBS += -luser32 -lshell32 -ladvapi32
|
||||
RC_FILE = $$PWD/example.rc
|
||||
OTHER_FILES += $$PWD/example.manifest
|
||||
}
|
||||
|
|
|
@ -54,8 +54,14 @@
|
|||
#define qAsConst(i) std::as_const(i)
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_WINDOWS) || defined(FRAMELESSHELPER_TEST_UNIX)
|
||||
#define FRAMELESSHELPER_USE_UNIX_VERSION
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
|
||||
#define QStringView const QString &
|
||||
#else
|
||||
#include <QtCore/qstringview.h>
|
||||
#endif
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
||||
#define qExchange(a, b) std::exchange(a, b)
|
||||
#endif
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
|
@ -64,6 +70,10 @@
|
|||
#define Q_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_WINDOWS) || defined(FRAMELESSHELPER_TEST_UNIX)
|
||||
#define FRAMELESSHELPER_USE_UNIX_VERSION
|
||||
#endif
|
||||
|
||||
#ifndef FRAMELESSHELPER_NAMESPACE
|
||||
#define FRAMELESSHELPER_NAMESPACE __flh_ns
|
||||
#endif
|
||||
|
|
2
lib.pro
2
lib.pro
|
@ -34,7 +34,7 @@ win32 {
|
|||
utilities_win32.cpp \
|
||||
framelesshelper_win32.cpp \
|
||||
qwinregistry.cpp
|
||||
LIBS += -luser32 -lshell32
|
||||
LIBS += -luser32 -lshell32 -ladvapi32
|
||||
RC_FILE = framelesshelper.rc
|
||||
}
|
||||
linux*: SOURCES += utilities_linux.cpp
|
||||
|
|
|
@ -50,13 +50,12 @@
|
|||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include "framelesshelper_global.h"
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
#include <QtCore/private/qwinregistry_p.h>
|
||||
#else // QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
#include <QtCore/qpair.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qstringview.h>
|
||||
#include <QtCore/qt_windows.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -72,9 +71,13 @@ public:
|
|||
~QWinRegistryKey();
|
||||
|
||||
QWinRegistryKey(QWinRegistryKey &&other) noexcept
|
||||
: m_key(qExchange(other.m_key, nullptr)) {}
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QWinRegistryKey)
|
||||
void swap(QWinRegistryKey &other) noexcept { qSwap(m_key, other.m_key); }
|
||||
: m_key(std::exchange(other.m_key, nullptr)) {}
|
||||
QWinRegistryKey &operator=(QWinRegistryKey &&other) noexcept {
|
||||
QWinRegistryKey moved(std::move(other));
|
||||
swap(moved);
|
||||
return *this;
|
||||
}
|
||||
void swap(QWinRegistryKey &other) noexcept { std::swap(m_key, other.m_key); }
|
||||
|
||||
bool isValid() const { return m_key != nullptr; }
|
||||
operator HKEY() const { return m_key; }
|
||||
|
|
Loading…
Reference in New Issue