mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
core: move load of display variables to qPrefDisplay from SettingsObjectWrapper
ensure SettingsObjectWrapper load() loads all display variables. Copy font setting code from SettingsObjectWrapper to qPrefDisplay Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
9732194bf8
commit
928fc1ee79
4 changed files with 42 additions and 29 deletions
|
@ -20,8 +20,8 @@ public:
|
||||||
|
|
||||||
// Load/Sync local settings (disk) and struct preference
|
// Load/Sync local settings (disk) and struct preference
|
||||||
void loadSync(bool doSync);
|
void loadSync(bool doSync);
|
||||||
void load() { loadSync(false); };
|
void load() { loadSync(false); }
|
||||||
void sync() { loadSync(true); };
|
void sync() { loadSync(true); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum cloud_status {
|
enum cloud_status {
|
||||||
|
|
|
@ -39,7 +39,12 @@ void qPrefDisplay::set_divelist_font(const QString& value)
|
||||||
emit divelist_font_changed(value);
|
emit divelist_font_changed(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DISK_LOADSYNC_TXT(Display, "/divelist_font", divelist_font);
|
void qPrefDisplay::disk_divelist_font(bool doSync)
|
||||||
|
{
|
||||||
|
LOADSYNC_TXT("/divelist_font", divelist_font);
|
||||||
|
if (!doSync)
|
||||||
|
setCorrectFont();
|
||||||
|
}
|
||||||
|
|
||||||
GET_PREFERENCE_DOUBLE(Display, font_size);
|
GET_PREFERENCE_DOUBLE(Display, font_size);
|
||||||
void qPrefDisplay::set_font_size(double value)
|
void qPrefDisplay::set_font_size(double value)
|
||||||
|
@ -53,10 +58,37 @@ void qPrefDisplay::set_font_size(double value)
|
||||||
emit font_size_changed(value);
|
emit font_size_changed(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DISK_LOADSYNC_DOUBLE(Display, "/font_size", font_size);
|
void qPrefDisplay::disk_font_size(bool doSync)
|
||||||
|
{
|
||||||
|
LOADSYNC_DOUBLE("/font_size", font_size);
|
||||||
|
if (!doSync)
|
||||||
|
setCorrectFont();
|
||||||
|
}
|
||||||
|
|
||||||
HANDLE_PREFERENCE_BOOL(Display, "/displayinvalid", display_invalid_dives);
|
HANDLE_PREFERENCE_BOOL(Display, "/displayinvalid", display_invalid_dives);
|
||||||
|
|
||||||
HANDLE_PREFERENCE_BOOL(Display, "/show_developer", show_developer);
|
HANDLE_PREFERENCE_BOOL(Display, "/show_developer", show_developer);
|
||||||
|
|
||||||
HANDLE_PREFERENCE_TXT(Display, "/theme", theme);
|
HANDLE_PREFERENCE_TXT(Display, "/theme", theme);
|
||||||
|
|
||||||
|
|
||||||
|
void qPrefDisplay::setCorrectFont()
|
||||||
|
{
|
||||||
|
// get the font from the settings or our defaults
|
||||||
|
// respect the system default font size if none is explicitly set
|
||||||
|
QFont defaultFont(prefs.divelist_font);
|
||||||
|
if (IS_FP_SAME(system_divelist_default_font_size, -1.0)) {
|
||||||
|
prefs.font_size = qApp->font().pointSizeF();
|
||||||
|
system_divelist_default_font_size = prefs.font_size; // this way we don't save it on exit
|
||||||
|
}
|
||||||
|
// painful effort to ignore previous default fonts on Windows - ridiculous
|
||||||
|
QString fontName = defaultFont.toString();
|
||||||
|
if (fontName.contains(","))
|
||||||
|
fontName = fontName.left(fontName.indexOf(","));
|
||||||
|
if (subsurface_ignore_font(qPrintable(fontName)))
|
||||||
|
defaultFont = QFont(prefs.divelist_font);
|
||||||
|
else
|
||||||
|
COPY_TXT(divelist_font, fontName);
|
||||||
|
defaultFont.setPointSizeF(prefs.font_size);
|
||||||
|
qApp->setFont(defaultFont);
|
||||||
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ public:
|
||||||
|
|
||||||
// Load/Sync local settings (disk) and struct preference
|
// Load/Sync local settings (disk) and struct preference
|
||||||
void loadSync(bool doSync);
|
void loadSync(bool doSync);
|
||||||
void load() { loadSync(false); };
|
void load() { loadSync(false); }
|
||||||
void sync() { loadSync(true); };
|
void sync() { loadSync(true); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QString divelist_font() const;
|
const QString divelist_font() const;
|
||||||
|
@ -53,5 +53,8 @@ private:
|
||||||
void disk_display_invalid_dives(bool doSync);
|
void disk_display_invalid_dives(bool doSync);
|
||||||
void disk_show_developer(bool doSync);
|
void disk_show_developer(bool doSync);
|
||||||
void disk_theme(bool doSync);
|
void disk_theme(bool doSync);
|
||||||
|
|
||||||
|
// font helper function
|
||||||
|
void setCorrectFont();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2218,29 +2218,7 @@ void SettingsObjectWrapper::load()
|
||||||
GET_BOOL("auto_recalculate_thumbnails", auto_recalculate_thumbnails);
|
GET_BOOL("auto_recalculate_thumbnails", auto_recalculate_thumbnails);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Display");
|
qPrefDisplay::instance()->load();
|
||||||
// get the font from the settings or our defaults
|
|
||||||
// respect the system default font size if none is explicitly set
|
|
||||||
QFont defaultFont = s.value("divelist_font", prefs.divelist_font).value<QFont>();
|
|
||||||
if (IS_FP_SAME(system_divelist_default_font_size, -1.0)) {
|
|
||||||
prefs.font_size = qApp->font().pointSizeF();
|
|
||||||
system_divelist_default_font_size = prefs.font_size; // this way we don't save it on exit
|
|
||||||
}
|
|
||||||
prefs.font_size = s.value("font_size", prefs.font_size).toFloat();
|
|
||||||
// painful effort to ignore previous default fonts on Windows - ridiculous
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
defaultFont.setPointSizeF(prefs.font_size);
|
|
||||||
qApp->setFont(defaultFont);
|
|
||||||
GET_BOOL("displayinvalid", display_invalid_dives);
|
|
||||||
s.endGroup();
|
|
||||||
|
|
||||||
s.beginGroup("Animations");
|
s.beginGroup("Animations");
|
||||||
GET_INT("animation_speed", animation_speed);
|
GET_INT("animation_speed", animation_speed);
|
||||||
|
|
Loading…
Add table
Reference in a new issue