bind standard icon sizes (desktop, toolbar etc)
they should be preferred over smallIconSize, mediumIconSize etc
This commit is contained in:
parent
cafb39f1ba
commit
171c795ac2
@ -92,6 +92,8 @@ void CoreBindingsPlugin::registerTypes(const char *uri)
|
||||
qmlRegisterInterface<Plasma::QueryMatch>("QueryMatch");
|
||||
qRegisterMetaType<Plasma::QueryMatch *>("QueryMatch");
|
||||
|
||||
qmlRegisterType<QDeclarativePropertyMap>();
|
||||
|
||||
/*qmlRegisterInterface<Plasma::DataSource>("DataSource");
|
||||
qRegisterMetaType<Plasma::DataSource*>("DataSource");*/
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "theme.h"
|
||||
|
||||
#include <QDeclarativePropertyMap>
|
||||
|
||||
#include <KIconLoader>
|
||||
|
||||
class FontProxySingleton
|
||||
@ -155,6 +157,14 @@ ThemeProxy::ThemeProxy(QObject *parent)
|
||||
{
|
||||
m_defaultIconSize = KIconLoader::global()->currentSize(KIconLoader::Desktop);
|
||||
|
||||
m_iconSizes = new QDeclarativePropertyMap(this);
|
||||
m_iconSizes->insert("desktop", QVariant(KIconLoader::global()->currentSize(KIconLoader::Desktop)));
|
||||
m_iconSizes->insert("toolbar", KIconLoader::global()->currentSize(KIconLoader::Toolbar));
|
||||
m_iconSizes->insert("mainToolbar", KIconLoader::global()->currentSize(KIconLoader::MainToolbar));
|
||||
m_iconSizes->insert("small", KIconLoader::global()->currentSize(KIconLoader::Small));
|
||||
m_iconSizes->insert("panel", KIconLoader::global()->currentSize(KIconLoader::Panel));
|
||||
m_iconSizes->insert("dialog", KIconLoader::global()->currentSize(KIconLoader::Dialog));
|
||||
|
||||
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SIGNAL(themeChanged()));
|
||||
connect(KIconLoader::global(), SIGNAL(iconLoaderSettingsChanged()), this, SLOT(iconLoaderSettingsChanged()));
|
||||
}
|
||||
@ -316,7 +326,16 @@ void ThemeProxy::iconLoaderSettingsChanged()
|
||||
|
||||
m_defaultIconSize = KIconLoader::global()->currentSize(KIconLoader::Desktop);
|
||||
|
||||
m_iconSizes->insert("desktop", QVariant(KIconLoader::global()->currentSize(KIconLoader::Desktop)));
|
||||
m_iconSizes->insert("toolbar", KIconLoader::global()->currentSize(KIconLoader::Toolbar));
|
||||
m_iconSizes->insert("mainToolbar", KIconLoader::global()->currentSize(KIconLoader::MainToolbar));
|
||||
m_iconSizes->insert("small", KIconLoader::global()->currentSize(KIconLoader::Small));
|
||||
m_iconSizes->insert("panel", KIconLoader::global()->currentSize(KIconLoader::Panel));
|
||||
m_iconSizes->insert("dialog", KIconLoader::global()->currentSize(KIconLoader::Dialog));
|
||||
|
||||
|
||||
emit defaultIconSizeChanged();
|
||||
emit iconSizesChanged();
|
||||
}
|
||||
|
||||
int ThemeProxy::defaultIconSize() const
|
||||
@ -324,5 +343,10 @@ int ThemeProxy::defaultIconSize() const
|
||||
return m_defaultIconSize;
|
||||
}
|
||||
|
||||
QDeclarativePropertyMap *ThemeProxy::iconSizes() const
|
||||
{
|
||||
return m_iconSizes;
|
||||
}
|
||||
|
||||
#include "theme.moc"
|
||||
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include <Plasma/Theme>
|
||||
|
||||
class QDeclarativePropertyMap;
|
||||
|
||||
class FontProxy : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -204,6 +206,19 @@ class ThemeProxy : public QObject
|
||||
Q_PROPERTY(int enormousIconSize READ enormousIconSize CONSTANT)
|
||||
Q_PROPERTY(int defaultIconSize READ defaultIconSize NOTIFY defaultIconSizeChanged)
|
||||
|
||||
/**
|
||||
* icon sizes depending from the context: use those if possible
|
||||
* Access with theme.iconSizes.desktop theme.iconSizes.small etc.
|
||||
* available keys are:
|
||||
* * desktop
|
||||
* * toolbar
|
||||
* * mainToolbar
|
||||
* * small
|
||||
* * panel
|
||||
* * dialog
|
||||
*/
|
||||
Q_PROPERTY(QDeclarativePropertyMap *iconSizes READ iconSizes NOTIFY iconSizesChanged)
|
||||
|
||||
public:
|
||||
ThemeProxy(QObject *parent = 0);
|
||||
~ThemeProxy();
|
||||
@ -240,6 +255,7 @@ public:
|
||||
int hugeIconSize() const;
|
||||
int enormousIconSize() const;
|
||||
int defaultIconSize() const;
|
||||
QDeclarativePropertyMap *iconSizes() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void iconLoaderSettingsChanged();
|
||||
@ -247,9 +263,11 @@ private Q_SLOTS:
|
||||
Q_SIGNALS:
|
||||
void themeChanged();
|
||||
void defaultIconSizeChanged();
|
||||
void iconSizesChanged();
|
||||
|
||||
private:
|
||||
int m_defaultIconSize;
|
||||
QDeclarativePropertyMap *m_iconSizes;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user