From 2df2df12fb44d0a3fbe1ae53f8f81a0a3ac627a0 Mon Sep 17 00:00:00 2001 From: Dominik Louven Date: Fri, 27 Mar 2020 14:29:44 +0100 Subject: [PATCH] Migrate from QGuiApplication to QApplication for linux support --- ScreenPlay/app.cpp | 20 ++++++++++---------- ScreenPlay/main.cpp | 8 ++++---- ScreenPlay/src/monitorlistmodel.cpp | 6 +++--- ScreenPlay/src/monitorlistmodel.h | 4 ++-- ScreenPlay/src/screenplaymanager.h | 2 +- ScreenPlay/src/settings.cpp | 4 ++-- ScreenPlay/src/settings.h | 2 +- ScreenPlay/src/util.cpp | 6 +++--- ScreenPlay/src/util.h | 2 +- ScreenPlayWallpaper/main.cpp | 2 +- ScreenPlayWidget/main.cpp | 8 ++++---- ScreenPlayWidget/src/widgetwindow.cpp | 2 +- ScreenPlayWidget/src/widgetwindow.h | 2 +- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index 8d9b6caf..539988d0 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -45,12 +45,12 @@ App::App() : QObject(nullptr) { - QGuiApplication::setWindowIcon(QIcon(":/assets/icons/favicon.ico")); - QGuiApplication::setOrganizationName("ScreenPlay"); - QGuiApplication::setOrganizationDomain("screen-play.app"); - QGuiApplication::setApplicationName("ScreenPlay"); - QGuiApplication::setApplicationVersion("0.10.0"); - QGuiApplication::setQuitOnLastWindowClosed(false); + QApplication::setWindowIcon(QIcon(":/assets/icons/favicon.ico")); + QApplication::setOrganizationName("ScreenPlay"); + QApplication::setOrganizationDomain("screen-play.app"); + QApplication::setApplicationName("ScreenPlay"); + QApplication::setApplicationVersion("0.10.0"); + QApplication::setQuitOnLastWindowClosed(false); #ifdef Q_OS_WINDOWS QtBreakpad::init(QDir::current().absolutePath()); @@ -112,7 +112,7 @@ App::App() m_telemetry->setNetworkAccessManager(nam); m_telemetry->setSendInterval(1000); m_telemetry->startSession(); - m_telemetry->sendEvent("version", QGuiApplication::applicationVersion()); + m_telemetry->sendEvent("version", QApplication::applicationVersion()); } m_create = make_unique(m_globalVariables); @@ -134,7 +134,7 @@ App::App() m_installedListModel->init(); // Set visible if the -silent parameter was not set - if (QGuiApplication::instance()->arguments().contains("-silent")) { + if (QApplication::instance()->arguments().contains("-silent")) { settings()->setSilentStart(true); } @@ -145,13 +145,13 @@ App::App() void App::exit() { if (!m_telemetry) { - QGuiApplication::instance()->quit(); + QApplication::instance()->quit(); return; } else { // Workaround because we cannot force to send exit event m_telemetry->setSendInterval(5); m_telemetry->endSession(); - QTimer::singleShot(150, []() { QGuiApplication::instance()->quit(); }); + QTimer::singleShot(150, []() { QApplication::instance()->quit(); }); } } } diff --git a/ScreenPlay/main.cpp b/ScreenPlay/main.cpp index e910ec0e..866dacb3 100644 --- a/ScreenPlay/main.cpp +++ b/ScreenPlay/main.cpp @@ -1,13 +1,13 @@ -#include +#include #include "app.h" int main(int argc, char* argv[]) { - QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); - QGuiApplication qtGuiApp(argc, argv); + QApplication qtGuiApp(argc, argv); ScreenPlay::App app; diff --git a/ScreenPlay/src/monitorlistmodel.cpp b/ScreenPlay/src/monitorlistmodel.cpp index 6c60abf2..bd22bc9f 100644 --- a/ScreenPlay/src/monitorlistmodel.cpp +++ b/ScreenPlay/src/monitorlistmodel.cpp @@ -25,9 +25,9 @@ MonitorListModel::MonitorListModel(QObject* parent) { loadMonitors(); - auto* guiAppInst = dynamic_cast(QGuiApplication::instance()); - connect(guiAppInst, &QGuiApplication::screenAdded, this, &MonitorListModel::screenAdded); - connect(guiAppInst, &QGuiApplication::screenRemoved, this, &MonitorListModel::screenRemoved); + auto* guiAppInst = dynamic_cast(QApplication::instance()); + connect(guiAppInst, &QApplication::screenAdded, this, &MonitorListModel::screenAdded); + connect(guiAppInst, &QApplication::screenRemoved, this, &MonitorListModel::screenRemoved); } QHash MonitorListModel::roleNames() const diff --git a/ScreenPlay/src/monitorlistmodel.h b/ScreenPlay/src/monitorlistmodel.h index fd16791e..8274a56a 100644 --- a/ScreenPlay/src/monitorlistmodel.h +++ b/ScreenPlay/src/monitorlistmodel.h @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -100,7 +100,7 @@ public slots: QRect getAbsoluteDesktopSize() const { - auto* app = static_cast(QGuiApplication::instance()); + auto* app = static_cast(QApplication::instance()); return app->screens().at(0)->availableVirtualGeometry(); } diff --git a/ScreenPlay/src/screenplaymanager.h b/ScreenPlay/src/screenplaymanager.h index dd117a91..c3caf0f0 100644 --- a/ScreenPlay/src/screenplaymanager.h +++ b/ScreenPlay/src/screenplaymanager.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index 6b343987..399d70fc 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -96,7 +96,7 @@ Settings::Settings(const shared_ptr& globalVariables, * not generate warnings. */ QDir dir; - QString path = QGuiApplication::instance()->applicationDirPath() + "/../../workshop/content/672870"; + QString path = QApplication::instance()->applicationDirPath() + "/../../workshop/content/672870"; if (!dir.mkpath(path)) { qWarning() << "Could not create steam workshop path for path: " << path; } else { @@ -235,7 +235,7 @@ void Settings::setupLanguage() bool Settings::retranslateUI() { - auto* app = static_cast(QGuiApplication::instance()); + auto* app = static_cast(QApplication::instance()); QString langCode = QVariant::fromValue(language()).toString(); langCode = langCode.toLower(); QFile tsFile; diff --git a/ScreenPlay/src/settings.h b/ScreenPlay/src/settings.h index 5bc1316c..9770ed3a 100644 --- a/ScreenPlay/src/settings.h +++ b/ScreenPlay/src/settings.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/ScreenPlay/src/util.cpp b/ScreenPlay/src/util.cpp index b7d33707..119b8409 100644 --- a/ScreenPlay/src/util.cpp +++ b/ScreenPlay/src/util.cpp @@ -28,7 +28,7 @@ Util::Util(QNetworkAccessManager* networkAccessManager, QObject* parent) // This gives us nice clickable output in QtCreator qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]"); - QString path = QGuiApplication::instance()->applicationDirPath() + "/"; + QString path = QApplication::instance()->applicationDirPath() + "/"; QFile fileFFMPEG; QFile fileFFPROBE; @@ -49,7 +49,7 @@ Util::Util(QNetworkAccessManager* networkAccessManager, QObject* parent) */ void Util::copyToClipboard(const QString& text) const { - auto* clipboard = QGuiApplication::clipboard(); + auto* clipboard = QApplication::clipboard(); clipboard->setText(text); } @@ -323,7 +323,7 @@ void Util::downloadFFMPEG() return; } - string path = QGuiApplication::instance()->applicationDirPath().toStdString() + "/"; + string path = QApplication::instance()->applicationDirPath().toStdString() + "/"; ZipEntry entryFFMPEG; std::string entryFFMPEGPath; diff --git a/ScreenPlay/src/util.h b/ScreenPlay/src/util.h index 03777a35..8bf4b539 100644 --- a/ScreenPlay/src/util.h +++ b/ScreenPlay/src/util.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/ScreenPlayWallpaper/main.cpp b/ScreenPlayWallpaper/main.cpp index 7397c8fc..1ea3976b 100644 --- a/ScreenPlayWallpaper/main.cpp +++ b/ScreenPlayWallpaper/main.cpp @@ -25,7 +25,7 @@ int main(int argc, char* argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QApplication app(argc, argv); diff --git a/ScreenPlayWidget/main.cpp b/ScreenPlayWidget/main.cpp index 7933406e..d3cfd00e 100644 --- a/ScreenPlayWidget/main.cpp +++ b/ScreenPlayWidget/main.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -7,10 +7,10 @@ int main(int argc, char* argv[]) { - QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); - QGuiApplication app(argc, argv); + QApplication app(argc, argv); QStringList argumentList = app.arguments(); diff --git a/ScreenPlayWidget/src/widgetwindow.cpp b/ScreenPlayWidget/src/widgetwindow.cpp index 59827db5..a4a60d6d 100644 --- a/ScreenPlayWidget/src/widgetwindow.cpp +++ b/ScreenPlayWidget/src/widgetwindow.cpp @@ -13,7 +13,7 @@ WidgetWindow::WidgetWindow(const QString projectPath, const QString appid, const }; if (!availableTypes.contains(m_type)) { - QGuiApplication::exit(-4); + QApplication::exit(-4); } Qt::WindowFlags flags = m_window.flags(); diff --git a/ScreenPlayWidget/src/widgetwindow.h b/ScreenPlayWidget/src/widgetwindow.h index ba840154..c44584be 100644 --- a/ScreenPlayWidget/src/widgetwindow.h +++ b/ScreenPlayWidget/src/widgetwindow.h @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include