1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 18:52:30 +01:00

Migrate from QGuiApplication to QApplication for linux support

This commit is contained in:
Dominik Louven 2020-03-27 14:29:44 +01:00
parent 0af6940c3d
commit 2df2df12fb
13 changed files with 34 additions and 34 deletions

View File

@ -45,12 +45,12 @@ App::App()
: QObject(nullptr) : QObject(nullptr)
{ {
QGuiApplication::setWindowIcon(QIcon(":/assets/icons/favicon.ico")); QApplication::setWindowIcon(QIcon(":/assets/icons/favicon.ico"));
QGuiApplication::setOrganizationName("ScreenPlay"); QApplication::setOrganizationName("ScreenPlay");
QGuiApplication::setOrganizationDomain("screen-play.app"); QApplication::setOrganizationDomain("screen-play.app");
QGuiApplication::setApplicationName("ScreenPlay"); QApplication::setApplicationName("ScreenPlay");
QGuiApplication::setApplicationVersion("0.10.0"); QApplication::setApplicationVersion("0.10.0");
QGuiApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
QtBreakpad::init(QDir::current().absolutePath()); QtBreakpad::init(QDir::current().absolutePath());
@ -112,7 +112,7 @@ App::App()
m_telemetry->setNetworkAccessManager(nam); m_telemetry->setNetworkAccessManager(nam);
m_telemetry->setSendInterval(1000); m_telemetry->setSendInterval(1000);
m_telemetry->startSession(); m_telemetry->startSession();
m_telemetry->sendEvent("version", QGuiApplication::applicationVersion()); m_telemetry->sendEvent("version", QApplication::applicationVersion());
} }
m_create = make_unique<Create>(m_globalVariables); m_create = make_unique<Create>(m_globalVariables);
@ -134,7 +134,7 @@ App::App()
m_installedListModel->init(); m_installedListModel->init();
// Set visible if the -silent parameter was not set // Set visible if the -silent parameter was not set
if (QGuiApplication::instance()->arguments().contains("-silent")) { if (QApplication::instance()->arguments().contains("-silent")) {
settings()->setSilentStart(true); settings()->setSilentStart(true);
} }
@ -145,13 +145,13 @@ App::App()
void App::exit() void App::exit()
{ {
if (!m_telemetry) { if (!m_telemetry) {
QGuiApplication::instance()->quit(); QApplication::instance()->quit();
return; return;
} else { } else {
// Workaround because we cannot force to send exit event // Workaround because we cannot force to send exit event
m_telemetry->setSendInterval(5); m_telemetry->setSendInterval(5);
m_telemetry->endSession(); m_telemetry->endSession();
QTimer::singleShot(150, []() { QGuiApplication::instance()->quit(); }); QTimer::singleShot(150, []() { QApplication::instance()->quit(); });
} }
} }
} }

View File

@ -1,13 +1,13 @@
#include <QGuiApplication> #include <QApplication>
#include "app.h" #include "app.h"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QGuiApplication qtGuiApp(argc, argv); QApplication qtGuiApp(argc, argv);
ScreenPlay::App app; ScreenPlay::App app;

View File

@ -25,9 +25,9 @@ MonitorListModel::MonitorListModel(QObject* parent)
{ {
loadMonitors(); loadMonitors();
auto* guiAppInst = dynamic_cast<QGuiApplication*>(QGuiApplication::instance()); auto* guiAppInst = dynamic_cast<QApplication*>(QApplication::instance());
connect(guiAppInst, &QGuiApplication::screenAdded, this, &MonitorListModel::screenAdded); connect(guiAppInst, &QApplication::screenAdded, this, &MonitorListModel::screenAdded);
connect(guiAppInst, &QGuiApplication::screenRemoved, this, &MonitorListModel::screenRemoved); connect(guiAppInst, &QApplication::screenRemoved, this, &MonitorListModel::screenRemoved);
} }
QHash<int, QByteArray> MonitorListModel::roleNames() const QHash<int, QByteArray> MonitorListModel::roleNames() const

View File

