misc: general cleanup

This commit is contained in:
Zhao Yuhang 2023-10-21 10:44:07 +08:00
parent c7f48684ec
commit 78fc5057ab
45 changed files with 155 additions and 34 deletions

View File

@ -74,6 +74,7 @@ if(WIN32)
PATH "${__manifest_path}"
ID "org.wangwenx190.demo.Dialog"
VERSION "${PROJECT_VERSION}"
DESCRIPTION "FramelessHelper Demo Application: Dialog"
VISTA_COMPAT
WIN7_COMPAT
WIN8_COMPAT
@ -103,6 +104,31 @@ setup_gui_app(
BUNDLE_VERSION_SHORT "1.0"
)
setup_target_rpaths(TARGETS ${DEMO_NAME})
setup_qt_stuff(TARGETS ${DEMO_NAME})
set(__extra_flags "")
if(NOT FRAMELESSHELPER_NO_PERMISSIVE_CHECKS)
list(APPEND __extra_flags PERMISSIVE)
endif()
if(FRAMELESSHELPER_ENABLE_SPECTRE)
list(APPEND __extra_flags SPECTRE)
endif()
if(FRAMELESSHELPER_ENABLE_EHCONTGUARD)
list(APPEND __extra_flags EHCONTGUARD)
endif()
if(FRAMELESSHELPER_ENABLE_INTELCET)
list(APPEND __extra_flags INTELCET)
endif()
if(FRAMELESSHELPER_ENABLE_CFGUARD)
list(APPEND __extra_flags CFGUARD)
endif()
if(FRAMELESSHELPER_FORCE_LTO)
list(APPEND __extra_flags FORCE_LTO)
endif()
setup_compile_params(TARGETS ${DEMO_NAME} ${__extra_flags})
if(FRAMELESSHELPER_EXAMPLES_DEPLOYQT)
set(__extra_flags)
if(FRAMELESSHELPER_NO_INSTALL)

View File

@ -25,7 +25,7 @@ FRAMELESSHELPER_END_NAMESPACE
class Dialog : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessDialog)
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(Dialog)
Q_DISABLE_COPY(Dialog)
public:
explicit Dialog(QWidget *parent = nullptr);

View File

@ -79,6 +79,7 @@ if(WIN32)
PATH "${__manifest_path}"
ID "org.wangwenx190.demo.MainWindow"
VERSION "${PROJECT_VERSION}"
DESCRIPTION "FramelessHelper Demo Application: MainWindow"
VISTA_COMPAT
WIN7_COMPAT
WIN8_COMPAT
@ -108,6 +109,31 @@ setup_gui_app(
BUNDLE_VERSION_SHORT "1.0"
)
setup_target_rpaths(TARGETS ${DEMO_NAME})
setup_qt_stuff(TARGETS ${DEMO_NAME})
set(__extra_flags "")
if(NOT FRAMELESSHELPER_NO_PERMISSIVE_CHECKS)
list(APPEND __extra_flags PERMISSIVE)
endif()
if(FRAMELESSHELPER_ENABLE_SPECTRE)
list(APPEND __extra_flags SPECTRE)
endif()
if(FRAMELESSHELPER_ENABLE_EHCONTGUARD)
list(APPEND __extra_flags EHCONTGUARD)
endif()
if(FRAMELESSHELPER_ENABLE_INTELCET)
list(APPEND __extra_flags INTELCET)
endif()
if(FRAMELESSHELPER_ENABLE_CFGUARD)
list(APPEND __extra_flags CFGUARD)
endif()
if(FRAMELESSHELPER_FORCE_LTO)
list(APPEND __extra_flags FORCE_LTO)
endif()
setup_compile_params(TARGETS ${DEMO_NAME} ${__extra_flags})
if(FRAMELESSHELPER_EXAMPLES_DEPLOYQT)
set(__extra_flags)
if(FRAMELESSHELPER_NO_INSTALL)

View File

@ -42,7 +42,7 @@ class MainWindow;
class MainWindow : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessMainWindow)
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(MainWindow)
Q_DISABLE_COPY(MainWindow)
public:
explicit MainWindow(QWidget *parent = nullptr, const Qt::WindowFlags flags = {});

View File

@ -35,7 +35,7 @@ class GLWidget;
class MainWindow : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidget)
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(MainWindow)
Q_DISABLE_COPY(MainWindow)
public:
explicit MainWindow(QWidget *parent = nullptr);

View File

@ -74,6 +74,7 @@ if(WIN32)
PATH "${__manifest_path}"
ID "org.wangwenx190.demo.Quick"
VERSION "${PROJECT_VERSION}"
DESCRIPTION "FramelessHelper Demo Application: Quick"
VISTA_COMPAT
WIN7_COMPAT
WIN8_COMPAT
@ -135,6 +136,31 @@ setup_gui_app(
BUNDLE_VERSION_SHORT "1.0"
)
setup_target_rpaths(TARGETS ${DEMO_NAME})
setup_qt_stuff(TARGETS ${DEMO_NAME})
set(__extra_flags "")
if(NOT FRAMELESSHELPER_NO_PERMISSIVE_CHECKS)
list(APPEND __extra_flags PERMISSIVE)
endif()
if(FRAMELESSHELPER_ENABLE_SPECTRE)
list(APPEND __extra_flags SPECTRE)
endif()
if(FRAMELESSHELPER_ENABLE_EHCONTGUARD)
list(APPEND __extra_flags EHCONTGUARD)
endif()
if(FRAMELESSHELPER_ENABLE_INTELCET)
list(APPEND __extra_flags INTELCET)
endif()
if(FRAMELESSHELPER_ENABLE_CFGUARD)
list(APPEND __extra_flags CFGUARD)
endif()
if(FRAMELESSHELPER_FORCE_LTO)
list(APPEND __extra_flags FORCE_LTO)
endif()
setup_compile_params(TARGETS ${DEMO_NAME} ${__extra_flags})
if(FRAMELESSHELPER_EXAMPLES_DEPLOYQT)
set(__extra_flags)
if(FRAMELESSHELPER_NO_INSTALL)

View File

@ -36,7 +36,7 @@ class QuickSettings : public QObject
#ifdef QML_SINGLETON
QML_SINGLETON
#endif
Q_DISABLE_COPY_MOVE(QuickSettings)
Q_DISABLE_COPY(QuickSettings)
public:
explicit QuickSettings(QObject *parent = nullptr);

View File

@ -74,6 +74,7 @@ if(WIN32)
PATH "${__manifest_path}"
ID "org.wangwenx190.demo.Widget"
VERSION "${PROJECT_VERSION}"
DESCRIPTION "FramelessHelper Demo Application: Widget"
VISTA_COMPAT
WIN7_COMPAT
WIN8_COMPAT
@ -103,6 +104,31 @@ setup_gui_app(
BUNDLE_VERSION_SHORT "1.0"
)
setup_target_rpaths(TARGETS ${DEMO_NAME})
setup_qt_stuff(TARGETS ${DEMO_NAME})
set(__extra_flags "")
if(NOT FRAMELESSHELPER_NO_PERMISSIVE_CHECKS)
list(APPEND __extra_flags PERMISSIVE)
endif()
if(FRAMELESSHELPER_ENABLE_SPECTRE)
list(APPEND __extra_flags SPECTRE)
endif()
if(FRAMELESSHELPER_ENABLE_EHCONTGUARD)
list(APPEND __extra_flags EHCONTGUARD)
endif()
if(FRAMELESSHELPER_ENABLE_INTELCET)
list(APPEND __extra_flags INTELCET)
endif()
if(FRAMELESSHELPER_ENABLE_CFGUARD)
list(APPEND __extra_flags CFGUARD)
endif()
if(FRAMELESSHELPER_FORCE_LTO)
list(APPEND __extra_flags FORCE_LTO)
endif()
setup_compile_params(TARGETS ${DEMO_NAME} ${__extra_flags})
if(FRAMELESSHELPER_EXAMPLES_DEPLOYQT)
set(__extra_flags)
if(FRAMELESSHELPER_NO_INSTALL)

View File

@ -42,7 +42,7 @@ FRAMELESSHELPER_END_NAMESPACE
class Widget : public FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidget)
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(Widget)
Q_DISABLE_COPY(Widget)
public:
explicit Widget(QWidget *parent = nullptr);

View File

@ -25,6 +25,7 @@
#pragma once
#include <FramelessHelper/Core/framelesshelpercore_global.h>
#include <memory>
#if FRAMELESSHELPER_CONFIG(titlebar)

View File

@ -25,6 +25,7 @@
#pragma once
#include <FramelessHelper/Core/framelesshelpercore_global.h>
#include <memory>
#if !FRAMELESSHELPER_CONFIG(native_impl)

View File

@ -268,7 +268,7 @@ QT_END_NAMESPACE
# define FRAMELESSHELPER_CLASS_DPTR(Class) \
private: \
Q_DECLARE_PRIVATE(Class) \
const QScopedPointer<Class##Private> d_ptr;
const std::unique_ptr<Class##Private> d_ptr;
#endif
#ifndef FRAMELESSHELPER_CLASS_QPTR

View File

