a way to read and write global shortcuts from qml config views

This commit is contained in:
Marco Martin 2014-02-14 17:28:10 +01:00
parent 7e8aa867b0
commit d1b0e89a63
2 changed files with 22 additions and 1 deletions

View File

@ -124,6 +124,21 @@ ConfigModel *ConfigView::configModel() const
return d->configModel;
}
QString ConfigView::appletGlobalShortcut() const
{
return d->applet->globalShortcut().toString();
}
void ConfigView::setAppletGlobalShortcut(const QString &shortcut)
{
if (d->applet->globalShortcut().toString().toLower() == shortcut.toLower()) {
return;
}
d->applet->setGlobalShortcut(shortcut);
emit appletGlobalShortcutChanged();
}
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
void ConfigView::hideEvent(QHideEvent *ev)
{
@ -141,5 +156,4 @@ void ConfigView::resizeEvent(QResizeEvent *re)
QQuickWindow::resizeEvent(re);
}
#include "moc_configview.cpp"

View File

@ -37,6 +37,7 @@ class PLASMAQUICK_EXPORT ConfigView : public QQuickView
{
Q_OBJECT
Q_PROPERTY(ConfigModel *configModel READ configModel CONSTANT)
Q_PROPERTY(QString appletGlobalShortcut READ appletGlobalShortcut WRITE setAppletGlobalShortcut NOTIFY appletGlobalShortcutChanged)
public:
/**
@ -48,11 +49,17 @@ public:
virtual void init();
QString appletGlobalShortcut() const;
void setAppletGlobalShortcut(const QString &shortcut);
/**
* @return the ConfigModel of the ConfigView
**/
ConfigModel *configModel() const;
Q_SIGNALS:
void appletGlobalShortcutChanged();
protected:
void hideEvent(QHideEvent *ev);
void resizeEvent(QResizeEvent *re);