replace QScopedPointer with std::unique_ptr

QScopedPointer is being deprecated in latest qtbase code.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-12-12 11:59:38 +08:00
parent ed3771c949
commit f00adba67c
70 changed files with 281 additions and 263 deletions

View File

@ -40,7 +40,7 @@ int main(int argc, char *argv[])
// of any Q(Core|Gui)Application instances. // of any Q(Core|Gui)Application instances.
FramelessHelper::Widgets::initialize(); FramelessHelper::Widgets::initialize();
const QScopedPointer<QApplication> application(new QApplication(argc, argv)); const auto application = std::make_unique<QApplication>(argc, argv);
// Must be called after QGuiApplication has been constructed, we are using // Must be called after QGuiApplication has been constructed, we are using
// some private functions from QPA which won't be available until there's // 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::EnableBlurBehindWindow);
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
const QScopedPointer<Dialog> dialog(new Dialog); const auto dialog = std::make_unique<Dialog>();
dialog->show(); dialog->show();
const int exec = QCoreApplication::exec(); const int exec = QCoreApplication::exec();

View File

@ -40,7 +40,7 @@ int main(int argc, char *argv[])
// of any Q(Core|Gui)Application instances. // of any Q(Core|Gui)Application instances.
FramelessHelper::Widgets::initialize(); FramelessHelper::Widgets::initialize();
const QScopedPointer<QApplication> application(new QApplication(argc, argv)); const auto application = std::make_unique<QApplication>(argc, argv);
// Must be called after QGuiApplication has been constructed, we are using // Must be called after QGuiApplication has been constructed, we are using
// some private functions from QPA which won't be available until there's // 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::EnableBlurBehindWindow);
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
const QScopedPointer<MainWindow> mainWindow(new MainWindow); const auto mainWindow = std::make_unique<MainWindow>();
mainWindow->show(); mainWindow->show();
const int exec = QCoreApplication::exec(); const int exec = QCoreApplication::exec();

View File

@ -55,9 +55,9 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::initialize() void MainWindow::initialize()
{ {
m_titleBar.reset(new StandardTitleBar(this)); m_titleBar = new StandardTitleBar(this);
m_titleBar->setTitleLabelAlignment(Qt::AlignCenter); m_titleBar->setTitleLabelAlignment(Qt::AlignCenter);
m_mainWindow.reset(new Ui::MainWindow); m_mainWindow = new Ui::MainWindow;
m_mainWindow->setupUi(this); m_mainWindow->setupUi(this);
QMenuBar * const mb = menuBar(); QMenuBar * const mb = menuBar();
@ -83,10 +83,10 @@ QMenuBar::item:pressed {
titleBarLayout->insertWidget(0, mb); titleBarLayout->insertWidget(0, mb);
// setMenuWidget(): make the menu widget become the first row of the window. // setMenuWidget(): make the menu widget become the first row of the window.
setMenuWidget(m_titleBar.data()); setMenuWidget(m_titleBar);
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this); 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->minimizeButton(), SystemButtonType::Minimize);
helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize); helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize);
helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close); helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close);

View File

@ -51,6 +51,6 @@ private:
void initialize(); void initialize();
private: private:
QScopedPointer<FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar)> m_titleBar; FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr;
QScopedPointer<Ui::MainWindow> m_mainWindow; Ui::MainWindow *m_mainWindow = nullptr;
}; };

View File

@ -77,7 +77,7 @@ int main(int argc, char *argv[])
// of any Q(Core|Gui)Application instances. // of any Q(Core|Gui)Application instances.
FramelessHelper::Widgets::initialize(); FramelessHelper::Widgets::initialize();
const QScopedPointer<QApplication> application(new QApplication(argc, argv)); const auto application = std::make_unique<QApplication>(argc, argv);
// Must be called after QGuiApplication has been constructed, we are using // Must be called after QGuiApplication has been constructed, we are using
// some private functions from QPA which won't be available until there's // 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); QSurfaceFormat::setDefaultFormat(fmt);
const QScopedPointer<MainWindow> mainWindow(new MainWindow); const auto mainWindow = std::make_unique<MainWindow>();
mainWindow->show(); mainWindow->show();
const int exec = QCoreApplication::exec(); const int exec = QCoreApplication::exec();

View File

@ -52,7 +52,7 @@ int main(int argc, char *argv[])
// of any Q(Core|Gui)Application instances. // of any Q(Core|Gui)Application instances.
FramelessHelper::Quick::initialize(); FramelessHelper::Quick::initialize();
const QScopedPointer<QGuiApplication> application(new QGuiApplication(argc, argv)); const auto application = std::make_unique<QGuiApplication>(argc, argv);
// Must be called after QGuiApplication has been constructed, we are using // Must be called after QGuiApplication has been constructed, we are using
// some private functions from QPA which won't be available until there's // some private functions from QPA which won't be available until there's
@ -82,14 +82,14 @@ int main(int argc, char *argv[])
#endif #endif
} }
const QScopedPointer<QQmlApplicationEngine> engine(new QQmlApplicationEngine); const auto engine = std::make_unique<QQmlApplicationEngine>();
#if (!QMLTC_ENABLED && !defined(QUICK_USE_QMAKE)) #if (!QMLTC_ENABLED && !defined(QUICK_USE_QMAKE))
engine->addImportPath(FRAMELESSHELPER_STRING_LITERAL("../imports")); engine->addImportPath(FRAMELESSHELPER_STRING_LITERAL("../imports"));
#endif #endif
#if (((QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) || defined(QUICK_USE_QMAKE)) && !QMLTC_ENABLED) #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! // Don't forget to register our own custom QML types!
FramelessHelper::Quick::registerTypes(engine.data()); FramelessHelper::Quick::registerTypes(engine.get());
qmlRegisterSingletonType<QuickSettings>("Demo", 1, 0, "Settings", qmlRegisterSingletonType<QuickSettings>("Demo", 1, 0, "Settings",
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
@ -116,14 +116,14 @@ int main(int argc, char *argv[])
#endif #endif
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) #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){ [](const QUrl &url){
qCritical() << "The QML engine failed to create component:" << url; qCritical() << "The QML engine failed to create component:" << url;
QCoreApplication::exit(-1); QCoreApplication::exit(-1);
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
#elif !QMLTC_ENABLED #elif !QMLTC_ENABLED
const QMetaObject::Connection connection = QObject::connect( const QMetaObject::Connection connection = QObject::connect(
engine.data(), &QQmlApplicationEngine::objectCreated, &application, engine.get(), &QQmlApplicationEngine::objectCreated, &application,
[&mainUrl, &connection](QObject *object, const QUrl &url) { [&mainUrl, &connection](QObject *object, const QUrl &url) {
if (url != mainUrl) { if (url != mainUrl) {
return; return;
@ -141,7 +141,7 @@ int main(int argc, char *argv[])
#endif #endif
#if QMLTC_ENABLED #if QMLTC_ENABLED
QScopedPointer<HomePage> homePage(new HomePage(engine.data())); const auto homePage = std::make_unique<HomePage>(engine.get());
homePage->show(); homePage->show();
#endif #endif

View File

@ -40,8 +40,8 @@
static QString g_app = {}; static QString g_app = {};
static bool g_logError = false; static bool g_logError = false;
static QScopedPointer<QFile> g_logFile; static std::unique_ptr<QFile> g_logFile = nullptr;
static QScopedPointer<QTextStream> g_logStream; static std::unique_ptr<QTextStream> g_logStream = nullptr;
static inline void myMessageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message) 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) { if (g_logError) {
return; return;
} }
if (g_logFile.isNull()) { if (!g_logFile) {
g_logFile.reset(new QFile); g_logFile = std::make_unique<QFile>();
g_logFile->setFileName(FRAMELESSHELPER_STRING_LITERAL("debug-%1.log").arg(g_app)); g_logFile->setFileName(FRAMELESSHELPER_STRING_LITERAL("debug-%1.log").arg(g_app));
if (!g_logFile->open(QFile::WriteOnly | QFile::Text | QFile::Append)) { if (!g_logFile->open(QFile::WriteOnly | QFile::Text | QFile::Append)) {
std::cerr << "Can't open file to write: " << qUtf8Printable(g_logFile->errorString()) << std::endl; std::cerr << "Can't open file to write: " << qUtf8Printable(g_logFile->errorString()) << std::endl;
g_logFile.reset(); delete g_logFile.release();
g_logError = true; g_logError = true;
return; return;
} }
} }
if (g_logStream.isNull()) { if (!g_logStream) {
g_logStream.reset(new QTextStream); g_logStream = std::make_unique<QTextStream>();
g_logStream->setDevice(g_logFile.data()); g_logStream->setDevice(g_logFile.get());
} }
(*g_logStream) << finalMessage << QT_ENDL; (*g_logStream) << finalMessage << QT_ENDL;
} }

View File

@ -28,7 +28,7 @@
#include <QtCore/qfileinfo.h> #include <QtCore/qfileinfo.h>
#include <framelesshelpercore_global.h> #include <framelesshelpercore_global.h>
static QScopedPointer<QSettings> g_settings; static std::unique_ptr<QSettings> g_settings = nullptr;
[[nodiscard]] static inline QSettings *appConfigFile() [[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()) { if (key.isEmpty() || data.isEmpty()) {
return; return;
} }
if (g_settings.isNull()) { if (!g_settings) {
g_settings.reset(appConfigFile()); g_settings.reset(appConfigFile());
} }
g_settings->setValue(appKey(id, key), data); g_settings->setValue(appKey(id, key), data);
@ -66,7 +66,7 @@ QByteArray Settings::get(const QString &id, const QString &key)
if (key.isEmpty()) { if (key.isEmpty()) {
return {}; return {};
} }
if (g_settings.isNull()) { if (!g_settings) {
g_settings.reset(appConfigFile()); g_settings.reset(appConfigFile());
} }
return g_settings->value(appKey(id, key)).toByteArray(); return g_settings->value(appKey(id, key)).toByteArray();

View File

@ -40,7 +40,7 @@ int main(int argc, char *argv[])
// of any Q(Core|Gui)Application instances. // of any Q(Core|Gui)Application instances.
FramelessHelper::Widgets::initialize(); FramelessHelper::Widgets::initialize();
const QScopedPointer<QApplication> application(new QApplication(argc, argv)); const auto application = std::make_unique<QApplication>(argc, argv);
// Must be called after QGuiApplication has been constructed, we are using // Must be called after QGuiApplication has been constructed, we are using
// some private functions from QPA which won't be available until there's // 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::EnableBlurBehindWindow);
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
const QScopedPointer<Widget> window1(new Widget); const auto window1 = std::make_unique<Widget>();
window1->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window1")); window1->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window1"));
window1->show(); window1->show();
const QScopedPointer<Widget> window2(new Widget); const auto window2 = std::make_unique<Widget>();
window2->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window2")); window2->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window2"));
window2->show(); window2->show();

