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

cabana: use applicationPath for settings #29875

Merged
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
2 changes: 2 additions & 0 deletions tools/cabana/cabana.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ int main(int argc, char *argv[]) {
app.setWindowIcon(QIcon(":cabana-icon.png"));

UnixSignalHandler signalHandler;

settings.load();
utils::setTheme(settings.theme);

QCommandLineParser cmd_parser;
Expand Down
8 changes: 2 additions & 6 deletions tools/cabana/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@

Settings settings;

Settings::Settings() {
load();
}

void Settings::save() {
QSettings s("settings", QSettings::IniFormat);
QSettings s(filePath(), QSettings::IniFormat);
s.setValue("fps", fps);
s.setValue("max_cached_minutes", max_cached_minutes);
s.setValue("chart_height", chart_height);
Expand All @@ -42,7 +38,7 @@ void Settings::save() {
}

void Settings::load() {
QSettings s("settings", QSettings::IniFormat);
QSettings s(filePath(), QSettings::IniFormat);
fps = s.value("fps", 10).toInt();
max_cached_minutes = s.value("max_cached_minutes", 30).toInt();
chart_height = s.value("chart_height", 200).toInt();
Expand Down
4 changes: 3 additions & 1 deletion tools/cabana/settings.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <QApplication>
#include <QByteArray>
#include <QCheckBox>
#include <QComboBox>
Expand All @@ -22,9 +23,10 @@ class Settings : public QObject {
AlwaysBE,
};

Settings();
Settings() {}
void save();
void load();
inline static QString filePath() { return QApplication::applicationDirPath() + "/settings"; }

int fps = 10;
int max_cached_minutes = 30;
Expand Down