1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 10:42:29 +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)
{
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<Create>(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(); });
}
}
}

View File

@ -1,13 +1,13 @@
#include <QGuiApplication>
#include <QApplication>
#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;

View File

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

View File

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

View File

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

View File

@ -96,7 +96,7 @@ Settings::Settings(const shared_ptr<GlobalVariables>& 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*>(QGuiApplication::instance());
auto* app = static_cast<QApplication*>(QApplication::instance());
QString langCode = QVariant::fromValue(language()).toString();
langCode = langCode.toLower();
QFile tsFile;

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
#include <QGuiApplication>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QStringList>
@ -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();

View File

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

View File

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