View File

@ -73,9 +73,9 @@ void Widget::initialize()
setWindowTitle(tr("FramelessHelper demo application - Qt Widgets")); setWindowTitle(tr("FramelessHelper demo application - Qt Widgets"));
setWindowIcon(QFileIconProvider().icon(QFileIconProvider::Computer)); setWindowIcon(QFileIconProvider().icon(QFileIconProvider::Computer));
resize(800, 600); resize(800, 600);
m_titleBar.reset(new StandardTitleBar(this)); m_titleBar = new StandardTitleBar(this);
m_titleBar->setWindowIconVisible(true); m_titleBar->setWindowIconVisible(true);
m_clockLabel.reset(new QLabel(this)); m_clockLabel = new QLabel(this);
m_clockLabel->setFrameShape(QFrame::NoFrame); m_clockLabel->setFrameShape(QFrame::NoFrame);
QFont clockFont = font(); QFont clockFont = font();
clockFont.setBold(true); clockFont.setBold(true);
@ -85,19 +85,19 @@ void Widget::initialize()
contentLayout->setContentsMargins(0, 0, 0, 0); contentLayout->setContentsMargins(0, 0, 0, 0);
contentLayout->setSpacing(0); contentLayout->setSpacing(0);
contentLayout->addStretch(); contentLayout->addStretch();
contentLayout->addWidget(m_clockLabel.data()); contentLayout->addWidget(m_clockLabel);
contentLayout->addStretch(); contentLayout->addStretch();
const auto mainLayout = new QVBoxLayout(this); const auto mainLayout = new QVBoxLayout(this);
mainLayout->setSpacing(0); mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(m_titleBar.data()); mainLayout->addWidget(m_titleBar);
mainLayout->addLayout(contentLayout); mainLayout->addLayout(contentLayout);
setLayout(mainLayout); setLayout(mainLayout);
updateStyleSheet(); updateStyleSheet();
m_cancelShortcut.reset(new QShortcut(this)); m_cancelShortcut = new QShortcut(this);
m_cancelShortcut->setKey(FRAMELESSHELPER_STRING_LITERAL("ESC")); m_cancelShortcut->setKey(FRAMELESSHELPER_STRING_LITERAL("ESC"));
connect(m_cancelShortcut.data(), &QShortcut::activated, this, [this](){ connect(m_cancelShortcut, &QShortcut::activated, this, [this](){
if (isFullScreen()) { if (isFullScreen()) {
Q_EMIT m_fullScreenShortcut->activated(); Q_EMIT m_fullScreenShortcut->activated();
} else { } 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")); 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()) { if (isFullScreen()) {
setWindowState(windowState() & ~Qt::WindowFullScreen); setWindowState(windowState() & ~Qt::WindowFullScreen);
} else { } else {
@ -116,7 +116,7 @@ void Widget::initialize()
}); });
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this); 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->minimizeButton(), SystemButtonType::Minimize);
helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize); helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize);
helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close); helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close);

View File

@ -55,8 +55,8 @@ private Q_SLOTS:
void updateStyleSheet(); void updateStyleSheet();
private: private:
QScopedPointer<QLabel> m_clockLabel; QLabel *m_clockLabel = nullptr;
QScopedPointer<FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar)> m_titleBar; FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr;
QScopedPointer<QShortcut> m_fullScreenShortcut; QShortcut *m_fullScreenShortcut = nullptr;
QScopedPointer<QShortcut> m_cancelShortcut; QShortcut *m_cancelShortcut = nullptr;
}; };

View File

@ -121,7 +121,7 @@ Q_SIGNALS:
void chromeButtonColorChanged(); void chromeButtonColorChanged();
private: private:
QScopedPointer<ChromePalettePrivate> d_ptr; std::unique_ptr<ChromePalettePrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -62,7 +62,7 @@ Q_SIGNALS:
void wallpaperChanged(); void wallpaperChanged();
private: private:
QScopedPointer<FramelessManagerPrivate> d_ptr; std::unique_ptr<FramelessManagerPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -65,7 +65,7 @@ Q_SIGNALS:
void shouldRedraw(); void shouldRedraw();
private: private:
QScopedPointer<MicaMaterialPrivate> d_ptr; std::unique_ptr<MicaMaterialPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -25,10 +25,11 @@
#pragma once #pragma once
#include "framelesshelpercore_global.h" #include "framelesshelpercore_global.h"
#include "chromepalette.h"
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class ChromePalette;
class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -46,7 +47,7 @@ public Q_SLOTS:
void refresh(); void refresh();
private: private:
QPointer<ChromePalette> q_ptr = nullptr; ChromePalette *q_ptr = nullptr;
// System-defined ones: // System-defined ones:
QColor titleBarActiveBackgroundColor_sys = {}; QColor titleBarActiveBackgroundColor_sys = {};
QColor titleBarInactiveBackgroundColor_sys = {}; QColor titleBarInactiveBackgroundColor_sys = {};

View File

@ -25,10 +25,11 @@
#pragma once #pragma once
#include "framelesshelpercore_global.h" #include "framelesshelpercore_global.h"
#include "framelessmanager.h"
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessManager;
class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -62,7 +63,7 @@ private:
void initialize(); void initialize();
private: private:
QPointer<FramelessManager> q_ptr = nullptr; FramelessManager *q_ptr = nullptr;
Global::SystemTheme m_systemTheme = Global::SystemTheme::Unknown; Global::SystemTheme m_systemTheme = Global::SystemTheme::Unknown;
QColor m_accentColor = {}; QColor m_accentColor = {};
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS

View File

@ -25,11 +25,12 @@
#pragma once #pragma once
#include "framelesshelpercore_global.h" #include "framelesshelpercore_global.h"
#include "micamaterial.h"
#include <QtGui/qbrush.h> #include <QtGui/qbrush.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class MicaMaterial;
class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -53,7 +54,7 @@ private:
void prepareGraphicsResources(); void prepareGraphicsResources();
private: private:
QPointer<MicaMaterial> q_ptr = nullptr; MicaMaterial *q_ptr = nullptr;
QColor tintColor = {}; QColor tintColor = {};
qreal tintOpacity = 0.0; qreal tintOpacity = 0.0;
qreal noiseOpacity = 0.0; qreal noiseOpacity = 0.0;

View File

@ -83,9 +83,9 @@ private:
Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser; Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser;
QString m_subKey = {}; QString m_subKey = {};
#if REGISTRYKEY_QWINREGISTRYKEY #if REGISTRYKEY_QWINREGISTRYKEY
QScopedPointer<QWinRegistryKey> m_registryKey; std::unique_ptr<QWinRegistryKey> m_registryKey = nullptr;
#else #else
QScopedPointer<QSettings> m_settings; std::unique_ptr<QSettings> m_settings = nullptr;
#endif #endif
}; };

View File

@ -25,10 +25,11 @@
#pragma once #pragma once
#include "framelesshelpercore_global.h" #include "framelesshelpercore_global.h"
#include "windowborderpainter.h"
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class WindowBorderPainter;
class FRAMELESSHELPER_CORE_API WindowBorderPainterPrivate : public QObject class FRAMELESSHELPER_CORE_API WindowBorderPainterPrivate : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -53,7 +54,7 @@ private:
void initialize(); void initialize();
private: private:
QPointer<WindowBorderPainter> q_ptr = nullptr; WindowBorderPainter *q_ptr = nullptr;
std::optional<int> m_thickness = std::nullopt; std::optional<int> m_thickness = std::nullopt;
std::optional<Global::WindowEdges> m_edges = std::nullopt; std::optional<Global::WindowEdges> m_edges = std::nullopt;
std::optional<QColor> m_activeColor = std::nullopt; std::optional<QColor> m_activeColor = std::nullopt;

View File

@ -78,7 +78,7 @@ Q_SIGNALS:
void shouldRepaint(); void shouldRepaint();
private: private:
QScopedPointer<WindowBorderPainterPrivate> d_ptr; std::unique_ptr<WindowBorderPainterPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -101,7 +101,7 @@ Q_SIGNALS:
void ready(); void ready();
private: private:
QScopedPointer<FramelessQuickHelperPrivate> d_ptr; std::unique_ptr<FramelessQuickHelperPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -77,7 +77,7 @@ Q_SIGNALS:
void fullScreenChanged(); void fullScreenChanged();
private: private:
QScopedPointer<FramelessQuickApplicationWindowPrivate> d_ptr; std::unique_ptr<FramelessQuickApplicationWindowPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -27,10 +27,11 @@
#ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE #ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#include "framelessquickapplicationwindow_p.h" #include <QtQuick/qquickwindow.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessQuickApplicationWindow;
class QuickWindowBorder; class QuickWindowBorder;
class FRAMELESSHELPER_QUICK_API FramelessQuickApplicationWindowPrivate : public QObject class FRAMELESSHELPER_QUICK_API FramelessQuickApplicationWindowPrivate : public QObject
@ -62,8 +63,8 @@ private:
void initialize(); void initialize();
private: private:
QPointer<FramelessQuickApplicationWindow> q_ptr = nullptr; FramelessQuickApplicationWindow *q_ptr = nullptr;
QScopedPointer<QuickWindowBorder> m_windowBorder; QuickWindowBorder *m_windowBorder = nullptr;
QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed; QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed;
}; };

View File

@ -25,7 +25,6 @@
#pragma once #pragma once
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#include "framelessquickhelper.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QQuickItem; class QQuickItem;
@ -33,6 +32,9 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessQuickHelper;
class QuickMicaMaterial;
class QuickWindowBorder;
struct QuickHelperData; struct QuickHelperData;
class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject
@ -97,7 +99,7 @@ private:
void rebindWindow(); void rebindWindow();
private: private:
QPointer<FramelessQuickHelper> q_ptr = nullptr; FramelessQuickHelper *q_ptr = nullptr;
QColor m_savedWindowBackgroundColor = {}; QColor m_savedWindowBackgroundColor = {};
bool m_blurBehindWindowEnabled = false; bool m_blurBehindWindowEnabled = false;
std::optional<bool> m_extendIntoTitleBar = std::nullopt; std::optional<bool> m_extendIntoTitleBar = std::nullopt;

View File

