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

@ -77,9 +77,9 @@ void qPrefDisplay::set_divelist_font(const QString &value)
if (value.contains(","))
newValue = value.left(value.indexOf(","));
if (newValue != prefs.divelist_font &&
!subsurface_ignore_font(qPrintable(newValue))) {
qPrefPrivate::copy_txt(&prefs.divelist_font, value);
if (newValue.toStdString() != prefs.divelist_font &&
!subsurface_ignore_font(newValue.toStdString())) {
prefs.divelist_font = value.toStdString();
disk_divelist_font(true);
qApp->setFont(QFont(newValue));
@ -170,12 +170,10 @@ void qPrefDisplay::setCorrectFont()
QString fontName = defaultFont.toString();
if (fontName.contains(","))
fontName = fontName.left(fontName.indexOf(","));
if (subsurface_ignore_font(qPrintable(fontName))) {
defaultFont = QFont(prefs.divelist_font);
} else {
free((void *)prefs.divelist_font);
prefs.divelist_font = copy_qstring(fontName);
}
if (subsurface_ignore_font(fontName.toStdString()))
defaultFont = QFont(QString::fromStdString(prefs.divelist_font));
else
prefs.divelist_font = fontName.toStdString();
defaultFont.setPointSizeF(prefs.font_size * prefs.mobile_scale);
qApp->setFont(defaultFont);