[WIP DO NOT MERGE] qt: move backend setting to its own config
Some checks failed
eden-license / license-header (pull_request) Failing after 24s

* this is totally a mess but builds, I just need to format and check everything
  im late to go work!
* prevents error on migration

Signed-off-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
This commit is contained in:
Caio Oliveira 2025-09-27 12:19:24 -03:00
parent 466472e89f
commit 2bdcb0472e
Signed by: DraVee
GPG key ID: 362DA3DC1901E080
6 changed files with 83 additions and 12 deletions

View file

@ -643,8 +643,6 @@ struct Values {
// Linux
SwitchableSetting<bool> enable_gamemode{linkage, true, "enable_gamemode", Category::Linux};
SwitchableSetting<bool> force_x11{linkage, false, "force_x11", Category::Linux};
Setting<bool> hide_backend_warning_popup{linkage, false, "hide_backend_warning_popup", Category::Linux};
// Controls
InputSetting<std::array<PlayerInput, 10>> players;

View file

@ -28,6 +28,8 @@ add_library(qt_common STATIC
qt_applet_util.h qt_applet_util.cpp
qt_progress_dialog.h qt_progress_dialog.cpp
backendsettings.cpp
backendsettings.h
)
create_target_directory_groups(qt_common)

View file

@ -0,0 +1,45 @@
#include "backendsettings.h"
#include "common/fs/fs.h"
#include "common/fs/path_util.h"
#include <QSettings>
namespace FS = Common::FS;
namespace BackEndSettings {
Settings::Linkage backend_linkage;
Values::Values()
: backend_force_x11(backend_linkage, false, "backend_force_x11", Settings::Category::Linux),
backend_hide_warning_popup(backend_linkage, false, "backend_hide_warning_popup", Settings::Category::Linux)
{
Restore();
}
Values values{};
static const auto backend_config_path =
FS::PathToUTF8String(FS::GetEdenPath(FS::EdenPath::ConfigDir) / "backend_config.ini");
void Save() {
(void)FS::CreateParentDir(backend_config_path);
QSettings config(QString::fromStdString(backend_config_path), QSettings::IniFormat);
config.setValue("backend_force_x11", values.backend_force_x11.GetValue());
config.setValue("backend_hide_warning_popup", values.backend_hide_warning_popup.GetValue());
config.sync();
}
void Restore() {
if (!FS::Exists(backend_config_path))
return;
QSettings config(QString::fromStdString(backend_config_path), QSettings::IniFormat);
values.backend_force_x11.SetValue(config.value("backend_force_x11", false).toBool());
values.backend_hide_warning_popup.SetValue(config.value("backend_hide_warning_popup", false).toBool());
}
} // namespace BackEndSettings

View file

@ -0,0 +1,21 @@
#pragma once
#include "common/settings.h"
namespace BackEndSettings {
using namespace Settings;
struct Values {
SwitchableSetting<bool> backend_force_x11;
Setting<bool> backend_hide_warning_popup;
Values();
};
extern Values values;
void Save();
void Restore();
} // namespace BackEndSettings

View file

@ -15,6 +15,7 @@
#include "common/settings_setting.h"
#include "common/time_zone.h"
#include "qt_common/uisettings.h"
#include "qt_common/backendsettings.h"
#include <map>
#include <memory>
#include <utility>
@ -451,8 +452,8 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QObject* parent)
// Linux
INSERT(Settings, enable_gamemode, tr("Enable Gamemode"), QString());
INSERT(Settings, force_x11, tr("Force X11 as Graphics Backend"), QString());
INSERT(Settings, hide_backend_warning_popup, QString(), QString());
INSERT(BackEndSettings, backend_force_x11, tr("Force X11 as Graphics Backend"), QString());
INSERT(BackEndSettings, backend_hide_warning_popup, QString(), QString());
// Ui Debugging

View file

@ -24,6 +24,7 @@
#endif
#ifdef __linux__
#include "common/linux/gamemode.h"
#include "qt_common/backendsettings.h"
#endif
#include <boost/container/flat_set.hpp>
@ -4466,7 +4467,7 @@ void GMainWindow::OnCheckBackend() {
if (!isWayland)
return;
const bool currently_hidden = Settings::values.hide_backend_warning_popup.GetValue();
const bool currently_hidden = BackEndSettings::values.backend_hide_warning_popup.GetValue();
if (currently_hidden)
return;
@ -4489,16 +4490,20 @@ void GMainWindow::OnCheckBackend() {
const bool hide = cb->isChecked();
if (hide != currently_hidden) {
Settings::values.hide_backend_warning_popup.SetValue(hide);
BackEndSettings::values.backend_hide_warning_popup.SetValue(hide);
BackEndSettings::Save();
}
if (msgbox.clickedButton() == okButton) {
Settings::values.force_x11.SetValue(true);
BackEndSettings::values.backend_force_x11.SetValue(true);
BackEndSettings::Save();
QMessageBox::information(this,
tr("Restart Required"),
tr("Restart Eden to apply the X11 backend."));
tr("Restart Required"),
tr("Restart Eden to apply the X11 backend."));
}
}
#endif
bool GMainWindow::CheckFirmwarePresence() {
@ -4992,9 +4997,8 @@ int main(int argc, char* argv[]) {
}
// TODO: (DraVee) Un-alive the guy who wrote this
const auto config_path = Common::FS::PathToUTF8String(Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir) / "qt-config.ini");
const bool forceX11 = QSettings(QString::fromStdString(config_path), QSettings::IniFormat).value("Linux/force_x11", false).toBool();
if (forceX11)
BackEndSettings::Restore();
if (BackEndSettings::values.backend_force_x11.GetValue())
qputenv("QT_QPA_PLATFORM", "xcb");
// Fix the Wayland appId. This needs to match the name of the .desktop file without the .desktop