@ -77,7 +77,7 @@ Q_SIGNALS:
void fullScreenChanged(); void fullScreenChanged();
private: private:
QScopedPointer<FramelessQuickWindowPrivate> d_ptr; std::unique_ptr<FramelessQuickWindowPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -27,10 +27,11 @@
#ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE #ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#include "framelessquickwindow_p.h" #include <QtQuick/qquickwindow.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessQuickWindow;
class QuickWindowBorder; class QuickWindowBorder;
class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject
@ -62,8 +63,8 @@ private:
void initialize(); void initialize();
private: private:
QPointer<FramelessQuickWindow> q_ptr = nullptr; FramelessQuickWindow *q_ptr = nullptr;
QScopedPointer<QuickWindowBorder> m_windowBorder; QuickWindowBorder *m_windowBorder = nullptr;
QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed; QQuickWindow::Visibility m_savedVisibility = QQuickWindow::Windowed;
}; };

View File

@ -25,11 +25,12 @@
#pragma once #pragma once
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#include "quickimageitem.h"
#include <QtCore/qvariant.h> #include <QtCore/qvariant.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class QuickImageItem;
class FRAMELESSHELPER_QUICK_API QuickImageItemPrivate : public QObject class FRAMELESSHELPER_QUICK_API QuickImageItemPrivate : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -58,7 +59,7 @@ private:
Q_NODISCARD QRect paintArea() const; Q_NODISCARD QRect paintArea() const;
private: private:
QPointer<QuickImageItem> q_ptr = nullptr; QuickImageItem *q_ptr = nullptr;
QVariant m_source = {}; QVariant m_source = {};
}; };

View File

@ -25,10 +25,10 @@
#pragma once #pragma once
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#include "quickmicamaterial.h"
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class QuickMicaMaterial;
class WallpaperImageNode; class WallpaperImageNode;
class FRAMELESSHELPER_QUICK_API QuickMicaMaterialPrivate : public QObject class FRAMELESSHELPER_QUICK_API QuickMicaMaterialPrivate : public QObject
@ -53,7 +53,7 @@ private:
void initialize(); void initialize();
private: private:
QPointer<QuickMicaMaterial> q_ptr = nullptr; QuickMicaMaterial *q_ptr = nullptr;
QMetaObject::Connection m_rootWindowXChangedConnection = {}; QMetaObject::Connection m_rootWindowXChangedConnection = {};
QMetaObject::Connection m_rootWindowYChangedConnection = {}; QMetaObject::Connection m_rootWindowYChangedConnection = {};
QList<QPointer<WallpaperImageNode>> m_nodes = {}; QList<QPointer<WallpaperImageNode>> m_nodes = {};

View File

@ -96,8 +96,8 @@ Q_SIGNALS:
void iconSizeChanged(); void iconSizeChanged();
private: private:
QScopedPointer<QQuickText> m_contentItem; QQuickText *m_contentItem = nullptr;
QScopedPointer<QQuickRectangle> m_backgroundItem; QQuickRectangle *m_backgroundItem = nullptr;
QuickGlobal::SystemButtonType m_buttonType = QuickGlobal::SystemButtonType::Unknown; QuickGlobal::SystemButtonType m_buttonType = QuickGlobal::SystemButtonType::Unknown;
QString m_code = {}; QString m_code = {};
QColor m_normalColor = {}; QColor m_normalColor = {};

View File

@ -124,18 +124,18 @@ private:
private: private:
Qt::Alignment m_labelAlignment = {}; Qt::Alignment m_labelAlignment = {};
QScopedPointer<QuickImageItem> m_windowIcon; QuickImageItem *m_windowIcon = nullptr;
QScopedPointer<QQuickLabel> m_windowTitleLabel; QQuickLabel *m_windowTitleLabel = nullptr;
QScopedPointer<QQuickRow> m_systemButtonsRow; QQuickRow *m_systemButtonsRow = nullptr;
QScopedPointer<QuickStandardSystemButton> m_minimizeButton; QuickStandardSystemButton *m_minimizeButton = nullptr;
QScopedPointer<QuickStandardSystemButton> m_maximizeButton; QuickStandardSystemButton *m_maximizeButton = nullptr;
QScopedPointer<QuickStandardSystemButton> m_closeButton; QuickStandardSystemButton *m_closeButton = nullptr;
QMetaObject::Connection m_windowStateChangeConnection = {}; QMetaObject::Connection m_windowStateChangeConnection = {};
QMetaObject::Connection m_windowActiveChangeConnection = {}; QMetaObject::Connection m_windowActiveChangeConnection = {};
QMetaObject::Connection m_windowTitleChangeConnection = {}; QMetaObject::Connection m_windowTitleChangeConnection = {};
bool m_extended = false; bool m_extended = false;
bool m_hideWhenClose = false; bool m_hideWhenClose = false;
QScopedPointer<QuickChromePalette> m_chromePalette; QuickChromePalette *m_chromePalette = nullptr;
bool m_closeTriggered = false; bool m_closeTriggered = false;
}; };

View File

@ -25,10 +25,10 @@
#pragma once #pragma once
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#include "quickwindowborder.h"
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class QuickWindowBorder;
class WindowBorderPainter; class WindowBorderPainter;
class FRAMELESSHELPER_QUICK_API QuickWindowBorderPrivate : public QObject class FRAMELESSHELPER_QUICK_API QuickWindowBorderPrivate : public QObject
@ -54,8 +54,8 @@ private:
void rebindWindow(); void rebindWindow();
private: private:
QPointer<QuickWindowBorder> q_ptr = nullptr; QuickWindowBorder *q_ptr = nullptr;
QScopedPointer<WindowBorderPainter> m_borderPainter; WindowBorderPainter *m_borderPainter = nullptr;
QMetaObject::Connection m_activeChangeConnection = {}; QMetaObject::Connection m_activeChangeConnection = {};
QMetaObject::Connection m_visibilityChangeConnection = {}; QMetaObject::Connection m_visibilityChangeConnection = {};
}; };

View File

@ -61,7 +61,7 @@ Q_SIGNALS:
void sourceChanged(); void sourceChanged();
private: private:
QScopedPointer<QuickImageItemPrivate> d_ptr; std::unique_ptr<QuickImageItemPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -53,7 +53,7 @@ protected:
void componentComplete() override; void componentComplete() override;
private: private:
QScopedPointer<QuickMicaMaterialPrivate> d_ptr; std::unique_ptr<QuickMicaMaterialPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -87,7 +87,7 @@ Q_SIGNALS:
void nativeBorderChanged(); void nativeBorderChanged();
private: private:
QScopedPointer<QuickWindowBorderPrivate> d_ptr; std::unique_ptr<QuickWindowBorderPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -44,7 +44,7 @@ public:
~FramelessDialog() override; ~FramelessDialog() override;
private: private:
QScopedPointer<FramelessDialogPrivate> d_ptr; std::unique_ptr<FramelessDialogPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -59,7 +59,7 @@ Q_SIGNALS:
void zoomedChanged(); void zoomedChanged();
private: private:
QScopedPointer<FramelessMainWindowPrivate> d_ptr; std::unique_ptr<FramelessMainWindowPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -59,7 +59,7 @@ Q_SIGNALS:
void zoomedChanged(); void zoomedChanged();
private: private:
QScopedPointer<FramelessWidgetPrivate> d_ptr; std::unique_ptr<FramelessWidgetPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -88,7 +88,7 @@ Q_SIGNALS:
void ready(); void ready();
private: private:
QScopedPointer<FramelessWidgetsHelperPrivate> d_ptr; std::unique_ptr<FramelessWidgetsHelperPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -25,10 +25,10 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include "framelessdialog.h"
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessDialog;
class WidgetsSharedHelper; class WidgetsSharedHelper;
class FRAMELESSHELPER_WIDGETS_API FramelessDialogPrivate : public QObject class FRAMELESSHELPER_WIDGETS_API FramelessDialogPrivate : public QObject
@ -50,8 +50,8 @@ private:
void initialize(); void initialize();
private: private:
QPointer<FramelessDialog> q_ptr = nullptr; FramelessDialog *q_ptr = nullptr;
QScopedPointer<WidgetsSharedHelper> m_helper; WidgetsSharedHelper *m_sharedHelper = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -25,10 +25,10 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include "framelessmainwindow.h"
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessMainWindow;
class WidgetsSharedHelper; class WidgetsSharedHelper;
class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject
@ -56,9 +56,9 @@ private:
void initialize(); void initialize();
private: private:
QPointer<FramelessMainWindow> q_ptr = nullptr; FramelessMainWindow *q_ptr = nullptr;
Qt::WindowState m_savedWindowState = Qt::WindowNoState; Qt::WindowState m_savedWindowState = Qt::WindowNoState;
QScopedPointer<WidgetsSharedHelper> m_helper; WidgetsSharedHelper *m_sharedHelper = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -25,10 +25,10 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include "framelesswidget.h"
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessWidget;
class WidgetsSharedHelper; class WidgetsSharedHelper;
class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject
@ -56,9 +56,9 @@ private:
void initialize(); void initialize();
private: private:
QPointer<FramelessWidget> q_ptr = nullptr; FramelessWidget *q_ptr = nullptr;
Qt::WindowState m_savedWindowState = Qt::WindowNoState; Qt::WindowState m_savedWindowState = Qt::WindowNoState;
QScopedPointer<WidgetsSharedHelper> m_helper; WidgetsSharedHelper *m_sharedHelper = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -25,12 +25,15 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include "framelesswidgetshelper.h" #include <QtCore/qvariant.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessWidgetsHelper;
struct WidgetsHelperData; struct WidgetsHelperData;
class WidgetsSharedHelper; class WidgetsSharedHelper;
class MicaMaterial;
class WindowBorderPainter;
class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject
{ {
@ -94,7 +97,7 @@ private:
Q_NODISCARD WidgetsHelperData *getWindowDataMutable() const; Q_NODISCARD WidgetsHelperData *getWindowDataMutable() const;
private: private:
QPointer<FramelessWidgetsHelper> q_ptr = nullptr; FramelessWidgetsHelper *q_ptr = nullptr;
QColor m_savedWindowBackgroundColor = {}; QColor m_savedWindowBackgroundColor = {};
bool m_blurBehindWindowEnabled = false; bool m_blurBehindWindowEnabled = false;
QPointer<QWidget> m_window = nullptr; QPointer<QWidget> m_window = nullptr;

View File

@ -25,7 +25,6 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include "standardsystembutton.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QEnterEvent; class QEnterEvent;
@ -34,6 +33,8 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class StandardSystemButton;
class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -83,7 +84,7 @@ private:
void initialize(); void initialize();
private: private:
QPointer<StandardSystemButton> q_ptr = nullptr; StandardSystemButton *q_ptr = nullptr;
Global::SystemButtonType m_buttonType = Global::SystemButtonType::Unknown; Global::SystemButtonType m_buttonType = Global::SystemButtonType::Unknown;
QString m_code = {}; QString m_code = {};
QColor m_hoverColor = {}; QColor m_hoverColor = {};

View File

@ -25,7 +25,6 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include "standardtitlebar.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QPaintEvent; class QPaintEvent;
@ -33,6 +32,7 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class StandardTitleBar;
class StandardSystemButton; class StandardSystemButton;
class ChromePalette; class ChromePalette;
@ -93,15 +93,15 @@ private:
void initialize(); void initialize();
private: private:
QPointer<StandardTitleBar> q_ptr = nullptr; StandardTitleBar *q_ptr = nullptr;
QScopedPointer<StandardSystemButton> m_minimizeButton; StandardSystemButton *m_minimizeButton = nullptr;
QScopedPointer<StandardSystemButton> m_maximizeButton; StandardSystemButton *m_maximizeButton = nullptr;
QScopedPointer<StandardSystemButton> m_closeButton; StandardSystemButton *m_closeButton = nullptr;
QPointer<QWidget> m_window = nullptr; QPointer<QWidget> m_window = nullptr;
bool m_extended = false; bool m_extended = false;
Qt::Alignment m_labelAlignment = {}; Qt::Alignment m_labelAlignment = {};
bool m_hideWhenClose = false; bool m_hideWhenClose = false;
QScopedPointer<ChromePalette> m_chromePalette; ChromePalette *m_chromePalette = nullptr;
bool m_titleLabelVisible = true; bool m_titleLabelVisible = true;
std::optional<QSize> m_windowIconSize = std::nullopt; std::optional<QSize> m_windowIconSize = std::nullopt;
bool m_windowIconVisible = false; bool m_windowIconVisible = false;

View File

@ -79,11 +79,11 @@ private:
QPointer<QScreen> m_screen = nullptr; QPointer<QScreen> m_screen = nullptr;
#endif #endif
bool m_micaEnabled = false; bool m_micaEnabled = false;
QScopedPointer<MicaMaterial> m_micaMaterial; MicaMaterial *m_micaMaterial = nullptr;
QMetaObject::Connection m_micaRedrawConnection = {}; QMetaObject::Connection m_micaRedrawConnection = {};
qreal m_screenDpr = 0.0; qreal m_screenDpr = 0.0;
QMetaObject::Connection m_screenDpiChangeConnection = {}; QMetaObject::Connection m_screenDpiChangeConnection = {};
QScopedPointer<WindowBorderPainter> m_borderPainter; WindowBorderPainter *m_borderPainter = nullptr;
QMetaObject::Connection m_borderRepaintConnection = {}; QMetaObject::Connection m_borderRepaintConnection = {};
QMetaObject::Connection m_screenChangeConnection = {}; QMetaObject::Connection m_screenChangeConnection = {};
}; };

