From eba1a79b5702b2680cf38ba70cc7f267d7258b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Sun, 12 Jan 2014 19:17:37 +0100 Subject: [PATCH 1/7] themeName, useGlobalSettings and wallpaperPath move into Plasma::Theme --- src/declarativeimports/core/theme.cpp | 17 ----------------- src/declarativeimports/core/theme.h | 4 ---- src/plasma/theme.h | 5 +++++ 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/declarativeimports/core/theme.cpp b/src/declarativeimports/core/theme.cpp index 0033f0465..8ae726e53 100644 --- a/src/declarativeimports/core/theme.cpp +++ b/src/declarativeimports/core/theme.cpp @@ -72,11 +72,6 @@ void ThemeProxy::updateSpacing() m_largeSpacing = _s; } -QString ThemeProxy::themeName() const -{ - return Plasma::Theme::themeName(); -} - QFont ThemeProxy::defaultFont() const { return QApplication::font(); @@ -102,16 +97,6 @@ int ThemeProxy::largeSpacing() const return m_largeSpacing; } -bool ThemeProxy::useGlobalSettings() const -{ - return Plasma::Theme::useGlobalSettings(); -} - -QString ThemeProxy::wallpaperPath() const -{ - return Plasma::Theme::wallpaperPath(); -} - QString ThemeProxy::wallpaperPathForSize(int width, int height) const { return Plasma::Theme::wallpaperPath(QSize(width, height)); @@ -226,7 +211,6 @@ void ThemeProxy::iconLoaderSettingsChanged() m_iconSizes->insert("small", KIconLoader::global()->currentSize(KIconLoader::Small)); m_iconSizes->insert("dialog", KIconLoader::global()->currentSize(KIconLoader::Dialog)); - emit defaultIconSizeChanged(); emit iconSizesChanged(); } @@ -242,4 +226,3 @@ QQmlPropertyMap *ThemeProxy::iconSizes() const } #include "moc_theme.cpp" - diff --git a/src/declarativeimports/core/theme.h b/src/declarativeimports/core/theme.h index a4b30eb20..18274ce68 100644 --- a/src/declarativeimports/core/theme.h +++ b/src/declarativeimports/core/theme.h @@ -40,10 +40,6 @@ class ThemeProxy : public Plasma::Theme { Q_OBJECT - Q_PROPERTY(QString themeName READ themeName NOTIFY themeChanged) - 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) diff --git a/src/plasma/theme.h b/src/plasma/theme.h index 9f175fdb8..bd46e87cb 100644 --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -52,6 +52,11 @@ class PLASMA_EXPORT Theme : public QObject { Q_OBJECT + Q_PROPERTY(QString themeName READ themeName NOTIFY themeChanged) + Q_PROPERTY(bool useGlobalSettings READ useGlobalSettings NOTIFY themeChanged) + Q_PROPERTY(QString wallpaperPath READ wallpaperPath NOTIFY themeChanged) + + public: enum ColorRole { TextColor = 0, /**< the text color to be used by items resting on the background */ From 13242c8a5f34f7dc8e8c52dd631cb0ecdaca6ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Sun, 12 Jan 2014 19:33:56 +0100 Subject: [PATCH 2/7] Move smallestFont and defaultFont properties into Plasma::Theme --- src/declarativeimports/core/theme.cpp | 23 ----------------------- src/declarativeimports/core/theme.h | 11 ----------- src/plasma/private/theme_p.cpp | 5 +++++ src/plasma/private/theme_p.h | 2 ++ src/plasma/theme.cpp | 14 ++++++++++++++ src/plasma/theme.h | 9 +++++++++ 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/declarativeimports/core/theme.cpp b/src/declarativeimports/core/theme.cpp index 8ae726e53..454ea93f8 100644 --- a/src/declarativeimports/core/theme.cpp +++ b/src/declarativeimports/core/theme.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -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(); diff --git a/src/declarativeimports/core/theme.h b/src/declarativeimports/core/theme.h index 18274ce68..e2912e907 100644 --- a/src/declarativeimports/core/theme.h +++ b/src/declarativeimports/core/theme.h @@ -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; diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index 7b77cb2fb..dc1a8690f 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -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); } diff --git a/src/plasma/private/theme_p.h b/src/plasma/private/theme_p.h index 408546ecf..3bdb9615f 100644 --- a/src/plasma/private/theme_p.h +++ b/src/plasma/private/theme_p.h @@ -94,6 +94,8 @@ public Q_SLOTS: Q_SIGNALS: void themeChanged(); + void defaultFontChanged(); + void smallestFontChanged(); public: static const char *defaultTheme; diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp index f4a1d7d5f..9f3b786e4 100644 --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -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" diff --git a/src/plasma/theme.h b/src/plasma/theme.h index bd46e87cb..3367f0658 100644 --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -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; From 25dcdd39a45f2d09006d0a9607e889c9c98b727b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Sun, 12 Jan 2014 19:49:56 +0100 Subject: [PATCH 3/7] Color properties move into Plasma::Theme They're now convenience API in Plasma:Theme, PlasmaCore.Theme is becoming smaller and smaller. Another nail in its coffin. --- src/declarativeimports/core/theme.cpp | 65 --------------------------- src/declarativeimports/core/theme.h | 30 ------------- src/plasma/theme.cpp | 64 ++++++++++++++++++++++++++ src/plasma/theme.h | 31 +++++++++++++ 4 files changed, 95 insertions(+), 95 deletions(-) diff --git a/src/declarativeimports/core/theme.cpp b/src/declarativeimports/core/theme.cpp index 454ea93f8..470ec1af2 100644 --- a/src/declarativeimports/core/theme.cpp +++ b/src/declarativeimports/core/theme.cpp @@ -79,71 +79,6 @@ QString ThemeProxy::wallpaperPathForSize(int width, int height) const return Plasma::Theme::wallpaperPath(QSize(width, height)); } -QColor ThemeProxy::textColor() const -{ - return Plasma::Theme::color(Plasma::Theme::TextColor); -} - -QColor ThemeProxy::highlightColor() const -{ - return Plasma::Theme::color(Plasma::Theme::HighlightColor); -} - -QColor ThemeProxy::backgroundColor() const -{ - return Plasma::Theme::color(Plasma::Theme::BackgroundColor); -} - -QColor ThemeProxy::buttonTextColor() const -{ - return Plasma::Theme::color(Plasma::Theme::ButtonTextColor); -} - -QColor ThemeProxy::buttonBackgroundColor() const -{ - return Plasma::Theme::color(Plasma::Theme::ButtonBackgroundColor); -} - -QColor ThemeProxy::linkColor() const -{ - return Plasma::Theme::color(Plasma::Theme::LinkColor); -} - -QColor ThemeProxy::visitedLinkColor() const -{ - return Plasma::Theme::color(Plasma::Theme::VisitedLinkColor); -} - -QColor ThemeProxy::buttonHoverColor() const -{ - return Plasma::Theme::color(Plasma::Theme::ButtonHoverColor); -} - -QColor ThemeProxy::buttonFocusColor() const -{ - return Plasma::Theme::color(Plasma::Theme::ButtonFocusColor); -} - -QColor ThemeProxy::viewTextColor() const -{ - return Plasma::Theme::color(Plasma::Theme::ViewTextColor); -} - -QColor ThemeProxy::viewBackgroundColor() const -{ - return Plasma::Theme::color(Plasma::Theme::ViewBackgroundColor); -} - -QColor ThemeProxy::viewHoverColor() const -{ - return Plasma::Theme::color(Plasma::Theme::ViewHoverColor); -} - -QColor ThemeProxy::viewFocusColor() const -{ - return Plasma::Theme::color(Plasma::Theme::ViewFocusColor); -} - QString ThemeProxy::styleSheet() const { return Plasma::Theme::styleSheet(QString()); diff --git a/src/declarativeimports/core/theme.h b/src/declarativeimports/core/theme.h index e2912e907..2ee8d86f9 100644 --- a/src/declarativeimports/core/theme.h +++ b/src/declarativeimports/core/theme.h @@ -40,23 +40,6 @@ class ThemeProxy : public Plasma::Theme { Q_OBJECT - // colors - Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChanged) - Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY themeChanged) - Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY themeChanged) - Q_PROPERTY(QColor buttonTextColor READ buttonTextColor NOTIFY themeChanged) - Q_PROPERTY(QColor buttonBackgroundColor READ buttonBackgroundColor NOTIFY themeChanged) - Q_PROPERTY(QColor linkColor READ linkColor NOTIFY themeChanged) - Q_PROPERTY(QColor visitedLinkColor READ visitedLinkColor NOTIFY themeChanged) - Q_PROPERTY(QColor visitedLinkColor READ visitedLinkColor NOTIFY themeChanged) - Q_PROPERTY(QColor buttonHoverColor READ buttonHoverColor NOTIFY themeChanged) - Q_PROPERTY(QColor buttonFocusColor READ buttonFocusColor NOTIFY themeChanged) - Q_PROPERTY(QColor viewTextColor READ viewTextColor NOTIFY themeChanged) - Q_PROPERTY(QColor viewBackgroundColor READ viewBackgroundColor NOTIFY themeChanged) - Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY themeChanged) - Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY themeChanged) - Q_PROPERTY(QString styleSheet READ styleSheet NOTIFY themeChanged) - // icon sizes Q_PROPERTY(int smallIconSize READ smallIconSize CONSTANT) Q_PROPERTY(int smallMediumIconSize READ smallMediumIconSize CONSTANT) @@ -93,19 +76,6 @@ public: Q_INVOKABLE QString wallpaperPathForSize(int width=-1, int height=-1) const; - QColor textColor() const; - QColor highlightColor() const; - QColor backgroundColor() const; - QColor buttonTextColor() const; - QColor buttonBackgroundColor() const; - QColor linkColor() const; - QColor visitedLinkColor() const; - QColor buttonHoverColor() const; - QColor buttonFocusColor() const; - QColor viewTextColor() const; - QColor viewBackgroundColor() const; - QColor viewHoverColor() const; - QColor viewFocusColor() const; QString styleSheet() const; int smallIconSize() const; diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp index 9f3b786e4..b6ce1baa8 100644 --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -465,6 +465,70 @@ QFont Theme::smallestFont() const return QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont); } +QColor Theme::textColor() const +{ + return Plasma::Theme::color(Plasma::Theme::TextColor); +} + +QColor Theme::highlightColor() const +{ + return Plasma::Theme::color(Plasma::Theme::HighlightColor); +} + +QColor Theme::backgroundColor() const +{ + return Plasma::Theme::color(Plasma::Theme::BackgroundColor); +} + +QColor Theme::buttonTextColor() const +{ + return Plasma::Theme::color(Plasma::Theme::ButtonTextColor); +} + +QColor Theme::buttonBackgroundColor() const +{ + return Plasma::Theme::color(Plasma::Theme::ButtonBackgroundColor); +} + +QColor Theme::linkColor() const +{ + return Plasma::Theme::color(Plasma::Theme::LinkColor); +} + +QColor Theme::visitedLinkColor() const +{ + return Plasma::Theme::color(Plasma::Theme::VisitedLinkColor); +} + +QColor Theme::buttonHoverColor() const +{ + return Plasma::Theme::color(Plasma::Theme::ButtonHoverColor); +} + +QColor Theme::buttonFocusColor() const +{ + return Plasma::Theme::color(Plasma::Theme::ButtonFocusColor); +} + +QColor Theme::viewTextColor() const +{ + return Plasma::Theme::color(Plasma::Theme::ViewTextColor); +} + +QColor Theme::viewBackgroundColor() const +{ + return Plasma::Theme::color(Plasma::Theme::ViewBackgroundColor); +} + +QColor Theme::viewHoverColor() const +{ + return Plasma::Theme::color(Plasma::Theme::ViewHoverColor); +} + +QColor Theme::viewFocusColor() const +{ + return Plasma::Theme::color(Plasma::Theme::ViewFocusColor); +} } diff --git a/src/plasma/theme.h b/src/plasma/theme.h index 3367f0658..3831b4172 100644 --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -60,6 +60,22 @@ class PLASMA_EXPORT Theme : public QObject 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) + Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY themeChanged) + Q_PROPERTY(QColor buttonTextColor READ buttonTextColor NOTIFY themeChanged) + Q_PROPERTY(QColor buttonBackgroundColor READ buttonBackgroundColor NOTIFY themeChanged) + Q_PROPERTY(QColor linkColor READ linkColor NOTIFY themeChanged) + Q_PROPERTY(QColor visitedLinkColor READ visitedLinkColor NOTIFY themeChanged) + Q_PROPERTY(QColor visitedLinkColor READ visitedLinkColor NOTIFY themeChanged) + Q_PROPERTY(QColor buttonHoverColor READ buttonHoverColor NOTIFY themeChanged) + Q_PROPERTY(QColor buttonFocusColor READ buttonFocusColor NOTIFY themeChanged) + Q_PROPERTY(QColor viewTextColor READ viewTextColor NOTIFY themeChanged) + Q_PROPERTY(QColor viewBackgroundColor READ viewBackgroundColor NOTIFY themeChanged) + Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY themeChanged) + Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY themeChanged) + public: enum ColorRole { TextColor = 0, /**< the text color to be used by items resting on the background */ @@ -310,6 +326,21 @@ class PLASMA_EXPORT Theme : public QObject QFont defaultFont() const; QFont smallestFont() const; + QColor textColor() const; + QColor highlightColor() const; + QColor backgroundColor() const; + QColor buttonTextColor() const; + QColor buttonBackgroundColor() const; + QColor linkColor() const; + QColor visitedLinkColor() const; + QColor buttonHoverColor() const; + QColor buttonFocusColor() const; + QColor viewTextColor() const; + QColor viewBackgroundColor() const; + QColor viewHoverColor() const; + QColor viewFocusColor() const; + QString styleSheet() const; + Q_SIGNALS: /** * Emitted when the user changes the theme. Stylesheet usage, colors, etc. should From a9b1f2c619c0d02f1a2f8743ec5348c1d49e4f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Sun, 12 Jan 2014 20:10:19 +0100 Subject: [PATCH 4/7] Most of iconSize moves to Plasma::Theme The QQmlPropertyMap isn't moved with this commit, this needs a bit more changing, so we do a separate one for that, once the more trivial stuff is moved out. --- src/declarativeimports/core/theme.cpp | 38 --------------------------- src/declarativeimports/core/theme.h | 18 ------------- src/plasma/private/theme_p.cpp | 2 ++ src/plasma/private/theme_p.h | 2 ++ src/plasma/theme.cpp | 37 ++++++++++++++++++++++++++ src/plasma/theme.h | 20 ++++++++++++++ 6 files changed, 61 insertions(+), 56 deletions(-) diff --git a/src/declarativeimports/core/theme.cpp b/src/declarativeimports/core/theme.cpp index 470ec1af2..9db454f26 100644 --- a/src/declarativeimports/core/theme.cpp +++ b/src/declarativeimports/core/theme.cpp @@ -33,8 +33,6 @@ ThemeProxy::ThemeProxy(QQmlEngine *parent) : Plasma::Theme(parent), m_engine(parent) { - m_defaultIconSize = KIconLoader::global()->currentSize(KIconLoader::Desktop); - m_iconSizes = new QQmlPropertyMap(this); m_iconSizes->insert("desktop", QVariant(KIconLoader::global()->currentSize(KIconLoader::Desktop))); m_iconSizes->insert("panel", QVariant(KIconLoader::global()->currentSize(KIconLoader::Panel))); @@ -84,40 +82,9 @@ QString ThemeProxy::styleSheet() const return Plasma::Theme::styleSheet(QString()); } -int ThemeProxy::smallIconSize() const -{ - return KIconLoader::SizeSmall; -} - -int ThemeProxy::smallMediumIconSize() const -{ - return KIconLoader::SizeSmallMedium; -} - -int ThemeProxy::mediumIconSize() const -{ - return KIconLoader::SizeMedium; -} - -int ThemeProxy::largeIconSize() const -{ - return KIconLoader::SizeLarge; -} - -int ThemeProxy::hugeIconSize() const -{ - return KIconLoader::SizeHuge; -} - -int ThemeProxy::enormousIconSize() const -{ - return KIconLoader::SizeEnormous; -} void ThemeProxy::iconLoaderSettingsChanged() { - m_defaultIconSize = KIconLoader::global()->currentSize(KIconLoader::Desktop); - m_iconSizes->insert("desktop", QVariant(KIconLoader::global()->currentSize(KIconLoader::Desktop))); m_iconSizes->insert("toolbar", KIconLoader::global()->currentSize(KIconLoader::Toolbar)); m_iconSizes->insert("small", KIconLoader::global()->currentSize(KIconLoader::Small)); @@ -127,11 +94,6 @@ void ThemeProxy::iconLoaderSettingsChanged() emit iconSizesChanged(); } -int ThemeProxy::defaultIconSize() const -{ - return m_defaultIconSize; -} - QQmlPropertyMap *ThemeProxy::iconSizes() const { return m_iconSizes; diff --git a/src/declarativeimports/core/theme.h b/src/declarativeimports/core/theme.h index 2ee8d86f9..5d1737472 100644 --- a/src/declarativeimports/core/theme.h +++ b/src/declarativeimports/core/theme.h @@ -40,15 +40,6 @@ class ThemeProxy : public Plasma::Theme { Q_OBJECT - // icon sizes - Q_PROPERTY(int smallIconSize READ smallIconSize CONSTANT) - Q_PROPERTY(int smallMediumIconSize READ smallMediumIconSize CONSTANT) - Q_PROPERTY(int mediumIconSize READ mediumIconSize CONSTANT) - Q_PROPERTY(int largeIconSize READ largeIconSize CONSTANT) - Q_PROPERTY(int hugeIconSize READ hugeIconSize CONSTANT) - Q_PROPERTY(int enormousIconSize READ enormousIconSize CONSTANT) - Q_PROPERTY(int defaultIconSize READ defaultIconSize NOTIFY defaultIconSizeChanged) - /** * icon sizes depending from the context: use those if possible * Access with theme.iconSizes.desktop theme.iconSizes.small etc. @@ -78,13 +69,6 @@ public: QString styleSheet() const; - int smallIconSize() const; - int smallMediumIconSize() const; - int mediumIconSize() const; - int largeIconSize() const; - int hugeIconSize() const; - int enormousIconSize() const; - int defaultIconSize() const; QQmlPropertyMap *iconSizes() const; int smallSpacing() const; @@ -95,14 +79,12 @@ private Q_SLOTS: Q_SIGNALS: void themeChanged(); - void defaultIconSizeChanged(); void iconSizesChanged(); private: void updateSpacing(); int m_smallSpacing; int m_largeSpacing; - int m_defaultIconSize; QQmlPropertyMap *m_iconSizes; QQmlEngine *m_engine; }; diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index dc1a8690f..97d19599c 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -26,6 +26,7 @@ #include #include +#include #include namespace Plasma @@ -51,6 +52,7 @@ ThemePrivate::ThemePrivate(QObject *parent) colorScheme(QPalette::Active, KColorScheme::Window, KSharedConfigPtr(0)), buttonColorScheme(QPalette::Active, KColorScheme::Button, KSharedConfigPtr(0)), viewColorScheme(QPalette::Active, KColorScheme::View, KSharedConfigPtr(0)), + defaultIconSize(KIconLoader::global()->currentSize(KIconLoader::Desktop)), defaultWallpaperTheme(DEFAULT_WALLPAPER_THEME), defaultWallpaperSuffix(DEFAULT_WALLPAPER_SUFFIX), defaultWallpaperWidth(DEFAULT_WALLPAPER_WIDTH), diff --git a/src/plasma/private/theme_p.h b/src/plasma/private/theme_p.h index 3bdb9615f..25fc1cd08 100644 --- a/src/plasma/private/theme_p.h +++ b/src/plasma/private/theme_p.h @@ -136,6 +136,8 @@ public: unsigned cacheSize; CacheTypes cachesToDiscard; + int defaultIconSize; + bool locolor : 1; bool compositingActive : 1; bool blurActive : 1; diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp index b6ce1baa8..55b820a8c 100644 --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -530,6 +531,42 @@ QColor Theme::viewFocusColor() const return Plasma::Theme::color(Plasma::Theme::ViewFocusColor); } +int Theme::defaultIconSize() const +{ + return d->defaultIconSize; +} + +int Theme::smallIconSize() const +{ + return KIconLoader::SizeSmall; +} + +int Theme::smallMediumIconSize() const +{ + return KIconLoader::SizeSmallMedium; +} + +int Theme::mediumIconSize() const +{ + return KIconLoader::SizeMedium; +} + +int Theme::largeIconSize() const +{ + return KIconLoader::SizeLarge; +} + +int Theme::hugeIconSize() const +{ + return KIconLoader::SizeHuge; +} + +int Theme::enormousIconSize() const +{ + return KIconLoader::SizeEnormous; +} + + } #include "moc_theme.cpp" diff --git a/src/plasma/theme.h b/src/plasma/theme.h index 3831b4172..db62484b3 100644 --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -76,6 +76,16 @@ class PLASMA_EXPORT Theme : public QObject Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY themeChanged) Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY themeChanged) + // icon sizes + Q_PROPERTY(int smallIconSize READ smallIconSize CONSTANT) + Q_PROPERTY(int smallMediumIconSize READ smallMediumIconSize CONSTANT) + Q_PROPERTY(int mediumIconSize READ mediumIconSize CONSTANT) + Q_PROPERTY(int largeIconSize READ largeIconSize CONSTANT) + Q_PROPERTY(int hugeIconSize READ hugeIconSize CONSTANT) + Q_PROPERTY(int enormousIconSize READ enormousIconSize CONSTANT) + Q_PROPERTY(int defaultIconSize READ defaultIconSize NOTIFY defaultIconSizeChanged) + + public: enum ColorRole { TextColor = 0, /**< the text color to be used by items resting on the background */ @@ -341,6 +351,14 @@ class PLASMA_EXPORT Theme : public QObject QColor viewFocusColor() const; QString styleSheet() const; + int smallIconSize() const; + int smallMediumIconSize() const; + int mediumIconSize() const; + int largeIconSize() const; + int hugeIconSize() const; + int enormousIconSize() const; + int defaultIconSize() const; + Q_SIGNALS: /** * Emitted when the user changes the theme. Stylesheet usage, colors, etc. should @@ -355,6 +373,8 @@ class PLASMA_EXPORT Theme : public QObject void defaultFontChanged(); void smallestFontChanged(); + void defaultIconSizeChanged(); + private: friend class SvgPrivate; friend class ThemePrivate; From 563035a1fabe75b75afdf8eb9a86f57a7e12ac6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Sun, 12 Jan 2014 23:05:55 +0100 Subject: [PATCH 5/7] themeName is already gone --- src/declarativeimports/core/theme.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/declarativeimports/core/theme.h b/src/declarativeimports/core/theme.h index 5d1737472..76c3ad869 100644 --- a/src/declarativeimports/core/theme.h +++ b/src/declarativeimports/core/theme.h @@ -59,7 +59,6 @@ public: ThemeProxy(QQmlEngine *parent = 0); ~ThemeProxy(); - QString themeName() const; /** * @return The size of an uppercase M in a font, defaultFont() by default */ From ea2a4db7ab813a0effbb416b887a0a86bd4525a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Mon, 13 Jan 2014 01:31:46 +0100 Subject: [PATCH 6/7] Move spacing, stylesheet and mSize into Plasma::Theme --- src/declarativeimports/core/theme.cpp | 30 --------------------------- src/declarativeimports/core/theme.h | 11 ---------- src/plasma/private/theme_p.cpp | 10 ++++++++- src/plasma/private/theme_p.h | 5 +++++ src/plasma/theme.cpp | 17 ++++++++++++++- src/plasma/theme.h | 12 ++++++++++- 6 files changed, 41 insertions(+), 44 deletions(-) diff --git a/src/declarativeimports/core/theme.cpp b/src/declarativeimports/core/theme.cpp index 9db454f26..284154db0 100644 --- a/src/declarativeimports/core/theme.cpp +++ b/src/declarativeimports/core/theme.cpp @@ -42,47 +42,17 @@ ThemeProxy::ThemeProxy(QQmlEngine *parent) connect(this, &Plasma::Theme::themeChanged, this, &ThemeProxy::themeChanged); connect(KIconLoader::global(), SIGNAL(iconLoaderSettingsChanged()), this, SLOT(iconLoaderSettingsChanged())); - - updateSpacing(); } ThemeProxy::~ThemeProxy() { } -void ThemeProxy::updateSpacing() -{ - const int _s = mSize().height(); - m_smallSpacing = qMax(2, (int)(_s / 8)); - m_largeSpacing = _s; -} - -QSizeF ThemeProxy::mSize(const QFont &font) const -{ - return QFontMetrics(font).boundingRect("M").size(); -} - -int ThemeProxy::smallSpacing() const -{ - return m_smallSpacing; -} - -int ThemeProxy::largeSpacing() const -{ - return m_largeSpacing; -} - QString ThemeProxy::wallpaperPathForSize(int width, int height) const { return Plasma::Theme::wallpaperPath(QSize(width, height)); } -QString ThemeProxy::styleSheet() const -{ - return Plasma::Theme::styleSheet(QString()); -} - - void ThemeProxy::iconLoaderSettingsChanged() { m_iconSizes->insert("desktop", QVariant(KIconLoader::global()->currentSize(KIconLoader::Desktop))); diff --git a/src/declarativeimports/core/theme.h b/src/declarativeimports/core/theme.h index 76c3ad869..8c5841bc2 100644 --- a/src/declarativeimports/core/theme.h +++ b/src/declarativeimports/core/theme.h @@ -59,20 +59,10 @@ public: ThemeProxy(QQmlEngine *parent = 0); ~ThemeProxy(); - /** - * @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 QString wallpaperPathForSize(int width=-1, int height=-1) const; - QString styleSheet() const; - QQmlPropertyMap *iconSizes() const; - int smallSpacing() const; - int largeSpacing() const; - private Q_SLOTS: void iconLoaderSettingsChanged(); @@ -81,7 +71,6 @@ Q_SIGNALS: void iconSizesChanged(); private: - void updateSpacing(); int m_smallSpacing; int m_largeSpacing; QQmlPropertyMap *m_iconSizes; diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index 97d19599c..93fc266ec 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -52,7 +52,6 @@ ThemePrivate::ThemePrivate(QObject *parent) colorScheme(QPalette::Active, KColorScheme::Window, KSharedConfigPtr(0)), buttonColorScheme(QPalette::Active, KColorScheme::Button, KSharedConfigPtr(0)), viewColorScheme(QPalette::Active, KColorScheme::View, KSharedConfigPtr(0)), - defaultIconSize(KIconLoader::global()->currentSize(KIconLoader::Desktop)), defaultWallpaperTheme(DEFAULT_WALLPAPER_THEME), defaultWallpaperSuffix(DEFAULT_WALLPAPER_SUFFIX), defaultWallpaperWidth(DEFAULT_WALLPAPER_WIDTH), @@ -60,6 +59,7 @@ ThemePrivate::ThemePrivate(QObject *parent) pixmapCache(0), cacheSize(0), cachesToDiscard(NoCache), + defaultIconSize(KIconLoader::global()->currentSize(KIconLoader::Desktop)), locolor(false), compositingActive(KWindowSystem::self()->compositingActive()), blurActive(false), @@ -91,6 +91,7 @@ ThemePrivate::ThemePrivate(QObject *parent) #endif } installEventFilter(qApp); + updateSpacing(); } ThemePrivate::~ThemePrivate() @@ -585,6 +586,13 @@ bool ThemePrivate::eventFilter(QObject *watched, QEvent *event) return QObject::eventFilter(watched, event); } +void ThemePrivate::updateSpacing() +{ + const int _s = QFontMetrics(QApplication::font()).boundingRect("M").size().height(); + smallSpacing = qMax(2, (int)(_s / 8)); + largeSpacing = _s; +} + } #include "moc_theme_p.cpp" diff --git a/src/plasma/private/theme_p.h b/src/plasma/private/theme_p.h index 25fc1cd08..6c490d7c5 100644 --- a/src/plasma/private/theme_p.h +++ b/src/plasma/private/theme_p.h @@ -77,6 +77,7 @@ public: bool useCache(); void setThemeName(const QString &themeName, bool writeSettings); void processWallpaperSettings(KConfigBase *metadata); + void updateSpacing(); const QString processStyleSheet(const QString &css); const QString svgStyleSheet(); @@ -137,6 +138,8 @@ public: CacheTypes cachesToDiscard; int defaultIconSize; + int smallSpacing; + int largeSpacing; bool locolor : 1; bool compositingActive : 1; @@ -150,3 +153,5 @@ public: } #endif + +extern const QString s; diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp index 55b820a8c..799d122ac 100644 --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -20,7 +20,6 @@ #include "theme.h" #include "private/theme_p.h" -#include #include #include #include @@ -566,6 +565,22 @@ int Theme::enormousIconSize() const return KIconLoader::SizeEnormous; } +QSizeF Theme::mSize(const QFont &font) const +{ + return QFontMetrics(font).boundingRect("M").size(); +} + +int Theme::smallSpacing() const +{ + return d->smallSpacing; +} + +int Theme::largeSpacing() const +{ + return d->largeSpacing; +} + + } diff --git a/src/plasma/theme.h b/src/plasma/theme.h index db62484b3..b718232c8 100644 --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -21,6 +21,8 @@ #ifndef PLASMA_THEME_H #define PLASMA_THEME_H +#include +#include #include #include @@ -60,6 +62,9 @@ class PLASMA_EXPORT Theme : public QObject Q_PROPERTY(QFont defaultFont READ defaultFont NOTIFY defaultFontChanged) Q_PROPERTY(QFont smallestFont READ smallestFont NOTIFY smallestFontChanged) + // stylesheet + Q_PROPERTY(QString styleSheet READ styleSheet NOTIFY themeChanged) + // colors Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChanged) Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY themeChanged) @@ -349,7 +354,6 @@ class PLASMA_EXPORT Theme : public QObject QColor viewBackgroundColor() const; QColor viewHoverColor() const; QColor viewFocusColor() const; - QString styleSheet() const; int smallIconSize() const; int smallMediumIconSize() const; @@ -359,6 +363,12 @@ class PLASMA_EXPORT Theme : public QObject int enormousIconSize() const; int defaultIconSize() const; + int smallSpacing() const; + int largeSpacing() const; + + Q_INVOKABLE QSizeF mSize(const QFont &font = QApplication::font()) const; + + Q_SIGNALS: /** * Emitted when the user changes the theme. Stylesheet usage, colors, etc. should From 374d23093219bc49b66259564af7e4c9d5e3c5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Mon, 13 Jan 2014 02:11:37 +0100 Subject: [PATCH 7/7] wallpaperForSize moves to Plasma::Theme --- src/declarativeimports/core/theme.cpp | 5 ----- src/declarativeimports/core/theme.h | 8 -------- src/plasma/theme.cpp | 5 +++++ src/plasma/theme.h | 5 +++++ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/declarativeimports/core/theme.cpp b/src/declarativeimports/core/theme.cpp index 284154db0..5ac53f35e 100644 --- a/src/declarativeimports/core/theme.cpp +++ b/src/declarativeimports/core/theme.cpp @@ -48,11 +48,6 @@ ThemeProxy::~ThemeProxy() { } -QString ThemeProxy::wallpaperPathForSize(int width, int height) const -{ - return Plasma::Theme::wallpaperPath(QSize(width, height)); -} - void ThemeProxy::iconLoaderSettingsChanged() { m_iconSizes->insert("desktop", QVariant(KIconLoader::global()->currentSize(KIconLoader::Desktop))); diff --git a/src/declarativeimports/core/theme.h b/src/declarativeimports/core/theme.h index 8c5841bc2..4c83d4b84 100644 --- a/src/declarativeimports/core/theme.h +++ b/src/declarativeimports/core/theme.h @@ -51,16 +51,10 @@ class ThemeProxy : public Plasma::Theme */ Q_PROPERTY(QQmlPropertyMap *iconSizes READ iconSizes NOTIFY iconSizesChanged) - // layout hints - Q_PROPERTY(int smallSpacing READ smallSpacing CONSTANT) - Q_PROPERTY(int largeSpacing READ largeSpacing CONSTANT) - public: ThemeProxy(QQmlEngine *parent = 0); ~ThemeProxy(); - Q_INVOKABLE QString wallpaperPathForSize(int width=-1, int height=-1) const; - QQmlPropertyMap *iconSizes() const; private Q_SLOTS: @@ -71,8 +65,6 @@ Q_SIGNALS: void iconSizesChanged(); private: - int m_smallSpacing; - int m_largeSpacing; QQmlPropertyMap *m_iconSizes; QQmlEngine *m_engine; }; diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp index 799d122ac..2a40e6d9d 100644 --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -256,6 +256,11 @@ QString Theme::wallpaperPath(const QSize &size) const return fullPath; } +QString Theme::wallpaperPathForSize(int width, int height) const +{ + return Plasma::Theme::wallpaperPath(QSize(width, height)); +} + bool Theme::currentThemeHasImage(const QString &name) const { if (name.contains("../")) { diff --git a/src/plasma/theme.h b/src/plasma/theme.h index b718232c8..07af1c937 100644 --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -90,6 +90,9 @@ class PLASMA_EXPORT Theme : public QObject Q_PROPERTY(int enormousIconSize READ enormousIconSize CONSTANT) Q_PROPERTY(int defaultIconSize READ defaultIconSize NOTIFY defaultIconSizeChanged) + // layout hints + Q_PROPERTY(int smallSpacing READ smallSpacing CONSTANT) + Q_PROPERTY(int largeSpacing READ largeSpacing CONSTANT) public: enum ColorRole { @@ -153,6 +156,8 @@ class PLASMA_EXPORT Theme : public QObject */ QString wallpaperPath(const QSize &size = QSize()) const; + Q_INVOKABLE QString wallpaperPathForSize(int width=-1, int height=-1) const; + /** * Checks if this theme has an image named in a certain way *