preferences: use std::string in struct preferences

This is a messy commit, because the "qPref" system relies
heavily on QString, which means lots of conversions between
the two worlds. Ultimately, I plan to base the preferences
system on std::string and only convert to QString when
pushing through Qt's property system or when writing into
Qt's settings.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-13 22:59:32 +02:00 committed by bstoeger
parent 82fc9de40b
commit ccdd92aeb7
78 changed files with 645 additions and 694 deletions

View file

@ -99,40 +99,39 @@ static std::wstring make_default_filename()
return path + L"\\" + filename;
}
const char non_standard_system_divelist_default_font[] = "Calibri";
const char current_system_divelist_default_font[] = "Segoe UI";
const char *system_divelist_default_font = non_standard_system_divelist_default_font;
using namespace std::string_literals;
static std::string non_standard_system_divelist_default_font = "Calibri"s;
static std::string current_system_divelist_default_font = "Segoe UI"s;
std::string system_divelist_default_font;
double system_divelist_default_font_size = -1;
void subsurface_OS_pref_setup()
{
if (isWin7Or8())
system_divelist_default_font = current_system_divelist_default_font;
system_divelist_default_font = isWin7Or8() ? current_system_divelist_default_font
: non_standard_system_divelist_default_font;
}
bool subsurface_ignore_font(const char *font)
bool subsurface_ignore_font(const std::string &font)
{
// if this is running on a recent enough version of Windows and the font
// passed in is the pre 4.3 default font, ignore it
if (isWin7Or8() && strcmp(font, non_standard_system_divelist_default_font) == 0)
return true;
return false;
return isWin7Or8() && font == non_standard_system_divelist_default_font;
}
#define utf8_to_utf16(s) utf8_to_utf16_fl(s, __FILE__, __LINE__)
/* '\' not included at the end.
*/
const char *system_default_directory()
std::string system_default_directory()
{
static std::string path = utf16_to_utf8(system_default_path());
return path.c_str();
return path;
}
const char *system_default_filename()
std::string system_default_filename()
{
static std::string path = utf16_to_utf8(make_default_filename());
return path.c_str();
return path;
}
int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport)