mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: qPrefDisplay correct font setting.
SettingsObjectWrapper contained some delicate font handling mixing font and font_size, breaking that into 2 parts broke font handling on some platforms Copy font + font_size handling 1-1 from SettingsObjectWrapper Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
55336bd7ad
commit
8d857a650d
1 changed files with 23 additions and 10 deletions
|
@ -34,15 +34,17 @@ void qPrefDisplay::set_divelist_font(const QString& value)
|
||||||
if (newValue != prefs.divelist_font &&
|
if (newValue != prefs.divelist_font &&
|
||||||
!subsurface_ignore_font(qPrintable(newValue))) {
|
!subsurface_ignore_font(qPrintable(newValue))) {
|
||||||
COPY_TXT(divelist_font, value);
|
COPY_TXT(divelist_font, value);
|
||||||
qApp->setFont(QFont(newValue));
|
|
||||||
disk_divelist_font(true);
|
disk_divelist_font(true);
|
||||||
|
|
||||||
|
qApp->setFont(QFont(newValue));
|
||||||
emit divelist_font_changed(value);
|
emit divelist_font_changed(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void qPrefDisplay::disk_divelist_font(bool doSync)
|
void qPrefDisplay::disk_divelist_font(bool doSync)
|
||||||
{
|
{
|
||||||
LOADSYNC_TXT("/divelist_font", divelist_font);
|
if (doSync)
|
||||||
if (!doSync)
|
LOADSYNC_TXT("/divelist_font", divelist_font)
|
||||||
|
else
|
||||||
setCorrectFont();
|
setCorrectFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,17 +53,19 @@ void qPrefDisplay::set_font_size(double value)
|
||||||
{
|
{
|
||||||
if (value != prefs.font_size) {
|
if (value != prefs.font_size) {
|
||||||
prefs.font_size = value;
|
prefs.font_size = value;
|
||||||
|
disk_font_size(true);
|
||||||
|
|
||||||
QFont defaultFont = qApp->font();
|
QFont defaultFont = qApp->font();
|
||||||
defaultFont.setPointSizeF(prefs.font_size);
|
defaultFont.setPointSizeF(prefs.font_size);
|
||||||
qApp->setFont(defaultFont);
|
qApp->setFont(defaultFont);
|
||||||
disk_font_size(true);
|
|
||||||
emit font_size_changed(value);
|
emit font_size_changed(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void qPrefDisplay::disk_font_size(bool doSync)
|
void qPrefDisplay::disk_font_size(bool doSync)
|
||||||
{
|
{
|
||||||
LOADSYNC_DOUBLE("/font_size", font_size);
|
if (doSync)
|
||||||
if (!doSync)
|
LOADSYNC_DOUBLE("/font_size", font_size)
|
||||||
|
else
|
||||||
setCorrectFont();
|
setCorrectFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,21 +78,30 @@ HANDLE_PREFERENCE_TXT(Display, "/theme", theme);
|
||||||
|
|
||||||
void qPrefDisplay::setCorrectFont()
|
void qPrefDisplay::setCorrectFont()
|
||||||
{
|
{
|
||||||
|
bool doSync = false;
|
||||||
|
QSettings s;
|
||||||
|
QVariant v;
|
||||||
|
|
||||||
// get the font from the settings or our defaults
|
// get the font from the settings or our defaults
|
||||||
// respect the system default font size if none is explicitly set
|
// respect the system default font size if none is explicitly set
|
||||||
QFont defaultFont(prefs.divelist_font);
|
QFont defaultFont = s.value(group + "/divelist_font", prefs.divelist_font).value<QFont>();
|
||||||
if (IS_FP_SAME(system_divelist_default_font_size, -1.0)) {
|
if (IS_FP_SAME(system_divelist_default_font_size, -1.0)) {
|
||||||
prefs.font_size = qApp->font().pointSizeF();
|
prefs.font_size = qApp->font().pointSizeF();
|
||||||
system_divelist_default_font_size = prefs.font_size; // this way we don't save it on exit
|
system_divelist_default_font_size = prefs.font_size; // this way we don't save it on exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prefs.font_size = s.value(group + "/font_size", prefs.font_size).toFloat();
|
||||||
// painful effort to ignore previous default fonts on Windows - ridiculous
|
// painful effort to ignore previous default fonts on Windows - ridiculous
|
||||||
QString fontName = defaultFont.toString();
|
QString fontName = defaultFont.toString();
|
||||||
if (fontName.contains(","))
|
if (fontName.contains(","))
|
||||||
fontName = fontName.left(fontName.indexOf(","));
|
fontName = fontName.left(fontName.indexOf(","));
|
||||||
if (subsurface_ignore_font(qPrintable(fontName)))
|
if (subsurface_ignore_font(qPrintable(fontName))) {
|
||||||
defaultFont = QFont(prefs.divelist_font);
|
defaultFont = QFont(prefs.divelist_font);
|
||||||
else
|
} else {
|
||||||
COPY_TXT(divelist_font, fontName);
|
free((void *)prefs.divelist_font);
|
||||||
|
prefs.divelist_font = copy_qstring(fontName);
|
||||||
|
}
|
||||||
defaultFont.setPointSizeF(prefs.font_size);
|
defaultFont.setPointSizeF(prefs.font_size);
|
||||||
qApp->setFont(defaultFont);
|
qApp->setFont(defaultFont);
|
||||||
|
LOADSYNC_BOOL("/displayinvalid", display_invalid_dives);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue