apparently we can't tap into the valuetype conversion of QFont at all
theme.mSize(font) it is
This commit is contained in:
Marco Martin 2013-08-28 14:07:07 +02:00
parent 82a880396f
commit 86a2847c84
3 changed files with 13 additions and 20 deletions

View File

@ -59,26 +59,14 @@ QString ThemeProxy::themeName() const
return Plasma::Theme::themeName(); return Plasma::Theme::themeName();
} }
QJSValue ThemeProxy::defaultFont() const QFont ThemeProxy::defaultFont() const
{ {
QJSValue val(m_engine->toScriptValue(QApplication::font())); return QApplication::font();
const QSize size(QFontMetrics(QApplication::font()).boundingRect("M").size());
QJSValue sizeObj(m_engine->newObject());
sizeObj.setProperty("width", size.width());
sizeObj.setProperty("height", size.height());
val.setProperty("mSize", sizeObj);
return val;
} }
QJSValue ThemeProxy::smallestFont() const QFont ThemeProxy::smallestFont() const
{ {
QJSValue val(m_engine->toScriptValue(KGlobalSettings::smallestReadableFont())); return KGlobalSettings::smallestReadableFont();
const QSize size(QFontMetrics(QApplication::font()).boundingRect("M").size());
QJSValue sizeObj(m_engine->newObject());
sizeObj.setProperty("width", size.width());
sizeObj.setProperty("height", size.height());
val.setProperty("mSize", sizeObj);
return val;
} }
QSizeF ThemeProxy::mSize(const QFont &font) const QSizeF ThemeProxy::mSize(const QFont &font) const

View File

@ -45,8 +45,8 @@ class ThemeProxy : public Plasma::Theme
Q_PROPERTY(QString wallpaperPath READ wallpaperPath NOTIFY themeChanged) Q_PROPERTY(QString wallpaperPath READ wallpaperPath NOTIFY themeChanged)
//fonts //fonts
Q_PROPERTY(QJSValue defaultFont READ defaultFont NOTIFY defaultFontChanged) Q_PROPERTY(QFont defaultFont READ defaultFont NOTIFY defaultFontChanged)
Q_PROPERTY(QJSValue smallestFont READ smallestFont NOTIFY smallestFontChanged) Q_PROPERTY(QFont smallestFont READ smallestFont NOTIFY smallestFontChanged)
// colors // colors
Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChanged) Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChanged)
@ -90,8 +90,8 @@ public:
~ThemeProxy(); ~ThemeProxy();
QString themeName() const; QString themeName() const;
QJSValue defaultFont() const; QFont defaultFont() const;
QJSValue smallestFont() const; QFont smallestFont() const;
/** /**
* @return The size of an uppercase M in a font, defaultFont() by default * @return The size of an uppercase M in a font, defaultFont() by default
*/ */

View File

@ -48,4 +48,9 @@ Text {
color: theme.textColor color: theme.textColor
opacity: enabled? 1 : 0.6 opacity: enabled? 1 : 0.6
Component.onCompleted: {
for (var i in theme.defaultFont) {
print("AA"+i+theme.defaultFont[i])
}
}
} }