View File

@ -100,7 +100,7 @@ Q_SIGNALS:
void iconSize2Changed(); void iconSize2Changed();
private: private:
QScopedPointer<StandardSystemButtonPrivate> d_ptr; std::unique_ptr<StandardSystemButtonPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -98,7 +98,7 @@ Q_SIGNALS:
void titleFontChanged(); void titleFontChanged();
private: private:
QScopedPointer<StandardTitleBarPrivate> d_ptr; std::unique_ptr<StandardTitleBarPrivate> d_ptr = nullptr;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

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

View File

@ -107,7 +107,7 @@ void FramelessConfig::reload(const bool force)
if (g_data()->loaded && !force) { if (g_data()->loaded && !force) {
return; return;
} }
const QScopedPointer<QSettings> configFile([]() -> QSettings * { const std::unique_ptr<QSettings> configFile([]() -> QSettings * {
if (!QCoreApplication::instance()) { if (!QCoreApplication::instance()) {
return nullptr; return nullptr;
} }
@ -118,7 +118,7 @@ void FramelessConfig::reload(const bool force)
const bool envVar = (!g_data()->disableEnvVar const bool envVar = (!g_data()->disableEnvVar
&& qEnvironmentVariableIsSet(OptionsTable[i].env.constData()) && qEnvironmentVariableIsSet(OptionsTable[i].env.constData())
&& (qEnvironmentVariableIntValue(OptionsTable[i].env.constData()) > 0)); && (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()); && configFile->value(QUtf8String(OptionsTable[i].cfg), false).toBool());
g_data()->options[i] = (envVar || cfgFile); g_data()->options[i] = (envVar || cfgFile);
} }

View File

@ -101,7 +101,7 @@ struct Win32HelperData
struct Win32Helper struct Win32Helper
{ {
QMutex mutex; QMutex mutex;
QScopedPointer<FramelessHelperWin> nativeEventFilter; std::unique_ptr<FramelessHelperWin> nativeEventFilter = nullptr;
QHash<WId, Win32HelperData> data = {}; QHash<WId, Win32HelperData> data = {};
QHash<WId, WId> fallbackTitleBarToParentWindowMapping = {}; QHash<WId, WId> fallbackTitleBarToParentWindowMapping = {};
}; };
@ -524,9 +524,9 @@ void FramelessHelperWin::addWindow(const SystemParameters &params)
data.params = params; data.params = params;
data.dpi = {Utils::getWindowDpi(windowId, true), Utils::getWindowDpi(windowId, false)}; data.dpi = {Utils::getWindowDpi(windowId, true), Utils::getWindowDpi(windowId, false)};
g_win32Helper()->data.insert(windowId, data); g_win32Helper()->data.insert(windowId, data);
if (g_win32Helper()->nativeEventFilter.isNull()) { if (!g_win32Helper()->nativeEventFilter) {
g_win32Helper()->nativeEventFilter.reset(new FramelessHelperWin); g_win32Helper()->nativeEventFilter = std::make_unique<FramelessHelperWin>();
qApp->installNativeEventFilter(g_win32Helper()->nativeEventFilter.data()); qApp->installNativeEventFilter(g_win32Helper()->nativeEventFilter.get());
} }
g_win32Helper()->mutex.unlock(); g_win32Helper()->mutex.unlock();
DEBUG.noquote() << "The DPI of window" << hwnd2str(windowId) << "is" << data.dpi; 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); g_win32Helper()->data.remove(windowId);
if (g_win32Helper()->data.isEmpty()) { if (g_win32Helper()->data.isEmpty()) {
if (!g_win32Helper()->nativeEventFilter.isNull()) { if (g_win32Helper()->nativeEventFilter) {
qApp->removeNativeEventFilter(g_win32Helper()->nativeEventFilter.data()); qApp->removeNativeEventFilter(g_win32Helper()->nativeEventFilter.get());
g_win32Helper()->nativeEventFilter.reset(); delete g_win32Helper()->nativeEventFilter.release();
} }
} }
HWND hwnd = nullptr; HWND hwnd = nullptr;

View File

@ -22,6 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "framelessmanager.h"
#include "framelessmanager_p.h" #include "framelessmanager_p.h"
#include <QtCore/qmutex.h> #include <QtCore/qmutex.h>
#include <QtCore/qcoreapplication.h> #include <QtCore/qcoreapplication.h>
@ -370,7 +371,7 @@ void FramelessManagerPrivate::initialize()
} }
FramelessManager::FramelessManager(QObject *parent) : FramelessManager::FramelessManager(QObject *parent) :
QObject(parent), d_ptr(new FramelessManagerPrivate(this)) QObject(parent), d_ptr(std::make_unique<FramelessManagerPrivate>(this))
{ {
} }

View File

@ -664,7 +664,7 @@ void MicaMaterialPrivate::prepareGraphicsResources()
} }
MicaMaterial::MicaMaterial(QObject *parent) MicaMaterial::MicaMaterial(QObject *parent)
: QObject(parent), d_ptr(new MicaMaterialPrivate(this)) : QObject(parent), d_ptr(std::make_unique<MicaMaterialPrivate>(this))
{ {
} }

View File

@ -85,18 +85,19 @@ RegistryKey::RegistryKey(const RegistryRootKey root, const QString &key, QObject
m_rootKey = root; m_rootKey = root;
m_subKey = key; m_subKey = key;
#if REGISTRYKEY_QWINREGISTRYKEY #if REGISTRYKEY_QWINREGISTRYKEY
m_registryKey.reset(new QWinRegistryKey(g_keyMap[static_cast<int>(m_rootKey)], m_subKey)); m_registryKey = std::make_unique<QWinRegistryKey>(g_keyMap[static_cast<int>(m_rootKey)], m_subKey);
if (!m_registryKey->isValid()) { if (!m_registryKey->isValid()) {
m_registryKey.reset(); delete m_registryKey.release();
} }
#else #else
const QString rootKey = g_strMap[static_cast<int>(m_rootKey)]; const QString rootKey = g_strMap[static_cast<int>(m_rootKey)];
const auto lastSlashPos = m_subKey.lastIndexOf(u'\\'); 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))) { 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<QSettings>(rootKey + u'\\' + m_subKey, QSettings::NativeFormat);
} else { } else {
m_settings.reset(); delete m_settings.release();
} }
#endif #endif
} }
@ -116,9 +117,9 @@ QString RegistryKey::subKey() const
bool RegistryKey::isValid() const bool RegistryKey::isValid() const
{ {
#if REGISTRYKEY_QWINREGISTRYKEY #if REGISTRYKEY_QWINREGISTRYKEY
return (!m_registryKey.isNull() && m_registryKey->isValid()); return (m_registryKey && m_registryKey->isValid());
#else #else
return !m_settings.isNull(); return m_settings;
#endif #endif
} }

View File

