Fixes and improvements (#617)

This commit is contained in:
Ken Van Hoeylandt
2026-08-20 17:22:01 +02:00
committed by GitHub
parent b03759a111
commit 0ff1627385
38 changed files with 309 additions and 342 deletions
+22 -4
View File
@@ -1,5 +1,7 @@
#include <Tactility/settings/AudioSettings.h>
#include "tactility/paths.h"
#include <Tactility/DeprecatedPaths.h>
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
@@ -12,8 +14,14 @@
namespace tt::settings::audio {
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/audio.properties";
static bool getSettingsFilePath(std::string& outPath) {
char root[128];
// Not really a service, but this is the best way of organising it for now
if (paths_get_data_path(root, sizeof(root)) != ERROR_NONE) {
return false;
}
outPath = std::string(root) + "/settings/audio.properties";
return true;
}
constexpr auto* SETTINGS_KEY_INPUT_ENABLED = "inputEnabled";
@@ -56,7 +64,11 @@ static std::string toString(float value) {
}
bool load(AudioSettings& settings) {
auto settings_path = getSettingsFilePath();
std::string settings_path;
if (!getSettingsFilePath(settings_path)) {
return false;
}
if (!file::isFile(settings_path)) {
return false;
}
@@ -103,10 +115,16 @@ bool save(const AudioSettings& settings) {
map[SETTINGS_KEY_OUTPUT_MUTED] = toString(settings.outputMuted);
map[SETTINGS_KEY_INPUT_VOLUME] = toString(settings.inputVolume);
map[SETTINGS_KEY_OUTPUT_VOLUME] = toString(settings.outputVolume);
auto settings_path = getSettingsFilePath();
std::string settings_path;
if (getSettingsFilePath(settings_path)) {
return false;
}
if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
return false;
}
return file::savePropertiesFile(settings_path, map);
}
+1 -1
View File
@@ -14,7 +14,7 @@ constexpr auto* PROPERTIES_KEY_LAUNCHER_APP_ID = "launcherAppId";
constexpr auto* PROPERTIES_KEY_AUTO_START_APP_ID = "autoStartAppId";
static std::string getPropertiesFilePath() {
return std::format(PROPERTIES_FILE_FORMAT, getUserDataPath());
return std::format(PROPERTIES_FILE_FORMAT, getDataPath());
}
bool loadBootSettings(BootSettings& properties) {
@@ -9,7 +9,7 @@
namespace tt::settings::keyboard {
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/keyboard.properties";
return getDataPath() + "/settings/keyboard.properties";
}
constexpr auto* KEY_BACKLIGHT_ENABLED = "backlightEnabled";
+3 -3
View File
@@ -21,12 +21,12 @@ static bool cached = false;
static SystemSettings cachedSettings;
static bool hasSystemSettingsFile() {
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
auto file_path = std::format(FILE_PATH_FORMAT, getDataPath());
return file::isFile(file_path);
}
static bool loadSystemSettingsFromFile(SystemSettings& properties) {
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
auto file_path = std::format(FILE_PATH_FORMAT, getDataPath());
LOG_I(TAG, "System settings loading from %s", file_path.c_str());
std::map<std::string, std::string> map;
if (!file::loadPropertiesFile(file_path, map)) {
@@ -75,7 +75,7 @@ bool loadSystemSettings(SystemSettings& properties) {
}
bool saveSystemSettings(const SystemSettings& properties) {
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
auto file_path = std::format(FILE_PATH_FORMAT, getDataPath());
std::map<std::string, std::string> map;
map["language"] = toString(properties.language);
map["timeFormat24h"] = properties.timeFormat24h ? "true" : "false";
@@ -13,7 +13,7 @@
namespace tt::settings::touch {
static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/touch-calibration.properties";
return getDataPath() + "/settings/touch-calibration.properties";
}
constexpr auto* SETTINGS_KEY_ENABLED = "enabled";
+5 -5
View File
@@ -1,5 +1,6 @@
#include <Tactility/settings/Time.h>
#include <service/paths.h>
#include <Tactility/settings/Time.h>
#include <Tactility/settings/SystemSettings.h>
#include <tactility/paths.h>
@@ -12,8 +13,6 @@
namespace tt::settings {
constexpr auto* TIME_SETTINGS_NAMESPACE = "time";
constexpr auto* TIMEZONE_PREFERENCES_KEY_NAME = "tz_name";
constexpr auto* TIMEZONE_PREFERENCES_KEY_CODE = "tz_code";
constexpr auto* TIMEZONE_PREFERENCES_KEY_TIME24 = "tz_time24";
@@ -24,10 +23,11 @@ namespace {
// "syncTime" - matches the shared NVS namespace this used to be.
bool getPreferencesPath(std::string& outPath) {
char root[128];
if (paths_get_user_data_path(root, sizeof(root)) != ERROR_NONE) {
// Not really a service, but this is the best way of organising it for now
if (paths_get_data_path(root, sizeof(root)) != ERROR_NONE) {
return false;
}
outPath = std::string(root) + "/" + TIME_SETTINGS_NAMESPACE + ".properties";
outPath = std::string(root) + "/settings/time.properties";
return true;
}