cabana: use applicationPath for settings (#29875)

old-commit-hash: 5e1b5b36e4
test-msgs
Dean Lee 2 years ago committed by GitHub
parent 0987987f33
commit 5bac1f771c
  1. 2
      tools/cabana/cabana.cc
  2. 8
      tools/cabana/settings.cc
  3. 4
      tools/cabana/settings.h

@ -18,6 +18,8 @@ int main(int argc, char *argv[]) {
app.setWindowIcon(QIcon(":cabana-icon.png")); app.setWindowIcon(QIcon(":cabana-icon.png"));
UnixSignalHandler signalHandler; UnixSignalHandler signalHandler;
settings.load();
utils::setTheme(settings.theme); utils::setTheme(settings.theme);
QCommandLineParser cmd_parser; QCommandLineParser cmd_parser;

@ -13,12 +13,8 @@
Settings settings; Settings settings;
Settings::Settings() {
load();
}
void Settings::save() { void Settings::save() {
QSettings s("settings", QSettings::IniFormat); QSettings s(filePath(), QSettings::IniFormat);
s.setValue("fps", fps); s.setValue("fps", fps);
s.setValue("max_cached_minutes", max_cached_minutes); s.setValue("max_cached_minutes", max_cached_minutes);
s.setValue("chart_height", chart_height); s.setValue("chart_height", chart_height);
@ -42,7 +38,7 @@ void Settings::save() {
} }
void Settings::load() { void Settings::load() {
QSettings s("settings", QSettings::IniFormat); QSettings s(filePath(), QSettings::IniFormat);
fps = s.value("fps", 10).toInt(); fps = s.value("fps", 10).toInt();
max_cached_minutes = s.value("max_cached_minutes", 30).toInt(); max_cached_minutes = s.value("max_cached_minutes", 30).toInt();
chart_height = s.value("chart_height", 200).toInt(); chart_height = s.value("chart_height", 200).toInt();

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <QApplication>
#include <QByteArray> #include <QByteArray>
#include <QCheckBox> #include <QCheckBox>
#include <QComboBox> #include <QComboBox>
@ -22,9 +23,10 @@ public:
AlwaysBE, AlwaysBE,
}; };
Settings(); Settings() {}
void save(); void save();
void load(); void load();
inline static QString filePath() { return QApplication::applicationDirPath() + "/settings"; }
int fps = 10; int fps = 10;
int max_cached_minutes = 30; int max_cached_minutes = 30;

Loading…
Cancel
Save