@ -135,7 +135,7 @@ public:
} }
object = obj; object = obj;
keyPath = key; keyPath = key;
callback.reset(new Callback(cb)); callback = std::make_unique<Callback>(cb);
addObserver(options); addObserver(options);
} }
@ -151,20 +151,20 @@ public:
if (!object) { if (!object) {
return; return;
} }
[object removeObserver:observer forKeyPath:keyPath context:callback.data()]; [object removeObserver:observer forKeyPath:keyPath context:callback.get()];
object = nil; object = nil;
} }
private: private:
void addObserver(const NSKeyValueObservingOptions options) 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: private:
NSObject *object = nil; NSObject *object = nil;
NSString *keyPath = nil; NSString *keyPath = nil;
QScopedPointer<Callback> callback; std::unique_ptr<Callback> callback = nil;
static inline MyKeyValueObserver *observer = [[MyKeyValueObserver alloc] init]; static inline MyKeyValueObserver *observer = [[MyKeyValueObserver alloc] init];
}; };
@ -186,16 +186,16 @@ public:
static const bool isMojave = (QSysInfo::macVersion() > QSysInfo::MV_SIERRA); static const bool isMojave = (QSysInfo::macVersion() > QSysInfo::MV_SIERRA);
#endif #endif
if (isMojave) { if (isMojave) {
m_appearanceObserver.reset(new MacOSKeyValueObserver(NSApp, @"effectiveAppearance", [](){ m_appearanceObserver = std::make_unique<MacOSKeyValueObserver>(NSApp, @"effectiveAppearance", [](){
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_DEPRECATED
NSAppearance.currentAppearance = NSApp.effectiveAppearance; // FIXME: use latest API. NSAppearance.currentAppearance = NSApp.effectiveAppearance; // FIXME: use latest API.
QT_WARNING_POP QT_WARNING_POP
MacOSThemeObserver::notifySystemThemeChange(); MacOSThemeObserver::notifySystemThemeChange();
})); });
} }
m_systemColorObserver.reset(new MacOSNotificationObserver(nil, NSSystemColorsDidChangeNotification, m_systemColorObserver = std::make_unique<MacOSNotificationObserver>(nil, NSSystemColorsDidChangeNotification,
[](){ MacOSThemeObserver::notifySystemThemeChange(); })); [](){ MacOSThemeObserver::notifySystemThemeChange(); });
} }
~MacOSThemeObserver() = default; ~MacOSThemeObserver() = default;
@ -211,8 +211,8 @@ public:
} }
private: private:
QScopedPointer<MacOSNotificationObserver> m_systemColorObserver; std::unique_ptr<MacOSNotificationObserver> m_systemColorObserver = nil;
QScopedPointer<MacOSKeyValueObserver> m_appearanceObserver; std::unique_ptr<MacOSKeyValueObserver> m_appearanceObserver = nil;
}; };
class NSWindowProxy : public QObject class NSWindowProxy : public QObject

View File

@ -174,7 +174,7 @@ void WindowBorderPainterPrivate::initialize()
} }
WindowBorderPainter::WindowBorderPainter(QObject *parent) WindowBorderPainter::WindowBorderPainter(QObject *parent)
: QObject(parent), d_ptr(new WindowBorderPainterPrivate(this)) : QObject(parent), d_ptr(std::make_unique<WindowBorderPainterPrivate>(this))
{ {
} }

View File

@ -154,11 +154,11 @@ void FramelessQuickApplicationWindowPrivate::initialize()
Q_Q(FramelessQuickApplicationWindow); Q_Q(FramelessQuickApplicationWindow);
QQuickItem * const rootItem = q->contentItem(); QQuickItem * const rootItem = q->contentItem();
FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar(); FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar();
m_windowBorder.reset(new QuickWindowBorder); m_windowBorder = new QuickWindowBorder;
m_windowBorder->setParent(rootItem); m_windowBorder->setParent(rootItem);
m_windowBorder->setParentItem(rootItem); m_windowBorder->setParentItem(rootItem);
m_windowBorder->setZ(999); // Make sure it always stays on the top. 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](){ connect(q, &FramelessQuickApplicationWindow::visibilityChanged, q, [q](){
Q_EMIT q->hiddenChanged(); Q_EMIT q->hiddenChanged();
Q_EMIT q->normalChanged(); Q_EMIT q->normalChanged();
@ -170,7 +170,7 @@ void FramelessQuickApplicationWindowPrivate::initialize()
} }
FramelessQuickApplicationWindow::FramelessQuickApplicationWindow(QWindow *parent) FramelessQuickApplicationWindow::FramelessQuickApplicationWindow(QWindow *parent)
: QQuickApplicationWindow(parent), d_ptr(new FramelessQuickApplicationWindowPrivate(this)) : QQuickApplicationWindow(parent), d_ptr(std::make_unique<FramelessQuickApplicationWindowPrivate>(this))
{ {
} }

View File

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

View File

@ -154,11 +154,11 @@ void FramelessQuickWindowPrivate::initialize()
Q_Q(FramelessQuickWindow); Q_Q(FramelessQuickWindow);
QQuickItem * const rootItem = q->contentItem(); QQuickItem * const rootItem = q->contentItem();
FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar(); FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar();
m_windowBorder.reset(new QuickWindowBorder); m_windowBorder = new QuickWindowBorder;
m_windowBorder->setParent(rootItem); m_windowBorder->setParent(rootItem);
m_windowBorder->setParentItem(rootItem); m_windowBorder->setParentItem(rootItem);
m_windowBorder->setZ(999); // Make sure it always stays on the top. 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](){ connect(q, &FramelessQuickWindow::visibilityChanged, q, [q](){
Q_EMIT q->hiddenChanged(); Q_EMIT q->hiddenChanged();
Q_EMIT q->normalChanged(); Q_EMIT q->normalChanged();
@ -170,7 +170,7 @@ void FramelessQuickWindowPrivate::initialize()
} }
FramelessQuickWindow::FramelessQuickWindow(QWindow *parent) FramelessQuickWindow::FramelessQuickWindow(QWindow *parent)
: QQuickWindowQmlImpl(parent), d_ptr(new FramelessQuickWindowPrivate(this)) : QQuickWindowQmlImpl(parent), d_ptr(std::make_unique<FramelessQuickWindowPrivate>(this))
{ {
} }

View File

@ -220,7 +220,7 @@ QRect QuickImageItemPrivate::paintArea() const
} }
QuickImageItem::QuickImageItem(QQuickItem *parent) QuickImageItem::QuickImageItem(QQuickItem *parent)
: QQuickPaintedItem(parent), d_ptr(new QuickImageItemPrivate(this)) : QQuickPaintedItem(parent), d_ptr(std::make_unique<QuickImageItemPrivate>(this))
{ {
} }

View File

@ -77,11 +77,11 @@ private:
void initialize(); void initialize();
private: private:
QScopedPointer<QSGTexture> m_texture; QSGTexture *m_texture = nullptr;
QPointer<QuickMicaMaterial> m_item = nullptr; QPointer<QuickMicaMaterial> m_item = nullptr;
QSGSimpleTextureNode *m_node = nullptr; QSGSimpleTextureNode *m_node = nullptr;
QPixmap m_pixmapCache = {}; QPixmap m_pixmapCache = {};
QScopedPointer<MicaMaterial> m_micaMaterial; MicaMaterial *m_micaMaterial = nullptr;
}; };
WallpaperImageNode::WallpaperImageNode(QuickMicaMaterial *item) WallpaperImageNode::WallpaperImageNode(QuickMicaMaterial *item)
@ -101,7 +101,7 @@ void WallpaperImageNode::initialize()
g_data()->mutex.lock(); g_data()->mutex.lock();
QQuickWindow * const window = m_item->window(); QQuickWindow * const window = m_item->window();
m_micaMaterial.reset(new MicaMaterial); m_micaMaterial = new MicaMaterial(this);
m_node = new QSGSimpleTextureNode; m_node = new QSGSimpleTextureNode;
m_node->setFiltering(QSGTexture::Linear); m_node->setFiltering(QSGTexture::Linear);
@ -113,7 +113,7 @@ void WallpaperImageNode::initialize()
appendChildNode(m_node); appendChildNode(m_node);
connect(m_micaMaterial.data(), &MicaMaterial::shouldRedraw, this, [this](){ connect(m_micaMaterial, &MicaMaterial::shouldRedraw, this, [this](){
maybeGenerateWallpaperImageCache(true); maybeGenerateWallpaperImageCache(true);
}); });
connect(window, &QQuickWindow::beforeRendering, this, connect(window, &QQuickWindow::beforeRendering, this,
@ -134,8 +134,12 @@ void WallpaperImageNode::maybeGenerateWallpaperImageCache(const bool force)
m_pixmapCache.fill(kDefaultTransparentColor); m_pixmapCache.fill(kDefaultTransparentColor);
QPainter painter(&m_pixmapCache); QPainter painter(&m_pixmapCache);
m_micaMaterial->paint(&painter, desktopSize, originPoint); m_micaMaterial->paint(&painter, desktopSize, originPoint);
m_texture.reset(m_item->window()->createTextureFromImage(m_pixmapCache.toImage())); if (m_texture) {
m_node->setTexture(m_texture.data()); delete m_texture;
m_texture = nullptr;
}
m_texture = m_item->window()->createTextureFromImage(m_pixmapCache.toImage());
m_node->setTexture(m_texture);
} }
void WallpaperImageNode::maybeUpdateWallpaperImageClipRect() void WallpaperImageNode::maybeUpdateWallpaperImageClipRect()
@ -240,7 +244,7 @@ void QuickMicaMaterialPrivate::appendNode(WallpaperImageNode *node)
} }
QuickMicaMaterial::QuickMicaMaterial(QQuickItem *parent) QuickMicaMaterial::QuickMicaMaterial(QQuickItem *parent)
: QQuickItem(parent), d_ptr(new QuickMicaMaterialPrivate(this)) : QQuickItem(parent), d_ptr(std::make_unique<QuickMicaMaterialPrivate>(this))
{ {
} }

View File

@ -102,7 +102,7 @@ QColor QuickStandardSystemButton::inactiveForegroundColor() const
qreal QuickStandardSystemButton::iconSize() const qreal QuickStandardSystemButton::iconSize() const
{ {
if (m_contentItem.isNull()) { if (!m_contentItem) {
return -1; return -1;
} }
const QFont font = m_contentItem->font(); const QFont font = m_contentItem->font();
@ -271,13 +271,13 @@ void QuickStandardSystemButton::initialize()
setImplicitWidth(kDefaultSystemButtonSize.width()); setImplicitWidth(kDefaultSystemButtonSize.width());
setImplicitHeight(kDefaultSystemButtonSize.height()); setImplicitHeight(kDefaultSystemButtonSize.height());
m_contentItem.reset(new QQuickText(this)); m_contentItem = new QQuickText(this);
m_contentItem->setFont(FramelessManagerPrivate::getIconFont()); m_contentItem->setFont(FramelessManagerPrivate::getIconFont());
m_contentItem->setHAlign(QQuickText::AlignHCenter); m_contentItem->setHAlign(QQuickText::AlignHCenter);
m_contentItem->setVAlign(QQuickText::AlignVCenter); 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(); QQuickPen * const border = m_backgroundItem->border();
border->setWidth(0.0); border->setWidth(0.0);
border->setColor(kDefaultTransparentColor); border->setColor(kDefaultTransparentColor);
@ -286,8 +286,8 @@ void QuickStandardSystemButton::initialize()
updateColor(); updateColor();
setContentItem(m_contentItem.data()); setContentItem(m_contentItem);
setBackground(m_backgroundItem.data()); setBackground(m_backgroundItem);
} }
void QuickStandardSystemButton::classBegin() void QuickStandardSystemButton::classBegin()

View File

