diff --git a/ScreenPlay/main.cpp b/ScreenPlay/main.cpp index fc5c7aee..519ef94c 100644 --- a/ScreenPlay/main.cpp +++ b/ScreenPlay/main.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -9,13 +8,8 @@ #include #include #include -#include #include -#ifdef Q_OS_WIN -#include -#endif - #include "src/create.h" #include "src/installedlistfilter.h" #include "src/installedlistmodel.h" @@ -36,6 +30,7 @@ int main(int argc, char* argv[]) QGuiApplication::setApplicationVersion("0.2.0"); QGuiApplication app(argc, argv); + app.setQuitOnLastWindowClosed(false); app.setWindowIcon(QIcon(":/assets/icons/favicon.ico")); @@ -55,15 +50,15 @@ int main(int argc, char* argv[]) QMLUtilities qmlUtil; InstalledListModel installedListModel; InstalledListFilter installedListFilter(&installedListModel); - MonitorListModel monitorListModel(&app); + MonitorListModel monitorListModel; ProfileListModel profileListModel; SDKConnector sdkConnector; // Create settings in the end because for now it depends on // such things as the profile list model to complete // It will also set the m_absoluteStoragePath in profileListModel and installedListModel - Settings settings(&profileListModel, &monitorListModel, &installedListModel, &sdkConnector, &app); - ScreenPlay screenPlay(&installedListModel, &settings, &monitorListModel, &app, &sdkConnector); + Settings settings(&profileListModel, &monitorListModel, &installedListModel, &sdkConnector); + ScreenPlay screenPlay(&installedListModel, &settings, &monitorListModel, &sdkConnector); Create create(&settings, &qmlUtil); // All the list need the default path from the settings diff --git a/ScreenPlay/src/monitorlistmodel.cpp b/ScreenPlay/src/monitorlistmodel.cpp index c3cafc1a..b24ecf4f 100644 --- a/ScreenPlay/src/monitorlistmodel.cpp +++ b/ScreenPlay/src/monitorlistmodel.cpp @@ -1,17 +1,17 @@ #include "monitorlistmodel.h" -MonitorListModel::MonitorListModel(QGuiApplication* guiapp, QObject* parent) +MonitorListModel::MonitorListModel(QObject* parent) : QAbstractListModel(parent) { loadMonitors(); - m_qGuiApplication = guiapp; + m_qGuiApplication = static_cast(QGuiApplication::instance()); connect(m_qGuiApplication, &QGuiApplication::screenAdded, this, &MonitorListModel::screenAdded); connect(m_qGuiApplication, &QGuiApplication::screenRemoved, this, &MonitorListModel::screenRemoved); } QHash MonitorListModel::roleNames() const { - static const QHash roles{ + static const QHash roles { { IDRole, "monitorID" }, { NameRole, "monitorName" }, { SizeRole, "monitorSize" }, @@ -126,7 +126,6 @@ int MonitorListModel::size() void MonitorListModel::wallpaperRemoved() { - } bool MonitorListModel::getMonitorListItemAt(int position, Monitor* monitor) @@ -163,17 +162,17 @@ void MonitorListModel::reset() void MonitorListModel::setWallpaperActiveMonitor(QScreen* screen, QString fullPreviewImagePath) { -// qDebug() << fullPreviewImagePath; -// for (int i = 0; i < m_monitorList.size(); ++i) { -// if (m_monitorList.at(i).m_screen == screen) { -// m_monitorList[i].m_wallpaperPreviewPath = fullPreviewImagePath; -// } -// } -// beginResetModel(); -// endResetModel(); + // qDebug() << fullPreviewImagePath; + // for (int i = 0; i < m_monitorList.size(); ++i) { + // if (m_monitorList.at(i).m_screen == screen) { + // m_monitorList[i].m_wallpaperPreviewPath = fullPreviewImagePath; + // } + // } + // beginResetModel(); + // endResetModel(); for (int i = 0; i < m_qGuiApplication->screens().length(); ++i) { - if(m_qGuiApplication->screens().at(i) == screen){ - emit setNewActiveMonitor(i,fullPreviewImagePath); + if (m_qGuiApplication->screens().at(i) == screen) { + emit setNewActiveMonitor(i, fullPreviewImagePath); } } //emit monitorReloadCompleted(); diff --git a/ScreenPlay/src/monitorlistmodel.h b/ScreenPlay/src/monitorlistmodel.h index ff9bc21b..55085a23 100644 --- a/ScreenPlay/src/monitorlistmodel.h +++ b/ScreenPlay/src/monitorlistmodel.h @@ -25,7 +25,7 @@ class MonitorListModel : public QAbstractListModel { Q_OBJECT public: - explicit MonitorListModel(QGuiApplication* guiapp, QObject* parent = nullptr); + explicit MonitorListModel(QObject* parent = nullptr); QHash roleNames() const override; diff --git a/ScreenPlay/src/screenplay.cpp b/ScreenPlay/src/screenplay.cpp index 442c3022..07359a90 100644 --- a/ScreenPlay/src/screenplay.cpp +++ b/ScreenPlay/src/screenplay.cpp @@ -1,12 +1,12 @@ #include "screenplay.h" -ScreenPlay::ScreenPlay(InstalledListModel* ilm, Settings* set, MonitorListModel* mlm, QGuiApplication* qGuiApplication, SDKConnector* sdkc, QObject* parent) +ScreenPlay::ScreenPlay(InstalledListModel* ilm, Settings* set, MonitorListModel* mlm, SDKConnector* sdkc, QObject* parent) : QObject(parent) { m_ilm = ilm; m_settings = set; m_mlm = mlm; - m_qGuiApplication = qGuiApplication; + m_qGuiApplication = static_cast(QGuiApplication::instance()); m_sdkc = sdkc; } @@ -19,7 +19,7 @@ void ScreenPlay::createWallpaper(int monitorIndex, QUrl absoluteStoragePath, QSt } // Remove previous wallpaper - //removeWallpaperAt(monitorIndex); + removeWallpaperAt(monitorIndex); m_settings->increaseActiveWallpaperCounter(); QVector tmpMonitorIndex; @@ -96,9 +96,10 @@ void ScreenPlay::setAllWallpaperValue(QString key, QString value) void ScreenPlay::removeWallpaperAt(int at) { - Q_ASSERT(at < m_screenPlayWallpaperList.size()); - // if(m_screenPlayWallpaperList.isEmpty()) - // return; + //Q_ASSERT(m_screenPlayWallpaperList.size() < at); + + if (m_screenPlayWallpaperList.isEmpty()) + return; for (int i = 0; i < m_screenPlayWallpaperList.length(); ++i) { diff --git a/ScreenPlay/src/screenplay.h b/ScreenPlay/src/screenplay.h index 3570a636..e720954e 100644 --- a/ScreenPlay/src/screenplay.h +++ b/ScreenPlay/src/screenplay.h @@ -27,7 +27,7 @@ class ScreenPlayWidget; class ScreenPlay : public QObject { Q_OBJECT public: - explicit ScreenPlay(InstalledListModel* ilm, Settings* set, MonitorListModel* mlm, QGuiApplication* qGuiApplication, SDKConnector* sdkc, QObject* parent = nullptr); + explicit ScreenPlay(InstalledListModel* ilm, Settings* set, MonitorListModel* mlm, SDKConnector* sdkc, QObject* parent = nullptr); Settings* settings() const; @@ -94,7 +94,7 @@ public: m_appID = parent->generateID(); proArgs.append("appID=" + m_appID); proArgs.append(parent->m_settings->decoder()); - proArgs.append(QString::number(volume)); + proArgs.append(QString::number(static_cast(volume))); proArgs.append(fillMode); qDebug() << proArgs; @@ -138,7 +138,6 @@ signals: void previewImageChanged(QString previewImage); void projectSettingsListModelAt(ProjectSettingsListModel* li); void appIDChanged(QString appID); - void typeChanged(QString type); public slots: @@ -229,9 +228,8 @@ public: m_process->setProgram(parent->m_settings->getScreenPlayWidgetPath().path()); } qDebug() << m_process->program(); - connect(m_process,&QProcess::errorOccurred, this, [](QProcess::ProcessError error){ + connect(m_process, &QProcess::errorOccurred, this, [](QProcess::ProcessError error) { qDebug() << "error: " << error; - }); m_process->start(); } diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index 55639d55..eab8b48d 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -2,17 +2,16 @@ #include #include -Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, QGuiApplication* app, QObject* parent) +Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, QObject* parent) : QObject(parent) , m_version(QVersionNumber(0, 0, 1)) - , m_qSettings(QSettings(QSettings::NativeFormat, QSettings::Scope::UserScope, app->organizationName(), app->applicationName())) { m_plm = plm; m_mlm = mlm; m_ilm = ilm; m_sdkc = sdkc; - m_app = app; + m_app = static_cast(QGuiApplication::instance()); if (m_qSettings.value("language").isNull()) { auto locale = QLocale::system().uiLanguages(); @@ -25,13 +24,13 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo m_translator.load(":/translations/ScreenPlay_" + localeSplits.at(0) + ".qm"); m_qSettings.setValue("language", QVariant(localeSplits.at(0))); m_qSettings.sync(); - app->installTranslator(&m_translator); + m_app->installTranslator(&m_translator); } } else { QFile tsFile; if (tsFile.exists(":/translations/ScreenPlay_" + m_qSettings.value("language").toString() + ".qm")) { m_translator.load(":/translations/ScreenPlay_" + m_qSettings.value("language").toString() + ".qm"); - app->installTranslator(&m_translator); + m_app->installTranslator(&m_translator); } } diff --git a/ScreenPlay/src/settings.h b/ScreenPlay/src/settings.h index 7ef1c91c..4c3e3b2f 100644 --- a/ScreenPlay/src/settings.h +++ b/ScreenPlay/src/settings.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -11,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -21,8 +21,9 @@ #include #include #include -#include #include +#include +#include #include "installedlistmodel.h" #include "monitorlistmodel.h" @@ -50,7 +51,7 @@ class Settings : public QObject { Q_OBJECT public: - explicit Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, QGuiApplication* app, QObject* parent = nullptr); + explicit Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, QObject* parent = nullptr); ~Settings(); Q_PROPERTY(QVersionNumber version READ version)