Move smallestFont and defaultFont properties into Plasma::Theme
This commit is contained in:
parent
eba1a79b57
commit
13242c8a5f
@ -22,7 +22,6 @@
|
||||
#include <QQmlPropertyMap>
|
||||
|
||||
#include <QFontMetrics>
|
||||
#include <QFontDatabase>
|
||||
#include <kiconloader.h>
|
||||
#include <QApplication>
|
||||
|
||||
@ -47,24 +46,12 @@ ThemeProxy::ThemeProxy(QQmlEngine *parent)
|
||||
connect(KIconLoader::global(), SIGNAL(iconLoaderSettingsChanged()), this, SLOT(iconLoaderSettingsChanged()));
|
||||
|
||||
updateSpacing();
|
||||
installEventFilter(qApp);
|
||||
}
|
||||
|
||||
ThemeProxy::~ThemeProxy()
|
||||
{
|
||||
}
|
||||
|
||||
bool ThemeProxy::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == QCoreApplication::instance()) {
|
||||
if (event->type() == QEvent::ApplicationFontChange || event->type() == QEvent::FontChange) {
|
||||
defaultFontChanged();
|
||||
smallestFontChanged();
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void ThemeProxy::updateSpacing()
|
||||
{
|
||||
const int _s = mSize().height();
|
||||
@ -72,16 +59,6 @@ void ThemeProxy::updateSpacing()
|
||||
m_largeSpacing = _s;
|
||||
}
|
||||
|
||||
QFont ThemeProxy::defaultFont() const
|
||||
{
|
||||
return QApplication::font();
|
||||
}
|
||||
|
||||
QFont ThemeProxy::smallestFont() const
|
||||
{
|
||||
return QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont);
|
||||
}
|
||||
|
||||
QSizeF ThemeProxy::mSize(const QFont &font) const
|
||||
{
|
||||
return QFontMetrics(font).boundingRect("M").size();
|
||||
|
@ -40,10 +40,6 @@ class ThemeProxy : public Plasma::Theme
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
//fonts
|
||||
Q_PROPERTY(QFont defaultFont READ defaultFont NOTIFY defaultFontChanged)
|
||||
Q_PROPERTY(QFont smallestFont READ smallestFont NOTIFY smallestFontChanged)
|
||||
|
||||
// colors
|
||||
Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChanged)
|
||||
Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY themeChanged)
|
||||
@ -90,15 +86,11 @@ public:
|
||||
~ThemeProxy();
|
||||
|
||||
QString themeName() const;
|
||||
QFont defaultFont() const;
|
||||
QFont smallestFont() const;
|
||||
/**
|
||||
* @return The size of an uppercase M in a font, defaultFont() by default
|
||||
*/
|
||||
Q_INVOKABLE QSizeF mSize(const QFont &font = QApplication::font()) const;
|
||||
|
||||
bool useGlobalSettings() const;
|
||||
QString wallpaperPath() const;
|
||||
Q_INVOKABLE QString wallpaperPathForSize(int width=-1, int height=-1) const;
|
||||
|
||||
QColor textColor() const;
|
||||
@ -135,11 +127,8 @@ Q_SIGNALS:
|
||||
void themeChanged();
|
||||
void defaultIconSizeChanged();
|
||||
void iconSizesChanged();
|
||||
void defaultFontChanged();
|
||||
void smallestFontChanged();
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
void updateSpacing();
|
||||
int m_smallSpacing;
|
||||
int m_largeSpacing;
|
||||
|
@ -88,6 +88,7 @@ ThemePrivate::ThemePrivate(QObject *parent)
|
||||
QObject::connect(s_blurEffectWatcher, SIGNAL(effectChanged(bool)), this, SLOT(blurBehindChanged(bool)));
|
||||
#endif
|
||||
}
|
||||
installEventFilter(qApp);
|
||||
}
|
||||
|
||||
ThemePrivate::~ThemePrivate()
|
||||
@ -574,6 +575,10 @@ bool ThemePrivate::eventFilter(QObject *watched, QEvent *event)
|
||||
if (event->type() == QEvent::ApplicationPaletteChange) {
|
||||
colorsChanged();
|
||||
}
|
||||
if (event->type() == QEvent::ApplicationFontChange || event->type() == QEvent::FontChange) {
|
||||
defaultFontChanged();
|
||||
smallestFontChanged();
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
@ -94,6 +94,8 @@ public Q_SLOTS:
|
||||
|
||||
Q_SIGNALS:
|
||||
void themeChanged();
|
||||
void defaultFontChanged();
|
||||
void smallestFontChanged();
|
||||
|
||||
public:
|
||||
static const char *defaultTheme;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
#include <QFileInfo>
|
||||
#include <QMutableListIterator>
|
||||
#include <QPair>
|
||||
@ -62,6 +63,8 @@ Theme::Theme(QObject *parent)
|
||||
d, SLOT(onAppExitCleanup()));
|
||||
}
|
||||
connect(d, &ThemePrivate::themeChanged, this, &Theme::themeChanged);
|
||||
connect(d, &ThemePrivate::defaultFontChanged, this, &Theme::defaultFontChanged);
|
||||
connect(d, &ThemePrivate::smallestFontChanged, this, &Theme::smallestFontChanged);
|
||||
}
|
||||
|
||||
Theme::Theme(const QString &themeName, QObject *parent)
|
||||
@ -452,6 +455,17 @@ KPluginInfo Theme::pluginInfo() const
|
||||
return d->pluginInfo;
|
||||
}
|
||||
|
||||
QFont Theme::defaultFont() const
|
||||
{
|
||||
return QApplication::font();
|
||||
}
|
||||
|
||||
QFont Theme::smallestFont() const
|
||||
{
|
||||
return QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#include "moc_theme.cpp"
|
||||
|
@ -56,6 +56,9 @@ class PLASMA_EXPORT Theme : public QObject
|
||||
Q_PROPERTY(bool useGlobalSettings READ useGlobalSettings NOTIFY themeChanged)
|
||||
Q_PROPERTY(QString wallpaperPath READ wallpaperPath NOTIFY themeChanged)
|
||||
|
||||
//fonts
|
||||
Q_PROPERTY(QFont defaultFont READ defaultFont NOTIFY defaultFontChanged)
|
||||
Q_PROPERTY(QFont smallestFont READ smallestFont NOTIFY smallestFontChanged)
|
||||
|
||||
public:
|
||||
enum ColorRole {
|
||||
@ -304,6 +307,9 @@ class PLASMA_EXPORT Theme : public QObject
|
||||
*/
|
||||
KPluginInfo pluginInfo() const;
|
||||
|
||||
QFont defaultFont() const;
|
||||
QFont smallestFont() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* Emitted when the user changes the theme. Stylesheet usage, colors, etc. should
|
||||
@ -315,6 +321,9 @@ class PLASMA_EXPORT Theme : public QObject
|
||||
*/
|
||||
void themeChanged();
|
||||
|
||||
void defaultFontChanged();
|
||||
void smallestFontChanged();
|
||||
|
||||
private:
|
||||
friend class SvgPrivate;
|
||||
friend class ThemePrivate;
|
||||
|
Loading…
Reference in New Issue
Block a user