From 9ed1f28d0f44ee9a66c93249fce15b5ebe32bb7d Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 17 Feb 2023 13:47:16 +0200 Subject: [PATCH] scripting: Drop registerShortcut() function in QML API Use ShortcutHandler type instead. --- src/scripting/scripting.cpp | 21 --------------------- src/scripting/scripting.h | 1 - 2 files changed, 22 deletions(-) diff --git a/src/scripting/scripting.cpp b/src/scripting/scripting.cpp index 7ad1a86c3a..a17e03013a 100644 --- a/src/scripting/scripting.cpp +++ b/src/scripting/scripting.cpp @@ -624,27 +624,6 @@ void KWin::JSEngineGlobalMethodsWrapper::registerWindow(QQuickWindow *window) } } -bool KWin::JSEngineGlobalMethodsWrapper::registerShortcut(const QString &name, const QString &text, const QKeySequence &keys, QJSValue function) -{ - if (!function.isCallable()) { - qCDebug(KWIN_SCRIPTING) << "Fourth and final argument must be a javascript function"; - return false; - } - - QAction *a = new QAction(this); - a->setObjectName(name); - a->setText(text); - const QKeySequence shortcut = QKeySequence(keys); - KGlobalAccel::self()->setShortcut(a, QList{shortcut}); - - connect(a, &QAction::triggered, this, [=]() mutable { - QJSValueList arguments; - arguments << Scripting::self()->qmlEngine()->toScriptValue(a); - function.call(arguments); - }); - return true; -} - KWin::Scripting *KWin::Scripting::s_self = nullptr; KWin::Scripting *KWin::Scripting::create(QObject *parent) diff --git a/src/scripting/scripting.h b/src/scripting/scripting.h index 39b47aada9..ce209c3bca 100644 --- a/src/scripting/scripting.h +++ b/src/scripting/scripting.h @@ -299,7 +299,6 @@ public: public Q_SLOTS: QVariant readConfig(const QString &key, QVariant defaultValue = QVariant()); void registerWindow(QQuickWindow *window); - bool registerShortcut(const QString &name, const QString &text, const QKeySequence &keys, QJSValue function); private: DeclarativeScript *m_script;