@ -3,7 +3,7 @@
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
#include <QGuiApplication> #include <QApplication>
#include <QRect> #include <QRect>
#include <QScreen> #include <QScreen>
#include <QSize> #include <QSize>
@ -100,7 +100,7 @@ public slots:
QRect getAbsoluteDesktopSize() const QRect getAbsoluteDesktopSize() const
{ {
auto* app = static_cast<QGuiApplication*>(QGuiApplication::instance()); auto* app = static_cast<QApplication*>(QApplication::instance());
return app->screens().at(0)->availableVirtualGeometry(); return app->screens().at(0)->availableVirtualGeometry();
} }

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <QGuiApplication> #include <QApplication>
#include <QObject> #include <QObject>
#include <QPoint> #include <QPoint>
#include <QProcess> #include <QProcess>

View File

@ -96,7 +96,7 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
* not generate warnings. * not generate warnings.
*/ */
QDir dir; QDir dir;
QString path = QGuiApplication::instance()->applicationDirPath() + "/../../workshop/content/672870"; QString path = QApplication::instance()->applicationDirPath() + "/../../workshop/content/672870";
if (!dir.mkpath(path)) { if (!dir.mkpath(path)) {
qWarning() << "Could not create steam workshop path for path: " << path; qWarning() << "Could not create steam workshop path for path: " << path;
} else { } else {
@ -235,7 +235,7 @@ void Settings::setupLanguage()
bool Settings::retranslateUI() bool Settings::retranslateUI()
{ {
auto* app = static_cast<QGuiApplication*>(QGuiApplication::instance()); auto* app = static_cast<QApplication*>(QApplication::instance());
QString langCode = QVariant::fromValue(language()).toString(); QString langCode = QVariant::fromValue(language()).toString();
langCode = langCode.toLower(); langCode = langCode.toLower();
QFile tsFile; QFile tsFile;

View File

@ -4,7 +4,7 @@
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QFontDatabase> #include <QFontDatabase>
#include <QGuiApplication> #include <QApplication>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>

View File

@ -28,7 +28,7 @@ Util::Util(QNetworkAccessManager* networkAccessManager, QObject* parent)
// This gives us nice clickable output in QtCreator // This gives us nice clickable output in QtCreator
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]"); qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]");
QString path = QGuiApplication::instance()->applicationDirPath() + "/"; QString path = QApplication::instance()->applicationDirPath() + "/";
QFile fileFFMPEG; QFile fileFFMPEG;
QFile fileFFPROBE; QFile fileFFPROBE;
@ -49,7 +49,7 @@ Util::Util(QNetworkAccessManager* networkAccessManager, QObject* parent)
*/ */
void Util::copyToClipboard(const QString& text) const void Util::copyToClipboard(const QString& text) const
{ {
auto* clipboard = QGuiApplication::clipboard(); auto* clipboard = QApplication::clipboard();
clipboard->setText(text); clipboard->setText(text);
} }
@ -323,7 +323,7 @@ void Util::downloadFFMPEG()
return; return;
} }
string path = QGuiApplication::instance()->applicationDirPath().toStdString() + "/"; string path = QApplication::instance()->applicationDirPath().toStdString() + "/";
ZipEntry entryFFMPEG; ZipEntry entryFFMPEG;
std::string entryFFMPEGPath; std::string entryFFMPEGPath;

View File

@ -5,7 +5,7 @@
#include <QDateTime> #include <QDateTime>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QGuiApplication> #include <QApplication>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>

View File

@ -25,7 +25,7 @@ int main(int argc, char* argv[])
{ {
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication app(argc, argv); QApplication app(argc, argv);

View File

@ -1,4 +1,4 @@
#include <QGuiApplication> #include <QApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QStringList> #include <QStringList>
@ -7,10 +7,10 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QGuiApplication app(argc, argv); QApplication app(argc, argv);
QStringList argumentList = app.arguments(); QStringList argumentList = app.arguments();

View File

@ -13,7 +13,7 @@ WidgetWindow::WidgetWindow(const QString projectPath, const QString appid, const
}; };
if (!availableTypes.contains(m_type)) { if (!availableTypes.contains(m_type)) {
QGuiApplication::exit(-4); QApplication::exit(-4);
} }
Qt::WindowFlags flags = m_window.flags(); Qt::WindowFlags flags = m_window.flags();

View File

@ -2,7 +2,7 @@
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QGuiApplication> #include <QApplication>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonParseError> #include <QJsonParseError>