From 7be6e23d587e72eb736787b0f8532027192d4e9e Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 20 Dec 2007 23:44:08 +0000 Subject: [PATCH] add ability to set the general font to something else at runtime svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=751049 --- theme.cpp | 11 +++++++++-- theme.h | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/theme.cpp b/theme.cpp index a6b5b43e2..e550d2afb 100644 --- a/theme.cpp +++ b/theme.cpp @@ -36,6 +36,7 @@ class Theme::Private public: Private() { + generalFont = QApplication::font(); } KConfigGroup config() @@ -52,6 +53,7 @@ public: QString themeName; QString app; KSharedConfigPtr colors; + QFont generalFont; }; class ThemeSingleton @@ -165,16 +167,21 @@ QColor Theme::textColor() const return colors.foreground(KColorScheme::NormalText).color(); } +void Theme::setFont(const QFont &font) +{ + d->generalFont = font; +} + QFont Theme::font() const { //TODO: allow this to be overridden with a plasma specific font? - return QApplication::font(); + return d->generalFont; } QFontMetrics Theme::fontMetrics() const { //TODO: allow this to be overridden with a plasma specific font? - return QApplication::fontMetrics(); + return QFontMetrics(d->generalFont); } } diff --git a/theme.h b/theme.h index 8621a9a5e..c108ab86d 100644 --- a/theme.h +++ b/theme.h @@ -103,6 +103,12 @@ class PLASMA_EXPORT Theme : public QObject */ Q_INVOKABLE QColor textColor() const; + /** + * Sets the default font to be used with themed items. Defaults to + * the application wide default font. + */ + Q_INVOKABLE void setFont(const QFont &font); + /** * Returns the font to be used by themed items */