From 51db1f99f0c4cddc0af224d46d6e5679d18d2a53 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 28 Dec 2020 01:25:33 -0500 Subject: custom browser command changed some places that used QDesktopServices to use shell::Open() from uibase instead --- src/settings.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'src/settings.cpp') diff --git a/src/settings.cpp b/src/settings.cpp index ebb4fabe..6445bfbe 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -66,7 +66,8 @@ Settings::Settings(const QString& path, bool globalInstance) : m_Settings(path, QSettings::IniFormat), m_Game(m_Settings), m_Geometry(m_Settings), m_Widgets(m_Settings, globalInstance), m_Colors(m_Settings), - m_Plugins(m_Settings), m_Paths(m_Settings), m_Network(m_Settings), + m_Plugins(m_Settings), m_Paths(m_Settings), + m_Network(m_Settings, globalInstance), m_Nexus(*this, m_Settings), m_Steam(*this, m_Settings), m_Interface(m_Settings), m_Diagnostics(m_Settings) { @@ -1670,9 +1671,21 @@ void PathSettings::setOverwrite(const QString& path) } -NetworkSettings::NetworkSettings(QSettings& settings) +NetworkSettings::NetworkSettings(QSettings& settings, bool globalInstance) : m_Settings(settings) { + if (globalInstance) { + updateCustomBrowser(); + } +} + +void NetworkSettings::updateCustomBrowser() +{ + if (useCustomBrowser()) { + MOBase::shell::SetUrlHandler(customBrowserCommand()); + } else { + MOBase::shell::SetUrlHandler(""); + } } bool NetworkSettings::offlineMode() const @@ -1804,6 +1817,28 @@ void NetworkSettings::updateFromOldMap() updateServers(servers); } +bool NetworkSettings::useCustomBrowser() const +{ + return get(m_Settings, "Settings", "use_custom_browser", false); +} + +void NetworkSettings::setUseCustomBrowser(bool b) +{ + set(m_Settings, "Settings", "use_custom_browser", b); + updateCustomBrowser(); +} + +QString NetworkSettings::customBrowserCommand() const +{ + return get(m_Settings, "Settings", "custom_browser", ""); +} + +void NetworkSettings::setCustomBrowserCommand(const QString& s) +{ + set(m_Settings, "Settings", "custom_browser", s); + updateCustomBrowser(); +} + ServerList NetworkSettings::serversFromOldMap() const { // for 2.2.1 and before -- cgit v1.3.1 From 462ea08c348b6c524691e435ea7fb911ffd2367e Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 28 Dec 2020 04:17:16 -0500 Subject: fixed warning about ini files with utf8 bom fixed main thread name still getting clobbered by QWebEngine --- src/mainwindow.cpp | 4 ++++ src/moapplication.cpp | 3 --- src/settings.cpp | 29 ++++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) (limited to 'src/settings.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6c3801da..37e0027d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -286,6 +286,10 @@ MainWindow::MainWindow(Settings &settings QWebEngineProfile::defaultProfile()->setCachePath(settings.paths().cache()); QWebEngineProfile::defaultProfile()->setPersistentStoragePath(settings.paths().cache()); + // qt resets the thread name somewhere within the QWebEngineProfile calls + // above + MOShared::SetThisThreadName("main"); + ui->setupUi(this); languageChange(settings.interface().language()); ui->statusBar->setup(ui, settings); diff --git a/src/moapplication.cpp b/src/moapplication.cpp index 88b5710f..fb6a7121 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -359,9 +359,6 @@ int MOApplication::doOneRun(MOMultiProcess& multiProcess) tt.start("MOApplication::doOneRun() MainWindow setup"); MainWindow mainWindow(settings, organizer, *pluginContainer); - // qt resets the thread name somewhere when creating the main window - MOShared::SetThisThreadName("main"); - // the nexus interface can show dialogs, make sure they're parented to the // main window ni.getAccessManager()->setTopLevelWidget(&mainWindow); diff --git a/src/settings.cpp b/src/settings.cpp index 6445bfbe..f5ad83a7 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -470,7 +470,34 @@ const DiagnosticsSettings& Settings::diagnostics() const QSettings::Status Settings::sync() const { m_Settings.sync(); - return m_Settings.status(); + + const auto s = m_Settings.status(); + + // there's a bug in Qt at least until 5.15.0 where a utf-8 bom in the ini is + // handled correctly but still sets FormatError + // + // see qsettings.cpp, in QConfFileSettingsPrivate::readIniFile(), there's a + // specific check for utf-8, which adjusts `dataPos` so it's skipped, but + // the FLUSH_CURRENT_SECTION() macro uses `currentSectionStart`, and that one + // isn't adjusted when changing `dataPos` on the first line and so stays 0 + // + // this puts the bom in `unparsedIniSections` and eventually sets FormatError + // somewhere + // + // + // the other problem is that the status is never reset, not even when calling + // sync(), so the FormatError that's returned here is actually from reading + // the ini, not writing it + // + // + // since it's impossible to get a FormatError on write, it's considered to + // be a NoError here + + if (s == QSettings::FormatError) { + return QSettings::NoError; + } else { + return s; + } } QSettings::Status Settings::iniStatus() const -- cgit v1.3.1