@ -74,7 +74,7 @@ void QuickStandardTitleBar::setTitleLabelAlignment(const Qt::Alignment value)
return; return;
} }
m_labelAlignment = value; m_labelAlignment = value;
QQuickAnchors * const labelAnchors = QQuickItemPrivate::get(m_windowTitleLabel.data())->anchors(); QQuickAnchors * const labelAnchors = QQuickItemPrivate::get(m_windowTitleLabel)->anchors();
//labelAnchors->setMargins(0); //labelAnchors->setMargins(0);
labelAnchors->resetFill(); labelAnchors->resetFill();
labelAnchors->resetCenterIn(); labelAnchors->resetCenterIn();
@ -93,14 +93,14 @@ void QuickStandardTitleBar::setTitleLabelAlignment(const Qt::Alignment value)
} }
if (m_labelAlignment & Qt::AlignLeft) { if (m_labelAlignment & Qt::AlignLeft) {
if (m_windowIcon->isVisible()) { if (m_windowIcon->isVisible()) {
labelAnchors->setLeft(QQuickItemPrivate::get(m_windowIcon.data())->right()); labelAnchors->setLeft(QQuickItemPrivate::get(m_windowIcon)->right());
} else { } else {
labelAnchors->setLeft(titleBarPriv->left()); labelAnchors->setLeft(titleBarPriv->left());
} }
labelAnchors->setLeftMargin(kDefaultTitleBarContentsMargin); labelAnchors->setLeftMargin(kDefaultTitleBarContentsMargin);
} }
if (m_labelAlignment & Qt::AlignRight) { if (m_labelAlignment & Qt::AlignRight) {
labelAnchors->setRight(QQuickItemPrivate::get(m_systemButtonsRow.data())->left()); labelAnchors->setRight(QQuickItemPrivate::get(m_systemButtonsRow)->left());
labelAnchors->setRightMargin(kDefaultTitleBarContentsMargin); labelAnchors->setRightMargin(kDefaultTitleBarContentsMargin);
} }
if (m_labelAlignment & Qt::AlignVCenter) { if (m_labelAlignment & Qt::AlignVCenter) {
@ -118,22 +118,22 @@ void QuickStandardTitleBar::setTitleLabelAlignment(const Qt::Alignment value)
QQuickLabel *QuickStandardTitleBar::titleLabel() const QQuickLabel *QuickStandardTitleBar::titleLabel() const
{ {
return m_windowTitleLabel.data(); return m_windowTitleLabel;
} }
QuickStandardSystemButton *QuickStandardTitleBar::minimizeButton() const QuickStandardSystemButton *QuickStandardTitleBar::minimizeButton() const
{ {
return m_minimizeButton.data(); return m_minimizeButton;
} }
QuickStandardSystemButton *QuickStandardTitleBar::maximizeButton() const QuickStandardSystemButton *QuickStandardTitleBar::maximizeButton() const
{ {
return m_maximizeButton.data(); return m_maximizeButton;
} }
QuickStandardSystemButton *QuickStandardTitleBar::closeButton() const QuickStandardSystemButton *QuickStandardTitleBar::closeButton() const
{ {
return m_closeButton.data(); return m_closeButton;
} }
bool QuickStandardTitleBar::isExtended() const bool QuickStandardTitleBar::isExtended() const
@ -167,7 +167,7 @@ void QuickStandardTitleBar::setHideWhenClose(const bool value)
QuickChromePalette *QuickStandardTitleBar::chromePalette() const QuickChromePalette *QuickStandardTitleBar::chromePalette() const
{ {
return m_chromePalette.data(); return m_chromePalette;
} }
QSizeF QuickStandardTitleBar::windowIconSize() const QSizeF QuickStandardTitleBar::windowIconSize() const
@ -207,9 +207,9 @@ void QuickStandardTitleBar::setWindowIconVisible(const bool value)
return; return;
} }
m_windowIcon->setVisible(value); m_windowIcon->setVisible(value);
QQuickAnchors *labelAnchors = QQuickItemPrivate::get(m_windowTitleLabel.data())->anchors(); QQuickAnchors *labelAnchors = QQuickItemPrivate::get(m_windowTitleLabel)->anchors();
if (value) { if (value) {
labelAnchors->setLeft(QQuickItemPrivate::get(m_windowIcon.data())->right()); labelAnchors->setLeft(QQuickItemPrivate::get(m_windowIcon)->right());
} else { } else {
labelAnchors->setLeft(QQuickItemPrivate::get(this)->left()); labelAnchors->setLeft(QQuickItemPrivate::get(this)->left());
} }
@ -241,7 +241,7 @@ void QuickStandardTitleBar::updateMaximizeButton()
} }
const bool max = (w->visibility() == QQuickWindow::Maximized); const bool max = (w->visibility() == QQuickWindow::Maximized);
m_maximizeButton->setButtonType(max ? QuickGlobal::SystemButtonType::Restore : QuickGlobal::SystemButtonType::Maximize); m_maximizeButton->setButtonType(max ? QuickGlobal::SystemButtonType::Restore : QuickGlobal::SystemButtonType::Maximize);
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_maximizeButton.data()))->setText(max ? tr("Restore") : tr("Maximize")); qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_maximizeButton))->setText(max ? tr("Restore") : tr("Maximize"));
} }
void QuickStandardTitleBar::updateTitleLabelText() void QuickStandardTitleBar::updateTitleLabelText()
@ -342,8 +342,8 @@ void QuickStandardTitleBar::clickCloseButton()
void QuickStandardTitleBar::retranslateUi() void QuickStandardTitleBar::retranslateUi()
{ {
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_minimizeButton.data()))->setText(tr("Minimize")); qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_minimizeButton))->setText(tr("Minimize"));
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_maximizeButton.data()))->setText([this]() -> QString { qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_maximizeButton))->setText([this]() -> QString {
if (const QQuickWindow * const w = window()) { if (const QQuickWindow * const w = window()) {
if (w->visibility() == QQuickWindow::Maximized) { if (w->visibility() == QQuickWindow::Maximized) {
return tr("Restore"); return tr("Restore");
@ -351,7 +351,7 @@ void QuickStandardTitleBar::retranslateUi()
} }
return tr("Maximize"); return tr("Maximize");
}()); }());
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_closeButton.data()))->setText(tr("Close")); qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_closeButton))->setText(tr("Close"));
} }
void QuickStandardTitleBar::updateWindowIcon() void QuickStandardTitleBar::updateWindowIcon()
@ -445,7 +445,7 @@ QRect QuickStandardTitleBar::windowIconRect() const
bool QuickStandardTitleBar::windowIconVisible_real() 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 false;
} }
return true; return true;
@ -465,10 +465,10 @@ void QuickStandardTitleBar::initialize()
setClip(true); setClip(true);
setAntialiasing(true); setAntialiasing(true);
m_chromePalette.reset(new QuickChromePalette(this)); m_chromePalette = new QuickChromePalette(this);
connect(m_chromePalette.data(), &ChromePalette::titleBarColorChanged, connect(m_chromePalette, &ChromePalette::titleBarColorChanged,
this, &QuickStandardTitleBar::updateTitleBarColor); this, &QuickStandardTitleBar::updateTitleBarColor);
connect(m_chromePalette.data(), &ChromePalette::chromeButtonColorChanged, connect(m_chromePalette, &ChromePalette::chromeButtonColorChanged,
this, &QuickStandardTitleBar::updateChromeButtonColor); this, &QuickStandardTitleBar::updateChromeButtonColor);
QQuickPen * const b = border(); QQuickPen * const b = border();
@ -478,32 +478,31 @@ void QuickStandardTitleBar::initialize()
const QQuickItemPrivate * const thisPriv = QQuickItemPrivate::get(this); const QQuickItemPrivate * const thisPriv = QQuickItemPrivate::get(this);
m_windowIcon.reset(new QuickImageItem(this)); m_windowIcon = new QuickImageItem(this);
QQuickAnchors * const iconAnchors = QQuickItemPrivate::get(m_windowIcon.data())->anchors(); QQuickAnchors * const iconAnchors = QQuickItemPrivate::get(m_windowIcon)->anchors();
iconAnchors->setLeft(thisPriv->left()); iconAnchors->setLeft(thisPriv->left());
iconAnchors->setLeftMargin(kDefaultTitleBarContentsMargin); iconAnchors->setLeftMargin(kDefaultTitleBarContentsMargin);
iconAnchors->setVerticalCenter(thisPriv->verticalCenter()); iconAnchors->setVerticalCenter(thisPriv->verticalCenter());
connect(m_windowIcon.data(), &QuickImageItem::visibleChanged, this, &QuickStandardTitleBar::windowIconVisibleChanged); connect(m_windowIcon, &QuickImageItem::visibleChanged, this, &QuickStandardTitleBar::windowIconVisibleChanged);
connect(m_windowIcon.data(), &QuickImageItem::sourceChanged, this, &QuickStandardTitleBar::windowIconChanged); connect(m_windowIcon, &QuickImageItem::sourceChanged, this, &QuickStandardTitleBar::windowIconChanged);
// ### TODO: QuickImageItem::sizeChanged() connect(m_windowIcon, &QuickImageItem::widthChanged, this, &QuickStandardTitleBar::windowIconSizeChanged);
connect(m_windowIcon.data(), &QuickImageItem::widthChanged, this, &QuickStandardTitleBar::windowIconSizeChanged); connect(m_windowIcon, &QuickImageItem::heightChanged, this, &QuickStandardTitleBar::windowIconSizeChanged);
connect(m_windowIcon.data(), &QuickImageItem::heightChanged, this, &QuickStandardTitleBar::windowIconSizeChanged);
m_windowTitleLabel.reset(new QQuickLabel(this)); m_windowTitleLabel = new QQuickLabel(this);
QFont f = m_windowTitleLabel->font(); QFont f = m_windowTitleLabel->font();
f.setPointSize(kDefaultTitleBarFontPointSize); f.setPointSize(kDefaultTitleBarFontPointSize);
m_windowTitleLabel->setFont(f); m_windowTitleLabel->setFont(f);
m_systemButtonsRow.reset(new QQuickRow(this)); m_systemButtonsRow = new QQuickRow(this);
QQuickAnchors * const rowAnchors = QQuickItemPrivate::get(m_systemButtonsRow.data())->anchors(); QQuickAnchors * const rowAnchors = QQuickItemPrivate::get(m_systemButtonsRow)->anchors();
rowAnchors->setTop(thisPriv->top()); rowAnchors->setTop(thisPriv->top());
rowAnchors->setRight(thisPriv->right()); rowAnchors->setRight(thisPriv->right());
m_minimizeButton.reset(new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Minimize, m_systemButtonsRow.data())); m_minimizeButton = new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Minimize, m_systemButtonsRow);
connect(m_minimizeButton.data(), &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMinimizeButton); connect(m_minimizeButton, &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMinimizeButton);
m_maximizeButton.reset(new QuickStandardSystemButton(m_systemButtonsRow.data())); m_maximizeButton = new QuickStandardSystemButton(m_systemButtonsRow);
connect(m_maximizeButton.data(), &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMaximizeButton); connect(m_maximizeButton, &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickMaximizeButton);
m_closeButton.reset(new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Close, m_systemButtonsRow.data())); m_closeButton = new QuickStandardSystemButton(QuickGlobal::SystemButtonType::Close, m_systemButtonsRow);
connect(m_closeButton.data(), &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickCloseButton); connect(m_closeButton, &QuickStandardSystemButton::clicked, this, &QuickStandardTitleBar::clickCloseButton);
setWindowIconSize(kDefaultWindowIconSize); setWindowIconSize(kDefaultWindowIconSize);
setWindowIconVisible(false); setWindowIconVisible(false);

