[decorations] Emit DecorationSettings::fontChanged signal

Summary:
No one emits DecorationSettings::fontChanged signal, so if you change
the window title font, then titlebars might look differently after reboot.

Currently, there are two places where we can emit that signal:
- in KDecoration library itself;
- and in KWin.

Because we would need to listen for a Plasma specific D-Bus signal, the
latter option is preferable.

Surprisingly, KWin's implementation of DecorationSettingsPrivate already
reacts to refreshFonts D-Bus signal (even though indirectly), so all
what we have to do is get the current window title font in
SettingsImpl::readSettings, and if it's different from the previous one,
emit DecorationSettings::fontChanged signal.

BUG: 400980
FIXED-IN: 5.15.0

Test Plan:
* Increased the size of the window title font, titlebars got bigger;
* Decreased the font size, titlebars got smaller.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16908
This commit is contained in:
Vlad Zagorodniy 2018-11-15 19:40:00 +02:00
parent 841750438b
commit 80da18a143
2 changed files with 11 additions and 0 deletions

View file

@ -30,6 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KConfigGroup> #include <KConfigGroup>
#include <QFontDatabase>
namespace KWin namespace KWin
{ {
namespace Decoration namespace Decoration
@ -183,6 +185,11 @@ void SettingsImpl::readSettings()
m_borderSize = size; m_borderSize = size;
emit decorationSettings()->borderSizeChanged(m_borderSize); emit decorationSettings()->borderSizeChanged(m_borderSize);
} }
const QFont font = QFontDatabase::systemFont(QFontDatabase::TitleFont);
if (font != m_font) {
m_font = font;
emit decorationSettings()->fontChanged(m_font);
}
emit decorationSettings()->reconfigured(); emit decorationSettings()->reconfigured();
} }

View file

@ -49,6 +49,9 @@ public:
QVector< KDecoration2::DecorationButtonType > decorationButtonsRight() const override { QVector< KDecoration2::DecorationButtonType > decorationButtonsRight() const override {
return m_rightButtons; return m_rightButtons;
} }
QFont font() const override {
return m_font;
}
private: private:
void readSettings(); void readSettings();
@ -59,6 +62,7 @@ private:
QVector< KDecoration2::DecorationButtonType > m_rightButtons; QVector< KDecoration2::DecorationButtonType > m_rightButtons;
KDecoration2::BorderSize m_borderSize; KDecoration2::BorderSize m_borderSize;
bool m_closeDoubleClickMenu = false; bool m_closeDoubleClickMenu = false;
QFont m_font;
}; };
} // Decoration } // Decoration
} // KWin } // KWin