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