Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: store QSettings in a single location #129

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,16 @@ std::string getCertStore()
return "";
}

void initApplicationName()
{
QCoreApplication::setOrganizationName("unvanquished");
QCoreApplication::setApplicationName("updater");
}

// Settings are stored in ~/.config/unvanquished/updater.conf
QSettings* makePersistentSettings(QObject* parent)
{
return new QSettings("unvanquished", "updater", parent);
return new QSettings(parent);
}

QString getGameCommand(const QString& installPath)
Expand Down
3 changes: 1 addition & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ CommandLineOptions getCommandLineOptions(const QApplication& app) {

int main(int argc, char *argv[])
{
QCoreApplication::setApplicationName("Unvanquished Updater");
Sys::initApplicationName();
QCoreApplication::setApplicationVersion(GIT_VERSION);
QCoreApplication::setOrganizationName("Unvanquished Development");
QCoreApplication::setOrganizationDomain("unvanquished.net");
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
Expand Down
6 changes: 6 additions & 0 deletions osx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ std::string getCertStore()
return ""; // Not used on OSX.
}

void initApplicationName()
{
QCoreApplication::setOrganizationName("Unvanquished Development");
QCoreApplication::setApplicationName("Unvanquished Updater");
}

// Settings are stored in "~/Library/Preferences/net.unvanquished.Unvanquished Updater.plist"
// After deleting/changing the file, you must run `sudo killall cfprefsd` for it to take effect
QSettings* makePersistentSettings(QObject* parent)
Expand Down
1 change: 1 addition & 0 deletions system.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace Sys {
QString archiveName();
QString defaultInstallPath();
void initApplicationName(); // influences default storage location for QSettings
bool validateInstallPath(const QString& installPath); // Checks installing as root in homepath on Linux
bool installShortcuts(); // Install launch menu entries and protocol handlers
bool installUpdater(const QString& installPath); // Copies current application to <install path>/updater[.exe|.app]
Expand Down
9 changes: 9 additions & 0 deletions win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,20 @@ std::string getCertStore()
return ""; // Not used on Windows.
}

void initApplicationName()
{
QCoreApplication::setOrganizationName("Unvanquished Development");
QCoreApplication::setApplicationName("Unvanquished Updater");
}

// Settings are stored in the registry at (on 64-bit Windows)
// HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Unvanquished Development\Unvanquished Updater
// ≤v0.0.5 used HKEY_CURRENT_USER\Software\Unvanquished Development\Unvanquished Updater
// Note: a class that we use, QQControlsFileDialog, creates some of its own registry entries
// at HKEY_CURRENT_USER\SOFTWARE\Unvanquished Development\Unvanquished Updater
QSettings* makePersistentSettings(QObject* parent)
{
// We install to Program Files by default, so use global rather than per-user settings.
return new QSettings(QSettings::SystemScope, parent);
}

Expand Down