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.
This commit is contained in:
Sebastian Kügler 2014-01-12 20:10:19 +01:00
parent 25dcdd39a4
commit a9b1f2c619
6 changed files with 61 additions and 56 deletions

View File

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

View File

@ -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;
};

View File

@ -26,6 +26,7 @@
#include <QFontDatabase>
#include <kdirwatch.h>
#include <kiconloader.h>
#include <kwindoweffects.h>
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),

View File

@ -136,6 +136,8 @@ public:
unsigned cacheSize;
CacheTypes cachesToDiscard;
int defaultIconSize;
bool locolor : 1;
bool compositingActive : 1;
bool blurActive : 1;

View File

@ -36,6 +36,7 @@
#include <kconfiggroup.h>
#include <QDebug>
#include <kdirwatch.h>
#include <kiconloader.h>
#include <kmanagerselection.h>
#include <kimagecache.h>
#include <ksharedconfig.h>
@ -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"

View File

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