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.
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
// 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> dialog(new Dialog);
const auto dialog = std::make_unique<Dialog>();
dialog->show();
const int exec = QCoreApplication::exec();

View File

@ -40,7 +40,7 @@ int main(int argc, char *argv[])
// of any Q(Core|Gui)Application instances.
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
// 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> mainWindow(new MainWindow);
const auto mainWindow = std::make_unique<MainWindow>();
mainWindow->show();
const int exec = QCoreApplication::exec();

View File

@ -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);

View File

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

View File

@ -77,7 +77,7 @@ int main(int argc, char *argv[])
// of any Q(Core|Gui)Application instances.
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
// 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> mainWindow(new MainWindow);
const auto mainWindow = std::make_unique<MainWindow>();
mainWindow->show();
const int exec = QCoreApplication::exec();

View File

@ -52,7 +52,7 @@ int main(int argc, char *argv[])
// of any Q(Core|Gui)Application instances.
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
// 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<QQmlApplicationEngine> engine(new QQmlApplicationEngine);
const auto engine = std::make_unique<QQmlApplicationEngine>();
#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<QuickSettings>("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> homePage(new HomePage(engine.data()));
const auto homePage = std::make_unique<HomePage>(engine.get());
homePage->show();
#endif

View File

@ -40,8 +40,8 @@
static QString g_app = {};
static bool g_logError = false;
static QScopedPointer<QFile> g_logFile;
static QScopedPointer<QTextStream> g_logStream;
static std::unique_ptr<QFile> g_logFile = nullptr;
static std::unique_ptr<QTextStream> 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<QFile>();
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<QTextStream>();
g_logStream->setDevice(g_logFile.get());
}
(*g_logStream) << finalMessage << QT_ENDL;
}

View File

@ -28,7 +28,7 @@
#include <QtCore/qfileinfo.h>
#include <framelesshelpercore_global.h>
static QScopedPointer<QSettings> g_settings;
static std::unique_ptr<QSettings> 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();

View File

@ -40,7 +40,7 @@ int main(int argc, char *argv[])
// of any Q(Core|Gui)Application instances.
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
// 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<Widget> window1(new Widget);
const auto window1 = std::make_unique<Widget>();
window1->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window1"));
window1->show();
const QScopedPointer<Widget> window2(new Widget);
const auto window2 = std::make_unique<Widget>();
window2->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window2"));
window2->show();

View File

@ -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);

View File

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

View File

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

View File

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

View File

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

View File

@ -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<ChromePalette> q_ptr = nullptr;
ChromePalette *q_ptr = nullptr;
// System-defined ones:
QColor titleBarActiveBackgroundColor_sys = {};
QColor titleBarInactiveBackgroundColor_sys = {};

View File

@ -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<FramelessManager> q_ptr = nullptr;
FramelessManager *q_ptr = nullptr;
Global::SystemTheme m_systemTheme = Global::SystemTheme::Unknown;
QColor m_accentColor = {};
#ifdef Q_OS_WINDOWS

View File

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

View File

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

View File

@ -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<WindowBorderPainter> q_ptr = nullptr;
WindowBorderPainter *q_ptr = nullptr;
std::optional<int> m_thickness = std::nullopt;
std::optional<Global::WindowEdges> m_edges = std::nullopt;
std::optional<QColor> m_activeColor = std::nullopt;

View File

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

View File

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

View File

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

View File

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

View File

@ -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<FramelessQuickHelper> q_ptr = nullptr;
FramelessQuickHelper *q_ptr = nullptr;
QColor m_savedWindowBackgroundColor = {};
bool m_blurBehindWindowEnabled = false;
std::optional<bool> m_extendIntoTitleBar = std::nullopt;

View File

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

View File

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

View File

@ -25,11 +25,12 @@
#pragma once
#include "framelesshelperquick_global.h"
#include "quickimageitem.h"
#include <QtCore/qvariant.h>
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<QuickImageItem> q_ptr = nullptr;
QuickImageItem *q_ptr = nullptr;
QVariant m_source = {};
};

View File

@ -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<QuickMicaMaterial> q_ptr = nullptr;
QuickMicaMaterial *q_ptr = nullptr;
QMetaObject::Connection m_rootWindowXChangedConnection = {};
QMetaObject::Connection m_rootWindowYChangedConnection = {};
QList<QPointer<WallpaperImageNode>> m_nodes = {};

View File

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

View File

