forked from qt-creator/qt-creator
Add some additional shortcuts for actions
Add Cmd+Shift+- for decreasing font size on macOS. Do not add Cmd+= for increasing size, because it conflicts with the existing shortcut for "Replace and Find Next". Sprinkle some Backspace shortcuts in addition to Delete for removing items. There are (laptop) keyboards that either do not have a designated Delete key (requiring Fn+Backspace) or where the Delete key is not conveniently located/sized, and there is no benefit in making the distinction in that case anyhow. Fixes: QTCREATORBUG-706 Fixes: QTCREATORBUG-13733 Change-Id: I06274a9810b82800ec6158a883c95d2a7ae2465e Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -187,7 +187,7 @@ void WorkspaceView::showEvent(QShowEvent *event)
|
|||||||
|
|
||||||
void WorkspaceView::keyPressEvent(QKeyEvent *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);
|
TreeView::keyPressEvent(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -274,7 +274,7 @@ void BookmarkView::removeBookmark(const QModelIndex& index)
|
|||||||
|
|
||||||
void BookmarkView::keyPressEvent(QKeyEvent *event)
|
void BookmarkView::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if (event->key() == Qt::Key_Delete) {
|
if (event->key() == Qt::Key_Delete || event->key() == Qt::Key_Backspace) {
|
||||||
removeBookmark(currentIndex());
|
removeBookmark(currentIndex());
|
||||||
event->accept();
|
event->accept();
|
||||||
return;
|
return;
|
||||||
|
@@ -645,6 +645,9 @@ void MainWindow::registerDefaultActions()
|
|||||||
: Utils::Icons::ZOOMOUT_TOOLBAR.icon();
|
: Utils::Icons::ZOOMOUT_TOOLBAR.icon();
|
||||||
tmpaction = new QAction(icon, tr("Zoom Out"), this);
|
tmpaction = new QAction(icon, tr("Zoom Out"), this);
|
||||||
cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_OUT);
|
cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_OUT);
|
||||||
|
if (useMacShortcuts)
|
||||||
|
cmd->setDefaultKeySequences({QKeySequence(tr("Ctrl+-")), QKeySequence(tr("Ctrl+Shift+-"))});
|
||||||
|
else
|
||||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+-")));
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+-")));
|
||||||
tmpaction->setEnabled(false);
|
tmpaction->setEnabled(false);
|
||||||
|
|
||||||
|
@@ -1509,7 +1509,7 @@ bool BreakHandler::setData(const QModelIndex &idx, const QVariant &value, int ro
|
|||||||
return contextMenuEvent(ev);
|
return contextMenuEvent(ev);
|
||||||
|
|
||||||
if (auto kev = ev.as<QKeyEvent>(QEvent::KeyPress)) {
|
if (auto kev = ev.as<QKeyEvent>(QEvent::KeyPress)) {
|
||||||
if (kev->key() == Qt::Key_Delete) {
|
if (kev->key() == Qt::Key_Delete || kev->key() == Qt::Key_Backspace) {
|
||||||
QModelIndexList si = ev.currentOrSelectedRows();
|
QModelIndexList si = ev.currentOrSelectedRows();
|
||||||
const Breakpoints bps = findBreakpointsByIndex(si);
|
const Breakpoints bps = findBreakpointsByIndex(si);
|
||||||
for (Breakpoint bp : bps) {
|
for (Breakpoint bp : bps) {
|
||||||
@@ -2547,7 +2547,7 @@ bool BreakpointManager::setData(const QModelIndex &idx, const QVariant &value, i
|
|||||||
return contextMenuEvent(ev);
|
return contextMenuEvent(ev);
|
||||||
|
|
||||||
if (auto kev = ev.as<QKeyEvent>(QEvent::KeyPress)) {
|
if (auto kev = ev.as<QKeyEvent>(QEvent::KeyPress)) {
|
||||||
if (kev->key() == Qt::Key_Delete) {
|
if (kev->key() == Qt::Key_Delete || kev->key() == Qt::Key_Backspace) {
|
||||||
QModelIndexList si = ev.currentOrSelectedRows();
|
QModelIndexList si = ev.currentOrSelectedRows();
|
||||||
const GlobalBreakpoints gbps = findBreakpointsByIndex(si);
|
const GlobalBreakpoints gbps = findBreakpointsByIndex(si);
|
||||||
for (GlobalBreakpoint gbp : gbps)
|
for (GlobalBreakpoint gbp : gbps)
|
||||||
|
@@ -310,7 +310,7 @@ bool EngineItem::setData(int row, const QVariant &value, int role)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (auto kev = ev.as<QKeyEvent>(QEvent::KeyPress)) {
|
if (auto kev = ev.as<QKeyEvent>(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();
|
m_engine->quitDebugger();
|
||||||
} else if (kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter) {
|
} else if (kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter) {
|
||||||
d->activateEngineByIndex(row);
|
d->activateEngineByIndex(row);
|
||||||
|
@@ -1108,7 +1108,8 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (auto kev = ev.as<QKeyEvent>(QEvent::KeyPress)) {
|
if (auto kev = ev.as<QKeyEvent>(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())
|
foreach (const QModelIndex &idx, ev.selectedRows())
|
||||||
removeWatchItem(itemForIndex(idx));
|
removeWatchItem(itemForIndex(idx));
|
||||||
return true;
|
return true;
|
||||||
|
@@ -282,6 +282,7 @@ bool DocSettingsPageWidget::eventFilter(QObject *object, QEvent *event)
|
|||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
auto ke = static_cast<const QKeyEvent*>(event);
|
auto ke = static_cast<const QKeyEvent*>(event);
|
||||||
switch (ke->key()) {
|
switch (ke->key()) {
|
||||||
|
case Qt::Key_Backspace:
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
removeDocumentation(currentSelection());
|
removeDocumentation(currentSelection());
|
||||||
break;
|
break;
|
||||||
|
@@ -1362,7 +1362,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
dd->m_removeFileAction = new QAction(this);
|
dd->m_removeFileAction = new QAction(this);
|
||||||
cmd = ActionManager::registerAction(dd->m_removeFileAction, Constants::REMOVEFILE,
|
cmd = ActionManager::registerAction(dd->m_removeFileAction, Constants::REMOVEFILE,
|
||||||
projectTreeContext);
|
projectTreeContext);
|
||||||
cmd->setDefaultKeySequence(QKeySequence::Delete);
|
cmd->setDefaultKeySequences({QKeySequence::Delete, QKeySequence::Backspace});
|
||||||
mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
|
mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
|
||||||
|
|
||||||
// duplicate file action
|
// duplicate file action
|
||||||
@@ -1381,7 +1381,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
dd->m_deleteFileAction = new QAction(tr("Delete File..."), this);
|
dd->m_deleteFileAction = new QAction(tr("Delete File..."), this);
|
||||||
cmd = ActionManager::registerAction(dd->m_deleteFileAction, Constants::DELETEFILE,
|
cmd = ActionManager::registerAction(dd->m_deleteFileAction, Constants::DELETEFILE,
|
||||||
projectTreeContext);
|
projectTreeContext);
|
||||||
cmd->setDefaultKeySequence(QKeySequence::Delete);
|
cmd->setDefaultKeySequences({QKeySequence::Delete, QKeySequence::Backspace});
|
||||||
mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
|
mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
|
||||||
|
|
||||||
// renamefile action
|
// renamefile action
|
||||||
|
@@ -42,7 +42,7 @@ QAction *RemoveTaskHandler::createAction(QObject *parent) const
|
|||||||
{
|
{
|
||||||
QAction *removeAction = new QAction(tr("Remove", "Name of the action triggering the removetaskhandler"), parent);
|
QAction *removeAction = new QAction(tr("Remove", "Name of the action triggering the removetaskhandler"), parent);
|
||||||
removeAction->setToolTip(tr("Remove task from the task list."));
|
removeAction->setToolTip(tr("Remove task from the task list."));
|
||||||
removeAction->setShortcut(QKeySequence(QKeySequence::Delete));
|
removeAction->setShortcuts({QKeySequence::Delete, QKeySequence::Backspace});
|
||||||
removeAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
removeAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||||
return removeAction;
|
return removeAction;
|
||||||
}
|
}
|
||||||
|
@@ -152,7 +152,7 @@ void SessionView::showEvent(QShowEvent *event)
|
|||||||
|
|
||||||
void SessionView::keyPressEvent(QKeyEvent *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);
|
TreeView::keyPressEvent(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -147,6 +147,7 @@ void ClassList::removeCurrentClass()
|
|||||||
void ClassList::keyPressEvent(QKeyEvent *event)
|
void ClassList::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
|
case Qt::Key_Backspace:
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
removeCurrentClass();
|
removeCurrentClass();
|
||||||
break;
|
break;
|
||||||
|
@@ -58,7 +58,6 @@ ConnectionViewWidget::ConnectionViewWidget(QWidget *parent) :
|
|||||||
ui(new Ui::ConnectionViewWidget)
|
ui(new Ui::ConnectionViewWidget)
|
||||||
{
|
{
|
||||||
m_actionEditor = new QmlDesigner::ActionEditor(this);
|
m_actionEditor = new QmlDesigner::ActionEditor(this);
|
||||||
m_deleteShortcut = new QShortcut(this);
|
|
||||||
QObject::connect(m_actionEditor, &QmlDesigner::ActionEditor::accepted,
|
QObject::connect(m_actionEditor, &QmlDesigner::ActionEditor::accepted,
|
||||||
[&]() {
|
[&]() {
|
||||||
if (m_actionEditor->hasModelIndex()) {
|
if (m_actionEditor->hasModelIndex()) {
|
||||||
@@ -125,7 +124,6 @@ ConnectionViewWidget::~ConnectionViewWidget()
|
|||||||
{
|
{
|
||||||
delete m_actionEditor;
|
delete m_actionEditor;
|
||||||
delete ui;
|
delete ui;
|
||||||
delete m_deleteShortcut;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionViewWidget::setBindingModel(BindingModel *model)
|
void ConnectionViewWidget::setBindingModel(BindingModel *model)
|
||||||
@@ -215,9 +213,11 @@ QList<QToolButton *> ConnectionViewWidget::createToolBarWidgets()
|
|||||||
connect(buttons.constLast(), &QAbstractButton::clicked, this, &ConnectionViewWidget::removeButtonClicked);
|
connect(buttons.constLast(), &QAbstractButton::clicked, this, &ConnectionViewWidget::removeButtonClicked);
|
||||||
connect(this, &ConnectionViewWidget::setEnabledRemoveButton, buttons.constLast(), &QWidget::setEnabled);
|
connect(this, &ConnectionViewWidget::setEnabledRemoveButton, buttons.constLast(), &QWidget::setEnabled);
|
||||||
|
|
||||||
m_deleteShortcut->setKey(Qt::Key_Delete);
|
QAction *deleteShortcut = new QAction(this);
|
||||||
m_deleteShortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
this->addAction(deleteShortcut);
|
||||||
connect(m_deleteShortcut, &QShortcut::activated, this, &ConnectionViewWidget::removeButtonClicked);
|
deleteShortcut->setShortcuts({QKeySequence::Delete, QKeySequence::Backspace});
|
||||||
|
deleteShortcut->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||||
|
connect(deleteShortcut, &QAction::triggered, this, &ConnectionViewWidget::removeButtonClicked);
|
||||||
|
|
||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
@@ -102,7 +102,6 @@ private:
|
|||||||
private:
|
private:
|
||||||
Ui::ConnectionViewWidget *ui;
|
Ui::ConnectionViewWidget *ui;
|
||||||
QmlDesigner::ActionEditor *m_actionEditor;
|
QmlDesigner::ActionEditor *m_actionEditor;
|
||||||
QShortcut *m_deleteShortcut;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -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()));
|
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);
|
command = Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_DELETE, qmlDesignerMainContext);
|
||||||
if (Utils::HostOsInfo::isMacHost())
|
command->setDefaultKeySequences({QKeySequence::Delete, QKeySequence::Backspace});
|
||||||
command->setDefaultKeySequence(QKeySequence::Backspace);
|
|
||||||
else
|
|
||||||
command->setDefaultKeySequence(QKeySequence::Delete);
|
|
||||||
|
|
||||||
Utils::HostOsInfo::isMacHost() ;
|
|
||||||
|
|
||||||
command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes
|
command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes
|
||||||
if (!Utils::HostOsInfo::isMacHost())
|
if (!Utils::HostOsInfo::isMacHost())
|
||||||
|
@@ -175,7 +175,7 @@ void ResourceView::removeFiles(int prefixIndex, int firstFileIndex, int lastFile
|
|||||||
|
|
||||||
void ResourceView::keyPressEvent(QKeyEvent *e)
|
void ResourceView::keyPressEvent(QKeyEvent *e)
|
||||||
{
|
{
|
||||||
if (e->key() == Qt::Key_Delete)
|
if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace)
|
||||||
emit removeItem();
|
emit removeItem();
|
||||||
else
|
else
|
||||||
Utils::TreeView::keyPressEvent(e);
|
Utils::TreeView::keyPressEvent(e);
|
||||||
|
@@ -239,7 +239,7 @@ void Structure::childAdded(const QModelIndex &childIndex)
|
|||||||
|
|
||||||
void Structure::keyPressEvent(QKeyEvent *e)
|
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());
|
QModelIndex ind = m_proxyModel->mapToSource(m_structureView->currentIndex());
|
||||||
auto tag = static_cast<ScxmlTag*>(ind.internalPointer());
|
auto tag = static_cast<ScxmlTag*>(ind.internalPointer());
|
||||||
if (tag && m_currentDocument) {
|
if (tag && m_currentDocument) {
|
||||||
|
@@ -679,7 +679,7 @@ void GraphicsScene::keyPressEvent(QKeyEvent *event)
|
|||||||
{
|
{
|
||||||
QGraphicsItem *focusItem = this->focusItem();
|
QGraphicsItem *focusItem = this->focusItem();
|
||||||
if (!focusItem || focusItem->type() != TextType) {
|
if (!focusItem || focusItem->type() != TextType) {
|
||||||
if (event->key() == Qt::Key_Delete)
|
if (event->key() == Qt::Key_Delete || event->key() == Qt::Key_Backspace)
|
||||||
removeSelectedItems();
|
removeSelectedItems();
|
||||||
}
|
}
|
||||||
QGraphicsScene::keyPressEvent(event);
|
QGraphicsScene::keyPressEvent(event);
|
||||||
|
@@ -457,7 +457,7 @@ void TransitionItem::selectedMenuAction(const QAction *action)
|
|||||||
|
|
||||||
void TransitionItem::keyPressEvent(QKeyEvent *event)
|
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;
|
bool bFound = false;
|
||||||
if (m_cornerGrabbers.count() > 2) {
|
if (m_cornerGrabbers.count() > 2) {
|
||||||
for (int i = m_cornerGrabbers.count() - 1; i >= 1; i--) {
|
for (int i = m_cornerGrabbers.count() - 1; i >= 1; i--) {
|
||||||
|
@@ -61,7 +61,7 @@ MemcheckErrorView::MemcheckErrorView(QWidget *parent)
|
|||||||
{":/valgrind/images/suppressoverlay.png", Utils::Theme::IconsErrorColor}},
|
{":/valgrind/images/suppressoverlay.png", Utils::Theme::IconsErrorColor}},
|
||||||
Utils::Icon::Tint | Utils::Icon::PunchEdges).icon();
|
Utils::Icon::Tint | Utils::Icon::PunchEdges).icon();
|
||||||
m_suppressAction->setIcon(icon);
|
m_suppressAction->setIcon(icon);
|
||||||
m_suppressAction->setShortcut(QKeySequence(Qt::Key_Delete));
|
m_suppressAction->setShortcuts({QKeySequence::Delete, QKeySequence::Backspace});
|
||||||
m_suppressAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
m_suppressAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||||
connect(m_suppressAction, &QAction::triggered, this, &MemcheckErrorView::suppressError);
|
connect(m_suppressAction, &QAction::triggered, this, &MemcheckErrorView::suppressError);
|
||||||
addAction(m_suppressAction);
|
addAction(m_suppressAction);
|
||||||
|
@@ -273,6 +273,7 @@ bool BookmarkDialog::eventFilter(QObject *object, QEvent *e)
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case Qt::Key_Backspace:
|
||||||
case Qt::Key_Delete: {
|
case Qt::Key_Delete: {
|
||||||
bookmarkManager->removeBookmarkItem(ui.treeView,
|
bookmarkManager->removeBookmarkItem(ui.treeView,
|
||||||
proxyModel->mapToSource(index));
|
proxyModel->mapToSource(index));
|
||||||
@@ -489,7 +490,7 @@ bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
|
|||||||
treeView->edit(index);
|
treeView->edit(index);
|
||||||
item->setEditable(false);
|
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);
|
bookmarkManager->removeBookmarkItem(treeView, src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user