diff --git a/src/libs/advanceddockingsystem/workspaceview.cpp b/src/libs/advanceddockingsystem/workspaceview.cpp index 383aa2d0a52..087fc056afc 100644 --- a/src/libs/advanceddockingsystem/workspaceview.cpp +++ b/src/libs/advanceddockingsystem/workspaceview.cpp @@ -187,7 +187,7 @@ void WorkspaceView::showEvent(QShowEvent *event) void WorkspaceView::keyPressEvent(QKeyEvent *event) { - if (event->key() != Qt::Key_Delete) { + if (event->key() != Qt::Key_Delete && event->key() != Qt::Key_Backspace) { TreeView::keyPressEvent(event); return; } diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index f4147f02a32..7c1854ff294 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -274,7 +274,7 @@ void BookmarkView::removeBookmark(const QModelIndex& index) void BookmarkView::keyPressEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Delete) { + if (event->key() == Qt::Key_Delete || event->key() == Qt::Key_Backspace) { removeBookmark(currentIndex()); event->accept(); return; diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 67a3e80635f..929d498827a 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -645,7 +645,10 @@ void MainWindow::registerDefaultActions() : Utils::Icons::ZOOMOUT_TOOLBAR.icon(); tmpaction = new QAction(icon, tr("Zoom Out"), this); cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_OUT); - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+-"))); + if (useMacShortcuts) + cmd->setDefaultKeySequences({QKeySequence(tr("Ctrl+-")), QKeySequence(tr("Ctrl+Shift+-"))}); + else + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+-"))); tmpaction->setEnabled(false); // Zoom Reset Action diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index ae840e772c6..930f63bf4fa 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -1509,7 +1509,7 @@ bool BreakHandler::setData(const QModelIndex &idx, const QVariant &value, int ro return contextMenuEvent(ev); if (auto kev = ev.as(QEvent::KeyPress)) { - if (kev->key() == Qt::Key_Delete) { + if (kev->key() == Qt::Key_Delete || kev->key() == Qt::Key_Backspace) { QModelIndexList si = ev.currentOrSelectedRows(); const Breakpoints bps = findBreakpointsByIndex(si); for (Breakpoint bp : bps) { @@ -2547,7 +2547,7 @@ bool BreakpointManager::setData(const QModelIndex &idx, const QVariant &value, i return contextMenuEvent(ev); if (auto kev = ev.as(QEvent::KeyPress)) { - if (kev->key() == Qt::Key_Delete) { + if (kev->key() == Qt::Key_Delete || kev->key() == Qt::Key_Backspace) { QModelIndexList si = ev.currentOrSelectedRows(); const GlobalBreakpoints gbps = findBreakpointsByIndex(si); for (GlobalBreakpoint gbp : gbps) diff --git a/src/plugins/debugger/enginemanager.cpp b/src/plugins/debugger/enginemanager.cpp index 8c2bbca1468..1770758b111 100644 --- a/src/plugins/debugger/enginemanager.cpp +++ b/src/plugins/debugger/enginemanager.cpp @@ -310,7 +310,7 @@ bool EngineItem::setData(int row, const QVariant &value, int role) } if (auto kev = ev.as(QEvent::KeyPress)) { - if (kev->key() == Qt::Key_Delete && m_engine) { + if ((kev->key() == Qt::Key_Delete || kev->key() == Qt::Key_Backspace) && m_engine) { m_engine->quitDebugger(); } else if (kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter) { d->activateEngineByIndex(row); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 066f9be23b0..9aac88f9e37 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -1108,7 +1108,8 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role } if (auto kev = ev.as(QEvent::KeyPress)) { - if (item && kev->key() == Qt::Key_Delete && item->isWatcher()) { + if (item && (kev->key() == Qt::Key_Delete || kev->key() == Qt::Key_Backspace) + && item->isWatcher()) { foreach (const QModelIndex &idx, ev.selectedRows()) removeWatchItem(itemForIndex(idx)); return true; diff --git a/src/plugins/help/docsettingspage.cpp b/src/plugins/help/docsettingspage.cpp index dca464a462d..efb9b8a6256 100644 --- a/src/plugins/help/docsettingspage.cpp +++ b/src/plugins/help/docsettingspage.cpp @@ -282,6 +282,7 @@ bool DocSettingsPageWidget::eventFilter(QObject *object, QEvent *event) if (event->type() == QEvent::KeyPress) { auto ke = static_cast(event); switch (ke->key()) { + case Qt::Key_Backspace: case Qt::Key_Delete: removeDocumentation(currentSelection()); break; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 8791ae69ed5..440acf9cf09 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1362,7 +1362,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_removeFileAction = new QAction(this); cmd = ActionManager::registerAction(dd->m_removeFileAction, Constants::REMOVEFILE, projectTreeContext); - cmd->setDefaultKeySequence(QKeySequence::Delete); + cmd->setDefaultKeySequences({QKeySequence::Delete, QKeySequence::Backspace}); mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER); // duplicate file action @@ -1381,7 +1381,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_deleteFileAction = new QAction(tr("Delete File..."), this); cmd = ActionManager::registerAction(dd->m_deleteFileAction, Constants::DELETEFILE, projectTreeContext); - cmd->setDefaultKeySequence(QKeySequence::Delete); + cmd->setDefaultKeySequences({QKeySequence::Delete, QKeySequence::Backspace}); mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER); // renamefile action diff --git a/src/plugins/projectexplorer/removetaskhandler.cpp b/src/plugins/projectexplorer/removetaskhandler.cpp index b71b9b0556c..b8abc22e11d 100644 --- a/src/plugins/projectexplorer/removetaskhandler.cpp +++ b/src/plugins/projectexplorer/removetaskhandler.cpp @@ -42,7 +42,7 @@ QAction *RemoveTaskHandler::createAction(QObject *parent) const { QAction *removeAction = new QAction(tr("Remove", "Name of the action triggering the removetaskhandler"), parent); removeAction->setToolTip(tr("Remove task from the task list.")); - removeAction->setShortcut(QKeySequence(QKeySequence::Delete)); + removeAction->setShortcuts({QKeySequence::Delete, QKeySequence::Backspace}); removeAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); return removeAction; } diff --git a/src/plugins/projectexplorer/sessionview.cpp b/src/plugins/projectexplorer/sessionview.cpp index ab92ce16b8d..49cd8b1486d 100644 --- a/src/plugins/projectexplorer/sessionview.cpp +++ b/src/plugins/projectexplorer/sessionview.cpp @@ -152,7 +152,7 @@ void SessionView::showEvent(QShowEvent *event) void SessionView::keyPressEvent(QKeyEvent *event) { - if (event->key() != Qt::Key_Delete) { + if (event->key() != Qt::Key_Delete && event->key() != Qt::Key_Backspace) { TreeView::keyPressEvent(event); return; } diff --git a/src/plugins/qmakeprojectmanager/customwidgetwizard/classlist.cpp b/src/plugins/qmakeprojectmanager/customwidgetwizard/classlist.cpp index 6c6a3ad7c67..1dcca7754c6 100644 --- a/src/plugins/qmakeprojectmanager/customwidgetwizard/classlist.cpp +++ b/src/plugins/qmakeprojectmanager/customwidgetwizard/classlist.cpp @@ -147,6 +147,7 @@ void ClassList::removeCurrentClass() void ClassList::keyPressEvent(QKeyEvent *event) { switch (event->key()) { + case Qt::Key_Backspace: case Qt::Key_Delete: removeCurrentClass(); break; diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.cpp index ae4532f1f13..1163af6c58b 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.cpp @@ -58,7 +58,6 @@ ConnectionViewWidget::ConnectionViewWidget(QWidget *parent) : ui(new Ui::ConnectionViewWidget) { m_actionEditor = new QmlDesigner::ActionEditor(this); - m_deleteShortcut = new QShortcut(this); QObject::connect(m_actionEditor, &QmlDesigner::ActionEditor::accepted, [&]() { if (m_actionEditor->hasModelIndex()) { @@ -125,7 +124,6 @@ ConnectionViewWidget::~ConnectionViewWidget() { delete m_actionEditor; delete ui; - delete m_deleteShortcut; } void ConnectionViewWidget::setBindingModel(BindingModel *model) @@ -215,9 +213,11 @@ QList ConnectionViewWidget::createToolBarWidgets() connect(buttons.constLast(), &QAbstractButton::clicked, this, &ConnectionViewWidget::removeButtonClicked); connect(this, &ConnectionViewWidget::setEnabledRemoveButton, buttons.constLast(), &QWidget::setEnabled); - m_deleteShortcut->setKey(Qt::Key_Delete); - m_deleteShortcut->setContext(Qt::WidgetWithChildrenShortcut); - connect(m_deleteShortcut, &QShortcut::activated, this, &ConnectionViewWidget::removeButtonClicked); + QAction *deleteShortcut = new QAction(this); + this->addAction(deleteShortcut); + deleteShortcut->setShortcuts({QKeySequence::Delete, QKeySequence::Backspace}); + deleteShortcut->setShortcutContext(Qt::WidgetWithChildrenShortcut); + connect(deleteShortcut, &QAction::triggered, this, &ConnectionViewWidget::removeButtonClicked); return buttons; } diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.h b/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.h index c1f1271fcac..d69d0de2801 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.h +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionviewwidget.h @@ -102,7 +102,6 @@ private: private: Ui::ConnectionViewWidget *ui; QmlDesigner::ActionEditor *m_actionEditor; - QShortcut *m_deleteShortcut; }; } // namespace Internal diff --git a/src/plugins/qmldesigner/shortcutmanager.cpp b/src/plugins/qmldesigner/shortcutmanager.cpp index 1ae2ef14819..617c1775aba 100644 --- a/src/plugins/qmldesigner/shortcutmanager.cpp +++ b/src/plugins/qmldesigner/shortcutmanager.cpp @@ -154,12 +154,7 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex m_deleteAction.setIcon(QIcon::fromTheme(QLatin1String("edit-cut"), Utils::Icons::EDIT_CLEAR_TOOLBAR.icon())); command = Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_DELETE, qmlDesignerMainContext); - if (Utils::HostOsInfo::isMacHost()) - command->setDefaultKeySequence(QKeySequence::Backspace); - else - command->setDefaultKeySequence(QKeySequence::Delete); - - Utils::HostOsInfo::isMacHost() ; + command->setDefaultKeySequences({QKeySequence::Delete, QKeySequence::Backspace}); command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes if (!Utils::HostOsInfo::isMacHost()) diff --git a/src/plugins/resourceeditor/qrceditor/resourceview.cpp b/src/plugins/resourceeditor/qrceditor/resourceview.cpp index 8e2c70ad792..1fc524bf28e 100644 --- a/src/plugins/resourceeditor/qrceditor/resourceview.cpp +++ b/src/plugins/resourceeditor/qrceditor/resourceview.cpp @@ -175,7 +175,7 @@ void ResourceView::removeFiles(int prefixIndex, int firstFileIndex, int lastFile void ResourceView::keyPressEvent(QKeyEvent *e) { - if (e->key() == Qt::Key_Delete) + if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) emit removeItem(); else Utils::TreeView::keyPressEvent(e); diff --git a/src/plugins/scxmleditor/common/structure.cpp b/src/plugins/scxmleditor/common/structure.cpp index be49e9711df..08164e0aa30 100644 --- a/src/plugins/scxmleditor/common/structure.cpp +++ b/src/plugins/scxmleditor/common/structure.cpp @@ -239,7 +239,7 @@ void Structure::childAdded(const QModelIndex &childIndex) void Structure::keyPressEvent(QKeyEvent *e) { - if (e->key() == Qt::Key_Delete) { + if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) { QModelIndex ind = m_proxyModel->mapToSource(m_structureView->currentIndex()); auto tag = static_cast(ind.internalPointer()); if (tag && m_currentDocument) { diff --git a/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp b/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp index 5513ed1ee79..863b40ae0c0 100644 --- a/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp +++ b/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp @@ -679,7 +679,7 @@ void GraphicsScene::keyPressEvent(QKeyEvent *event) { QGraphicsItem *focusItem = this->focusItem(); if (!focusItem || focusItem->type() != TextType) { - if (event->key() == Qt::Key_Delete) + if (event->key() == Qt::Key_Delete || event->key() == Qt::Key_Backspace) removeSelectedItems(); } QGraphicsScene::keyPressEvent(event); diff --git a/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp b/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp index e388a43cc82..fb0c5743ab2 100644 --- a/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp +++ b/src/plugins/scxmleditor/plugin_interface/transitionitem.cpp @@ -457,7 +457,7 @@ void TransitionItem::selectedMenuAction(const QAction *action) void TransitionItem::keyPressEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Delete) { + if (event->key() == Qt::Key_Delete || event->key() == Qt::Key_Backspace) { bool bFound = false; if (m_cornerGrabbers.count() > 2) { for (int i = m_cornerGrabbers.count() - 1; i >= 1; i--) { diff --git a/src/plugins/valgrind/memcheckerrorview.cpp b/src/plugins/valgrind/memcheckerrorview.cpp index 3dfa939dddb..0e45b76d43b 100644 --- a/src/plugins/valgrind/memcheckerrorview.cpp +++ b/src/plugins/valgrind/memcheckerrorview.cpp @@ -61,7 +61,7 @@ MemcheckErrorView::MemcheckErrorView(QWidget *parent) {":/valgrind/images/suppressoverlay.png", Utils::Theme::IconsErrorColor}}, Utils::Icon::Tint | Utils::Icon::PunchEdges).icon(); m_suppressAction->setIcon(icon); - m_suppressAction->setShortcut(QKeySequence(Qt::Key_Delete)); + m_suppressAction->setShortcuts({QKeySequence::Delete, QKeySequence::Backspace}); m_suppressAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); connect(m_suppressAction, &QAction::triggered, this, &MemcheckErrorView::suppressError); addAction(m_suppressAction); diff --git a/src/shared/help/bookmarkmanager.cpp b/src/shared/help/bookmarkmanager.cpp index c067334d4cd..e67f910e9c0 100644 --- a/src/shared/help/bookmarkmanager.cpp +++ b/src/shared/help/bookmarkmanager.cpp @@ -273,6 +273,7 @@ bool BookmarkDialog::eventFilter(QObject *object, QEvent *e) } } break; + case Qt::Key_Backspace: case Qt::Key_Delete: { bookmarkManager->removeBookmarkItem(ui.treeView, proxyModel->mapToSource(index)); @@ -489,7 +490,7 @@ bool BookmarkWidget::eventFilter(QObject *object, QEvent *e) treeView->edit(index); item->setEditable(false); } - } else if (ke->key() == Qt::Key_Delete) { + } else if (ke->key() == Qt::Key_Delete || ke->key() == Qt::Key_Backspace) { bookmarkManager->removeBookmarkItem(treeView, src); } }