mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Simplify custom font settings
Instead of having 3 separate config keys, use the KConfig QFont de/serilaization.
This commit is contained in:
parent
573abcaf25
commit
802ecc92d2
|
@ -12,21 +12,8 @@
|
|||
<label>Use system font</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="FontFamily" type="String">
|
||||
<label>Font family</label>
|
||||
<default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).family()</default>
|
||||
</entry>
|
||||
<entry name="FontSize" type="Double">
|
||||
<label>Font size</label>
|
||||
<default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSizeF()</default>
|
||||
</entry>
|
||||
<entry name="ItalicFont" type="Bool">
|
||||
<label>Italic</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="FontWeight" type="Int">
|
||||
<label>Font weight</label>
|
||||
<default>0</default>
|
||||
<entry name="ViewFont" type="Font">
|
||||
<default code="true">QFont()</default>
|
||||
</entry>
|
||||
<entry name="IconSize" type="Int">
|
||||
<label>Icon size</label>
|
||||
|
|
|
@ -8,26 +8,13 @@
|
|||
<include>QFontDatabase</include>
|
||||
<kcfgfile name="dolphinrc"/>
|
||||
<group name="DetailsMode">
|
||||
<entry name="FontFamily" type="String">
|
||||
<label>Font family</label>
|
||||
<default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).family()</default>
|
||||
<entry name="ViewFont" type="Font">
|
||||
<default code="true">QFont()</default>
|
||||
</entry>
|
||||
<entry name="UseSystemFont" type="Bool">
|
||||
<label>Use system font</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="FontSize" type="Double">
|
||||
<label>Font size</label>
|
||||
<default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSizeF()</default>
|
||||
</entry>
|
||||
<entry name="ItalicFont" type="Bool">
|
||||
<label>Italic</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="FontWeight" type="Int">
|
||||
<label>Font weight</label>
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="IconSize" type="Int">
|
||||
<label>Icon size</label>
|
||||
<default code="true">KIconLoader::SizeSmall</default>
|
||||
|
|
|
@ -12,21 +12,8 @@
|
|||
<label>Use system font</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="FontFamily" type="String">
|
||||
<label>Font family</label>
|
||||
<default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).family()</default>
|
||||
</entry>
|
||||
<entry name="FontSize" type="Double">
|
||||
<label>Font size</label>
|
||||
<default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSizeF()</default>
|
||||
</entry>
|
||||
<entry name="ItalicFont" type="Bool">
|
||||
<label>Italic</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="FontWeight" type="Int">
|
||||
<label>Font weight</label>
|
||||
<default>0</default>
|
||||
<entry name="ViewFont" type="Font">
|
||||
<default code="true">QFont()</default>
|
||||
</entry>
|
||||
<entry name="IconSize" type="Int">
|
||||
<label>Icon size</label>
|
||||
|
|
|
@ -86,59 +86,17 @@ bool ViewModeSettings::useSystemFont() const
|
|||
}, m_viewModeSettingsVariant);
|
||||
}
|
||||
|
||||
void ViewModeSettings::setFontFamily(const QString &fontFamily)
|
||||
void ViewModeSettings::setViewFont(const QFont &font)
|
||||
{
|
||||
std::visit([&fontFamily](auto &&v) {
|
||||
v->setFontFamily(fontFamily);
|
||||
std::visit([&font](auto &&v) {
|
||||
v->setViewFont(font);
|
||||
}, m_viewModeSettingsVariant);
|
||||
}
|
||||
|
||||
QString ViewModeSettings::fontFamily() const
|
||||
QFont ViewModeSettings::viewFont() const
|
||||
{
|
||||
return std::visit([](auto &&v) {
|
||||
return v->fontFamily();
|
||||
}, m_viewModeSettingsVariant);
|
||||
}
|
||||
|
||||
void ViewModeSettings::setFontSize(qreal fontSize)
|
||||
{
|
||||
std::visit([fontSize](auto &&v) {
|
||||
v->setFontSize(fontSize);
|
||||
}, m_viewModeSettingsVariant);
|
||||
}
|
||||
|
||||
qreal ViewModeSettings::fontSize() const
|
||||
{
|
||||
return std::visit([](auto &&v) {
|
||||
return v->fontSize();
|
||||
}, m_viewModeSettingsVariant);
|
||||
}
|
||||
|
||||
void ViewModeSettings::setItalicFont(bool italic)
|
||||
{
|
||||
std::visit([italic](auto &&v) {
|
||||
v->setItalicFont(italic);
|
||||
}, m_viewModeSettingsVariant);
|
||||
}
|
||||
|
||||
bool ViewModeSettings::italicFont() const
|
||||
{
|
||||
return std::visit([](auto &&v) {
|
||||
return v->italicFont();
|
||||
}, m_viewModeSettingsVariant);
|
||||
}
|
||||
|
||||
void ViewModeSettings::setFontWeight(int fontWeight)
|
||||
{
|
||||
std::visit([fontWeight](auto &&v) {
|
||||
v->setFontWeight(fontWeight);
|
||||
}, m_viewModeSettingsVariant);
|
||||
}
|
||||
|
||||
int ViewModeSettings::fontWeight() const
|
||||
{
|
||||
return std::visit([](auto &&v) {
|
||||
return v->fontWeight();
|
||||
return v->viewFont();
|
||||
}, m_viewModeSettingsVariant);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,17 +39,8 @@ public:
|
|||
void setUseSystemFont(bool useSystemFont);
|
||||
bool useSystemFont() const;
|
||||
|
||||
void setFontFamily(const QString &fontFamily);
|
||||
QString fontFamily() const;
|
||||
|
||||
void setFontSize(qreal fontSize);
|
||||
qreal fontSize() const;
|
||||
|
||||
void setItalicFont(bool italic);
|
||||
bool italicFont() const;
|
||||
|
||||
void setFontWeight(int fontWeight);
|
||||
int fontWeight() const;
|
||||
void setViewFont(const QFont &font);
|
||||
QFont viewFont() const;
|
||||
|
||||
void useDefaults(bool useDefaults);
|
||||
|
||||
|
|
|
@ -215,10 +215,7 @@ void ViewSettingsTab::applySettings()
|
|||
settings.setPreviewSize(previewSize);
|
||||
|
||||
settings.setUseSystemFont(useSystemFont);
|
||||
settings.setFontFamily(font.family());
|
||||
settings.setFontSize(font.pointSizeF());
|
||||
settings.setItalicFont(font.italic());
|
||||
settings.setFontWeight(font.weight());
|
||||
settings.setViewFont(font);
|
||||
|
||||
settings.save();
|
||||
}
|
||||
|
@ -272,10 +269,7 @@ void ViewSettingsTab::loadSettings()
|
|||
? DolphinFontRequester::SystemFont
|
||||
: DolphinFontRequester::CustomFont);
|
||||
|
||||
QFont font(settings.fontFamily(), qRound(settings.fontSize()));
|
||||
font.setItalic(settings.italicFont());
|
||||
font.setWeight(settings.fontWeight());
|
||||
font.setPointSizeF(settings.fontSize());
|
||||
QFont font(settings.viewFont());
|
||||
m_fontRequester->setCustomFont(font);
|
||||
}
|
||||
|
||||
|
|
|
@ -132,10 +132,7 @@ void DolphinItemListView::updateFont()
|
|||
if (settings.useSystemFont()) {
|
||||
KItemListView::updateFont();
|
||||
} else {
|
||||
QFont font(settings.fontFamily(), qRound(settings.fontSize()));
|
||||
font.setItalic(settings.italicFont());
|
||||
font.setWeight(settings.fontWeight());
|
||||
font.setPointSizeF(settings.fontSize());
|
||||
QFont font(settings.viewFont());
|
||||
|
||||
KItemListStyleOption option = styleOption();
|
||||
option.font = font;
|
||||
|
|
Loading…
Reference in a new issue