diff --git a/examples/dialog/main.cpp b/examples/dialog/main.cpp index 3dfea6c..1d38f11 100644 --- a/examples/dialog/main.cpp +++ b/examples/dialog/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) // of any Q(Core|Gui)Application instances. FramelessHelper::Widgets::initialize(); - const QScopedPointer application(new QApplication(argc, argv)); + const auto application = std::make_unique(argc, argv); // Must be called after QGuiApplication has been constructed, we are using // some private functions from QPA which won't be available until there's @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); - const QScopedPointer dialog(new Dialog); + const auto dialog = std::make_unique(); dialog->show(); const int exec = QCoreApplication::exec(); diff --git a/examples/mainwindow/main.cpp b/examples/mainwindow/main.cpp index 66dafe7..0cb4162 100644 --- a/examples/mainwindow/main.cpp +++ b/examples/mainwindow/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) // of any Q(Core|Gui)Application instances. FramelessHelper::Widgets::initialize(); - const QScopedPointer application(new QApplication(argc, argv)); + const auto application = std::make_unique(argc, argv); // Must be called after QGuiApplication has been constructed, we are using // some private functions from QPA which won't be available until there's @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); - const QScopedPointer mainWindow(new MainWindow); + const auto mainWindow = std::make_unique(); mainWindow->show(); const int exec = QCoreApplication::exec(); diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp index 92235b0..2c263f6 100644 --- a/examples/mainwindow/mainwindow.cpp +++ b/examples/mainwindow/mainwindow.cpp @@ -55,9 +55,9 @@ void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::initialize() { - m_titleBar.reset(new StandardTitleBar(this)); + m_titleBar = new StandardTitleBar(this); m_titleBar->setTitleLabelAlignment(Qt::AlignCenter); - m_mainWindow.reset(new Ui::MainWindow); + m_mainWindow = new Ui::MainWindow; m_mainWindow->setupUi(this); QMenuBar * const mb = menuBar(); @@ -83,10 +83,10 @@ QMenuBar::item:pressed { titleBarLayout->insertWidget(0, mb); // setMenuWidget(): make the menu widget become the first row of the window. - setMenuWidget(m_titleBar.data()); + setMenuWidget(m_titleBar); FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this); - helper->setTitleBarWidget(m_titleBar.data()); + helper->setTitleBarWidget(m_titleBar); helper->setSystemButton(m_titleBar->minimizeButton(), SystemButtonType::Minimize); helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize); helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close); diff --git a/examples/mainwindow/mainwindow.h b/examples/mainwindow/mainwindow.h index 490cf91..55b737f 100644 --- a/examples/mainwindow/mainwindow.h +++ b/examples/mainwindow/mainwindow.h @@ -51,6 +51,6 @@ private: void initialize(); private: - QScopedPointer m_titleBar; - QScopedPointer m_mainWindow; + FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr; + Ui::MainWindow *m_mainWindow = nullptr; }; diff --git a/examples/openglwidget/main.cpp b/examples/openglwidget/main.cpp index ff5ff61..72ded5c 100644 --- a/examples/openglwidget/main.cpp +++ b/examples/openglwidget/main.cpp @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) // of any Q(Core|Gui)Application instances. FramelessHelper::Widgets::initialize(); - const QScopedPointer application(new QApplication(argc, argv)); + const auto application = std::make_unique(argc, argv); // Must be called after QGuiApplication has been constructed, we are using // some private functions from QPA which won't be available until there's @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) QSurfaceFormat::setDefaultFormat(fmt); - const QScopedPointer mainWindow(new MainWindow); + const auto mainWindow = std::make_unique(); mainWindow->show(); const int exec = QCoreApplication::exec(); diff --git a/examples/quick/main.cpp b/examples/quick/main.cpp index bf668f5..4d8ce64 100644 --- a/examples/quick/main.cpp +++ b/examples/quick/main.cpp @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) // of any Q(Core|Gui)Application instances. FramelessHelper::Quick::initialize(); - const QScopedPointer application(new QGuiApplication(argc, argv)); + const auto application = std::make_unique(argc, argv); // Must be called after QGuiApplication has been constructed, we are using // some private functions from QPA which won't be available until there's @@ -82,14 +82,14 @@ int main(int argc, char *argv[]) #endif } - const QScopedPointer engine(new QQmlApplicationEngine); + const auto engine = std::make_unique(); #if (!QMLTC_ENABLED && !defined(QUICK_USE_QMAKE)) engine->addImportPath(FRAMELESSHELPER_STRING_LITERAL("../imports")); #endif #if (((QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) || defined(QUICK_USE_QMAKE)) && !QMLTC_ENABLED) // Don't forget to register our own custom QML types! - FramelessHelper::Quick::registerTypes(engine.data()); + FramelessHelper::Quick::registerTypes(engine.get()); qmlRegisterSingletonType("Demo", 1, 0, "Settings", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { @@ -116,14 +116,14 @@ int main(int argc, char *argv[]) #endif #if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) - QObject::connect(engine.data(), &QQmlApplicationEngine::objectCreationFailed, qApp, + QObject::connect(engine.get(), &QQmlApplicationEngine::objectCreationFailed, qApp, [](const QUrl &url){ qCritical() << "The QML engine failed to create component:" << url; QCoreApplication::exit(-1); }, Qt::QueuedConnection); #elif !QMLTC_ENABLED const QMetaObject::Connection connection = QObject::connect( - engine.data(), &QQmlApplicationEngine::objectCreated, &application, + engine.get(), &QQmlApplicationEngine::objectCreated, &application, [&mainUrl, &connection](QObject *object, const QUrl &url) { if (url != mainUrl) { return; @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) #endif #if QMLTC_ENABLED - QScopedPointer homePage(new HomePage(engine.data())); + const auto homePage = std::make_unique(engine.get()); homePage->show(); #endif diff --git a/examples/shared/log.cpp b/examples/shared/log.cpp index a0b6cec..aab4f78 100644 --- a/examples/shared/log.cpp +++ b/examples/shared/log.cpp @@ -40,8 +40,8 @@ static QString g_app = {}; static bool g_logError = false; -static QScopedPointer g_logFile; -static QScopedPointer g_logStream; +static std::unique_ptr g_logFile = nullptr; +static std::unique_ptr g_logStream = nullptr; static inline void myMessageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message) { @@ -57,19 +57,19 @@ static inline void myMessageHandler(const QtMsgType type, const QMessageLogConte if (g_logError) { return; } - if (g_logFile.isNull()) { - g_logFile.reset(new QFile); + if (!g_logFile) { + g_logFile = std::make_unique(); g_logFile->setFileName(FRAMELESSHELPER_STRING_LITERAL("debug-%1.log").arg(g_app)); if (!g_logFile->open(QFile::WriteOnly | QFile::Text | QFile::Append)) { std::cerr << "Can't open file to write: " << qUtf8Printable(g_logFile->errorString()) << std::endl; - g_logFile.reset(); + delete g_logFile.release(); g_logError = true; return; } } - if (g_logStream.isNull()) { - g_logStream.reset(new QTextStream); - g_logStream->setDevice(g_logFile.data()); + if (!g_logStream) { + g_logStream = std::make_unique(); + g_logStream->setDevice(g_logFile.get()); } (*g_logStream) << finalMessage << QT_ENDL; } diff --git a/examples/shared/settings.cpp b/examples/shared/settings.cpp index 1f65a04..a72b04e 100644 --- a/examples/shared/settings.cpp +++ b/examples/shared/settings.cpp @@ -28,7 +28,7 @@ #include #include -static QScopedPointer g_settings; +static std::unique_ptr g_settings = nullptr; [[nodiscard]] static inline QSettings *appConfigFile() { @@ -54,7 +54,7 @@ void Settings::set(const QString &id, const QString &key, const QByteArray &data if (key.isEmpty() || data.isEmpty()) { return; } - if (g_settings.isNull()) { + if (!g_settings) { g_settings.reset(appConfigFile()); } g_settings->setValue(appKey(id, key), data); @@ -66,7 +66,7 @@ QByteArray Settings::get(const QString &id, const QString &key) if (key.isEmpty()) { return {}; } - if (g_settings.isNull()) { + if (!g_settings) { g_settings.reset(appConfigFile()); } return g_settings->value(appKey(id, key)).toByteArray(); diff --git a/examples/widget/main.cpp b/examples/widget/main.cpp index adee115..834c274 100644 --- a/examples/widget/main.cpp +++ b/examples/widget/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) // of any Q(Core|Gui)Application instances. FramelessHelper::Widgets::initialize(); - const QScopedPointer application(new QApplication(argc, argv)); + const auto application = std::make_unique(argc, argv); // Must be called after QGuiApplication has been constructed, we are using // some private functions from QPA which won't be available until there's @@ -50,11 +50,11 @@ int main(int argc, char *argv[]) FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); - const QScopedPointer window1(new Widget); + const auto window1 = std::make_unique(); window1->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window1")); window1->show(); - const QScopedPointer window2(new Widget); + const auto window2 = std::make_unique(); window2->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window2")); window2->show(); diff --git a/examples/widget/widget.cpp b/examples/widget/widget.cpp index 9995b05..482c108 100644 --- a/examples/widget/widget.cpp +++ b/examples/widget/widget.cpp @@ -73,9 +73,9 @@ void Widget::initialize() setWindowTitle(tr("FramelessHelper demo application - Qt Widgets")); setWindowIcon(QFileIconProvider().icon(QFileIconProvider::Computer)); resize(800, 600); - m_titleBar.reset(new StandardTitleBar(this)); + m_titleBar = new StandardTitleBar(this); m_titleBar->setWindowIconVisible(true); - m_clockLabel.reset(new QLabel(this)); + m_clockLabel = new QLabel(this); m_clockLabel->setFrameShape(QFrame::NoFrame); QFont clockFont = font(); clockFont.setBold(true); @@ -85,19 +85,19 @@ void Widget::initialize() contentLayout->setContentsMargins(0, 0, 0, 0); contentLayout->setSpacing(0); contentLayout->addStretch(); - contentLayout->addWidget(m_clockLabel.data()); + contentLayout->addWidget(m_clockLabel); contentLayout->addStretch(); const auto mainLayout = new QVBoxLayout(this); mainLayout->setSpacing(0); mainLayout->setContentsMargins(0, 0, 0, 0); - mainLayout->addWidget(m_titleBar.data()); + mainLayout->addWidget(m_titleBar); mainLayout->addLayout(contentLayout); setLayout(mainLayout); updateStyleSheet(); - m_cancelShortcut.reset(new QShortcut(this)); + m_cancelShortcut = new QShortcut(this); m_cancelShortcut->setKey(FRAMELESSHELPER_STRING_LITERAL("ESC")); - connect(m_cancelShortcut.data(), &QShortcut::activated, this, [this](){ + connect(m_cancelShortcut, &QShortcut::activated, this, [this](){ if (isFullScreen()) { Q_EMIT m_fullScreenShortcut->activated(); } else { @@ -105,9 +105,9 @@ void Widget::initialize() } }); - m_fullScreenShortcut.reset(new QShortcut(this)); + m_fullScreenShortcut = new QShortcut(this); m_fullScreenShortcut->setKey(FRAMELESSHELPER_STRING_LITERAL("ALT+RETURN")); - connect(m_fullScreenShortcut.data(), &QShortcut::activated, this, [this](){ + connect(m_fullScreenShortcut, &QShortcut::activated, this, [this](){ if (isFullScreen()) { setWindowState(windowState() & ~Qt::WindowFullScreen); } else { @@ -116,7 +116,7 @@ void Widget::initialize() }); FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this); - helper->setTitleBarWidget(m_titleBar.data()); + helper->setTitleBarWidget(m_titleBar); helper->setSystemButton(m_titleBar->minimizeButton(), SystemButtonType::Minimize); helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize); helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close); diff --git a/examples/widget/widget.h b/examples/widget/widget.h index 721af5c..4942fcd 100644 --- a/examples/widget/widget.h +++ b/examples/widget/widget.h @@ -55,8 +55,8 @@ private Q_SLOTS: void updateStyleSheet(); private: - QScopedPointer m_clockLabel; - QScopedPointer m_titleBar; - QScopedPointer m_fullScreenShortcut; - QScopedPointer m_cancelShortcut; + QLabel *m_clockLabel = nullptr; + FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr; + QShortcut *m_fullScreenShortcut = nullptr; + QShortcut *m_cancelShortcut = nullptr; }; diff --git a/include/FramelessHelper/Core/chromepalette.h b/include/FramelessHelper/Core/chromepalette.h index 46a2cae..1121ce9 100644 --- a/include/FramelessHelper/Core/chromepalette.h +++ b/include/FramelessHelper/Core/chromepalette.h @@ -121,7 +121,7 @@ Q_SIGNALS: void chromeButtonColorChanged(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Core/framelessmanager.h b/include/FramelessHelper/Core/framelessmanager.h index 098cd74..e493fe6 100644 --- a/include/FramelessHelper/Core/framelessmanager.h +++ b/include/FramelessHelper/Core/framelessmanager.h @@ -62,7 +62,7 @@ Q_SIGNALS: void wallpaperChanged(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Core/micamaterial.h b/include/FramelessHelper/Core/micamaterial.h index 030763c..75d96d9 100644 --- a/include/FramelessHelper/Core/micamaterial.h +++ b/include/FramelessHelper/Core/micamaterial.h @@ -65,7 +65,7 @@ Q_SIGNALS: void shouldRedraw(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Core/private/chromepalette_p.h b/include/FramelessHelper/Core/private/chromepalette_p.h index de5640a..585014f 100644 --- a/include/FramelessHelper/Core/private/chromepalette_p.h +++ b/include/FramelessHelper/Core/private/chromepalette_p.h @@ -25,10 +25,11 @@ #pragma once #include "framelesshelpercore_global.h" -#include "chromepalette.h" FRAMELESSHELPER_BEGIN_NAMESPACE +class ChromePalette; + class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject { Q_OBJECT @@ -46,7 +47,7 @@ public Q_SLOTS: void refresh(); private: - QPointer q_ptr = nullptr; + ChromePalette *q_ptr = nullptr; // System-defined ones: QColor titleBarActiveBackgroundColor_sys = {}; QColor titleBarInactiveBackgroundColor_sys = {}; diff --git a/include/FramelessHelper/Core/private/framelessmanager_p.h b/include/FramelessHelper/Core/private/framelessmanager_p.h index 9f2e7eb..73ed72e 100644 --- a/include/FramelessHelper/Core/private/framelessmanager_p.h +++ b/include/FramelessHelper/Core/private/framelessmanager_p.h @@ -25,10 +25,11 @@ #pragma once #include "framelesshelpercore_global.h" -#include "framelessmanager.h" FRAMELESSHELPER_BEGIN_NAMESPACE +class FramelessManager; + class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject { Q_OBJECT @@ -62,7 +63,7 @@ private: void initialize(); private: - QPointer q_ptr = nullptr; + FramelessManager *q_ptr = nullptr; Global::SystemTheme m_systemTheme = Global::SystemTheme::Unknown; QColor m_accentColor = {}; #ifdef Q_OS_WINDOWS diff --git a/include/FramelessHelper/Core/private/micamaterial_p.h b/include/FramelessHelper/Core/private/micamaterial_p.h index 2c897db..2d7da94 100644 --- a/include/FramelessHelper/Core/private/micamaterial_p.h +++ b/include/FramelessHelper/Core/private/micamaterial_p.h @@ -25,11 +25,12 @@ #pragma once #include "framelesshelpercore_global.h" -#include "micamaterial.h" #include FRAMELESSHELPER_BEGIN_NAMESPACE +class MicaMaterial; + class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject { Q_OBJECT @@ -53,7 +54,7 @@ private: void prepareGraphicsResources(); private: - QPointer q_ptr = nullptr; + MicaMaterial *q_ptr = nullptr; QColor tintColor = {}; qreal tintOpacity = 0.0; qreal noiseOpacity = 0.0; diff --git a/include/FramelessHelper/Core/private/registrykey_p.h b/include/FramelessHelper/Core/private/registrykey_p.h index 72ade24..dd2a845 100644 --- a/include/FramelessHelper/Core/private/registrykey_p.h +++ b/include/FramelessHelper/Core/private/registrykey_p.h @@ -83,9 +83,9 @@ private: Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser; QString m_subKey = {}; #if REGISTRYKEY_QWINREGISTRYKEY - QScopedPointer m_registryKey; + std::unique_ptr m_registryKey = nullptr; #else - QScopedPointer m_settings; + std::unique_ptr m_settings = nullptr; #endif }; diff --git a/include/FramelessHelper/Core/private/windowborderpainter_p.h b/include/FramelessHelper/Core/private/windowborderpainter_p.h index 82861d0..05f8677 100644 --- a/include/FramelessHelper/Core/private/windowborderpainter_p.h +++ b/include/FramelessHelper/Core/private/windowborderpainter_p.h @@ -25,10 +25,11 @@ #pragma once #include "framelesshelpercore_global.h" -#include "windowborderpainter.h" FRAMELESSHELPER_BEGIN_NAMESPACE +class WindowBorderPainter; + class FRAMELESSHELPER_CORE_API WindowBorderPainterPrivate : public QObject { Q_OBJECT @@ -53,7 +54,7 @@ private: void initialize(); private: - QPointer q_ptr = nullptr; + WindowBorderPainter *q_ptr = nullptr; std::optional m_thickness = std::nullopt; std::optional m_edges = std::nullopt; std::optional m_activeColor = std::nullopt; diff --git a/include/FramelessHelper/Core/windowborderpainter.h b/include/FramelessHelper/Core/windowborderpainter.h index b9bb52c..f2cbb91 100644 --- a/include/FramelessHelper/Core/windowborderpainter.h +++ b/include/FramelessHelper/Core/windowborderpainter.h @@ -78,7 +78,7 @@ Q_SIGNALS: void shouldRepaint(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/framelessquickhelper.h b/include/FramelessHelper/Quick/framelessquickhelper.h index ce775da..719a475 100644 --- a/include/FramelessHelper/Quick/framelessquickhelper.h +++ b/include/FramelessHelper/Quick/framelessquickhelper.h @@ -101,7 +101,7 @@ Q_SIGNALS: void ready(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h b/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h index 8c52a27..91e2d6b 100644 --- a/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h +++ b/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h @@ -77,7 +77,7 @@ Q_SIGNALS: void fullScreenChanged(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h b/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h index 040dda4..dabba66 100644 --- a/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h +++ b/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h @@ -27,10 +27,11 @@ #ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE #include "framelesshelperquick_global.h" -#include "framelessquickapplicationwindow_p.h" +#include FRAMELESSHELPER_BEGIN_NAMESPACE +class FramelessQuickApplicationWindow; class QuickWindowBorder; class FRAMELESSHELPER_QUICK_API FramelessQuickApplicationWindowPrivate : public QObject @@ -62,8 +63,8 @@ private: void initialize(); private: - QPointer q_ptr = nullptr; - QScopedPointer m_windowBorder; + FramelessQuickApplicationWindow *q_ptr = nullptr; + QuickWindowBorder *m_windowBorder = nullptr; QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed; }; diff --git a/include/FramelessHelper/Quick/private/framelessquickhelper_p.h b/include/FramelessHelper/Quick/private/framelessquickhelper_p.h index fd2569e..cd43185 100644 --- a/include/FramelessHelper/Quick/private/framelessquickhelper_p.h +++ b/include/FramelessHelper/Quick/private/framelessquickhelper_p.h @@ -25,7 +25,6 @@ #pragma once #include "framelesshelperquick_global.h" -#include "framelessquickhelper.h" QT_BEGIN_NAMESPACE class QQuickItem; @@ -33,6 +32,9 @@ QT_END_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE +class FramelessQuickHelper; +class QuickMicaMaterial; +class QuickWindowBorder; struct QuickHelperData; class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject @@ -97,7 +99,7 @@ private: void rebindWindow(); private: - QPointer q_ptr = nullptr; + FramelessQuickHelper *q_ptr = nullptr; QColor m_savedWindowBackgroundColor = {}; bool m_blurBehindWindowEnabled = false; std::optional m_extendIntoTitleBar = std::nullopt; diff --git a/include/FramelessHelper/Quick/private/framelessquickwindow_p.h b/include/FramelessHelper/Quick/private/framelessquickwindow_p.h index 3643c22..726a448 100644 --- a/include/FramelessHelper/Quick/private/framelessquickwindow_p.h +++ b/include/FramelessHelper/Quick/private/framelessquickwindow_p.h @@ -77,7 +77,7 @@ Q_SIGNALS: void fullScreenChanged(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h b/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h index fa8604c..6360557 100644 --- a/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h +++ b/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h @@ -27,10 +27,11 @@ #ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE #include "framelesshelperquick_global.h" -#include "framelessquickwindow_p.h" +#include FRAMELESSHELPER_BEGIN_NAMESPACE +class FramelessQuickWindow; class QuickWindowBorder; class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject @@ -62,8 +63,8 @@ private: void initialize(); private: - QPointer q_ptr = nullptr; - QScopedPointer m_windowBorder; + FramelessQuickWindow *q_ptr = nullptr; + QuickWindowBorder *m_windowBorder = nullptr; QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed; }; diff --git a/include/FramelessHelper/Quick/private/quickimageitem_p.h b/include/FramelessHelper/Quick/private/quickimageitem_p.h index 3f51072..204349d 100644 --- a/include/FramelessHelper/Quick/private/quickimageitem_p.h +++ b/include/FramelessHelper/Quick/private/quickimageitem_p.h @@ -25,11 +25,12 @@ #pragma once #include "framelesshelperquick_global.h" -#include "quickimageitem.h" #include FRAMELESSHELPER_BEGIN_NAMESPACE +class QuickImageItem; + class FRAMELESSHELPER_QUICK_API QuickImageItemPrivate : public QObject { Q_OBJECT @@ -58,7 +59,7 @@ private: Q_NODISCARD QRect paintArea() const; private: - QPointer q_ptr = nullptr; + QuickImageItem *q_ptr = nullptr; QVariant m_source = {}; }; diff --git a/include/FramelessHelper/Quick/private/quickmicamaterial_p.h b/include/FramelessHelper/Quick/private/quickmicamaterial_p.h index b424765..c9ae021 100644 --- a/include/FramelessHelper/Quick/private/quickmicamaterial_p.h +++ b/include/FramelessHelper/Quick/private/quickmicamaterial_p.h @@ -25,10 +25,10 @@ #pragma once #include "framelesshelperquick_global.h" -#include "quickmicamaterial.h" FRAMELESSHELPER_BEGIN_NAMESPACE +class QuickMicaMaterial; class WallpaperImageNode; class FRAMELESSHELPER_QUICK_API QuickMicaMaterialPrivate : public QObject @@ -53,7 +53,7 @@ private: void initialize(); private: - QPointer q_ptr = nullptr; + QuickMicaMaterial *q_ptr = nullptr; QMetaObject::Connection m_rootWindowXChangedConnection = {}; QMetaObject::Connection m_rootWindowYChangedConnection = {}; QList> m_nodes = {}; diff --git a/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h b/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h index a487e38..8f2ca9b 100644 --- a/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h +++ b/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h @@ -96,8 +96,8 @@ Q_SIGNALS: void iconSizeChanged(); private: - QScopedPointer m_contentItem; - QScopedPointer m_backgroundItem; + QQuickText *m_contentItem = nullptr; + QQuickRectangle *m_backgroundItem = nullptr; QuickGlobal::SystemButtonType m_buttonType = QuickGlobal::SystemButtonType::Unknown; QString m_code = {}; QColor m_normalColor = {}; diff --git a/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h b/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h index eb30263..2716a04 100644 --- a/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h +++ b/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h @@ -124,18 +124,18 @@ private: private: Qt::Alignment m_labelAlignment = {}; - QScopedPointer m_windowIcon; - QScopedPointer m_windowTitleLabel; - QScopedPointer m_systemButtonsRow; - QScopedPointer m_minimizeButton; - QScopedPointer m_maximizeButton; - QScopedPointer m_closeButton; + QuickImageItem *m_windowIcon = nullptr; + QQuickLabel *m_windowTitleLabel = nullptr; + QQuickRow *m_systemButtonsRow = nullptr; + QuickStandardSystemButton *m_minimizeButton = nullptr; + QuickStandardSystemButton *m_maximizeButton = nullptr; + QuickStandardSystemButton *m_closeButton = nullptr; QMetaObject::Connection m_windowStateChangeConnection = {}; QMetaObject::Connection m_windowActiveChangeConnection = {}; QMetaObject::Connection m_windowTitleChangeConnection = {}; bool m_extended = false; bool m_hideWhenClose = false; - QScopedPointer m_chromePalette; + QuickChromePalette *m_chromePalette = nullptr; bool m_closeTriggered = false; }; diff --git a/include/FramelessHelper/Quick/private/quickwindowborder_p.h b/include/FramelessHelper/Quick/private/quickwindowborder_p.h index 8605ab8..f8d3375 100644 --- a/include/FramelessHelper/Quick/private/quickwindowborder_p.h +++ b/include/FramelessHelper/Quick/private/quickwindowborder_p.h @@ -25,10 +25,10 @@ #pragma once #include "framelesshelperquick_global.h" -#include "quickwindowborder.h" FRAMELESSHELPER_BEGIN_NAMESPACE +class QuickWindowBorder; class WindowBorderPainter; class FRAMELESSHELPER_QUICK_API QuickWindowBorderPrivate : public QObject @@ -54,8 +54,8 @@ private: void rebindWindow(); private: - QPointer q_ptr = nullptr; - QScopedPointer m_borderPainter; + QuickWindowBorder *q_ptr = nullptr; + WindowBorderPainter *m_borderPainter = nullptr; QMetaObject::Connection m_activeChangeConnection = {}; QMetaObject::Connection m_visibilityChangeConnection = {}; }; diff --git a/include/FramelessHelper/Quick/quickimageitem.h b/include/FramelessHelper/Quick/quickimageitem.h index 3dafbd1..e37ec1d 100644 --- a/include/FramelessHelper/Quick/quickimageitem.h +++ b/include/FramelessHelper/Quick/quickimageitem.h @@ -61,7 +61,7 @@ Q_SIGNALS: void sourceChanged(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/quickmicamaterial.h b/include/FramelessHelper/Quick/quickmicamaterial.h index 106bfea..ebc05f3 100644 --- a/include/FramelessHelper/Quick/quickmicamaterial.h +++ b/include/FramelessHelper/Quick/quickmicamaterial.h @@ -53,7 +53,7 @@ protected: void componentComplete() override; private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Quick/quickwindowborder.h b/include/FramelessHelper/Quick/quickwindowborder.h index db4335f..6441f04 100644 --- a/include/FramelessHelper/Quick/quickwindowborder.h +++ b/include/FramelessHelper/Quick/quickwindowborder.h @@ -87,7 +87,7 @@ Q_SIGNALS: void nativeBorderChanged(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/framelessdialog.h b/include/FramelessHelper/Widgets/framelessdialog.h index 04a18c3..aa48352 100644 --- a/include/FramelessHelper/Widgets/framelessdialog.h +++ b/include/FramelessHelper/Widgets/framelessdialog.h @@ -44,7 +44,7 @@ public: ~FramelessDialog() override; private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/framelessmainwindow.h b/include/FramelessHelper/Widgets/framelessmainwindow.h index b27a3b9..62a26f4 100644 --- a/include/FramelessHelper/Widgets/framelessmainwindow.h +++ b/include/FramelessHelper/Widgets/framelessmainwindow.h @@ -59,7 +59,7 @@ Q_SIGNALS: void zoomedChanged(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/framelesswidget.h b/include/FramelessHelper/Widgets/framelesswidget.h index c299e3d..fc800cf 100644 --- a/include/FramelessHelper/Widgets/framelesswidget.h +++ b/include/FramelessHelper/Widgets/framelesswidget.h @@ -59,7 +59,7 @@ Q_SIGNALS: void zoomedChanged(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/framelesswidgetshelper.h b/include/FramelessHelper/Widgets/framelesswidgetshelper.h index d5b1ddc..68e2c38 100644 --- a/include/FramelessHelper/Widgets/framelesswidgetshelper.h +++ b/include/FramelessHelper/Widgets/framelesswidgetshelper.h @@ -88,7 +88,7 @@ Q_SIGNALS: void ready(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/private/framelessdialog_p.h b/include/FramelessHelper/Widgets/private/framelessdialog_p.h index 494a8ff..bb9ec1d 100644 --- a/include/FramelessHelper/Widgets/private/framelessdialog_p.h +++ b/include/FramelessHelper/Widgets/private/framelessdialog_p.h @@ -25,10 +25,10 @@ #pragma once #include "framelesshelperwidgets_global.h" -#include "framelessdialog.h" FRAMELESSHELPER_BEGIN_NAMESPACE +class FramelessDialog; class WidgetsSharedHelper; class FRAMELESSHELPER_WIDGETS_API FramelessDialogPrivate : public QObject @@ -50,8 +50,8 @@ private: void initialize(); private: - QPointer q_ptr = nullptr; - QScopedPointer m_helper; + FramelessDialog *q_ptr = nullptr; + WidgetsSharedHelper *m_sharedHelper = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h b/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h index 670570f..95a45b0 100644 --- a/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h +++ b/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h @@ -25,10 +25,10 @@ #pragma once #include "framelesshelperwidgets_global.h" -#include "framelessmainwindow.h" FRAMELESSHELPER_BEGIN_NAMESPACE +class FramelessMainWindow; class WidgetsSharedHelper; class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject @@ -56,9 +56,9 @@ private: void initialize(); private: - QPointer q_ptr = nullptr; + FramelessMainWindow *q_ptr = nullptr; Qt::WindowState m_savedWindowState = Qt::WindowNoState; - QScopedPointer m_helper; + WidgetsSharedHelper *m_sharedHelper = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/private/framelesswidget_p.h b/include/FramelessHelper/Widgets/private/framelesswidget_p.h index 14bd9d6..a0babef 100644 --- a/include/FramelessHelper/Widgets/private/framelesswidget_p.h +++ b/include/FramelessHelper/Widgets/private/framelesswidget_p.h @@ -25,10 +25,10 @@ #pragma once #include "framelesshelperwidgets_global.h" -#include "framelesswidget.h" FRAMELESSHELPER_BEGIN_NAMESPACE +class FramelessWidget; class WidgetsSharedHelper; class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject @@ -56,9 +56,9 @@ private: void initialize(); private: - QPointer q_ptr = nullptr; + FramelessWidget *q_ptr = nullptr; Qt::WindowState m_savedWindowState = Qt::WindowNoState; - QScopedPointer m_helper; + WidgetsSharedHelper *m_sharedHelper = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h b/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h index ebd936e..2170784 100644 --- a/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h +++ b/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h @@ -25,12 +25,15 @@ #pragma once #include "framelesshelperwidgets_global.h" -#include "framelesswidgetshelper.h" +#include FRAMELESSHELPER_BEGIN_NAMESPACE +class FramelessWidgetsHelper; struct WidgetsHelperData; class WidgetsSharedHelper; +class MicaMaterial; +class WindowBorderPainter; class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject { @@ -94,7 +97,7 @@ private: Q_NODISCARD WidgetsHelperData *getWindowDataMutable() const; private: - QPointer q_ptr = nullptr; + FramelessWidgetsHelper *q_ptr = nullptr; QColor m_savedWindowBackgroundColor = {}; bool m_blurBehindWindowEnabled = false; QPointer m_window = nullptr; diff --git a/include/FramelessHelper/Widgets/private/standardsystembutton_p.h b/include/FramelessHelper/Widgets/private/standardsystembutton_p.h index 8880017..5868ec3 100644 --- a/include/FramelessHelper/Widgets/private/standardsystembutton_p.h +++ b/include/FramelessHelper/Widgets/private/standardsystembutton_p.h @@ -25,7 +25,6 @@ #pragma once #include "framelesshelperwidgets_global.h" -#include "standardsystembutton.h" QT_BEGIN_NAMESPACE class QEnterEvent; @@ -34,6 +33,8 @@ QT_END_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE +class StandardSystemButton; + class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject { Q_OBJECT @@ -83,7 +84,7 @@ private: void initialize(); private: - QPointer q_ptr = nullptr; + StandardSystemButton *q_ptr = nullptr; Global::SystemButtonType m_buttonType = Global::SystemButtonType::Unknown; QString m_code = {}; QColor m_hoverColor = {}; diff --git a/include/FramelessHelper/Widgets/private/standardtitlebar_p.h b/include/FramelessHelper/Widgets/private/standardtitlebar_p.h index c63ca05..d929ee2 100644 --- a/include/FramelessHelper/Widgets/private/standardtitlebar_p.h +++ b/include/FramelessHelper/Widgets/private/standardtitlebar_p.h @@ -25,7 +25,6 @@ #pragma once #include "framelesshelperwidgets_global.h" -#include "standardtitlebar.h" QT_BEGIN_NAMESPACE class QPaintEvent; @@ -33,6 +32,7 @@ QT_END_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE +class StandardTitleBar; class StandardSystemButton; class ChromePalette; @@ -93,15 +93,15 @@ private: void initialize(); private: - QPointer q_ptr = nullptr; - QScopedPointer m_minimizeButton; - QScopedPointer m_maximizeButton; - QScopedPointer m_closeButton; + StandardTitleBar *q_ptr = nullptr; + StandardSystemButton *m_minimizeButton = nullptr; + StandardSystemButton *m_maximizeButton = nullptr; + StandardSystemButton *m_closeButton = nullptr; QPointer m_window = nullptr; bool m_extended = false; Qt::Alignment m_labelAlignment = {}; bool m_hideWhenClose = false; - QScopedPointer m_chromePalette; + ChromePalette *m_chromePalette = nullptr; bool m_titleLabelVisible = true; std::optional m_windowIconSize = std::nullopt; bool m_windowIconVisible = false; diff --git a/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h b/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h index 8a8306b..d5c2b9a 100644 --- a/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h +++ b/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h @@ -79,11 +79,11 @@ private: QPointer m_screen = nullptr; #endif bool m_micaEnabled = false; - QScopedPointer m_micaMaterial; + MicaMaterial *m_micaMaterial = nullptr; QMetaObject::Connection m_micaRedrawConnection = {}; qreal m_screenDpr = 0.0; QMetaObject::Connection m_screenDpiChangeConnection = {}; - QScopedPointer m_borderPainter; + WindowBorderPainter *m_borderPainter = nullptr; QMetaObject::Connection m_borderRepaintConnection = {}; QMetaObject::Connection m_screenChangeConnection = {}; }; diff --git a/include/FramelessHelper/Widgets/standardsystembutton.h b/include/FramelessHelper/Widgets/standardsystembutton.h index bacd796..8330b23 100644 --- a/include/FramelessHelper/Widgets/standardsystembutton.h +++ b/include/FramelessHelper/Widgets/standardsystembutton.h @@ -100,7 +100,7 @@ Q_SIGNALS: void iconSize2Changed(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Widgets/standardtitlebar.h b/include/FramelessHelper/Widgets/standardtitlebar.h index 041ba9d..33876aa 100644 --- a/include/FramelessHelper/Widgets/standardtitlebar.h +++ b/include/FramelessHelper/Widgets/standardtitlebar.h @@ -98,7 +98,7 @@ Q_SIGNALS: void titleFontChanged(); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr = nullptr; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/src/core/chromepalette.cpp b/src/core/chromepalette.cpp index dffbe4d..56be7d0 100644 --- a/src/core/chromepalette.cpp +++ b/src/core/chromepalette.cpp @@ -138,7 +138,7 @@ void ChromePalettePrivate::refresh() } ChromePalette::ChromePalette(QObject *parent) : - QObject(parent), d_ptr(new ChromePalettePrivate(this)) + QObject(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/core/framelessconfig.cpp b/src/core/framelessconfig.cpp index 76bd94e..09e99bd 100644 --- a/src/core/framelessconfig.cpp +++ b/src/core/framelessconfig.cpp @@ -107,7 +107,7 @@ void FramelessConfig::reload(const bool force) if (g_data()->loaded && !force) { return; } - const QScopedPointer configFile([]() -> QSettings * { + const std::unique_ptr configFile([]() -> QSettings * { if (!QCoreApplication::instance()) { return nullptr; } @@ -118,7 +118,7 @@ void FramelessConfig::reload(const bool force) const bool envVar = (!g_data()->disableEnvVar && qEnvironmentVariableIsSet(OptionsTable[i].env.constData()) && (qEnvironmentVariableIntValue(OptionsTable[i].env.constData()) > 0)); - const bool cfgFile = (!g_data()->disableCfgFile && !configFile.isNull() + const bool cfgFile = (!g_data()->disableCfgFile && configFile && configFile->value(QUtf8String(OptionsTable[i].cfg), false).toBool()); g_data()->options[i] = (envVar || cfgFile); } diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index 606a4bc..5fa088e 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -101,7 +101,7 @@ struct Win32HelperData struct Win32Helper { QMutex mutex; - QScopedPointer nativeEventFilter; + std::unique_ptr nativeEventFilter = nullptr; QHash data = {}; QHash fallbackTitleBarToParentWindowMapping = {}; }; @@ -524,9 +524,9 @@ void FramelessHelperWin::addWindow(const SystemParameters ¶ms) data.params = params; data.dpi = {Utils::getWindowDpi(windowId, true), Utils::getWindowDpi(windowId, false)}; g_win32Helper()->data.insert(windowId, data); - if (g_win32Helper()->nativeEventFilter.isNull()) { - g_win32Helper()->nativeEventFilter.reset(new FramelessHelperWin); - qApp->installNativeEventFilter(g_win32Helper()->nativeEventFilter.data()); + if (!g_win32Helper()->nativeEventFilter) { + g_win32Helper()->nativeEventFilter = std::make_unique(); + qApp->installNativeEventFilter(g_win32Helper()->nativeEventFilter.get()); } g_win32Helper()->mutex.unlock(); DEBUG.noquote() << "The DPI of window" << hwnd2str(windowId) << "is" << data.dpi; @@ -586,9 +586,9 @@ void FramelessHelperWin::removeWindow(const WId windowId) } g_win32Helper()->data.remove(windowId); if (g_win32Helper()->data.isEmpty()) { - if (!g_win32Helper()->nativeEventFilter.isNull()) { - qApp->removeNativeEventFilter(g_win32Helper()->nativeEventFilter.data()); - g_win32Helper()->nativeEventFilter.reset(); + if (g_win32Helper()->nativeEventFilter) { + qApp->removeNativeEventFilter(g_win32Helper()->nativeEventFilter.get()); + delete g_win32Helper()->nativeEventFilter.release(); } } HWND hwnd = nullptr; diff --git a/src/core/framelessmanager.cpp b/src/core/framelessmanager.cpp index 63ff071..de517dc 100644 --- a/src/core/framelessmanager.cpp +++ b/src/core/framelessmanager.cpp @@ -22,6 +22,7 @@ * SOFTWARE. */ +#include "framelessmanager.h" #include "framelessmanager_p.h" #include #include @@ -370,7 +371,7 @@ void FramelessManagerPrivate::initialize() } FramelessManager::FramelessManager(QObject *parent) : - QObject(parent), d_ptr(new FramelessManagerPrivate(this)) + QObject(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/core/micamaterial.cpp b/src/core/micamaterial.cpp index f5b6cc8..a354748 100644 --- a/src/core/micamaterial.cpp +++ b/src/core/micamaterial.cpp @@ -664,7 +664,7 @@ void MicaMaterialPrivate::prepareGraphicsResources() } MicaMaterial::MicaMaterial(QObject *parent) - : QObject(parent), d_ptr(new MicaMaterialPrivate(this)) + : QObject(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/core/registrykey.cpp b/src/core/registrykey.cpp index 21cb472..6b9f8bc 100644 --- a/src/core/registrykey.cpp +++ b/src/core/registrykey.cpp @@ -85,18 +85,19 @@ RegistryKey::RegistryKey(const RegistryRootKey root, const QString &key, QObject m_rootKey = root; m_subKey = key; #if REGISTRYKEY_QWINREGISTRYKEY - m_registryKey.reset(new QWinRegistryKey(g_keyMap[static_cast(m_rootKey)], m_subKey)); + m_registryKey = std::make_unique(g_keyMap[static_cast(m_rootKey)], m_subKey); if (!m_registryKey->isValid()) { - m_registryKey.reset(); + delete m_registryKey.release(); } #else const QString rootKey = g_strMap[static_cast(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(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)); + delete m_settings.release(); + m_settings = std::make_unique(rootKey + u'\\' + m_subKey, QSettings::NativeFormat); } else { - m_settings.reset(); + delete m_settings.release(); } #endif } @@ -116,9 +117,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 } diff --git a/src/core/utils_mac.mm b/src/core/utils_mac.mm index 8179d0e..c28a1ed 100644 --- a/src/core/utils_mac.mm +++ b/src/core/utils_mac.mm @@ -135,7 +135,7 @@ public: } object = obj; keyPath = key; - callback.reset(new Callback(cb)); + callback = std::make_unique(cb); addObserver(options); } @@ -151,20 +151,20 @@ public: if (!object) { return; } - [object removeObserver:observer forKeyPath:keyPath context:callback.data()]; + [object removeObserver:observer forKeyPath:keyPath context:callback.get()]; object = nil; } private: void addObserver(const NSKeyValueObservingOptions options) { - [object addObserver:observer forKeyPath:keyPath options:options context:callback.data()]; + [object addObserver:observer forKeyPath:keyPath options:options context:callback.get()]; } private: NSObject *object = nil; NSString *keyPath = nil; - QScopedPointer callback; + std::unique_ptr callback = nil; static inline MyKeyValueObserver *observer = [[MyKeyValueObserver alloc] init]; }; @@ -186,16 +186,16 @@ public: static const bool isMojave = (QSysInfo::macVersion() > QSysInfo::MV_SIERRA); #endif if (isMojave) { - m_appearanceObserver.reset(new MacOSKeyValueObserver(NSApp, @"effectiveAppearance", [](){ + m_appearanceObserver = std::make_unique(NSApp, @"effectiveAppearance", [](){ QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED NSAppearance.currentAppearance = NSApp.effectiveAppearance; // FIXME: use latest API. QT_WARNING_POP MacOSThemeObserver::notifySystemThemeChange(); - })); + }); } - m_systemColorObserver.reset(new MacOSNotificationObserver(nil, NSSystemColorsDidChangeNotification, - [](){ MacOSThemeObserver::notifySystemThemeChange(); })); + m_systemColorObserver = std::make_unique(nil, NSSystemColorsDidChangeNotification, + [](){ MacOSThemeObserver::notifySystemThemeChange(); }); } ~MacOSThemeObserver() = default; @@ -211,8 +211,8 @@ public: } private: - QScopedPointer m_systemColorObserver; - QScopedPointer m_appearanceObserver; + std::unique_ptr m_systemColorObserver = nil; + std::unique_ptr m_appearanceObserver = nil; }; class NSWindowProxy : public QObject diff --git a/src/core/windowborderpainter.cpp b/src/core/windowborderpainter.cpp index 16e9a1d..f2256b6 100644 --- a/src/core/windowborderpainter.cpp +++ b/src/core/windowborderpainter.cpp @@ -174,7 +174,7 @@ void WindowBorderPainterPrivate::initialize() } WindowBorderPainter::WindowBorderPainter(QObject *parent) - : QObject(parent), d_ptr(new WindowBorderPainterPrivate(this)) + : QObject(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/quick/framelessquickapplicationwindow.cpp b/src/quick/framelessquickapplicationwindow.cpp index 3f276a8..cef3029 100644 --- a/src/quick/framelessquickapplicationwindow.cpp +++ b/src/quick/framelessquickapplicationwindow.cpp @@ -154,11 +154,11 @@ void FramelessQuickApplicationWindowPrivate::initialize() Q_Q(FramelessQuickApplicationWindow); QQuickItem * const rootItem = q->contentItem(); FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar(); - m_windowBorder.reset(new QuickWindowBorder); + m_windowBorder = new QuickWindowBorder; m_windowBorder->setParent(rootItem); m_windowBorder->setParentItem(rootItem); m_windowBorder->setZ(999); // Make sure it always stays on the top. - QQuickItemPrivate::get(m_windowBorder.data())->anchors()->setFill(rootItem); + QQuickItemPrivate::get(m_windowBorder)->anchors()->setFill(rootItem); connect(q, &FramelessQuickApplicationWindow::visibilityChanged, q, [q](){ Q_EMIT q->hiddenChanged(); Q_EMIT q->normalChanged(); @@ -170,7 +170,7 @@ void FramelessQuickApplicationWindowPrivate::initialize() } FramelessQuickApplicationWindow::FramelessQuickApplicationWindow(QWindow *parent) - : QQuickApplicationWindow(parent), d_ptr(new FramelessQuickApplicationWindowPrivate(this)) + : QQuickApplicationWindow(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/quick/framelessquickhelper.cpp b/src/quick/framelessquickhelper.cpp index 4faa40f..06a3ddc 100644 --- a/src/quick/framelessquickhelper.cpp +++ b/src/quick/framelessquickhelper.cpp @@ -957,7 +957,7 @@ void FramelessQuickHelperPrivate::rebindWindow() } FramelessQuickHelper::FramelessQuickHelper(QQuickItem *parent) - : QQuickItem(parent), d_ptr(new FramelessQuickHelperPrivate(this)) + : QQuickItem(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/quick/framelessquickwindow.cpp b/src/quick/framelessquickwindow.cpp index f5e8966..07b92e9 100644 --- a/src/quick/framelessquickwindow.cpp +++ b/src/quick/framelessquickwindow.cpp @@ -154,11 +154,11 @@ void FramelessQuickWindowPrivate::initialize() Q_Q(FramelessQuickWindow); QQuickItem * const rootItem = q->contentItem(); FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar(); - m_windowBorder.reset(new QuickWindowBorder); + m_windowBorder = new QuickWindowBorder; m_windowBorder->setParent(rootItem); m_windowBorder->setParentItem(rootItem); m_windowBorder->setZ(999); // Make sure it always stays on the top. - QQuickItemPrivate::get(m_windowBorder.data())->anchors()->setFill(rootItem); + QQuickItemPrivate::get(m_windowBorder)->anchors()->setFill(rootItem); connect(q, &FramelessQuickWindow::visibilityChanged, q, [q](){ Q_EMIT q->hiddenChanged(); Q_EMIT q->normalChanged(); @@ -170,7 +170,7 @@ void FramelessQuickWindowPrivate::initialize() } FramelessQuickWindow::FramelessQuickWindow(QWindow *parent) - : QQuickWindowQmlImpl(parent), d_ptr(new FramelessQuickWindowPrivate(this)) + : QQuickWindowQmlImpl(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/quick/quickimageitem.cpp b/src/quick/quickimageitem.cpp index 395a8e0..1ba2f8b 100644 --- a/src/quick/quickimageitem.cpp +++ b/src/quick/quickimageitem.cpp @@ -220,7 +220,7 @@ QRect QuickImageItemPrivate::paintArea() const } QuickImageItem::QuickImageItem(QQuickItem *parent) - : QQuickPaintedItem(parent), d_ptr(new QuickImageItemPrivate(this)) + : QQuickPaintedItem(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/quick/quickmicamaterial.cpp b/src/quick/quickmicamaterial.cpp index c4cc206..bdab9af 100644 --- a/src/quick/quickmicamaterial.cpp +++ b/src/quick/quickmicamaterial.cpp @@ -77,11 +77,11 @@ private: void initialize(); private: - QScopedPointer m_texture; + QSGTexture *m_texture = nullptr; QPointer m_item = nullptr; QSGSimpleTextureNode *m_node = nullptr; QPixmap m_pixmapCache = {}; - QScopedPointer m_micaMaterial; + MicaMaterial *m_micaMaterial = nullptr; }; WallpaperImageNode::WallpaperImageNode(QuickMicaMaterial *item) @@ -101,7 +101,7 @@ void WallpaperImageNode::initialize() g_data()->mutex.lock(); QQuickWindow * const window = m_item->window(); - m_micaMaterial.reset(new MicaMaterial); + m_micaMaterial = new MicaMaterial(this); m_node = new QSGSimpleTextureNode; m_node->setFiltering(QSGTexture::Linear); @@ -113,7 +113,7 @@ void WallpaperImageNode::initialize() appendChildNode(m_node); - connect(m_micaMaterial.data(), &MicaMaterial::shouldRedraw, this, [this](){ + connect(m_micaMaterial, &MicaMaterial::shouldRedraw, this, [this](){ maybeGenerateWallpaperImageCache(true); }); connect(window, &QQuickWindow::beforeRendering, this, @@ -134,8 +134,12 @@ void WallpaperImageNode::maybeGenerateWallpaperImageCache(const bool force) m_pixmapCache.fill(kDefaultTransparentColor); QPainter painter(&m_pixmapCache); m_micaMaterial->paint(&painter, desktopSize, originPoint); - m_texture.reset(m_item->window()->createTextureFromImage(m_pixmapCache.toImage())); - m_node->setTexture(m_texture.data()); + if (m_texture) { + delete m_texture; + m_texture = nullptr; + } + m_texture = m_item->window()->createTextureFromImage(m_pixmapCache.toImage()); + m_node->setTexture(m_texture); } void WallpaperImageNode::maybeUpdateWallpaperImageClipRect() @@ -240,7 +244,7 @@ void QuickMicaMaterialPrivate::appendNode(WallpaperImageNode *node) } QuickMicaMaterial::QuickMicaMaterial(QQuickItem *parent) - : QQuickItem(parent), d_ptr(new QuickMicaMaterialPrivate(this)) + : QQuickItem(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/quick/quickstandardsystembutton.cpp b/src/quick/quickstandardsystembutton.cpp index d2d7432..235c666 100644 --- a/src/quick/quickstandardsystembutton.cpp +++ b/src/quick/quickstandardsystembutton.cpp @@ -102,7 +102,7 @@ QColor QuickStandardSystemButton::inactiveForegroundColor() const qreal QuickStandardSystemButton::iconSize() const { - if (m_contentItem.isNull()) { + if (!m_contentItem) { return -1; } const QFont font = m_contentItem->font(); @@ -271,13 +271,13 @@ void QuickStandardSystemButton::initialize() setImplicitWidth(kDefaultSystemButtonSize.width()); setImplicitHeight(kDefaultSystemButtonSize.height()); - m_contentItem.reset(new QQuickText(this)); + m_contentItem = new QQuickText(this); m_contentItem->setFont(FramelessManagerPrivate::getIconFont()); m_contentItem->setHAlign(QQuickText::AlignHCenter); m_contentItem->setVAlign(QQuickText::AlignVCenter); - QQuickItemPrivate::get(m_contentItem.data())->anchors()->setFill(this); + QQuickItemPrivate::get(m_contentItem)->anchors()->setFill(this); - m_backgroundItem.reset(new QQuickRectangle(this)); + m_backgroundItem = new QQuickRectangle(this); QQuickPen * const border = m_backgroundItem->border(); border->setWidth(0.0); border->setColor(kDefaultTransparentColor); @@ -286,8 +286,8 @@ void QuickStandardSystemButton::initialize() updateColor(); - setContentItem(m_contentItem.data()); - setBackground(m_backgroundItem.data()); + setContentItem(m_contentItem); + setBackground(m_backgroundItem); } void QuickStandardSystemButton::classBegin() diff --git a/src/quick/quickstandardtitlebar.cpp b/src/quick/quickstandardtitlebar.cpp index bdf8cba..c762a32 100644 --- a/src/quick/quickstandardtitlebar.cpp +++ b/src/quick/quickstandardtitlebar.cpp @@ -74,7 +74,7 @@ void QuickStandardTitleBar::setTitleLabelAlignment(const Qt::Alignment value) return; } m_labelAlignment = value; - QQuickAnchors * const labelAnchors = QQuickItemPrivate::get(m_windowTitleLabel.data())->anchors(); + QQuickAnchors * const labelAnchors = QQuickItemPrivate::get(m_windowTitleLabel)->anchors(); //labelAnchors->setMargins(0); labelAnchors->resetFill(); labelAnchors->resetCenterIn(); @@ -93,14 +93,14 @@ void QuickStandardTitleBar::setTitleLabelAlignment(const Qt::Alignment value) } if (m_labelAlignment & Qt::AlignLeft) { if (m_windowIcon->isVisible()) { - labelAnchors->setLeft(QQuickItemPrivate::get(m_windowIcon.data())->right()); + labelAnchors->setLeft(QQuickItemPrivate::get(m_windowIcon)->right()); } else { labelAnchors->setLeft(titleBarPriv->left()); } labelAnchors->setLeftMargin(kDefaultTitleBarContentsMargin); } if (m_labelAlignment & Qt::AlignRight) { - labelAnchors->setRight(QQuickItemPrivate::get(m_systemButtonsRow.data())->left()); + labelAnchors->setRight(QQuickItemPrivate::get(m_systemButtonsRow)->left()); labelAnchors->setRightMargin(kDefaultTitleBarContentsMargin); } if (m_labelAlignment & Qt::AlignVCenter) { @@ -118,22 +118,22 @@ void QuickStandardTitleBar::setTitleLabelAlignment(const Qt::Alignment value) QQuickLabel *QuickStandardTitleBar::titleLabel() const { - return m_windowTitleLabel.data(); + return m_windowTitleLabel; } QuickStandardSystemButton *QuickStandardTitleBar::minimizeButton() const { - return m_minimizeButton.data(); + return m_minimizeButton; } QuickStandardSystemButton *QuickStandardTitleBar::maximizeButton() const { - return m_maximizeButton.data(); + return m_maximizeButton; } QuickStandardSystemButton *QuickStandardTitleBar::closeButton() const { - return m_closeButton.data(); + return m_closeButton; } bool QuickStandardTitleBar::isExtended() const @@ -167,7 +167,7 @@ void QuickStandardTitleBar::setHideWhenClose(const bool value) QuickChromePalette *QuickStandardTitleBar::chromePalette() const { - return m_chromePalette.data(); + return m_chromePalette; } QSizeF QuickStandardTitleBar::windowIconSize() const @@ -207,9 +207,9 @@ void QuickStandardTitleBar::setWindowIconVisible(const bool value) return; } m_windowIcon->setVisible(value); - QQuickAnchors *labelAnchors = QQuickItemPrivate::get(m_windowTitleLabel.data())->anchors(); + QQuickAnchors *labelAnchors = QQuickItemPrivate::get(m_windowTitleLabel)->anchors(); if (value) { - labelAnchors->setLeft(QQuickItemPrivate::get(m_windowIcon.data())->right()); + labelAnchors->setLeft(QQuickItemPrivate::get(m_windowIcon)->right()); } else { labelAnchors->setLeft(QQuickItemPrivate::get(this)->left()); } @@ -241,7 +241,7 @@ void QuickStandardTitleBar::updateMaximizeButton() } const bool max = (w->visibility() == QQuickWindow::Maximized); m_maximizeButton->setButtonType(max ? QuickGlobal::SystemButtonType::Restore : QuickGlobal::SystemButtonType::Maximize); - qobject_cast(qmlAttachedPropertiesObject(m_maximizeButton.data()))->setText(max ? tr("Restore") : tr("Maximize")); + qobject_cast(qmlAttachedPropertiesObject(m_maximizeButton))->setText(max ? tr("Restore") : tr("Maximize")); } void QuickStandardTitleBar::updateTitleLabelText() @@ -342,8 +342,8 @@ void QuickStandardTitleBar::clickCloseButton() void QuickStandardTitleBar::retranslateUi() { - qobject_cast(qmlAttachedPropertiesObject(m_minimizeButton.data()))->setText(tr("Minimize")); - qobject_cast(qmlAttachedPropertiesObject(m_maximizeButton.data()))->setText([this]() -> QString { + qobject_cast(qmlAttachedPropertiesObject(m_minimizeButton))->setText(tr("Minimize")); + qobject_cast(qmlAttachedPropertiesObject(m_maximizeButton))->setText([this]() -> QString { if (const QQuickWindow * const w = window()) { if (w->visibility() == QQuickWindow::Maximized) { return tr("Restore"); @@ -351,7 +351,7 @@ void QuickStandardTitleBar::retranslateUi() } return tr("Maximize"); }()); - qobject_cast(qmlAttachedPropertiesObject(m_closeButton.data()))->setText(tr("Close")); + qobject_cast(qmlAttachedPropertiesObject(m_closeButton))->setText(tr("Close")); } void QuickStandardTitleBar::updateWindowIcon() @@ -445,7 +445,7 @@ QRect QuickStandardTitleBar::windowIconRect() const bool QuickStandardTitleBar::windowIconVisible_real() const { - if (m_windowIcon.isNull() || !m_windowIcon->isVisible() || !m_windowIcon->source().isValid()) { + if (!m_windowIcon || !m_windowIcon->isVisible() || !m_windowIcon->source().isValid()) { return false; } return true; @@ -465,10 +465,10 @@ void QuickStandardTitleBar::initialize() setClip(true); setAntialiasing(true); - m_chromePalette.reset(new QuickChromePalette(this)); - connect(m_chromePalette.data(), &ChromePalette::titleBarColorChanged, + m_chromePalette = new QuickChromePalette(this); + connect(m_chromePalette, &ChromePalette::titleBarColorChanged, this, &QuickStandardTitleBar::updateTitleBarColor); - connect(m_chromePalette.data(), &ChromePalette::chromeButtonColorChanged, + connect(m_chromePalette, &ChromePalette::chromeButtonColorChanged, this, &QuickStandardTitleBar::updateChromeButtonColor); QQuickPen * const b = border(); @@ -478,32 +478,31 @@ void QuickStandardTitleBar::initialize() const QQuickItemPrivate * const thisPriv = QQuickItemPrivate::get(this); - m_windowIcon.reset(new QuickImageItem(this)); - QQuickAnchors * const iconAnchors = QQuickItemPrivate::get(m_windowIcon.data())->anchors(); + m_windowIcon = new QuickImageItem(this); + QQuickAnchors * const iconAnchors = QQuickItemPrivate::get(m_windowIcon)->anchors(); iconAnchors->setLeft(thisPriv->left()); iconAnchors->setLeftMargin(kDefaultTitleBarContentsMargin); iconAnchors->setVerticalCenter(thisPriv->verticalCenter()); - connect(m_windowIcon.data(), &QuickImageItem::visibleChanged, this, &QuickStandardTitleBar::windowIconVisibleChanged); - connect(m_windowIcon.data(), &QuickImageItem::sourceChanged, this, &QuickStandardTitleBar::windowIconChanged); - // ### TODO: QuickImageItem::sizeChanged() - connect(m_windowIcon.data(), &QuickImageItem::widthChanged, this, &QuickStandardTitleBar::windowIconSizeChanged); - connect(m_windowIcon.data(), &QuickImageItem::heightChanged, this, &QuickStandardTitleBar::windowIconSizeChanged); + connect(m_windowIcon, &QuickImageItem::visibleChanged, this, &QuickStandardTitleBar::windowIconVisibleChanged); + connect(m_windowIcon, &QuickImageItem::sourceChanged, this, &QuickStandardTitleBar::windowIconChanged); + connect(m_windowIcon, &QuickImageItem::widthChanged, this, &QuickStandardTitleBar::windowIconSizeChanged); + connect(m_windowIcon, &QuickImageItem::heightChanged, this, &QuickStandardTitleBar::windowIconSizeChanged); - m_windowTitleLabel.reset(new QQuickLabel(this)); + m_windowTitleLabel = new QQuickLabel(this); QFont f = m_windowTitleLabel->font(); f.setPointSize(kDefaultTitleBarFontPointSize); m_windowTitleLabel->setFont(f); - m_systemButtonsRow.reset(new QQuickRow(this)); - QQuickAnchors * const rowAnchors = QQuickItemPrivate::get(m_systemButtonsRow.data())->anchors(); + m_systemButtonsRow = new QQuickRow(this); + QQuickAnchors * const rowAnchors = QQuickItemPrivate::get(m_systemButtonsRow)->anchors(); rowAnchors->setTop(thisPriv->top()); rowAnchors->setRight(thisPriv->right()); - m_minimizeButton.reset(new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Minimize, m_systemButtonsRow.data())); - connect(m_minimizeButton.data(), &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMinimizeButton); - m_maximizeButton.reset(new QuickStandardSystemButton(m_systemButtonsRow.data())); - connect(m_maximizeButton.data(), &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMaximizeButton); - m_closeButton.reset(new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Close, m_systemButtonsRow.data())); - connect(m_closeButton.data(), &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickCloseButton); + m_minimizeButton = new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Minimize, m_systemButtonsRow); + connect(m_minimizeButton, &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMinimizeButton); + m_maximizeButton = new QuickStandardSystemButton(m_systemButtonsRow); + connect(m_maximizeButton, &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMaximizeButton); + m_closeButton = new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Close, m_systemButtonsRow); + connect(m_closeButton, &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickCloseButton); setWindowIconSize(kDefaultWindowIconSize); setWindowIconVisible(false); diff --git a/src/quick/quickwindowborder.cpp b/src/quick/quickwindowborder.cpp index a7923c1..8e32481 100644 --- a/src/quick/quickwindowborder.cpp +++ b/src/quick/quickwindowborder.cpp @@ -117,7 +117,7 @@ const QuickWindowBorderPrivate *QuickWindowBorderPrivate::get(const QuickWindowB void QuickWindowBorderPrivate::paint(QPainter *painter) const { Q_ASSERT(painter); - if (!painter || m_borderPainter.isNull()) { + if (!painter || !m_borderPainter) { return; } Q_Q(const QuickWindowBorder); @@ -149,18 +149,18 @@ void QuickWindowBorderPrivate::initialize() // some very thin lines that are too fragile. q->setAntialiasing(false); - m_borderPainter.reset(new WindowBorderPainter); - connect(m_borderPainter.data(), &WindowBorderPainter::thicknessChanged, + m_borderPainter = new WindowBorderPainter(this); + connect(m_borderPainter, &WindowBorderPainter::thicknessChanged, q, &QuickWindowBorder::thicknessChanged); - connect(m_borderPainter.data(), &WindowBorderPainter::edgesChanged, + connect(m_borderPainter, &WindowBorderPainter::edgesChanged, q, &QuickWindowBorder::edgesChanged); - connect(m_borderPainter.data(), &WindowBorderPainter::activeColorChanged, + connect(m_borderPainter, &WindowBorderPainter::activeColorChanged, q, &QuickWindowBorder::activeColorChanged); - connect(m_borderPainter.data(), &WindowBorderPainter::inactiveColorChanged, + connect(m_borderPainter, &WindowBorderPainter::inactiveColorChanged, q, &QuickWindowBorder::inactiveColorChanged); - connect(m_borderPainter.data(), &WindowBorderPainter::nativeBorderChanged, + connect(m_borderPainter, &WindowBorderPainter::nativeBorderChanged, q, &QuickWindowBorder::nativeBorderChanged); - connect(m_borderPainter.data(), &WindowBorderPainter::shouldRepaint, q, [q](){ q->update(); }); + connect(m_borderPainter, &WindowBorderPainter::shouldRepaint, q, [q](){ q->update(); }); } void QuickWindowBorderPrivate::rebindWindow() @@ -192,7 +192,7 @@ void QuickWindowBorderPrivate::rebindWindow() } QuickWindowBorder::QuickWindowBorder(QQuickItem *parent) - : QQuickPaintedItem(parent), d_ptr(new QuickWindowBorderPrivate(this)) + : QQuickPaintedItem(parent), d_ptr(std::make_unique(this)) { } @@ -207,57 +207,57 @@ void QuickWindowBorder::paint(QPainter *painter) qreal QuickWindowBorder::thickness() const { Q_D(const QuickWindowBorder); - return (d->m_borderPainter.isNull() ? 0 : d->m_borderPainter->thickness()); + return ((d->m_borderPainter == nullptr) ? 0 : d->m_borderPainter->thickness()); } QuickGlobal::WindowEdges QuickWindowBorder::edges() const { Q_D(const QuickWindowBorder); - return (d->m_borderPainter.isNull() ? QuickGlobal::WindowEdges() + return ((d->m_borderPainter == nullptr) ? QuickGlobal::WindowEdges() : edgesToQuickEdges(d->m_borderPainter->edges())); } QColor QuickWindowBorder::activeColor() const { Q_D(const QuickWindowBorder); - return (d->m_borderPainter.isNull() ? QColor() : d->m_borderPainter->activeColor()); + return ((d->m_borderPainter == nullptr) ? QColor() : d->m_borderPainter->activeColor()); } QColor QuickWindowBorder::inactiveColor() const { Q_D(const QuickWindowBorder); - return (d->m_borderPainter.isNull() ? QColor() : d->m_borderPainter->inactiveColor()); + return ((d->m_borderPainter == nullptr) ? QColor() : d->m_borderPainter->inactiveColor()); } qreal QuickWindowBorder::nativeThickness() const { Q_D(const QuickWindowBorder); - return (d->m_borderPainter.isNull() ? 0 : d->m_borderPainter->nativeThickness()); + return ((d->m_borderPainter == nullptr) ? 0 : d->m_borderPainter->nativeThickness()); } QuickGlobal::WindowEdges QuickWindowBorder::nativeEdges() const { Q_D(const QuickWindowBorder); - return (d->m_borderPainter.isNull() ? QuickGlobal::WindowEdges() + return ((d->m_borderPainter == nullptr) ? QuickGlobal::WindowEdges() : edgesToQuickEdges(d->m_borderPainter->nativeEdges())); } QColor QuickWindowBorder::nativeActiveColor() const { Q_D(const QuickWindowBorder); - return (d->m_borderPainter.isNull() ? QColor() : d->m_borderPainter->nativeActiveColor()); + return ((d->m_borderPainter == nullptr) ? QColor() : d->m_borderPainter->nativeActiveColor()); } QColor QuickWindowBorder::nativeInactiveColor() const { Q_D(const QuickWindowBorder); - return (d->m_borderPainter.isNull() ? QColor() : d->m_borderPainter->nativeInactiveColor()); + return ((d->m_borderPainter == nullptr) ? QColor() : d->m_borderPainter->nativeInactiveColor()); } void QuickWindowBorder::setThickness(const qreal value) { Q_D(QuickWindowBorder); - if (d->m_borderPainter.isNull()) { + if (!d->m_borderPainter) { return; } if (qFuzzyCompare(thickness(), value)) { @@ -269,7 +269,7 @@ void QuickWindowBorder::setThickness(const qreal value) void QuickWindowBorder::setEdges(const QuickGlobal::WindowEdges value) { Q_D(QuickWindowBorder); - if (d->m_borderPainter.isNull()) { + if (!d->m_borderPainter) { return; } if (edges() == value) { @@ -281,7 +281,7 @@ void QuickWindowBorder::setEdges(const QuickGlobal::WindowEdges value) void QuickWindowBorder::setActiveColor(const QColor &value) { Q_D(QuickWindowBorder); - if (d->m_borderPainter.isNull()) { + if (!d->m_borderPainter) { return; } if (activeColor() == value) { @@ -293,7 +293,7 @@ void QuickWindowBorder::setActiveColor(const QColor &value) void QuickWindowBorder::setInactiveColor(const QColor &value) { Q_D(QuickWindowBorder); - if (d->m_borderPainter.isNull()) { + if (!d->m_borderPainter) { return; } if (inactiveColor() == value) { diff --git a/src/widgets/framelessdialog.cpp b/src/widgets/framelessdialog.cpp index 314bc7a..152c26e 100644 --- a/src/widgets/framelessdialog.cpp +++ b/src/widgets/framelessdialog.cpp @@ -80,17 +80,17 @@ void FramelessDialogPrivate::initialize() { Q_Q(FramelessDialog); FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar(); - m_helper.reset(new WidgetsSharedHelper(this)); - m_helper->setup(q); + m_sharedHelper = new WidgetsSharedHelper(this); + m_sharedHelper->setup(q); } WidgetsSharedHelper *FramelessDialogPrivate::widgetsSharedHelper() const { - return (m_helper.isNull() ? nullptr : m_helper.data()); + return m_sharedHelper; } FramelessDialog::FramelessDialog(QWidget *parent) - : QDialog(parent), d_ptr(new FramelessDialogPrivate(this)) + : QDialog(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/widgets/framelessmainwindow.cpp b/src/widgets/framelessmainwindow.cpp index ab05601..7369e4a 100644 --- a/src/widgets/framelessmainwindow.cpp +++ b/src/widgets/framelessmainwindow.cpp @@ -80,8 +80,8 @@ void FramelessMainWindowPrivate::initialize() { Q_Q(FramelessMainWindow); FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar(); - m_helper.reset(new WidgetsSharedHelper(this)); - m_helper->setup(q); + m_sharedHelper = new WidgetsSharedHelper(this); + m_sharedHelper->setup(q); } bool FramelessMainWindowPrivate::isNormal() const @@ -119,11 +119,11 @@ void FramelessMainWindowPrivate::toggleFullScreen() WidgetsSharedHelper *FramelessMainWindowPrivate::widgetsSharedHelper() const { - return (m_helper.isNull() ? nullptr : m_helper.data()); + return m_sharedHelper; } FramelessMainWindow::FramelessMainWindow(QWidget *parent, const Qt::WindowFlags flags) - : QMainWindow(parent, flags), d_ptr(new FramelessMainWindowPrivate(this)) + : QMainWindow(parent, flags), d_ptr(std::make_unique(this)) { } diff --git a/src/widgets/framelesswidget.cpp b/src/widgets/framelesswidget.cpp index 5dea59c..086fed8 100644 --- a/src/widgets/framelesswidget.cpp +++ b/src/widgets/framelesswidget.cpp @@ -80,8 +80,8 @@ void FramelessWidgetPrivate::initialize() { Q_Q(FramelessWidget); FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar(); - m_helper.reset(new WidgetsSharedHelper(this)); - m_helper->setup(q); + m_sharedHelper = new WidgetsSharedHelper(this); + m_sharedHelper->setup(q); } bool FramelessWidgetPrivate::isNormal() const @@ -119,11 +119,11 @@ void FramelessWidgetPrivate::toggleFullScreen() WidgetsSharedHelper *FramelessWidgetPrivate::widgetsSharedHelper() const { - return (m_helper.isNull() ? nullptr : m_helper.data()); + return m_sharedHelper; } FramelessWidget::FramelessWidget(QWidget *parent) - : QWidget(parent), d_ptr(new FramelessWidgetPrivate(this)) + : QWidget(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/widgets/framelesswidgetshelper.cpp b/src/widgets/framelesswidgetshelper.cpp index 1e2deb7..f35e48a 100644 --- a/src/widgets/framelesswidgetshelper.cpp +++ b/src/widgets/framelesswidgetshelper.cpp @@ -882,7 +882,7 @@ void FramelessWidgetsHelperPrivate::setSystemButton(QWidget *widget, const Syste } FramelessWidgetsHelper::FramelessWidgetsHelper(QObject *parent) - : QObject(parent), d_ptr(new FramelessWidgetsHelperPrivate(this)) + : QObject(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/widgets/standardsystembutton.cpp b/src/widgets/standardsystembutton.cpp index 5537195..9cbdca3 100644 --- a/src/widgets/standardsystembutton.cpp +++ b/src/widgets/standardsystembutton.cpp @@ -399,7 +399,7 @@ void StandardSystemButtonPrivate::initialize() } StandardSystemButton::StandardSystemButton(QWidget *parent) - : QAbstractButton(parent), d_ptr(new StandardSystemButtonPrivate(this)) + : QAbstractButton(parent), d_ptr(std::make_unique(this)) { } diff --git a/src/widgets/standardtitlebar.cpp b/src/widgets/standardtitlebar.cpp index 2e8ac71..ca79a30 100644 --- a/src/widgets/standardtitlebar.cpp +++ b/src/widgets/standardtitlebar.cpp @@ -129,7 +129,7 @@ void StandardTitleBarPrivate::setHideWhenClose(const bool value) ChromePalette *StandardTitleBarPrivate::chromePalette() const { - return m_chromePalette.data(); + return m_chromePalette; } void StandardTitleBarPrivate::paintTitleBar(QPaintEvent *event) @@ -139,7 +139,7 @@ void StandardTitleBarPrivate::paintTitleBar(QPaintEvent *event) return; } Q_Q(StandardTitleBar); - if (!m_window || m_chromePalette.isNull()) { + if (!m_window || !m_chromePalette) { return; } const bool active = m_window->isActiveWindow(); @@ -442,10 +442,10 @@ void StandardTitleBarPrivate::initialize() { Q_Q(StandardTitleBar); m_window = (q->nativeParentWidget() ? q->nativeParentWidget() : q->window()); - m_chromePalette.reset(new ChromePalette(this)); - connect(m_chromePalette.data(), &ChromePalette::titleBarColorChanged, + m_chromePalette = new ChromePalette(this); + connect(m_chromePalette, &ChromePalette::titleBarColorChanged, this, &StandardTitleBarPrivate::updateTitleBarColor); - connect(m_chromePalette.data(), &ChromePalette::chromeButtonColorChanged, + connect(m_chromePalette, &ChromePalette::chromeButtonColorChanged, this, &StandardTitleBarPrivate::updateChromeButtonColor); q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); q->setFixedHeight(kDefaultTitleBarHeight); @@ -457,19 +457,19 @@ void StandardTitleBarPrivate::initialize() Q_UNUSED(title); q->update(); }); - m_minimizeButton.reset(new StandardSystemButton(SystemButtonType::Minimize, q)); - connect(m_minimizeButton.data(), &StandardSystemButton::clicked, m_window, &QWidget::showMinimized); - m_maximizeButton.reset(new StandardSystemButton(SystemButtonType::Maximize, q)); + m_minimizeButton = new StandardSystemButton(SystemButtonType::Minimize, q); + connect(m_minimizeButton, &StandardSystemButton::clicked, m_window, &QWidget::showMinimized); + m_maximizeButton = new StandardSystemButton(SystemButtonType::Maximize, q); updateMaximizeButton(); - connect(m_maximizeButton.data(), &StandardSystemButton::clicked, this, [this](){ + connect(m_maximizeButton, &StandardSystemButton::clicked, this, [this](){ if (m_window->isMaximized()) { m_window->showNormal(); } else { m_window->showMaximized(); } }); - m_closeButton.reset(new StandardSystemButton(SystemButtonType::Close, q)); - connect(m_closeButton.data(), &StandardSystemButton::clicked, this, [this](){ + m_closeButton = new StandardSystemButton(SystemButtonType::Close, q); + connect(m_closeButton, &StandardSystemButton::clicked, this, [this](){ if (m_hideWhenClose) { m_window->hide(); } else { @@ -482,9 +482,9 @@ void StandardTitleBarPrivate::initialize() const auto systemButtonsInnerLayout = new QHBoxLayout; systemButtonsInnerLayout->setSpacing(0); systemButtonsInnerLayout->setContentsMargins(0, 0, 0, 0); - systemButtonsInnerLayout->addWidget(m_minimizeButton.data()); - systemButtonsInnerLayout->addWidget(m_maximizeButton.data()); - systemButtonsInnerLayout->addWidget(m_closeButton.data()); + systemButtonsInnerLayout->addWidget(m_minimizeButton); + systemButtonsInnerLayout->addWidget(m_maximizeButton); + systemButtonsInnerLayout->addWidget(m_closeButton); const auto systemButtonsOuterLayout = new QVBoxLayout; systemButtonsOuterLayout->setSpacing(0); systemButtonsOuterLayout->setContentsMargins(0, 0, 0, 0); @@ -504,7 +504,7 @@ void StandardTitleBarPrivate::initialize() } StandardTitleBar::StandardTitleBar(QWidget *parent) - : QWidget(parent), d_ptr(new StandardTitleBarPrivate(this)) + : QWidget(parent), d_ptr(std::make_unique(this)) { } @@ -525,19 +525,19 @@ void StandardTitleBar::setTitleLabelAlignment(const Qt::Alignment value) StandardSystemButton *StandardTitleBar::minimizeButton() const { Q_D(const StandardTitleBar); - return d->m_minimizeButton.data(); + return d->m_minimizeButton; } StandardSystemButton *StandardTitleBar::maximizeButton() const { Q_D(const StandardTitleBar); - return d->m_maximizeButton.data(); + return d->m_maximizeButton; } StandardSystemButton *StandardTitleBar::closeButton() const { Q_D(const StandardTitleBar); - return d->m_closeButton.data(); + return d->m_closeButton; } bool StandardTitleBar::isExtended() const diff --git a/src/widgets/widgetssharedhelper.cpp b/src/widgets/widgetssharedhelper.cpp index e07a211..5b268e3 100644 --- a/src/widgets/widgetssharedhelper.cpp +++ b/src/widgets/widgetssharedhelper.cpp @@ -71,23 +71,23 @@ void WidgetsSharedHelper::setup(QWidget *widget) return; } m_targetWidget = widget; - m_borderPainter.reset(new WindowBorderPainter); + m_borderPainter = new WindowBorderPainter(this); if (m_borderRepaintConnection) { disconnect(m_borderRepaintConnection); m_borderRepaintConnection = {}; } - m_borderRepaintConnection = connect(m_borderPainter.data(), + m_borderRepaintConnection = connect(m_borderPainter, &WindowBorderPainter::shouldRepaint, this, [this](){ if (m_targetWidget) { m_targetWidget->update(); } }); - m_micaMaterial.reset(new MicaMaterial); + m_micaMaterial = new MicaMaterial(this); if (m_micaRedrawConnection) { disconnect(m_micaRedrawConnection); m_micaRedrawConnection = {}; } - m_micaRedrawConnection = connect(m_micaMaterial.data(), &MicaMaterial::shouldRedraw, + m_micaRedrawConnection = connect(m_micaMaterial, &MicaMaterial::shouldRedraw, this, [this](){ if (m_targetWidget) { m_targetWidget->update(); @@ -129,12 +129,12 @@ void WidgetsSharedHelper::setMicaEnabled(const bool value) MicaMaterial *WidgetsSharedHelper::rawMicaMaterial() const { - return (m_micaMaterial.isNull() ? nullptr : m_micaMaterial.data()); + return m_micaMaterial; } WindowBorderPainter *WidgetsSharedHelper::rawWindowBorder() const { - return (m_borderPainter.isNull() ? nullptr : m_borderPainter.data()); + return m_borderPainter; } bool WidgetsSharedHelper::eventFilter(QObject *object, QEvent *event) @@ -219,7 +219,7 @@ void WidgetsSharedHelper::paintEventHandler(QPaintEvent *event) m_targetWidget->mapToGlobal(QPoint(0, 0))); } if ((Utils::windowStatesToWindowState(m_targetWidget->windowState()) == Qt::WindowNoState) - && !m_borderPainter.isNull()) { + && m_borderPainter) { QPainter painter(m_targetWidget); m_borderPainter->paint(&painter, m_targetWidget->size(), m_targetWidget->isActiveWindow()); } @@ -254,8 +254,8 @@ void WidgetsSharedHelper::handleScreenChanged(QScreen *screen) return; } m_screenDpr = currentDpr; - if (m_micaEnabled && !m_micaMaterial.isNull()) { - MicaMaterialPrivate::get(m_micaMaterial.data())->maybeGenerateBlurredWallpaper(true); + if (m_micaEnabled && m_micaMaterial) { + MicaMaterialPrivate::get(m_micaMaterial)->maybeGenerateBlurredWallpaper(true); } }); }