theme.smallSpacing and theme.largeSpacing
Accessors to allow centralized control of spacing in a DPI-friendly way. Will be used to unify spacing across default widget to make them look more consistent. Currently, smallSpacing is font height / 10, large is font height / 2.
This commit is contained in:
parent
ae2ff16db7
commit
859e2ce352
@ -26,7 +26,7 @@
|
||||
#include <kiconloader.h>
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
//********** Theme *************
|
||||
|
||||
@ -46,6 +46,7 @@ ThemeProxy::ThemeProxy(QQmlEngine *parent)
|
||||
connect(this, &Plasma::Theme::themeChanged, this, &ThemeProxy::themeChanged);
|
||||
connect(KIconLoader::global(), SIGNAL(iconLoaderSettingsChanged()), this, SLOT(iconLoaderSettingsChanged()));
|
||||
|
||||
updateSpacing();
|
||||
installEventFilter(qApp);
|
||||
}
|
||||
|
||||
@ -57,6 +58,7 @@ bool ThemeProxy::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == QCoreApplication::instance()) {
|
||||
if (event->type() == QEvent::ApplicationFontChange || event->type() == QEvent::FontChange) {
|
||||
//updateSpacing();
|
||||
defaultFontChanged();
|
||||
smallestFontChanged();
|
||||
}
|
||||
@ -64,6 +66,13 @@ bool ThemeProxy::eventFilter(QObject *watched, QEvent *event)
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void ThemeProxy::updateSpacing()
|
||||
{
|
||||
const int _s = mSize().height();
|
||||
m_smallSpacing = (int)(_s / 10);
|
||||
m_largeSpacing = (int)(_s / 2);
|
||||
}
|
||||
|
||||
QString ThemeProxy::themeName() const
|
||||
{
|
||||
return Plasma::Theme::themeName();
|
||||
@ -84,6 +93,15 @@ 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
|
||||
{
|
||||
|
@ -85,6 +85,10 @@ class ThemeProxy : public Plasma::Theme
|
||||
*/
|
||||
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:
|
||||
ThemeProxy(QQmlEngine *parent = 0);
|
||||
~ThemeProxy();
|
||||
@ -125,6 +129,9 @@ public:
|
||||
int defaultIconSize() const;
|
||||
QQmlPropertyMap *iconSizes() const;
|
||||
|
||||
int smallSpacing() const;
|
||||
int largeSpacing() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void iconLoaderSettingsChanged();
|
||||
|
||||
@ -137,6 +144,9 @@ Q_SIGNALS:
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
void updateSpacing();
|
||||
int m_smallSpacing;
|
||||
int m_largeSpacing;
|
||||
int m_defaultIconSize;
|
||||
QQmlPropertyMap *m_iconSizes;
|
||||
QQmlEngine *m_engine;
|
||||
|
Loading…
Reference in New Issue
Block a user