defaultFont, desktopFont and smallestFont
This commit is contained in:
parent
3f4487e018
commit
9eda90088e
@ -19,18 +19,26 @@
|
||||
|
||||
#include "theme_p.h"
|
||||
|
||||
#include <plasma/theme.h>
|
||||
|
||||
class FontProxySingleton
|
||||
{
|
||||
public:
|
||||
FontProxy self;
|
||||
FontProxySingleton()
|
||||
: defaultFont(Plasma::Theme::DefaultFont),
|
||||
desktopFont(Plasma::Theme::DesktopFont),
|
||||
smallestFont(Plasma::Theme::SmallestFont)
|
||||
{
|
||||
}
|
||||
|
||||
FontProxy defaultFont;
|
||||
FontProxy desktopFont;
|
||||
FontProxy smallestFont;
|
||||
};
|
||||
|
||||
K_GLOBAL_STATIC(FontProxySingleton, privateFontProxySingleton)
|
||||
|
||||
FontProxy::FontProxy(QObject *parent)
|
||||
: QObject(parent)
|
||||
FontProxy::FontProxy(Plasma::Theme::FontRole role, QObject *parent)
|
||||
: QObject(parent),
|
||||
m_fontRole(role)
|
||||
{
|
||||
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
||||
this, SLOT(boldChanged()));
|
||||
@ -60,64 +68,74 @@ FontProxy::~FontProxy()
|
||||
{
|
||||
}
|
||||
|
||||
FontProxy *FontProxy::self()
|
||||
FontProxy *FontProxy::defaultFont()
|
||||
{
|
||||
return &privateFontProxySingleton->self;
|
||||
return &privateFontProxySingleton->defaultFont;
|
||||
}
|
||||
|
||||
FontProxy *FontProxy::desktopFont()
|
||||
{
|
||||
return &privateFontProxySingleton->desktopFont;
|
||||
}
|
||||
|
||||
FontProxy *FontProxy::smallestFont()
|
||||
{
|
||||
return &privateFontProxySingleton->smallestFont;
|
||||
}
|
||||
|
||||
bool FontProxy::bold() const
|
||||
{
|
||||
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).bold();
|
||||
return Plasma::Theme::defaultTheme()->font(m_fontRole).bold();
|
||||
}
|
||||
|
||||
FontProxy::Capitalization FontProxy::capitalization() const
|
||||
{
|
||||
return (FontProxy::Capitalization)Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).capitalization();
|
||||
return (FontProxy::Capitalization)Plasma::Theme::defaultTheme()->font(m_fontRole).capitalization();
|
||||
}
|
||||
|
||||
QString FontProxy::family() const
|
||||
{
|
||||
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).family();
|
||||
return Plasma::Theme::defaultTheme()->font(m_fontRole).family();
|
||||
}
|
||||
|
||||
bool FontProxy::italic() const
|
||||
{
|
||||
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).italic();
|
||||
return Plasma::Theme::defaultTheme()->font(m_fontRole).italic();
|
||||
}
|
||||
|
||||
qreal FontProxy::letterSpacing() const
|
||||
{
|
||||
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).letterSpacing();
|
||||
return Plasma::Theme::defaultTheme()->font(m_fontRole).letterSpacing();
|
||||
}
|
||||
|
||||
int FontProxy::pixelSize() const
|
||||
{
|
||||
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).pixelSize();
|
||||
return Plasma::Theme::defaultTheme()->font(m_fontRole).pixelSize();
|
||||
}
|
||||
|
||||
qreal FontProxy::pointSize() const
|
||||
{
|
||||
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).pointSize();
|
||||
return Plasma::Theme::defaultTheme()->font(m_fontRole).pointSize();
|
||||
}
|
||||
|
||||
bool FontProxy::strikeOut() const
|
||||
{
|
||||
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).strikeOut();
|
||||
return Plasma::Theme::defaultTheme()->font(m_fontRole).strikeOut();
|
||||
}
|
||||
|
||||
bool FontProxy::underline() const
|
||||
{
|
||||
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).underline();
|
||||
return Plasma::Theme::defaultTheme()->font(m_fontRole).underline();
|
||||
}
|
||||
|
||||
FontProxy::Weight FontProxy::weight() const
|
||||
{
|
||||
return (FontProxy::Weight)Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).weight();
|
||||
return (FontProxy::Weight)Plasma::Theme::defaultTheme()->font(m_fontRole).weight();
|
||||
}
|
||||
|
||||
qreal FontProxy::wordSpacing() const
|
||||
{
|
||||
return Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont).wordSpacing();
|
||||
return Plasma::Theme::defaultTheme()->font(m_fontRole).wordSpacing();
|
||||
}
|
||||
|
||||
|
||||
@ -139,9 +157,19 @@ QString ThemeProxy::themeName() const
|
||||
return Plasma::Theme::defaultTheme()->themeName();
|
||||
}
|
||||
|
||||
QObject *ThemeProxy::font() const
|
||||
QObject *ThemeProxy::defaultFont() const
|
||||
{
|
||||
return FontProxy::self();
|
||||
return FontProxy::defaultFont();
|
||||
}
|
||||
|
||||
QObject *ThemeProxy::desktopFont() const
|
||||
{
|
||||
return FontProxy::desktopFont();
|
||||
}
|
||||
|
||||
QObject *ThemeProxy::smallestFont() const
|
||||
{
|
||||
return FontProxy::smallestFont();
|
||||
}
|
||||
|
||||
bool ThemeProxy::windowTranslucencyEnabled() const
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <QFont>
|
||||
#include <QColor>
|
||||
|
||||
#include <Plasma/Theme>
|
||||
|
||||
class FontProxy : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -60,9 +62,11 @@ public:
|
||||
Black = 87
|
||||
};
|
||||
|
||||
FontProxy(QObject *parent = 0);
|
||||
FontProxy(Plasma::Theme::FontRole role, QObject *parent = 0);
|
||||
~FontProxy();
|
||||
static FontProxy *self();
|
||||
static FontProxy *defaultFont();
|
||||
static FontProxy *desktopFont();
|
||||
static FontProxy *smallestFont();
|
||||
|
||||
bool bold() const;
|
||||
Capitalization capitalization() const;
|
||||
@ -88,6 +92,9 @@ Q_SIGNALS:
|
||||
void underlineChanged();
|
||||
void weightChanged();
|
||||
void wordSpacingChanged();
|
||||
|
||||
private:
|
||||
Plasma::Theme::FontRole m_fontRole;
|
||||
};
|
||||
|
||||
class ThemeProxy : public QObject
|
||||
@ -101,7 +108,9 @@ class ThemeProxy : public QObject
|
||||
Q_PROPERTY(QString wallpaperPath READ wallpaperPath NOTIFY themeChanged)
|
||||
|
||||
//fonts
|
||||
Q_PROPERTY(QObject *font READ font CONSTANT)
|
||||
Q_PROPERTY(QObject *defaultFont READ defaultFont CONSTANT)
|
||||
Q_PROPERTY(QObject *desktopFont READ desktopFont CONSTANT)
|
||||
Q_PROPERTY(QObject *smallestFont READ smallestFont CONSTANT)
|
||||
|
||||
// colors
|
||||
Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChanged)
|
||||
@ -125,7 +134,9 @@ public:
|
||||
~ThemeProxy();
|
||||
|
||||
QString themeName() const;
|
||||
QObject *font() const;
|
||||
QObject *defaultFont() const;
|
||||
QObject *desktopFont() const;
|
||||
QObject *smallestFont() const;
|
||||
bool windowTranslucencyEnabled() const;
|
||||
KUrl homepage() const;
|
||||
bool useGlobalSettings() const;
|
||||
|
@ -23,15 +23,15 @@ import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
Text {
|
||||
id: root
|
||||
|
||||
font.capitalization: theme.font.capitalization
|
||||
font.family: theme.font.family
|
||||
font.italic: theme.font.italic
|
||||
font.letterSpacing: theme.font.letterSpacing
|
||||
font.pointSize: theme.font.pointSize
|
||||
font.strikeout: theme.font.strikeout
|
||||
font.underline: theme.font.underline
|
||||
font.weight: theme.font.weight
|
||||
font.wordSpacing: theme.font.wordSpacing
|
||||
font.capitalization: theme.defaultFont.capitalization
|
||||
font.family: theme.defaultFont.family
|
||||
font.italic: theme.defaultFont.italic
|
||||
font.letterSpacing: theme.defaultFont.letterSpacing
|
||||
font.pointSize: theme.defaultFont.pointSize
|
||||
font.strikeout: theme.defaultFont.strikeout
|
||||
font.underline: theme.defaultFont.underline
|
||||
font.weight: theme.defaultFont.weight
|
||||
font.wordSpacing: theme.defaultFont.wordSpacing
|
||||
|
||||
wrapMode: Text.Wrap
|
||||
color: theme.textColor
|
||||
|
Loading…
Reference in New Issue
Block a user