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();
}
QJSValue ThemeProxy::defaultFont() const
QFont ThemeProxy::defaultFont() const
{
QJSValue val(m_engine->toScriptValue(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;
return QApplication::font();
}
QJSValue ThemeProxy::smallestFont() const
QFont ThemeProxy::smallestFont() const
{
QJSValue val(m_engine->toScriptValue(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;
return KGlobalSettings::smallestReadableFont();
}
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)
//fonts
Q_PROPERTY(QJSValue defaultFont READ defaultFont NOTIFY defaultFontChanged)
Q_PROPERTY(QJSValue smallestFont READ smallestFont NOTIFY smallestFontChanged)
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)
@ -90,8 +90,8 @@ public:
~ThemeProxy();
QString themeName() const;
QJSValue defaultFont() const;
QJSValue smallestFont() const;
QFont defaultFont() const;
QFont smallestFont() const;
/**
* @return The size of an uppercase M in a font, defaultFont() by default
*/

View File

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