Merge branch 'sebas/theme'
This commit is contained in:
commit
0a3a236dfb
@ -22,7 +22,6 @@
|
|||||||
#include <QQmlPropertyMap>
|
#include <QQmlPropertyMap>
|
||||||
|
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QFontDatabase>
|
|
||||||
#include <kiconloader.h>
|
#include <kiconloader.h>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
@ -34,8 +33,6 @@ ThemeProxy::ThemeProxy(QQmlEngine *parent)
|
|||||||
: Plasma::Theme(parent),
|
: Plasma::Theme(parent),
|
||||||
m_engine(parent)
|
m_engine(parent)
|
||||||
{
|
{
|
||||||
m_defaultIconSize = KIconLoader::global()->currentSize(KIconLoader::Desktop);
|
|
||||||
|
|
||||||
m_iconSizes = new QQmlPropertyMap(this);
|
m_iconSizes = new QQmlPropertyMap(this);
|
||||||
m_iconSizes->insert("desktop", QVariant(KIconLoader::global()->currentSize(KIconLoader::Desktop)));
|
m_iconSizes->insert("desktop", QVariant(KIconLoader::global()->currentSize(KIconLoader::Desktop)));
|
||||||
m_iconSizes->insert("panel", QVariant(KIconLoader::global()->currentSize(KIconLoader::Panel)));
|
m_iconSizes->insert("panel", QVariant(KIconLoader::global()->currentSize(KIconLoader::Panel)));
|
||||||
@ -45,201 +42,26 @@ ThemeProxy::ThemeProxy(QQmlEngine *parent)
|
|||||||
|
|
||||||
connect(this, &Plasma::Theme::themeChanged, this, &ThemeProxy::themeChanged);
|
connect(this, &Plasma::Theme::themeChanged, this, &ThemeProxy::themeChanged);
|
||||||
connect(KIconLoader::global(), SIGNAL(iconLoaderSettingsChanged()), this, SLOT(iconLoaderSettingsChanged()));
|
connect(KIconLoader::global(), SIGNAL(iconLoaderSettingsChanged()), this, SLOT(iconLoaderSettingsChanged()));
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
const int _s = mSize().height();
|
|
||||||
m_smallSpacing = qMax(2, (int)(_s / 8));
|
|
||||||
m_largeSpacing = _s;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ThemeProxy::themeName() const
|
|
||||||
{
|
|
||||||
return Plasma::Theme::themeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ThemeProxy::smallSpacing() const
|
|
||||||
{
|
|
||||||
return m_smallSpacing;
|
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
void ThemeProxy::iconLoaderSettingsChanged()
|
||||||
{
|
{
|
||||||
m_defaultIconSize = KIconLoader::global()->currentSize(KIconLoader::Desktop);
|
|
||||||
|
|
||||||
m_iconSizes->insert("desktop", QVariant(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("toolbar", KIconLoader::global()->currentSize(KIconLoader::Toolbar));
|
||||||
m_iconSizes->insert("small", KIconLoader::global()->currentSize(KIconLoader::Small));
|
m_iconSizes->insert("small", KIconLoader::global()->currentSize(KIconLoader::Small));
|
||||||
m_iconSizes->insert("dialog", KIconLoader::global()->currentSize(KIconLoader::Dialog));
|
m_iconSizes->insert("dialog", KIconLoader::global()->currentSize(KIconLoader::Dialog));
|
||||||
|
|
||||||
|
|
||||||
emit defaultIconSizeChanged();
|
emit defaultIconSizeChanged();
|
||||||
emit iconSizesChanged();
|
emit iconSizesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ThemeProxy::defaultIconSize() const
|
|
||||||
{
|
|
||||||
return m_defaultIconSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
QQmlPropertyMap *ThemeProxy::iconSizes() const
|
QQmlPropertyMap *ThemeProxy::iconSizes() const
|
||||||
{
|
{
|
||||||
return m_iconSizes;
|
return m_iconSizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_theme.cpp"
|
#include "moc_theme.cpp"
|
||||||
|
|
||||||
|
@ -40,40 +40,6 @@ class ThemeProxy : public Plasma::Theme
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
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)
|
|
||||||
|
|
||||||
// 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)
|
|
||||||
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
|
* icon sizes depending from the context: use those if possible
|
||||||
* Access with theme.iconSizes.desktop theme.iconSizes.small etc.
|
* Access with theme.iconSizes.desktop theme.iconSizes.small etc.
|
||||||
@ -85,69 +51,20 @@ class ThemeProxy : public Plasma::Theme
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(QQmlPropertyMap *iconSizes READ iconSizes NOTIFY iconSizesChanged)
|
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:
|
public:
|
||||||
ThemeProxy(QQmlEngine *parent = 0);
|
ThemeProxy(QQmlEngine *parent = 0);
|
||||||
~ThemeProxy();
|
~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;
|
|
||||||
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;
|
|
||||||
int smallMediumIconSize() const;
|
|
||||||
int mediumIconSize() const;
|
|
||||||
int largeIconSize() const;
|
|
||||||
int hugeIconSize() const;
|
|
||||||
int enormousIconSize() const;
|
|
||||||
int defaultIconSize() const;
|
|
||||||
QQmlPropertyMap *iconSizes() const;
|
QQmlPropertyMap *iconSizes() const;
|
||||||
|
|
||||||
int smallSpacing() const;
|
|
||||||
int largeSpacing() const;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void iconLoaderSettingsChanged();
|
void iconLoaderSettingsChanged();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void themeChanged();
|
void themeChanged();
|
||||||
void defaultIconSizeChanged();
|
|
||||||
void iconSizesChanged();
|
void iconSizesChanged();
|
||||||
void defaultFontChanged();
|
|
||||||
void smallestFontChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool eventFilter(QObject *watched, QEvent *event);
|
|
||||||
void updateSpacing();
|
|
||||||
int m_smallSpacing;
|
|
||||||
int m_largeSpacing;
|
|
||||||
int m_defaultIconSize;
|
|
||||||
QQmlPropertyMap *m_iconSizes;
|
QQmlPropertyMap *m_iconSizes;
|
||||||
QQmlEngine *m_engine;
|
QQmlEngine *m_engine;
|
||||||
};
|
};
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
|
|
||||||
#include <kdirwatch.h>
|
#include <kdirwatch.h>
|
||||||
|
#include <kiconloader.h>
|
||||||
#include <kwindoweffects.h>
|
#include <kwindoweffects.h>
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
@ -58,6 +59,7 @@ ThemePrivate::ThemePrivate(QObject *parent)
|
|||||||
pixmapCache(0),
|
pixmapCache(0),
|
||||||
cacheSize(0),
|
cacheSize(0),
|
||||||
cachesToDiscard(NoCache),
|
cachesToDiscard(NoCache),
|
||||||
|
defaultIconSize(KIconLoader::global()->currentSize(KIconLoader::Desktop)),
|
||||||
locolor(false),
|
locolor(false),
|
||||||
compositingActive(KWindowSystem::self()->compositingActive()),
|
compositingActive(KWindowSystem::self()->compositingActive()),
|
||||||
blurActive(false),
|
blurActive(false),
|
||||||
@ -88,6 +90,8 @@ 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);
|
||||||
|
updateSpacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemePrivate::~ThemePrivate()
|
ThemePrivate::~ThemePrivate()
|
||||||
@ -574,10 +578,21 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"
|
#include "moc_theme_p.cpp"
|
||||||
|
@ -77,6 +77,7 @@ public:
|
|||||||
bool useCache();
|
bool useCache();
|
||||||
void setThemeName(const QString &themeName, bool writeSettings);
|
void setThemeName(const QString &themeName, bool writeSettings);
|
||||||
void processWallpaperSettings(KConfigBase *metadata);
|
void processWallpaperSettings(KConfigBase *metadata);
|
||||||
|
void updateSpacing();
|
||||||
|
|
||||||
const QString processStyleSheet(const QString &css);
|
const QString processStyleSheet(const QString &css);
|
||||||
const QString svgStyleSheet();
|
const QString svgStyleSheet();
|
||||||
@ -94,6 +95,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;
|
||||||
@ -134,6 +137,10 @@ public:
|
|||||||
unsigned cacheSize;
|
unsigned cacheSize;
|
||||||
CacheTypes cachesToDiscard;
|
CacheTypes cachesToDiscard;
|
||||||
|
|
||||||
|
int defaultIconSize;
|
||||||
|
int smallSpacing;
|
||||||
|
int largeSpacing;
|
||||||
|
|
||||||
bool locolor : 1;
|
bool locolor : 1;
|
||||||
bool compositingActive : 1;
|
bool compositingActive : 1;
|
||||||
bool blurActive : 1;
|
bool blurActive : 1;
|
||||||
@ -146,3 +153,5 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern const QString s;
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "private/theme_p.h"
|
#include "private/theme_p.h"
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
#include <QFontDatabase>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMutableListIterator>
|
#include <QMutableListIterator>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
@ -35,6 +35,7 @@
|
|||||||
#include <kconfiggroup.h>
|
#include <kconfiggroup.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <kdirwatch.h>
|
#include <kdirwatch.h>
|
||||||
|
#include <kiconloader.h>
|
||||||
#include <kmanagerselection.h>
|
#include <kmanagerselection.h>
|
||||||
#include <kimagecache.h>
|
#include <kimagecache.h>
|
||||||
#include <ksharedconfig.h>
|
#include <ksharedconfig.h>
|
||||||
@ -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)
|
||||||
@ -253,6 +256,11 @@ QString Theme::wallpaperPath(const QSize &size) const
|
|||||||
return fullPath;
|
return fullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Theme::wallpaperPathForSize(int width, int height) const
|
||||||
|
{
|
||||||
|
return Plasma::Theme::wallpaperPath(QSize(width, height));
|
||||||
|
}
|
||||||
|
|
||||||
bool Theme::currentThemeHasImage(const QString &name) const
|
bool Theme::currentThemeHasImage(const QString &name) const
|
||||||
{
|
{
|
||||||
if (name.contains("../")) {
|
if (name.contains("../")) {
|
||||||
@ -452,6 +460,133 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_theme.cpp"
|
#include "moc_theme.cpp"
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#ifndef PLASMA_THEME_H
|
#ifndef PLASMA_THEME_H
|
||||||
#define PLASMA_THEME_H
|
#define PLASMA_THEME_H
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QFont>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
#include <kplugininfo.h>
|
#include <kplugininfo.h>
|
||||||
@ -52,6 +54,46 @@ class PLASMA_EXPORT Theme : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
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)
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
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)
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
// layout hints
|
||||||
|
Q_PROPERTY(int smallSpacing READ smallSpacing CONSTANT)
|
||||||
|
Q_PROPERTY(int largeSpacing READ largeSpacing CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ColorRole {
|
enum ColorRole {
|
||||||
TextColor = 0, /**< the text color to be used by items resting on the background */
|
TextColor = 0, /**< the text color to be used by items resting on the background */
|
||||||
@ -114,6 +156,8 @@ class PLASMA_EXPORT Theme : public QObject
|
|||||||
*/
|
*/
|
||||||
QString wallpaperPath(const QSize &size = QSize()) const;
|
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
|
* Checks if this theme has an image named in a certain way
|
||||||
*
|
*
|
||||||
@ -299,6 +343,37 @@ class PLASMA_EXPORT Theme : public QObject
|
|||||||
*/
|
*/
|
||||||
KPluginInfo pluginInfo() const;
|
KPluginInfo pluginInfo() const;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
int smallIconSize() const;
|
||||||
|
int smallMediumIconSize() const;
|
||||||
|
int mediumIconSize() const;
|
||||||
|
int largeIconSize() const;
|
||||||
|
int hugeIconSize() const;
|
||||||
|
int enormousIconSize() const;
|
||||||
|
int defaultIconSize() const;
|
||||||
|
|
||||||
|
int smallSpacing() const;
|
||||||
|
int largeSpacing() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE QSizeF mSize(const QFont &font = QApplication::font()) 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
|
||||||
@ -310,6 +385,11 @@ class PLASMA_EXPORT Theme : public QObject
|
|||||||
*/
|
*/
|
||||||
void themeChanged();
|
void themeChanged();
|
||||||
|
|
||||||
|
void defaultFontChanged();
|
||||||
|
void smallestFontChanged();
|
||||||
|
|
||||||
|
void defaultIconSizeChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SvgPrivate;
|
friend class SvgPrivate;
|
||||||
friend class ThemePrivate;
|
friend class ThemePrivate;
|
||||||
|
Loading…
Reference in New Issue
Block a user