@ -25,6 +25,7 @@
#pragma once
#include <FramelessHelper/Core/framelesshelpercore_global.h>
#include <memory>
FRAMELESSHELPER_BEGIN_NAMESPACE

View File

@ -25,6 +25,7 @@
#pragma once
#include <FramelessHelper/Core/framelesshelpercore_global.h>
#include <memory>
#if FRAMELESSHELPER_CONFIG(mica_material)

View File

@ -27,6 +27,7 @@
#include <FramelessHelper/Core/framelesshelpercore_global.h>
#include <QtCore/qvariant.h>
#include <optional>
#include <memory>
#ifdef Q_OS_WINDOWS
@ -86,9 +87,9 @@ private:
Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser;
QString m_subKey = {};
#if REGISTRYKEY_QWINREGISTRYKEY
QScopedPointer<QWinRegistryKey> m_registryKey;
std::unique_ptr<QWinRegistryKey> m_registryKey;
#else
QScopedPointer<QSettings> m_settings;
std::unique_ptr<QSettings> m_settings;
#endif
};

View File

@ -25,6 +25,7 @@
#pragma once
#include <FramelessHelper/Core/framelesshelpercore_global.h>
#include <memory>
#if FRAMELESSHELPER_CONFIG(border_painter)

View File

@ -27,6 +27,7 @@
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickwindow.h>
#include <memory>
FRAMELESSHELPER_BEGIN_NAMESPACE

View File

@ -25,6 +25,7 @@
#pragma once
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
#include <memory>
#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)))

View File

@ -25,6 +25,7 @@
#pragma once
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
#include <memory>
#if (FRAMELESSHELPER_CONFIG(private_qt) && FRAMELESSHELPER_CONFIG(window))

View File

@ -26,6 +26,7 @@
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
#include <QtQuick/qquickpainteditem.h>
#include <memory>
#if FRAMELESSHELPER_CONFIG(mica_material)

View File

@ -26,6 +26,7 @@
#include <FramelessHelper/Quick/framelesshelperquick_global.h>
#include <QtQuick/qquickpainteditem.h>
#include <memory>
#if FRAMELESSHELPER_CONFIG(border_painter)

View File

@ -26,6 +26,7 @@
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
#include <QtWidgets/qdialog.h>
#include <memory>
#if FRAMELESSHELPER_CONFIG(window)

View File

@ -26,6 +26,7 @@
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
#include <QtWidgets/qmainwindow.h>
#include <memory>
#if FRAMELESSHELPER_CONFIG(window)

View File

@ -26,6 +26,7 @@
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
#include <QtWidgets/qwidget.h>
#include <memory>
#if FRAMELESSHELPER_CONFIG(window)

View File

@ -26,6 +26,7 @@
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
#include <QtWidgets/qwidget.h>
#include <memory>
FRAMELESSHELPER_BEGIN_NAMESPACE

View File

@ -26,6 +26,7 @@
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
#include <QtWidgets/qpushbutton.h>
#include <memory>
#if FRAMELESSHELPER_CONFIG(system_button)

View File

@ -25,6 +25,7 @@
#pragma once
#include <FramelessHelper/Widgets/framelesshelperwidgets_global.h>
#include <memory>
#if FRAMELESSHELPER_CONFIG(titlebar)

View File

@ -133,7 +133,7 @@ void ChromePalettePrivate::refresh()
}
ChromePalette::ChromePalette(QObject *parent) :
QObject(parent), d_ptr(new ChromePalettePrivate(this))
QObject(parent), d_ptr(std::make_unique<ChromePalettePrivate>(this))
{
}

View File

@ -103,7 +103,7 @@ FramelessHelperQtPrivate::FramelessHelperQtPrivate(FramelessHelperQt *q) : q_ptr
FramelessHelperQtPrivate::~FramelessHelperQtPrivate() = default;
FramelessHelperQt::FramelessHelperQt(QObject *parent) : QObject(parent), d_ptr(new FramelessHelperQtPrivate(this))
FramelessHelperQt::FramelessHelperQt(QObject *parent) : QObject(parent), d_ptr(std::make_unique<FramelessHelperQtPrivate>(this))
{
}

View File

@ -428,7 +428,7 @@ void FramelessManagerPrivate::initialize()
}
FramelessManager::FramelessManager(QObject *parent) :
QObject(parent), d_ptr(new FramelessManagerPrivate(this))
QObject(parent), d_ptr(std::make_unique<FramelessManagerPrivate>(this))
{
}

View File

