forked from qt-creator/qt-creator
QmlPreview: Register previewAction properly
To make Alt+p shortcut for live preview work, it must be registered
to ActionManager. We use global context for this action as it should
work regardless of which view is active.
Shortcut is now also available in Settings/Environment/Keyboard, since
it is properly registered.
(cherry picked from commit 8b5c454881
)
Fixes: QDS-9229
Change-Id: Iee9671acd58f264bdb7b035d0ff1a343bcbd223e
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
4bf2b843c8
commit
00e1a73c8a
@@ -19,6 +19,9 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
#include <projectexplorer/runcontrol.h>
|
#include <projectexplorer/runcontrol.h>
|
||||||
@@ -61,6 +64,22 @@ QmlPreviewWidgetPlugin::QmlPreviewWidgetPlugin()
|
|||||||
|
|
||||||
m_previewToggleAction = previewAction->action();
|
m_previewToggleAction = previewAction->action();
|
||||||
|
|
||||||
|
Core::Context globalContext;
|
||||||
|
auto registerCommand = [&globalContext](ActionInterface *action){
|
||||||
|
const QString id = QStringLiteral("QmlPreview.%1").arg(QString::fromLatin1(action->menuId()));
|
||||||
|
Core::Command *cmd = Core::ActionManager::registerAction(action->action(),
|
||||||
|
id.toLatin1().constData(),
|
||||||
|
globalContext);
|
||||||
|
|
||||||
|
cmd->setDefaultKeySequence(action->action()->shortcut());
|
||||||
|
cmd->setDescription(action->action()->toolTip());
|
||||||
|
|
||||||
|
action->action()->setToolTip(cmd->action()->toolTip());
|
||||||
|
action->action()->setShortcut(cmd->action()->shortcut());
|
||||||
|
};
|
||||||
|
// Only register previewAction as others don't have keyboard shortcuts for them
|
||||||
|
registerCommand(previewAction);
|
||||||
|
|
||||||
if (s_previewPlugin) {
|
if (s_previewPlugin) {
|
||||||
auto fpsAction = new FpsAction;
|
auto fpsAction = new FpsAction;
|
||||||
designerActionManager.addDesignerAction(fpsAction);
|
designerActionManager.addDesignerAction(fpsAction);
|
||||||
|
Reference in New Issue
Block a user