Move spacing, stylesheet and mSize into Plasma::Theme
This commit is contained in:
parent
563035a1fa
commit
ea2a4db7ab
@ -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)));
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "theme.h"
|
||||
#include "private/theme_p.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
#ifndef PLASMA_THEME_H
|
||||
#define PLASMA_THEME_H
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFont>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <kplugininfo.h>
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user