forked from Silverfish/proton-bridge
feat(GODT-2382): Added bridge-gui settings file with 'UseSoftwareRenderer' value.
This commit is contained in:
@ -19,6 +19,7 @@
|
|||||||
#include "AppController.h"
|
#include "AppController.h"
|
||||||
#include "QMLBackend.h"
|
#include "QMLBackend.h"
|
||||||
#include "SentryUtils.h"
|
#include "SentryUtils.h"
|
||||||
|
#include "Settings.h"
|
||||||
#include <bridgepp/GRPC/GRPCClient.h>
|
#include <bridgepp/GRPC/GRPCClient.h>
|
||||||
#include <bridgepp/Exception/Exception.h>
|
#include <bridgepp/Exception/Exception.h>
|
||||||
#include <bridgepp/ProcessMonitor.h>
|
#include <bridgepp/ProcessMonitor.h>
|
||||||
@ -32,6 +33,7 @@ namespace {
|
|||||||
QString const noWindowFlag = "--no-window"; ///< The no-window command-line flag.
|
QString const noWindowFlag = "--no-window"; ///< The no-window command-line flag.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \return The AppController instance.
|
/// \return The AppController instance.
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
@ -47,10 +49,19 @@ AppController &app() {
|
|||||||
AppController::AppController()
|
AppController::AppController()
|
||||||
: backend_(std::make_unique<QMLBackend>())
|
: backend_(std::make_unique<QMLBackend>())
|
||||||
, grpc_(std::make_unique<GRPCClient>())
|
, grpc_(std::make_unique<GRPCClient>())
|
||||||
, log_(std::make_unique<Log>()) {
|
, log_(std::make_unique<Log>())
|
||||||
|
, settings_(new Settings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
// The following is in the implementation file because of unique pointers with incomplete types in headers.
|
||||||
|
// See https://stackoverflow.com/questions/6012157/is-stdunique-ptrt-required-to-know-the-full-definition-of-t
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
AppController::~AppController() = default;
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \return The bridge worker, which can be null if the application was run in 'attach' mode (-a command-line switch).
|
/// \return The bridge worker, which can be null if the application was run in 'attach' mode (-a command-line switch).
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
@ -70,15 +81,24 @@ ProcessMonitor *AppController::bridgeMonitor() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// \return A reference to the application settings.
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
Settings &AppController::settings() {
|
||||||
|
return *settings_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \param[in] function The function that caught the exception.
|
/// \param[in] function The function that caught the exception.
|
||||||
/// \param[in] message The error message.
|
/// \param[in] message The error message.
|
||||||
/// \param[in] details The details for the error.
|
/// \param[in] details The details for the error.
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
void AppController::onFatalError(QString const &function, QString const &message, QString const& details) {
|
void AppController::onFatalError(QString const &function, QString const &message, QString const &details) {
|
||||||
QString fullMessage = QString("%1(): %2").arg(function, message);
|
QString fullMessage = QString("%1(): %2").arg(function, message);
|
||||||
if (!details.isEmpty())
|
if (!details.isEmpty()) {
|
||||||
fullMessage += "\n\nDetails:\n" + details;
|
fullMessage += "\n\nDetails:\n" + details;
|
||||||
|
}
|
||||||
sentry_uuid_s const uuid = reportSentryException(SENTRY_LEVEL_ERROR, "AppController got notified of a fatal error", "Exception",
|
sentry_uuid_s const uuid = reportSentryException(SENTRY_LEVEL_ERROR, "AppController got notified of a fatal error", "Exception",
|
||||||
fullMessage.toLocal8Bit());
|
fullMessage.toLocal8Bit());
|
||||||
QMessageBox::critical(nullptr, tr("Error"), message);
|
QMessageBox::critical(nullptr, tr("Error"), message);
|
||||||
@ -87,20 +107,23 @@ void AppController::onFatalError(QString const &function, QString const &message
|
|||||||
qApp->exit(EXIT_FAILURE);
|
qApp->exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppController::restart(bool isCrashing) {
|
void AppController::restart(bool isCrashing) {
|
||||||
if (!launcher_.isEmpty()) {
|
if (!launcher_.isEmpty()) {
|
||||||
QProcess p;
|
QProcess p;
|
||||||
log_->info(QString("Restarting - App : %1 - Args : %2").arg(launcher_,launcherArgs_.join(" ")));
|
log_->info(QString("Restarting - App : %1 - Args : %2").arg(launcher_, launcherArgs_.join(" ")));
|
||||||
QStringList args = launcherArgs_;
|
QStringList args = launcherArgs_;
|
||||||
if (isCrashing)
|
if (isCrashing) {
|
||||||
args.append(noWindowFlag);
|
args.append(noWindowFlag);
|
||||||
|
}
|
||||||
|
|
||||||
p.startDetached(launcher_, args);
|
p.startDetached(launcher_, args);
|
||||||
p.waitForStarted();
|
p.waitForStarted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppController::setLauncherArgs(const QString& launcher, const QStringList& args){
|
|
||||||
|
void AppController::setLauncherArgs(const QString &launcher, const QStringList &args) {
|
||||||
launcher_ = launcher;
|
launcher_ = launcher;
|
||||||
launcherArgs_ = args;
|
launcherArgs_ = args;
|
||||||
}
|
}
|
||||||
@ -20,21 +20,16 @@
|
|||||||
#define BRIDGE_GUI_APP_CONTROLLER_H
|
#define BRIDGE_GUI_APP_CONTROLLER_H
|
||||||
|
|
||||||
|
|
||||||
|
//@formatter:off
|
||||||
class QMLBackend;
|
class QMLBackend;
|
||||||
|
class Settings;
|
||||||
|
|
||||||
namespace bridgepp {
|
namespace bridgepp {
|
||||||
class Log;
|
class Log;
|
||||||
|
|
||||||
|
|
||||||
class Overseer;
|
class Overseer;
|
||||||
|
|
||||||
|
|
||||||
class GRPCClient;
|
class GRPCClient;
|
||||||
|
|
||||||
|
|
||||||
class ProcessMonitor;
|
class ProcessMonitor;
|
||||||
}
|
}
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
@ -47,7 +42,7 @@ Q_OBJECT
|
|||||||
public: // member functions.
|
public: // member functions.
|
||||||
AppController(AppController const &) = delete; ///< Disabled copy-constructor.
|
AppController(AppController const &) = delete; ///< Disabled copy-constructor.
|
||||||
AppController(AppController &&) = delete; ///< Disabled assignment copy-constructor.
|
AppController(AppController &&) = delete; ///< Disabled assignment copy-constructor.
|
||||||
~AppController() override = default; ///< Destructor.
|
~AppController() override; ///< Destructor.
|
||||||
AppController &operator=(AppController const &) = delete; ///< Disabled assignment operator.
|
AppController &operator=(AppController const &) = delete; ///< Disabled assignment operator.
|
||||||
AppController &operator=(AppController &&) = delete; ///< Disabled move assignment operator.
|
AppController &operator=(AppController &&) = delete; ///< Disabled move assignment operator.
|
||||||
QMLBackend &backend() { return *backend_; } ///< Return a reference to the backend.
|
QMLBackend &backend() { return *backend_; } ///< Return a reference to the backend.
|
||||||
@ -55,10 +50,11 @@ public: // member functions.
|
|||||||
bridgepp::Log &log() { return *log_; } ///< Return a reference to the log.
|
bridgepp::Log &log() { return *log_; } ///< Return a reference to the log.
|
||||||
std::unique_ptr<bridgepp::Overseer> &bridgeOverseer() { return bridgeOverseer_; }; ///< Returns a reference the bridge overseer
|
std::unique_ptr<bridgepp::Overseer> &bridgeOverseer() { return bridgeOverseer_; }; ///< Returns a reference the bridge overseer
|
||||||
bridgepp::ProcessMonitor *bridgeMonitor() const; ///< Return the bridge worker.
|
bridgepp::ProcessMonitor *bridgeMonitor() const; ///< Return the bridge worker.
|
||||||
void setLauncherArgs(const QString& launcher, const QStringList& args);
|
Settings &settings();; ///< Return the application settings.
|
||||||
|
void setLauncherArgs(const QString &launcher, const QStringList &args);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onFatalError(QString const &function, QString const &message, QString const& details); ///< Handle fatal errors.
|
void onFatalError(QString const &function, QString const &message, QString const &details); ///< Handle fatal errors.
|
||||||
|
|
||||||
private: // member functions
|
private: // member functions
|
||||||
AppController(); ///< Default constructor.
|
AppController(); ///< Default constructor.
|
||||||
@ -69,6 +65,7 @@ private: // data members
|
|||||||
std::unique_ptr<bridgepp::GRPCClient> grpc_; ///< The RPC client.
|
std::unique_ptr<bridgepp::GRPCClient> grpc_; ///< The RPC client.
|
||||||
std::unique_ptr<bridgepp::Log> log_; ///< The log.
|
std::unique_ptr<bridgepp::Log> log_; ///< The log.
|
||||||
std::unique_ptr<bridgepp::Overseer> bridgeOverseer_; ///< The overseer for the bridge monitor worker.
|
std::unique_ptr<bridgepp::Overseer> bridgeOverseer_; ///< The overseer for the bridge monitor worker.
|
||||||
|
std::unique_ptr<Settings> settings_; ///< The application settings.
|
||||||
QString launcher_;
|
QString launcher_;
|
||||||
QStringList launcherArgs_;
|
QStringList launcherArgs_;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -118,6 +118,7 @@ add_executable(bridge-gui
|
|||||||
QMLBackend.cpp QMLBackend.h
|
QMLBackend.cpp QMLBackend.h
|
||||||
UserList.cpp UserList.h
|
UserList.cpp UserList.h
|
||||||
SentryUtils.cpp SentryUtils.h
|
SentryUtils.cpp SentryUtils.h
|
||||||
|
Settings.cpp Settings.h
|
||||||
${DOCK_ICON_SRC_FILE} MacOS/DockIcon.h
|
${DOCK_ICON_SRC_FILE} MacOS/DockIcon.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
56
internal/frontend/bridge-gui/bridge-gui/Settings.cpp
Normal file
56
internal/frontend/bridge-gui/bridge-gui/Settings.cpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Copyright (c) 2023 Proton AG
|
||||||
|
//
|
||||||
|
// This file is part of Proton Mail Bridge.
|
||||||
|
//
|
||||||
|
// Proton Mail Bridge 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.
|
||||||
|
//
|
||||||
|
// Proton Mail Bridge 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 Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
#include "Settings.h"
|
||||||
|
#include <bridgepp/BridgeUtils.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace bridgepp;
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
|
||||||
|
QString const settingsFileName = "bridge-gui.ini"; ///< The name of the settings file.
|
||||||
|
QString const keyUseSoftwareRenderer = "UseSoftwareRenderer"; ///< The key for storing the 'Use software rendering' setting.
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
//
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
Settings::Settings()
|
||||||
|
: settings_(QDir(userConfigDir()).absoluteFilePath("bridge-gui.ini"), QSettings::Format::IniFormat) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// \return The value for the 'Use software renderer' setting.
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
bool Settings::useSoftwareRenderer() const {
|
||||||
|
return settings_.value(keyUseSoftwareRenderer, false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// \param[in] value The value for the 'Use software renderer' setting.
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
void Settings::setUseSoftwareRenderer(bool value) {
|
||||||
|
settings_.setValue(keyUseSoftwareRenderer, value);
|
||||||
|
}
|
||||||
47
internal/frontend/bridge-gui/bridge-gui/Settings.h
Normal file
47
internal/frontend/bridge-gui/bridge-gui/Settings.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (c) 2023 Proton AG
|
||||||
|
//
|
||||||
|
// This file is part of Proton Mail Bridge.
|
||||||
|
//
|
||||||
|
// Proton Mail Bridge 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.
|
||||||
|
//
|
||||||
|
// Proton Mail Bridge 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 Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef BRIDGE_GUI_SETTINGS_H
|
||||||
|
#define BRIDGE_GUI_SETTINGS_H
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// \brief Application settings class
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
class Settings {
|
||||||
|
public: // member functions.
|
||||||
|
Settings(Settings const&) = delete; ///< Disabled copy-constructor.
|
||||||
|
Settings(Settings&&) = delete; ///< Disabled assignment copy-constructor.
|
||||||
|
~Settings() = default; ///< Destructor.
|
||||||
|
Settings& operator=(Settings const&) = delete; ///< Disabled assignment operator.
|
||||||
|
Settings& operator=(Settings&&) = delete; ///< Disabled move assignment operator.
|
||||||
|
|
||||||
|
bool useSoftwareRenderer() const; ///< Get the 'Use software renderer' settings value.
|
||||||
|
void setUseSoftwareRenderer(bool value); ///< Set the 'Use software renderer' settings value.
|
||||||
|
|
||||||
|
private: // member functions.
|
||||||
|
Settings(); ///< Default constructor.
|
||||||
|
|
||||||
|
private: // data members.
|
||||||
|
QSettings settings_; ///< The settings.
|
||||||
|
|
||||||
|
friend class AppController;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //BRIDGE_GUI_SETTINGS_H
|
||||||
@ -16,13 +16,13 @@
|
|||||||
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
#include "Pch.h"
|
|
||||||
#include "BridgeApp.h"
|
#include "BridgeApp.h"
|
||||||
|
#include "BuildConfig.h"
|
||||||
#include "CommandLine.h"
|
#include "CommandLine.h"
|
||||||
#include "LogUtils.h"
|
#include "LogUtils.h"
|
||||||
#include "QMLBackend.h"
|
#include "QMLBackend.h"
|
||||||
#include "SentryUtils.h"
|
#include "SentryUtils.h"
|
||||||
#include "BuildConfig.h"
|
#include "Settings.h"
|
||||||
#include <bridgepp/BridgeUtils.h>
|
#include <bridgepp/BridgeUtils.h>
|
||||||
#include <bridgepp/Exception/Exception.h>
|
#include <bridgepp/Exception/Exception.h>
|
||||||
#include <bridgepp/FocusGRPC/FocusGRPCClient.h>
|
#include <bridgepp/FocusGRPC/FocusGRPCClient.h>
|
||||||
@ -334,7 +334,7 @@ int main(int argc, char *argv[]) {
|
|||||||
// The following allows to render QML content in software with a 'Rendering Hardware Interface' (OpenGL, Vulkan, Metal, Direct3D...)
|
// The following allows to render QML content in software with a 'Rendering Hardware Interface' (OpenGL, Vulkan, Metal, Direct3D...)
|
||||||
// Note that it is different from the Qt::AA_UseSoftwareOpenGL attribute we use on some platforms that instruct Qt that we would like
|
// Note that it is different from the Qt::AA_UseSoftwareOpenGL attribute we use on some platforms that instruct Qt that we would like
|
||||||
// to use a software-only implementation of OpenGL.
|
// to use a software-only implementation of OpenGL.
|
||||||
QQuickWindow::setSceneGraphBackend(cliOptions.useSoftwareRenderer ? "software" : "rhi");
|
QQuickWindow::setSceneGraphBackend((app().settings().useSoftwareRenderer() || cliOptions.useSoftwareRenderer) ? "software" : "rhi");
|
||||||
log.info(QString("Qt Quick renderer: %1").arg(QQuickWindow::sceneGraphBackend()));
|
log.info(QString("Qt Quick renderer: %1").arg(QQuickWindow::sceneGraphBackend()));
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
|||||||
Reference in New Issue
Block a user