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] 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;