@ -124,18 +124,18 @@ private:
private:
Qt::Alignment m_labelAlignment = {};
QScopedPointer<QuickImageItem> m_windowIcon;
QScopedPointer<QQuickLabel> m_windowTitleLabel;
QScopedPointer<QQuickRow> m_systemButtonsRow;
QScopedPointer<QuickStandardSystemButton> m_minimizeButton;
QScopedPointer<QuickStandardSystemButton> m_maximizeButton;
QScopedPointer<QuickStandardSystemButton> 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<QuickChromePalette> m_chromePalette;
QuickChromePalette *m_chromePalette = nullptr;
bool m_closeTriggered = false;
};

View File

@ -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<QuickWindowBorder> q_ptr = nullptr;
QScopedPointer<WindowBorderPainter> m_borderPainter;
QuickWindowBorder *q_ptr = nullptr;
WindowBorderPainter *m_borderPainter = nullptr;
QMetaObject::Connection m_activeChangeConnection = {};
QMetaObject::Connection m_visibilityChangeConnection = {};
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<FramelessDialog> q_ptr = nullptr;
QScopedPointer<WidgetsSharedHelper> m_helper;
FramelessDialog *q_ptr = nullptr;
WidgetsSharedHelper *m_sharedHelper = nullptr;
};
FRAMELESSHELPER_END_NAMESPACE

View File

@ -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<FramelessMainWindow> q_ptr = nullptr;
FramelessMainWindow *q_ptr = nullptr;
Qt::WindowState m_savedWindowState = Qt::WindowNoState;
QScopedPointer<WidgetsSharedHelper> m_helper;
WidgetsSharedHelper *m_sharedHelper = nullptr;
};
FRAMELESSHELPER_END_NAMESPACE

View File

@ -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<FramelessWidget> q_ptr = nullptr;
FramelessWidget *q_ptr = nullptr;
Qt::WindowState m_savedWindowState = Qt::WindowNoState;
QScopedPointer<WidgetsSharedHelper> m_helper;
WidgetsSharedHelper *m_sharedHelper = nullptr;
};
FRAMELESSHELPER_END_NAMESPACE

View File

@ -25,12 +25,15 @@
#pragma once
#include "framelesshelperwidgets_global.h"
#include "framelesswidgetshelper.h"
#include <QtCore/qvariant.h>
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<FramelessWidgetsHelper> q_ptr = nullptr;
FramelessWidgetsHelper *q_ptr = nullptr;
QColor m_savedWindowBackgroundColor = {};
bool m_blurBehindWindowEnabled = false;
QPointer<QWidget> m_window = nullptr;

View File

@ -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<StandardSystemButton> q_ptr = nullptr;
StandardSystemButton *q_ptr = nullptr;
Global::SystemButtonType m_buttonType = Global::SystemButtonType::Unknown;
QString m_code = {};
QColor m_hoverColor = {};

View File

@ -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<StandardTitleBar> q_ptr = nullptr;
QScopedPointer<StandardSystemButton> m_minimizeButton;
QScopedPointer<StandardSystemButton> m_maximizeButton;
QScopedPointer<StandardSystemButton> m_closeButton;
StandardTitleBar *q_ptr = nullptr;
StandardSystemButton *m_minimizeButton = nullptr;
StandardSystemButton *m_maximizeButton = nullptr;
StandardSystemButton *m_closeButton = nullptr;
QPointer<QWidget> m_window = nullptr;
bool m_extended = false;
Qt::Alignment m_labelAlignment = {};
bool m_hideWhenClose = false;
QScopedPointer<ChromePalette> m_chromePalette;
ChromePalette *m_chromePalette = nullptr;
bool m_titleLabelVisible = true;
std::optional<QSize> m_windowIconSize = std::nullopt;
bool m_windowIconVisible = false;

View File

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

View File

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

View File

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

View File

@ -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<ChromePalettePrivate>(this))
{
}

View File

@ -107,7 +107,7 @@ void FramelessConfig::reload(const bool force)
if (g_data()->loaded && !force) {
return;
}
const QScopedPointer<QSettings> configFile([]() -> QSettings * {
const std::unique_ptr<QSettings> 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);
}

View File

@ -101,7 +101,7 @@ struct Win32HelperData
struct Win32Helper
{
QMutex mutex;
QScopedPointer<FramelessHelperWin> nativeEventFilter;
std::unique_ptr<FramelessHelperWin> nativeEventFilter = nullptr;
QHash<WId, Win32HelperData> data = {};
QHash<WId, WId> fallbackTitleBarToParentWindowMapping = {};
};
@ -524,9 +524,9 @@ void FramelessHelperWin::addWindow(const SystemParameters &params)
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<FramelessHelperWin>();
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;

View File

@ -22,6 +22,7 @@
* SOFTWARE.
*/
#include "framelessmanager.h"
#include "framelessmanager_p.h"
#include <QtCore/qmutex.h>
#include <QtCore/qcoreapplication.h>
@ -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<FramelessManagerPrivate>(this))
{
}

View File

@ -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<MicaMaterialPrivate>(this))
{
}

View File

@ -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<int>(m_rootKey)], m_subKey));
m_registryKey = std::make_unique<QWinRegistryKey>(g_keyMap[static_cast<int>(m_rootKey)], m_subKey);
if (!m_registryKey->isValid()) {
m_registryKey.reset();
delete m_registryKey.release();
}
#else
const QString rootKey = g_strMap[static_cast<int>(m_rootKey)];
const auto lastSlashPos = m_subKey.lastIndexOf(u'\\');
m_settings.reset(new QSettings(rootKey + u'\\' + m_subKey.left(lastSlashPos), QSettings::NativeFormat));
m_settings = std::make_unique<QSettings>(rootKey + u'\\' + m_subKey.left(lastSlashPos), QSettings::NativeFormat);
if (m_settings->childGroups().contains(m_subKey.mid(lastSlashPos + 1))) {
m_settings.reset(new QSettings(rootKey + u'\\' + m_subKey, QSettings::NativeFormat));
delete m_settings.release();
m_settings = std::make_unique<QSettings>(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
}

View File

@ -135,7 +135,7 @@ public:
}
object = obj;
keyPath = key;
callback.reset(new Callback(cb));
callback = std::make_unique<Callback>(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> callback;
std::unique_ptr<Callback> 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<MacOSKeyValueObserver>(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<MacOSNotificationObserver>(nil, NSSystemColorsDidChangeNotification,
[](){ MacOSThemeObserver::notifySystemThemeChange(); });
}
~MacOSThemeObserver() = default;
@ -211,8 +211,8 @@ public:
}
private:
QScopedPointer<MacOSNotificationObserver> m_systemColorObserver;
QScopedPointer<MacOSKeyValueObserver> m_appearanceObserver;
std::unique_ptr<MacOSNotificationObserver> m_systemColorObserver = nil;
std::unique_ptr<MacOSKeyValueObserver> m_appearanceObserver = nil;
};
class NSWindowProxy : public QObject

View File

@ -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<WindowBorderPainterPrivate>(this))
{
}

View File

@ -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<FramelessQuickApplicationWindowPrivate>(this))
{
}

View File

@ -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<FramelessQuickHelperPrivate>(this))
{
}

View File

@ -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<FramelessQuickWindowPrivate>(this))
{
}

View File

@ -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<QuickImageItemPrivate>(this))
{
}

View File

@ -77,11 +77,11 @@ private:
void initialize();
private:
QScopedPointer<QSGTexture> m_texture;
QSGTexture *m_texture = nullptr;
QPointer<QuickMicaMaterial> m_item = nullptr;
QSGSimpleTextureNode *m_node = nullptr;
QPixmap m_pixmapCache = {};
QScopedPointer<MicaMaterial> 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<QuickMicaMaterialPrivate>(this))
{
}

View File

@ -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()

View File

@ -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<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()
@ -342,8 +342,8 @@ void QuickStandardTitleBar::clickCloseButton()
void QuickStandardTitleBar::retranslateUi()
{
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_minimizeButton.data()))->setText(tr("Minimize"));
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_maximizeButton.data()))->setText([this]() -> QString {
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_minimizeButton))->setText(tr("Minimize"));
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(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<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(m_closeButton.data()))->setText(tr("Close"));
qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(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);

View File

@ -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<QuickWindowBorderPrivate>(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) {

View File

@ -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<FramelessDialogPrivate>(this))
{
}

View File

@ -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<FramelessMainWindowPrivate>(this))
{
}

View File

@ -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<FramelessWidgetPrivate>(this))
{
}

View File

@ -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<FramelessWidgetsHelperPrivate>(this))
{
}

View File

@ -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<StandardSystemButtonPrivate>(this))
{
}

View File

@ -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<StandardTitleBarPrivate>(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

View File

@ -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);
}
});
}