a way to read and write global shortcuts from qml config views
This commit is contained in:
parent
7e8aa867b0
commit
d1b0e89a63
@ -124,6 +124,21 @@ ConfigModel *ConfigView::configModel() const
|
|||||||
return d->configModel;
|
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
|
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
|
||||||
void ConfigView::hideEvent(QHideEvent *ev)
|
void ConfigView::hideEvent(QHideEvent *ev)
|
||||||
{
|
{
|
||||||
@ -141,5 +156,4 @@ void ConfigView::resizeEvent(QResizeEvent *re)
|
|||||||
QQuickWindow::resizeEvent(re);
|
QQuickWindow::resizeEvent(re);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "moc_configview.cpp"
|
#include "moc_configview.cpp"
|
||||||
|
@ -37,6 +37,7 @@ class PLASMAQUICK_EXPORT ConfigView : public QQuickView
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(ConfigModel *configModel READ configModel CONSTANT)
|
Q_PROPERTY(ConfigModel *configModel READ configModel CONSTANT)
|
||||||
|
Q_PROPERTY(QString appletGlobalShortcut READ appletGlobalShortcut WRITE setAppletGlobalShortcut NOTIFY appletGlobalShortcutChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -48,11 +49,17 @@ public:
|
|||||||
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
|
||||||
|
QString appletGlobalShortcut() const;
|
||||||
|
void setAppletGlobalShortcut(const QString &shortcut);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the ConfigModel of the ConfigView
|
* @return the ConfigModel of the ConfigView
|
||||||
**/
|
**/
|
||||||
ConfigModel *configModel() const;
|
ConfigModel *configModel() const;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void appletGlobalShortcutChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void hideEvent(QHideEvent *ev);
|
void hideEvent(QHideEvent *ev);
|
||||||
void resizeEvent(QResizeEvent *re);
|
void resizeEvent(QResizeEvent *re);
|
||||||
|
Loading…
Reference in New Issue
Block a user