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)
|
||||
{
|
||||
if (event->key() != Qt::Key_Delete) {
|
||||
if (event->key() != Qt::Key_Delete && event->key() != Qt::Key_Backspace) {
|
||||
TreeView::keyPressEvent(event);
|
||||
return;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -1509,7 +1509,7 @@ bool BreakHandler::setData(const QModelIndex &idx, const QVariant &value, int ro
|
||||
return contextMenuEvent(ev);
|
||||
|
||||
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();
|
||||
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<QKeyEvent>(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)
|
||||
|
@@ -310,7 +310,7 @@ bool EngineItem::setData(int row, const QVariant &value, int role)
|
||||
}
|
||||
|
||||
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();
|
||||
} else if (kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter) {
|
||||
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 (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;
|
||||
|
@@ -282,6 +282,7 @@ bool DocSettingsPageWidget::eventFilter(QObject *object, QEvent *event)
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
auto ke = static_cast<const QKeyEvent*>(event);
|
||||
switch (ke->key()) {
|
||||
case Qt::Key_Backspace:
|
||||
case Qt::Key_Delete:
|
||||
removeDocumentation(currentSelection());
|
||||
break;
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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<QToolButton *> 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;
|
||||
}
|
||||
|
@@ -102,7 +102,6 @@ private:
|
||||
private:
|
||||
Ui::ConnectionViewWidget *ui;
|
||||
QmlDesigner::ActionEditor *m_actionEditor;
|
||||
QShortcut *m_deleteShortcut;
|
||||
};
|
||||
|
||||
} // 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()));
|
||||
|
||||
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())
|
||||
|
@@ -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);
|
||||
|
@@ -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<ScxmlTag*>(ind.internalPointer());
|
||||
if (tag && m_currentDocument) {
|
||||
|
@@ -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);
|
||||
|
@@ -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--) {
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user