@ -830,7 +830,7 @@ QRect MicaMaterialPrivate::mapToWallpaper(const QRect &rect) const
}
MicaMaterial::MicaMaterial(QObject *parent)
: QObject(parent), d_ptr(new MicaMaterialPrivate(this))
: QObject(parent), d_ptr(std::make_unique<MicaMaterialPrivate>(this))
{
}

View File

@ -66,7 +66,7 @@ static constexpr const std::array<ULONG_PTR, 10> g_registryKeyMap =
0x80000060 // HKEY_PERFORMANCE_NLSTEXT
};
static constexpr const auto registryKeyCount = std::size(g_registryKeyMap);
static_assert(registryKeyCount == (static_cast<int>(RegistryRootKey::PerformanceNlsText) + 1));
static_assert(registryKeyCount == (static_cast<quint8>(RegistryRootKey::PerformanceNlsText) + 1));
[[maybe_unused]] static Q_STRING_CONSTEXPR const std::array<FRAMELESSHELPER_STRING_TYPE, registryKeyCount> g_registryStrMap =
{
@ -91,14 +91,14 @@ RegistryKey::RegistryKey(const RegistryRootKey root, const QString &key, QObject
m_rootKey = root;
m_subKey = key;
#if REGISTRYKEY_QWINREGISTRYKEY
m_registryKey.reset(new QWinRegistryKey(reinterpret_cast<HKEY>(g_registryKeyMap.at(static_cast<int>(m_rootKey))), m_subKey));
m_registryKey = std::make_unique<QWinRegistryKey>(reinterpret_cast<HKEY>(g_registryKeyMap.at(static_cast<quint8>(m_rootKey))), m_subKey);
if (!m_registryKey->isValid()) {
m_registryKey.reset();
}
#else
const QString rootKey = g_registryStrMap.at(static_cast<int>(m_rootKey));
const QString rootKey = g_registryStrMap.at(static_cast<quint8>(m_rootKey));
const auto lastSlashPos = m_subKey.lastIndexOf(u'\\');
m_settings.reset(new QSettings(rootKey + u'\\' + m_subKey.left(lastSlashPos), QSettings::NativeFormat));
m_settings = std::make_unique<QSettings>(rootKey + u'\\' + m_subKey.left(lastSlashPos), QSettings::NativeFormat);
if (m_settings->childGroups().contains(m_subKey.mid(lastSlashPos + 1))) {
m_settings.reset(new QSettings(rootKey + u'\\' + m_subKey, QSettings::NativeFormat));
} else {
@ -122,9 +122,9 @@ QString RegistryKey::subKey() const
bool RegistryKey::isValid() const
{
#if REGISTRYKEY_QWINREGISTRYKEY
return (!m_registryKey.isNull() && m_registryKey->isValid());
return (m_registryKey && m_registryKey->isValid());
#else
return !m_settings.isNull();
return m_settings;
#endif
}

View File

@ -530,13 +530,13 @@ WallpaperAspectStyle Utils::getWallpaperAspectStyle()
if (options.isEmpty()) {
return defaultAspectStyle;
} else {
if ((options == u"wallpaper"_s) || (options == u"tiled"_s)) {
if ((options == "wallpaper"_L1) || (options == "tiled"_L1)) {
return WallpaperAspectStyle::Tile;
} else if (options == u"centered"_s) {
} else if (options == "centered"_L1) {
return WallpaperAspectStyle::Center;
} else if (options == u"stretched"_s) {
} else if (options == "stretched"_L1) {
return WallpaperAspectStyle::Stretch;
} else if (options == u"scaled"_s) {
} else if (options == "scaled"_L1) {
return WallpaperAspectStyle::Fit;
} else {
return defaultAspectStyle;

View File

@ -84,7 +84,7 @@ const WindowBorderPainterPrivate *WindowBorderPainterPrivate::get(const WindowBo
}
WindowBorderPainter::WindowBorderPainter(QObject *parent)
: QObject(parent), d_ptr(new WindowBorderPainterPrivate(this))
: QObject(parent), d_ptr(std::make_unique<WindowBorderPainterPrivate>(this))
{
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &WindowBorderPainter::nativeBorderChanged);
connect(this, &WindowBorderPainter::nativeBorderChanged, this, &WindowBorderPainter::shouldRepaint);

View File

@ -84,7 +84,7 @@ const FramelessQuickApplicationWindowPrivate *FramelessQuickApplicationWindowPri
}
FramelessQuickApplicationWindow::FramelessQuickApplicationWindow(QWindow *parent)
: QQuickApplicationWindow(parent), d_ptr(new FramelessQuickApplicationWindowPrivate(this))
: QQuickApplicationWindow(parent), d_ptr(std::make_unique<FramelessQuickApplicationWindowPrivate>(this))
{
QQuickItem * const rootItem = contentItem();
FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar();

View File

@ -641,7 +641,7 @@ void FramelessQuickHelperPrivate::rebindWindow()
}
FramelessQuickHelper::FramelessQuickHelper(QQuickItem *parent)
: QQuickItem(parent), d_ptr(new FramelessQuickHelperPrivate(this))
: QQuickItem(parent), d_ptr(std::make_unique<FramelessQuickHelperPrivate>(this))
{
}

View File

@ -84,7 +84,7 @@ const FramelessQuickWindowPrivate *FramelessQuickWindowPrivate::get(const Framel
}
FramelessQuickWindow::FramelessQuickWindow(QWindow *parent)
: QQuickWindowQmlImpl(parent), d_ptr(new FramelessQuickWindowPrivate(this))
: QQuickWindowQmlImpl(parent), d_ptr(std::make_unique<FramelessQuickWindowPrivate>(this))
{
QQuickItem * const rootItem = contentItem();
FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar();

View File

@ -145,7 +145,7 @@ void QuickMicaMaterialPrivate::rebindWindow()
}
QuickMicaMaterial::QuickMicaMaterial(QQuickItem *parent)
: QQuickPaintedItem(parent), d_ptr(new QuickMicaMaterialPrivate(this))
: QQuickPaintedItem(parent), d_ptr(std::make_unique<QuickMicaMaterialPrivate>(this))
{
}

View File

@ -180,7 +180,7 @@ void QuickWindowBorderPrivate::rebindWindow()
}
QuickWindowBorder::QuickWindowBorder(QQuickItem *parent)
: QQuickPaintedItem(parent), d_ptr(new QuickWindowBorderPrivate(this))
: QQuickPaintedItem(parent), d_ptr(std::make_unique<QuickWindowBorderPrivate>(this))
{
}

View File

@ -78,7 +78,7 @@ const FramelessDialogPrivate *FramelessDialogPrivate::get(const FramelessDialog
}
FramelessDialog::FramelessDialog(QWidget *parent)
: QDialog(parent), d_ptr(new FramelessDialogPrivate(this))
: QDialog(parent), d_ptr(std::make_unique<FramelessDialogPrivate>(this))
{
FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar();
Q_D(FramelessDialog);

View File

@ -79,7 +79,7 @@ const FramelessMainWindowPrivate *FramelessMainWindowPrivate::get(const Frameles
}
FramelessMainWindow::FramelessMainWindow(QWidget *parent, const Qt::WindowFlags flags)
: QMainWindow(parent, flags), d_ptr(new FramelessMainWindowPrivate(this))
: QMainWindow(parent, flags), d_ptr(std::make_unique<FramelessMainWindowPrivate>(this))
{
FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar();
Q_D(FramelessMainWindow);

View File

@ -79,7 +79,7 @@ const FramelessWidgetPrivate *FramelessWidgetPrivate::get(const FramelessWidget
}
FramelessWidget::FramelessWidget(QWidget *parent)
: QWidget(parent, Qt::Window), d_ptr(new FramelessWidgetPrivate(this))
: QWidget(parent, Qt::Window), d_ptr(std::make_unique<FramelessWidgetPrivate>(this))
{
FramelessWidgetsHelper::get(this)->extendsContentIntoTitleBar();
Q_D(FramelessWidget);

View File

@ -779,7 +779,7 @@ void FramelessWidgetsHelper::setSystemButton(QWidget *widget, const SystemButton
}
FramelessWidgetsHelper::FramelessWidgetsHelper(QObject *parent)
: QObject(parent), d_ptr(new FramelessWidgetsHelperPrivate(this))
: QObject(parent), d_ptr(std::make_unique<FramelessWidgetsHelperPrivate>(this))
{
}

View File

@ -86,7 +86,7 @@ QSize StandardSystemButtonPrivate::getRecommendedButtonSize()
}
StandardSystemButton::StandardSystemButton(QWidget *parent)
: QPushButton(parent), d_ptr(new StandardSystemButtonPrivate(this))
: QPushButton(parent), d_ptr(std::make_unique<StandardSystemButtonPrivate>(this))
{
FramelessManagerPrivate::initializeIconFont();
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

View File

@ -449,7 +449,7 @@ void StandardTitleBarPrivate::initialize()
}
StandardTitleBar::StandardTitleBar(QWidget *parent)
: QWidget(parent), d_ptr(new StandardTitleBarPrivate(this))
: QWidget(parent), d_ptr(std::make_unique<StandardTitleBarPrivate>(this))
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setFixedHeight(kDefaultTitleBarHeight);