aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/shortcutmanager.cpp
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2017-03-09 15:11:03 +0100
committerThomas Hartmann <thomas.hartmann@qt.io>2017-03-10 15:17:12 +0000
commit4b539cf56070044e1c4539b4ef6d6e3f7e76d260 (patch)
tree5f617ea4b3d3db48e8309682601d2054c6e94818 /src/plugins/qmldesigner/shortcutmanager.cpp
parent7826ec7ed5c44cf6bc5c80f10c8588dff8372c5d (diff)
QmlDesigner: Fixing delete action
The delete action should always be visible (not always enabled) in the toolbar. For this, we have to use the main Qml Designer context. We react to context changes manually to disable delete, cut, copy and paste. Those actions should only be available in the formeditor and navigator. Change-Id: Ibc3b718c14e787c8451a3e84b679eb37aac814b5 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner/shortcutmanager.cpp')
-rw-r--r--src/plugins/qmldesigner/shortcutmanager.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/plugins/qmldesigner/shortcutmanager.cpp b/src/plugins/qmldesigner/shortcutmanager.cpp
index 45ac8ff423..e5d775d81f 100644
--- a/src/plugins/qmldesigner/shortcutmanager.cpp
+++ b/src/plugins/qmldesigner/shortcutmanager.cpp
@@ -42,6 +42,8 @@
#include <qmljseditor/qmljseditorconstants.h>
#include <qmljseditor/qmljseditordocument.h>
+#include <coreplugin/icore.h>
+
#include <utils/hostosinfo.h>
#include <utils/proxyaction.h>
#include <utils/utilsicons.h>
@@ -198,15 +200,7 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
m_deleteAction.setIcon(QIcon::fromTheme(QLatin1String("edit-cut"), Utils::Icons::EDIT_CLEAR_TOOLBAR.icon()));
- Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_BACKSPACE, qmlDesignerFormEditorContext);
- command = Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_BACKSPACE, qmlDesignerNavigatorContext);
- command->setDefaultKeySequence(QKeySequence(Qt::Key_Backspace));
- command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes
- if (Utils::HostOsInfo::isMacHost())
- editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
-
- Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_DELETE, qmlDesignerFormEditorContext);
- command = Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_DELETE, qmlDesignerNavigatorContext);
+ command = Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_DELETE, qmlDesignerMainContext);
command->setDefaultKeySequence(QKeySequence::Delete);
command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes
if (!Utils::HostOsInfo::isMacHost())
@@ -274,6 +268,15 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
m_copyAction.setEnabled(itemsSelected);
});
+ connect(Core::ICore::instance(), &Core::ICore::contextChanged, this, [this](const Core::Context &context){
+ if (!context.contains(Constants::C_QMLFORMEDITOR) && !context.contains(Constants::C_QMLNAVIGATOR)) {
+ m_deleteAction.setEnabled(false);
+ m_cutAction.setEnabled(false);
+ m_copyAction.setEnabled(false);
+ m_pasteAction.setEnabled(false);
+ }
+ });
+
updateClipboard(&m_pasteAction);
connect(QApplication::clipboard(), &QClipboard::QClipboard::changed, this, [this]() {
updateClipboard(&m_pasteAction);