Commit 0a107dcb authored by Benjamin Port's avatar Benjamin Port
Browse files

Fix fonts KCM button state

Summary:
- Need to set "Regular" style name font to avoid not equal font

BUG: 416358

Reviewers: #plasma, ervin, crossi, meven

Subscribers: broulik, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26842
parent ec4dd2cc
......@@ -31,7 +31,6 @@
#include <QWindow>
#include <QQmlEngine>
#include <QQuickView>
#include <QDebug>
#include <QFontDialog>
#include <QApplication>
#include <QFontDatabase>
......@@ -470,6 +469,19 @@ bool FontAASettings::needsSave() const
return m_state != m_originalState;
}
bool FontAASettings::isDefaults() const
{
State defaultState{};
defaultState.exclude = false;
defaultState.excludeTo = 15;
defaultState.excludeFrom = 8;
defaultState.antiAliasing = true;
defaultState.dpi = 0;
defaultState.subPixel = KXftConfig::SubPixel::Rgb;
defaultState.hinting = KXftConfig::Hint::Slight;
return m_state == defaultState;
}
bool FontAASettings::State::operator==(const State& other) const
{
if (
......@@ -510,18 +522,14 @@ KFonts::KFonts(QObject *parent, const QVariantList &args)
setButtons(Apply | Default | Help);
auto updateState = [this]() {
setNeedsSave(m_fontAASettings->needsSave());
};
connect(m_fontAASettings, &FontAASettings::subPixelCurrentIndexChanged, this, updateState);
connect(m_fontAASettings, &FontAASettings::hintingCurrentIndexChanged, this, updateState);
connect(m_fontAASettings, &FontAASettings::excludeChanged, this, updateState);
connect(m_fontAASettings, &FontAASettings::excludeFromChanged, this, updateState);
connect(m_fontAASettings, &FontAASettings::excludeToChanged, this, updateState);
connect(m_fontAASettings, &FontAASettings::antiAliasingChanged, this, updateState);
connect(m_fontAASettings, &FontAASettings::aliasingChanged, this, updateState);
connect(m_fontAASettings, &FontAASettings::dpiChanged, this, updateState);
connect(m_fontAASettings, &FontAASettings::subPixelCurrentIndexChanged, this, &KFonts::settingsChanged);
connect(m_fontAASettings, &FontAASettings::hintingCurrentIndexChanged, this, &KFonts::settingsChanged);
connect(m_fontAASettings, &FontAASettings::excludeChanged, this, &KFonts::settingsChanged);
connect(m_fontAASettings, &FontAASettings::excludeFromChanged, this, &KFonts::settingsChanged);
connect(m_fontAASettings, &FontAASettings::excludeToChanged, this, &KFonts::settingsChanged);
connect(m_fontAASettings, &FontAASettings::antiAliasingChanged, this, &KFonts::settingsChanged);
connect(m_fontAASettings, &FontAASettings::aliasingChanged, this, &KFonts::settingsChanged);
connect(m_fontAASettings, &FontAASettings::dpiChanged, this, &KFonts::settingsChanged);
}
KFonts::~KFonts()
......@@ -601,6 +609,11 @@ bool KFonts::isSaveNeeded() const
return m_fontAASettings->needsSave();
}
bool KFonts::isDefaults() const
{
return m_fontAASettings->isDefaults();
}
void KFonts::adjustAllFonts()
{
QFont font = m_settings->font();
......
......@@ -77,7 +77,6 @@ public:
bool save(KXftConfig::AntiAliasing::State aaState);
void load();
void defaults();
void setAntiAliasingState(KXftConfig::AntiAliasing::State aaState);
QAbstractItemModel* subPixelOptionsModel() { return m_subPixelOptionsModel; }
QAbstractItemModel* hintingOptionsModel() { return m_hintingOptionsModel; }
......@@ -108,6 +107,7 @@ public:
void setHinting(int idx);
bool needsSave() const;
bool isDefaults() const;
#endif
......@@ -158,7 +158,8 @@ Q_SIGNALS:
void fontsHaveChanged();
private:
bool isSaveNeeded() const override ;
bool isSaveNeeded() const override;
bool isDefaults() const override;
QFont applyFontDiff(const QFont &fnt, const QFont &newFont, int fontDiffFlags);
void setNearestExistingFonts();
......
......@@ -12,6 +12,7 @@
QFont generalFont = QFont("Lucida Grande", 13);
#else
QFont generalFont = QFont("Noto Sans", 10);
generalFont.setStyleName("Regular");
#endif
</code>
<default code="true">generalFont</default>
......@@ -23,6 +24,7 @@
QFont fixedWidthFont = QFont("Monaco", 10);
#else
QFont fixedWidthFont = QFont("Hack", 9);
fixedWidthFont.setStyleName("Regular");
#endif
</code>
<default code="true">fixedWidthFont</default>
......@@ -34,6 +36,7 @@
QFont smallFont = QFont("Lucida Grande", 9);
#else
QFont smallFont = QFont("Noto Sans", 8);
smallFont.setStyleName("Regular");
#endif
</code>
<default code="true">smallFont</default>
......@@ -45,6 +48,7 @@
QFont toolBarFont = QFont("Lucida Grande", 11);
#else
QFont toolBarFont = QFont("Noto Sans", 10);
toolBarFont.setStyleName("Regular");
#endif
</code>
<default code="true">toolBarFont</default>
......@@ -56,6 +60,7 @@
QFont menuFont = QFont("Lucida Grande", 13);
#else
QFont menuFont = QFont("Noto Sans", 10);
menuFont.setStyleName("Regular");
#endif
</code>
<default code="true">menuFont</default>
......@@ -69,6 +74,7 @@
QFont windowTitleFont = QFont("Lucida Grande", 14);
#else
QFont windowTitleFont = QFont("Noto Sans", 10);
windowTitleFont.setStyleName("Regular");
#endif
</code>
<default code="true">windowTitleFont</default>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment