Changeset View
Standalone View
kcms/fonts/fonts.cpp
Show All 28 Lines | |||||
29 | #include <QQuickItem> | 29 | #include <QQuickItem> | ||
30 | #include <QWindow> | 30 | #include <QWindow> | ||
31 | #include <QQmlEngine> | 31 | #include <QQmlEngine> | ||
32 | #include <QQuickView> | 32 | #include <QQuickView> | ||
33 | #include <QDebug> | 33 | #include <QDebug> | ||
34 | #include <QFontDialog> | 34 | #include <QFontDialog> | ||
35 | #include <QApplication> | 35 | #include <QApplication> | ||
36 | #include <QFontDatabase> | 36 | #include <QFontDatabase> | ||
37 | #include <QDBusInterface> | ||||
37 | 38 | | |||
38 | #include <KAcceleratorManager> | 39 | #include <KAcceleratorManager> | ||
39 | #include <KGlobalSettings> | 40 | #include <KGlobalSettings> | ||
40 | #include <KConfigGroup> | 41 | #include <KConfigGroup> | ||
41 | #include <KConfig> | 42 | #include <KConfig> | ||
42 | #include <KAboutData> | 43 | #include <KAboutData> | ||
43 | #include <KLocalizedString> | 44 | #include <KLocalizedString> | ||
44 | #include <KPluginFactory> | 45 | #include <KPluginFactory> | ||
▲ Show 20 Lines • Show All 547 Lines • ▼ Show 20 Line(s) | 551 | { | |||
592 | 593 | | |||
593 | emit fontsHaveChanged(); | 594 | emit fontsHaveChanged(); | ||
594 | setNeedsSave(false); | 595 | setNeedsSave(false); | ||
595 | } | 596 | } | ||
596 | 597 | | |||
597 | void KFonts::updateNeedsSave() | 598 | void KFonts::updateNeedsSave() | ||
598 | { | 599 | { | ||
599 | setNeedsSave(m_defaultFontOriginal != m_defaultFont || | 600 | setNeedsSave(m_defaultFontOriginal != m_defaultFont || | ||
600 | m_generalFontOriginal != m_generalFont || | 601 | m_generalFontOriginal != m_generalFont || | ||
nicolasfella: QStringLiteral() around strings | |||||
601 | m_fixedWidthFontOriginal != m_fixedWidthFont || | 602 | m_fixedWidthFontOriginal != m_fixedWidthFont || | ||
602 | m_smallFontOriginal != m_smallFont || | 603 | m_smallFontOriginal != m_smallFont || | ||
603 | m_toolbarFontOriginal != m_toolbarFont || | 604 | m_toolbarFontOriginal != m_toolbarFont || | ||
604 | m_menuFontOriginal != m_menuFont || | 605 | m_menuFontOriginal != m_menuFont || | ||
Given this is a kded module and as such a regular qt application, you should be able to get all of this automatically. broulik: Given this is a kded module and as such a regular qt application, you should be able to get all… | |||||
There are two designs which are both sensible:
Both have an advantage, and a disadvantage. This is both running all the time *and* is being explicitly called, which is the worst of both worlds. davidedmundson: There are two designs which are both sensible:
1) we have a daemon that runs all the time so… | |||||
@davidedmundson So, what are advantages and disadvantages of each of those options and what way do you recommend me go? gikari: @davidedmundson So, what are advantages and disadvantages of each of those options and what way… | |||||
@broulik I do not understand. KDEDModule (which is a parent of GtkConfig) is QObject, not a QGuiApplication. Maybe I am missing something? You want me to create a connection with that signal within a module, so I don't have to ask from KCM to change a font via DBus? gikari: @broulik I do not understand. `KDEDModule` (which is a parent of `GtkConfig`) is `QObject`, not… | |||||
kded (the application you're running in) is a QApplication, so from the constructor of your kdedmodule you could do #include <QApplication> connect(qApp, &QGuiApplication::fontChanged, this, [this](this QFont &font) { // now check if you have the new fonts }); I can't guarantee this will work (accessing font from there will actually deadlock :D but I am curious whether that signal is emitted properly, so you dont have to listen to or ask the font kcm to tell you. broulik: kded (the application you're running in) is a `QApplication`, so from the constructor of your… | |||||
So, I wrote this: GtkConfig::GtkConfig(QObject *parent, const QVariantList&) : KDEDModule(parent), configEditor {new ConfigEditor()} { qDebug() << "Parent: " << parent; QGuiApplication *qapp = static_cast<QGuiApplication *>(parent); qDebug() << "Qapp: " << qapp; connect(qapp, &QGuiApplication::fontChanged, this, [this](const QFont &font) { qDebug() << "Font recieved"; qDebug() << font; }); qDebug() << "GTK configuration module loaded"; } And when I save fonts via KCM nothing (Except the "parent", "qapp" and "GTK ..." lines) was printed in konsole, where I run Kded5. So, it means signal was not send? gikari: So, I wrote this:
```
GtkConfig::GtkConfig(QObject *parent, const QVariantList&)… | |||||
Are you sure parent is a QGuiApplication? I don't think so. Perhaps you want to connect to QGuiApplication::instance() instead. broulik: Are you sure `parent` is a `QGuiApplication`? I don't think so. Perhaps you want to connect to… | |||||
Just tested. It works. So the plan is to remove explicit call from the font kcm and replace it with that signal binding? For fonts it sure will work, but what about other settings, that will be in the future, like color schemes, icons etc? Whose signals we will receive? gikari: Just tested. It works. So the plan is to remove explicit call from the font kcm and replace it… | |||||
605 | m_windowTitleFontOriginal != m_windowTitleFont || | 606 | m_windowTitleFontOriginal != m_windowTitleFont || | ||
nicolasfella: I think the specific string should be determined by the gtkconfig daemon | |||||
606 | m_fontAASettings->needsSave()); | 607 | m_fontAASettings->needsSave()); | ||
607 | } | 608 | } | ||
608 | 609 | | |||
We know it will be about GTK, so changeFont should be enough. Also, setFont would be more consistent with other API naming nicolasfella: We know it will be about GTK, so changeFont should be enough.
Also, setFont would be more… | |||||
609 | void KFonts::setGeneralFont(const QFont &font) | 610 | void KFonts::setGeneralFont(const QFont &font) | ||
610 | { | 611 | { | ||
611 | if (m_generalFont == font) { | 612 | if (m_generalFont == font) { | ||
612 | return; | 613 | return; | ||
613 | } | 614 | } | ||
614 | 615 | | |||
615 | m_generalFont = font; | 616 | m_generalFont = font; | ||
616 | emit generalFontChanged(); | 617 | emit generalFontChanged(); | ||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |
QStringLiteral() around strings