From 8e09ee2f139b893f465599a21328561123eaa82d Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 20 Sep 2019 13:31:35 +0200 Subject: [PATCH] Replace shared_ptr with unique_ptr where reasonable and add comments --- ScreenPlay/app.cpp | 28 ++++++++++++---------------- ScreenPlay/app.h | 6 +++--- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index 1a149c90..b380e172 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -9,6 +9,12 @@ App::App() QGuiApplication::setApplicationName("ScreenPlay"); QGuiApplication::setApplicationVersion("0.3.0"); QGuiApplication::setQuitOnLastWindowClosed(false); + QGuiApplication::setWindowIcon(QIcon(":/assets/icons/favicon.ico")); + + QQuickWindow::setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); + + // Qt < 6.0 needs this init QtWebEngine + QtWebEngine::initialize(); qRegisterMetaType(); qRegisterMetaType(); @@ -22,11 +28,6 @@ App::App() qRegisterMetaType(); qRegisterMetaType(); - QGuiApplication::setWindowIcon(QIcon(":/assets/icons/favicon.ico")); - - // Qt < 6.0 needs this init QtWebEngine - QtWebEngine::initialize(); - m_globalVariables = make_shared(); m_installedListModel = make_shared(m_globalVariables); m_installedListFilter = make_shared(m_installedListModel); @@ -34,19 +35,14 @@ App::App() m_profileListModel = make_shared(m_globalVariables); m_sdkConnector = make_shared(); m_settings = make_shared(m_globalVariables); - m_create = make_shared(m_globalVariables); - m_util = make_shared(new QNetworkAccessManager(this)); - m_screenPlayManager = make_shared(m_globalVariables, m_monitorListModel, m_sdkConnector); + m_create = make_unique(m_globalVariables); + m_util = make_unique(new QNetworkAccessManager(this)); + m_screenPlayManager = make_unique(m_globalVariables, m_monitorListModel, m_sdkConnector); + + // When the installed storage path changed QObject::connect(m_settings.get(), &Settings::resetInstalledListmodel, m_installedListModel.get(), &InstalledListModel::reset); - // Instead of setting "renderType: Text.NativeRendering" every time - // we can set it here once :) - QQuickWindow::setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); - - - + // Init after we have the paths from settings m_installedListModel->init(); - } - diff --git a/ScreenPlay/app.h b/ScreenPlay/app.h index 356183eb..5611e6a9 100644 --- a/ScreenPlay/app.h +++ b/ScreenPlay/app.h @@ -214,9 +214,9 @@ public slots: } private: - shared_ptr m_create; - shared_ptr m_screenPlayManager; - shared_ptr m_util; + unique_ptr m_create; + unique_ptr m_screenPlayManager; + unique_ptr m_util; shared_ptr m_globalVariables; shared_ptr m_settings;