View File

@ -117,7 +117,7 @@ const QuickWindowBorderPrivate *QuickWindowBorderPrivate::get(const QuickWindowB
void QuickWindowBorderPrivate::paint(QPainter *painter) const void QuickWindowBorderPrivate::paint(QPainter *painter) const
{ {
Q_ASSERT(painter); Q_ASSERT(painter);
if (!painter || m_borderPainter.isNull()) { if (!painter || !m_borderPainter) {
return; return;
} }
Q_Q(const QuickWindowBorder); Q_Q(const QuickWindowBorder);
@ -149,18 +149,18 @@ void QuickWindowBorderPrivate::initialize()
// some very thin lines that are too fragile. // some very thin lines that are too fragile.
q->setAntialiasing(false); q->setAntialiasing(false);
m_borderPainter.reset(new WindowBorderPainter); m_borderPainter = new WindowBorderPainter(this);
connect(m_borderPainter.data(), &WindowBorderPainter::thicknessChanged, connect(m_borderPainter, &WindowBorderPainter::thicknessChanged,
q, &QuickWindowBorder::thicknessChanged); q, &QuickWindowBorder::thicknessChanged);
connect(m_borderPainter.data(), &WindowBorderPainter::edgesChanged, connect(m_borderPainter, &WindowBorderPainter::edgesChanged,
q, &QuickWindowBorder::edgesChanged); q, &QuickWindowBorder::edgesChanged);
connect(m_borderPainter.data(), &WindowBorderPainter::activeColorChanged, connect(m_borderPainter, &WindowBorderPainter::activeColorChanged,
q, &QuickWindowBorder::activeColorChanged); q, &QuickWindowBorder::activeColorChanged);
connect(m_borderPainter.data(), &WindowBorderPainter::inactiveColorChanged, connect(m_borderPainter, &WindowBorderPainter::inactiveColorChanged,
q, &QuickWindowBorder::inactiveColorChanged); q, &QuickWindowBorder::inactiveColorChanged);
connect(m_borderPainter.data(), &WindowBorderPainter::nativeBorderChanged, connect(m_borderPainter, &WindowBorderPainter::nativeBorderChanged,
q, &QuickWindowBorder::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() void QuickWindowBorderPrivate::rebindWindow()
@ -192,7 +192,7 @@ void QuickWindowBorderPrivate::rebindWindow()
} }
QuickWindowBorder::QuickWindowBorder(QQuickItem *parent) QuickWindowBorder::QuickWindowBorder(QQuickItem *parent)
: QQuickPaintedItem(parent), d_ptr(new QuickWindowBorderPrivate(this)) : QQuickPaintedItem(parent), d_ptr(std::make_unique<QuickWindowBorderPrivate>(this))
{ {
} }
@ -207,57 +207,57 @@ void QuickWindowBorder::paint(QPainter *painter)
qreal QuickWindowBorder::thickness() const qreal QuickWindowBorder::thickness() const
{ {
Q_D(const QuickWindowBorder); 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 QuickGlobal::WindowEdges QuickWindowBorder::edges() const
{ {
Q_D(const QuickWindowBorder); Q_D(const QuickWindowBorder);
return (d->m_borderPainter.isNull() ? QuickGlobal::WindowEdges() return ((d->m_borderPainter == nullptr) ? QuickGlobal::WindowEdges()
: edgesToQuickEdges(d->m_borderPainter->edges())); : edgesToQuickEdges(d->m_borderPainter->edges()));
} }
QColor QuickWindowBorder::activeColor() const QColor QuickWindowBorder::activeColor() const
{ {
Q_D(const QuickWindowBorder); 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 QColor QuickWindowBorder::inactiveColor() const
{ {
Q_D(const QuickWindowBorder); 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 qreal QuickWindowBorder::nativeThickness() const
{ {
Q_D(const QuickWindowBorder); 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 QuickGlobal::WindowEdges QuickWindowBorder::nativeEdges() const
{ {
Q_D(const QuickWindowBorder); Q_D(const QuickWindowBorder);
return (d->m_borderPainter.isNull() ? QuickGlobal::WindowEdges() return ((d->m_borderPainter == nullptr) ? QuickGlobal::WindowEdges()
: edgesToQuickEdges(d->m_borderPainter->nativeEdges())); : edgesToQuickEdges(d->m_borderPainter->nativeEdges()));
} }
QColor QuickWindowBorder::nativeActiveColor() const QColor QuickWindowBorder::nativeActiveColor() const
{ {
Q_D(const QuickWindowBorder); 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 QColor QuickWindowBorder::nativeInactiveColor() const
{ {
Q_D(const QuickWindowBorder); 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) void QuickWindowBorder::setThickness(const qreal value)
{ {
Q_D(QuickWindowBorder); Q_D(QuickWindowBorder);
if (d->m_borderPainter.isNull()) { if (!d->m_borderPainter) {
return; return;
} }
if (qFuzzyCompare(thickness(), value)) { if (qFuzzyCompare(thickness(), value)) {
@ -269,7 +269,7 @@ void QuickWindowBorder::setThickness(const qreal value)
void QuickWindowBorder::setEdges(const QuickGlobal::WindowEdges value) void QuickWindowBorder::setEdges(const QuickGlobal::WindowEdges value)
{ {
Q_D(QuickWindowBorder); Q_D(QuickWindowBorder);
if (d->m_borderPainter.isNull()) { if (!d->m_borderPainter) {
return; return;
} }
if (edges() == value) { if (edges() == value) {
@ -281,7 +281,7 @@ void QuickWindowBorder::setEdges(const QuickGlobal::WindowEdges value)
void QuickWindowBorder::setActiveColor(const QColor &value) void QuickWindowBorder::setActiveColor(const QColor &value)
{ {
Q_D(QuickWindowBorder); Q_D(QuickWindowBorder);
if (d->m_borderPainter.isNull()) { if (!d->m_borderPainter) {
return; return;
} }
if (activeColor() == value) { if (activeColor() == value) {
@ -293,7 +293,7 @@ void QuickWindowBorder::setActiveColor(const QColor &value)
void QuickWindowBorder::setInactiveColor(const QColor &value) void QuickWindowBorder::setInactiveColor(const QColor &value)
{ {
Q_D(QuickWindowBorder); Q_D(QuickWindowBorder);
if (d->m_borderPainter.isNull()) { if (!d->m_borderPainter) {
return; return;
} }
if (inactiveColor() == value) { if (inactiveColor() == value) {

View File

@ -80,17 +80,17 @@ void FramelessDialogPrivate::initialize()
{ {
Q_Q(FramelessDialog); Q_Q(FramelessDialog);
FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar(); FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar();
m_helper.reset(new WidgetsSharedHelper(this)); m_sharedHelper = new WidgetsSharedHelper(this);
m_helper->setup(q); m_sharedHelper->setup(q);
} }
WidgetsSharedHelper *FramelessDialogPrivate::widgetsSharedHelper() const WidgetsSharedHelper *FramelessDialogPrivate::widgetsSharedHelper() const
{ {
return (m_helper.isNull() ? nullptr : m_helper.data()); return m_sharedHelper;
} }
FramelessDialog::FramelessDialog(QWidget *parent) FramelessDialog::FramelessDialog(QWidget *parent)
: QDialog(parent), d_ptr(new FramelessDialogPrivate(this)) : QDialog(parent), d_ptr(std::make_unique<FramelessDialogPrivate>(this))
{ {
} }

View File

@ -80,8 +80,8 @@ void FramelessMainWindowPrivate::initialize()
{ {
Q_Q(FramelessMainWindow); Q_Q(FramelessMainWindow);
FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar(); FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar();
m_helper.reset(new WidgetsSharedHelper(this)); m_sharedHelper = new WidgetsSharedHelper(this);
m_helper->setup(q); m_sharedHelper->setup(q);
} }
bool FramelessMainWindowPrivate::isNormal() const bool FramelessMainWindowPrivate::isNormal() const
@ -119,11 +119,11 @@ void FramelessMainWindowPrivate::toggleFullScreen()
WidgetsSharedHelper *FramelessMainWindowPrivate::widgetsSharedHelper() const WidgetsSharedHelper *FramelessMainWindowPrivate::widgetsSharedHelper() const
{ {
return (m_helper.isNull() ? nullptr : m_helper.data()); return m_sharedHelper;
} }
FramelessMainWindow::FramelessMainWindow(QWidget *parent, const Qt::WindowFlags flags) 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))
{ {
} }

View File

@ -80,8 +80,8 @@ void FramelessWidgetPrivate::initialize()
{ {
Q_Q(FramelessWidget); Q_Q(FramelessWidget);
FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar(); FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar();
m_helper.reset(new WidgetsSharedHelper(this)); m_sharedHelper = new WidgetsSharedHelper(this);
m_helper->setup(q); m_sharedHelper->setup(q);
} }
bool FramelessWidgetPrivate::isNormal() const bool FramelessWidgetPrivate::isNormal() const
@ -119,11 +119,11 @@ void FramelessWidgetPrivate::toggleFullScreen()
WidgetsSharedHelper *FramelessWidgetPrivate::widgetsSharedHelper() const WidgetsSharedHelper *FramelessWidgetPrivate::widgetsSharedHelper() const
{ {
return (m_helper.isNull() ? nullptr : m_helper.data()); return m_sharedHelper;
} }
FramelessWidget::FramelessWidget(QWidget *parent) FramelessWidget::FramelessWidget(QWidget *parent)
: QWidget(parent), d_ptr(new FramelessWidgetPrivate(this)) : QWidget(parent), d_ptr(std::make_unique<FramelessWidgetPrivate>(this))
{ {
} }

View File

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

View File

@ -399,7 +399,7 @@ void StandardSystemButtonPrivate::initialize()
} }
StandardSystemButton::StandardSystemButton(QWidget *parent) StandardSystemButton::StandardSystemButton(QWidget *parent)
: QAbstractButton(parent), d_ptr(new StandardSystemButtonPrivate(this)) : QAbstractButton(parent), d_ptr(std::make_unique<StandardSystemButtonPrivate>(this))
{ {
} }

View File

@ -129,7 +129,7 @@ void StandardTitleBarPrivate::setHideWhenClose(const bool value)
ChromePalette *StandardTitleBarPrivate::chromePalette() const ChromePalette *StandardTitleBarPrivate::chromePalette() const
{ {
return m_chromePalette.data(); return m_chromePalette;
} }
void StandardTitleBarPrivate::paintTitleBar(QPaintEvent *event) void StandardTitleBarPrivate::paintTitleBar(QPaintEvent *event)
@ -139,7 +139,7 @@ void StandardTitleBarPrivate::paintTitleBar(QPaintEvent *event)
return; return;
} }
Q_Q(StandardTitleBar); Q_Q(StandardTitleBar);
if (!m_window || m_chromePalette.isNull()) { if (!m_window || !m_chromePalette) {
return; return;
} }
const bool active = m_window->isActiveWindow(); const bool active = m_window->isActiveWindow();
@ -442,10 +442,10 @@ void StandardTitleBarPrivate::initialize()
{ {
Q_Q(StandardTitleBar); Q_Q(StandardTitleBar);
m_window = (q->nativeParentWidget() ? q->nativeParentWidget() : q->window()); m_window = (q->nativeParentWidget() ? q->nativeParentWidget() : q->window());
m_chromePalette.reset(new ChromePalette(this)); m_chromePalette = new ChromePalette(this);
connect(m_chromePalette.data(), &ChromePalette::titleBarColorChanged, connect(m_chromePalette, &ChromePalette::titleBarColorChanged,
this, &StandardTitleBarPrivate::updateTitleBarColor); this, &StandardTitleBarPrivate::updateTitleBarColor);
connect(m_chromePalette.data(), &ChromePalette::chromeButtonColorChanged, connect(m_chromePalette, &ChromePalette::chromeButtonColorChanged,
this, &StandardTitleBarPrivate::updateChromeButtonColor); this, &StandardTitleBarPrivate::updateChromeButtonColor);
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
q->setFixedHeight(kDefaultTitleBarHeight); q->setFixedHeight(kDefaultTitleBarHeight);
@ -457,19 +457,19 @@ void StandardTitleBarPrivate::initialize()
Q_UNUSED(title); Q_UNUSED(title);
q->update(); q->update();
}); });
m_minimizeButton.reset(new StandardSystemButton(SystemButtonType::Minimize, q)); m_minimizeButton = new StandardSystemButton(SystemButtonType::Minimize, q);
connect(m_minimizeButton.data(), &StandardSystemButton::clicked, m_window, &QWidget::showMinimized); connect(m_minimizeButton, &StandardSystemButton::clicked, m_window, &QWidget::showMinimized);
m_maximizeButton.reset(new StandardSystemButton(SystemButtonType::Maximize, q)); m_maximizeButton = new StandardSystemButton(SystemButtonType::Maximize, q);
updateMaximizeButton(); updateMaximizeButton();
connect(m_maximizeButton.data(), &StandardSystemButton::clicked, this, [this](){ connect(m_maximizeButton, &StandardSystemButton::clicked, this, [this](){
if (m_window->isMaximized()) { if (m_window->isMaximized()) {
m_window->showNormal(); m_window->showNormal();
} else { } else {
m_window->showMaximized(); m_window->showMaximized();
} }
}); });
m_closeButton.reset(new StandardSystemButton(SystemButtonType::Close, q)); m_closeButton = new StandardSystemButton(SystemButtonType::Close, q);
connect(m_closeButton.data(), &StandardSystemButton::clicked, this, [this](){ connect(m_closeButton, &StandardSystemButton::clicked, this, [this](){
if (m_hideWhenClose) { if (m_hideWhenClose) {
m_window->hide(); m_window->hide();
} else { } else {
@ -482,9 +482,9 @@ void StandardTitleBarPrivate::initialize()
const auto systemButtonsInnerLayout = new QHBoxLayout; const auto systemButtonsInnerLayout = new QHBoxLayout;
systemButtonsInnerLayout->setSpacing(0); systemButtonsInnerLayout->setSpacing(0);
systemButtonsInnerLayout->setContentsMargins(0, 0, 0, 0); systemButtonsInnerLayout->setContentsMargins(0, 0, 0, 0);
systemButtonsInnerLayout->addWidget(m_minimizeButton.data()); systemButtonsInnerLayout->addWidget(m_minimizeButton);
systemButtonsInnerLayout->addWidget(m_maximizeButton.data()); systemButtonsInnerLayout->addWidget(m_maximizeButton);
systemButtonsInnerLayout->addWidget(m_closeButton.data()); systemButtonsInnerLayout->addWidget(m_closeButton);
const auto systemButtonsOuterLayout = new QVBoxLayout; const auto systemButtonsOuterLayout = new QVBoxLayout;
systemButtonsOuterLayout->setSpacing(0); systemButtonsOuterLayout->setSpacing(0);
systemButtonsOuterLayout->setContentsMargins(0, 0, 0, 0); systemButtonsOuterLayout->setContentsMargins(0, 0, 0, 0);
@ -504,7 +504,7 @@ void StandardTitleBarPrivate::initialize()
} }
StandardTitleBar::StandardTitleBar(QWidget *parent) StandardTitleBar::StandardTitleBar(QWidget *parent)
: QWidget(parent), d_ptr(new StandardTitleBarPrivate(this)) : QWidget(parent), d_ptr(std::make_unique<StandardTitleBarPrivate>(this))
{ {
} }
@ -525,19 +525,19 @@ void StandardTitleBar::setTitleLabelAlignment(const Qt::Alignment value)
StandardSystemButton *StandardTitleBar::minimizeButton() const StandardSystemButton *StandardTitleBar::minimizeButton() const
{ {
Q_D(const StandardTitleBar); Q_D(const StandardTitleBar);
return d->m_minimizeButton.data(); return d->m_minimizeButton;
} }
StandardSystemButton *StandardTitleBar::maximizeButton() const StandardSystemButton *StandardTitleBar::maximizeButton() const
{ {
Q_D(const StandardTitleBar); Q_D(const StandardTitleBar);
return d->m_maximizeButton.data(); return d->m_maximizeButton;
} }
StandardSystemButton *StandardTitleBar::closeButton() const StandardSystemButton *StandardTitleBar::closeButton() const
{ {
Q_D(const StandardTitleBar); Q_D(const StandardTitleBar);
return d->m_closeButton.data(); return d->m_closeButton;
} }
bool StandardTitleBar::isExtended() const bool StandardTitleBar::isExtended() const

View File

@ -71,23 +71,23 @@ void WidgetsSharedHelper::setup(QWidget *widget)
return; return;
} }
m_targetWidget = widget; m_targetWidget = widget;
m_borderPainter.reset(new WindowBorderPainter); m_borderPainter = new WindowBorderPainter(this);
if (m_borderRepaintConnection) { if (m_borderRepaintConnection) {
disconnect(m_borderRepaintConnection); disconnect(m_borderRepaintConnection);
m_borderRepaintConnection = {}; m_borderRepaintConnection = {};
} }
m_borderRepaintConnection = connect(m_borderPainter.data(), m_borderRepaintConnection = connect(m_borderPainter,
&WindowBorderPainter::shouldRepaint, this, [this](){ &WindowBorderPainter::shouldRepaint, this, [this](){
if (m_targetWidget) { if (m_targetWidget) {
m_targetWidget->update(); m_targetWidget->update();
} }
}); });
m_micaMaterial.reset(new MicaMaterial); m_micaMaterial = new MicaMaterial(this);
if (m_micaRedrawConnection) { if (m_micaRedrawConnection) {
disconnect(m_micaRedrawConnection); disconnect(m_micaRedrawConnection);
m_micaRedrawConnection = {}; m_micaRedrawConnection = {};
} }
m_micaRedrawConnection = connect(m_micaMaterial.data(), &MicaMaterial::shouldRedraw, m_micaRedrawConnection = connect(m_micaMaterial, &MicaMaterial::shouldRedraw,
this, [this](){ this, [this](){
if (m_targetWidget) { if (m_targetWidget) {
m_targetWidget->update(); m_targetWidget->update();
@ -129,12 +129,12 @@ void WidgetsSharedHelper::setMicaEnabled(const bool value)
MicaMaterial *WidgetsSharedHelper::rawMicaMaterial() const MicaMaterial *WidgetsSharedHelper::rawMicaMaterial() const
{ {
return (m_micaMaterial.isNull() ? nullptr : m_micaMaterial.data()); return m_micaMaterial;
} }
WindowBorderPainter *WidgetsSharedHelper::rawWindowBorder() const WindowBorderPainter *WidgetsSharedHelper::rawWindowBorder() const
{ {
return (m_borderPainter.isNull() ? nullptr : m_borderPainter.data()); return m_borderPainter;
} }
bool WidgetsSharedHelper::eventFilter(QObject *object, QEvent *event) bool WidgetsSharedHelper::eventFilter(QObject *object, QEvent *event)
@ -219,7 +219,7 @@ void WidgetsSharedHelper::paintEventHandler(QPaintEvent *event)
m_targetWidget->mapToGlobal(QPoint(0, 0))); m_targetWidget->mapToGlobal(QPoint(0, 0)));
} }
if ((Utils::windowStatesToWindowState(m_targetWidget->windowState()) == Qt::WindowNoState) if ((Utils::windowStatesToWindowState(m_targetWidget->windowState()) == Qt::WindowNoState)
&& !m_borderPainter.isNull()) { && m_borderPainter) {
QPainter painter(m_targetWidget); QPainter painter(m_targetWidget);
m_borderPainter->paint(&painter, m_targetWidget->size(), m_targetWidget->isActiveWindow()); m_borderPainter->paint(&painter, m_targetWidget->size(), m_targetWidget->isActiveWindow());
} }
@ -254,8 +254,8 @@ void WidgetsSharedHelper::handleScreenChanged(QScreen *screen)
return; return;
} }
m_screenDpr = currentDpr; m_screenDpr = currentDpr;
if (m_micaEnabled && !m_micaMaterial.isNull()) { if (m_micaEnabled && m_micaMaterial) {
MicaMaterialPrivate::get(m_micaMaterial.data())->maybeGenerateBlurredWallpaper(true); MicaMaterialPrivate::get(m_micaMaterial)->maybeGenerateBlurredWallpaper(true);
} }
}); });
} }