1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-04 06:45:45 +02:00
jami-client-qt/src/main.cpp
Andreas Traczyk 733a2d000c app: use the default scenegraph render backend(OpenGL) on Windows
We've had reports of missing vulkan dependencies on fresh Windows
10 installs. Until this has been investigated, we should keep the
default rendering backend at the cost of some flicker.

Change-Id: Idaab06ff80d7841231270a207cceb134f8d790b0
2022-03-15 13:48:44 -04:00

123 lines
4 KiB
C++

/*
* Copyright (C) 2015-2022 Savoir-faire Linux Inc.
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "mainapplication.h"
#include "instancemanager.h"
#include "version.h"
#include <QCryptographicHash>
#include <QApplication>
#include <QtWebEngineCore>
#include <QtWebEngineQuick>
#include <clocale>
#ifndef ENABLE_TESTS
static char**
parseInputArgument(int& argc, char* argv[], QList<char*> argsToParse)
{
/*
* Forcefully append argsToParse.
*/
int oldArgc = argc;
argc += argsToParse.size();
char** newArgv = new char*[argc];
for (int i = 0; i < oldArgc; i++) {
newArgv[i] = argv[i];
}
for (int i = oldArgc; i < argc; i++) {
newArgv[i] = argsToParse.at(i - oldArgc);
}
return newArgv;
}
// Qt WebEngine Chromium Flags
static char disableWebSecurity[] {"--disable-web-security"};
static char singleProcess[] {"--single-process"};
int
main(int argc, char* argv[])
{
setlocale(LC_ALL, "en_US.utf8");
QList<char*> qtWebEngineChromiumFlags;
#ifdef Q_OS_LINUX
if (!getenv("QT_QPA_PLATFORMTHEME")
&& !(getenv("XDG_CURRENT_DESKTOP") == "KDE" || getenv("XDG_CURRENT_DESKTOP") == "GNOME"))
setenv("QT_QPA_PLATFORMTHEME", "gtk3", true);
setenv("QML_DISABLE_DISK_CACHE", "1", true);
/*
* Some GNU/Linux distros, like Zorin OS, set QT_STYLE_OVERRIDE
* to force a particular Qt style. This has been fine with Qt5
* even when using our own Qt package which may not have that
* style available. However, with Qt6, attempting to override
* to a nonexistent style seems to result in the main window
* simply not showing. So here we unset this variable, also
* because we currently hard-code the Material style anyway.
* https://bugreports.qt.io/browse/QTBUG-99889
*/
unsetenv("QT_STYLE_OVERRIDE");
#endif
qtWebEngineChromiumFlags << disableWebSecurity;
qtWebEngineChromiumFlags << singleProcess;
QApplication::setApplicationName("Jami");
QApplication::setOrganizationDomain("jami.net");
QApplication::setQuitOnLastWindowClosed(false);
QCoreApplication::setApplicationVersion(QString(VERSION_STRING));
QApplication::setHighDpiScaleFactorRoundingPolicy(
Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#if defined(Q_OS_MACOS)
QQuickWindow::setGraphicsApi(QSGRendererInterface::MetalRhi);
#endif
auto newArgv = parseInputArgument(argc, argv, qtWebEngineChromiumFlags);
MainApplication app(argc, newArgv);
// InstanceManager prevents multiple instances, and will handle
// IPC termination requests to and from secondary instances, which
// is used to gracefully terminate the app from an installer script
// during an update.
InstanceManager im(&app);
if (app.getOpt(MainApplication::Option::TerminationRequested).toBool()) {
qWarning() << "Attempting to terminate other instances.";
im.tryToKill();
return 0;
} else {
auto startUri = app.getOpt(MainApplication::Option::StartUri);
if (!im.tryToRun(startUri.toByteArray())) {
qWarning() << "Another instance is running.";
return 0;
}
}
if (!app.init()) {
return 0;
}
return app.exec();
}
#endif