Skip to content

Commit

Permalink
Merge pull request #1391 from davvid/macos/hotkeys
Browse files Browse the repository at this point in the history
* davvid/macos/hotkeys:
  hotkeys: make Cmd-M minimize the main window
  docs: advertise Alt + M for amend mode
  hotkeys: use Alt-m for amend on macOS

Closes: #1390
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Mar 25, 2024
2 parents c51e122 + 2c0df25 commit e7edb2b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ Usability, bells and whistles

Fixes
-----
* The `Cmd-m` hotkey on macOS will now minimize the application. The "Amend" action
can now be accessed using `Alt-m`.
(`#1390 <https://github.com/git-cola/git-cola/issues/1390>`_)
(`#1391 <https://github.com/git-cola/git-cola/pull/1391>`_)

* The `git-cola-sequence-editor` Rebase Editor will now be found correctly
in more situatios on Windows.
(`#1385 <https://github.com/git-cola/git-cola/issues/1385>`_)
Expand Down
10 changes: 9 additions & 1 deletion cola/hotkeys.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

from qtpy.QtGui import QKeySequence
from qtpy.QtCore import Qt

Expand Down Expand Up @@ -48,7 +50,13 @@ def hotkey(*seq):
FOCUS_INPUT = hotkey(Qt.CTRL | Qt.Key_L)
FOCUS_STATUS = hotkey(Qt.CTRL | Qt.Key_K)
FOCUS_TREE = hotkey(Qt.CTRL | Qt.Key_K)
AMEND = hotkey(Qt.CTRL | Qt.Key_M)
AMEND_DEFAULT = hotkey(Qt.CTRL | Qt.Key_M)
AMEND_MACOS = hotkey(Qt.ALT | Qt.Key_M)
if sys.platform == 'darwin':
AMEND = (AMEND_MACOS,)
else:
AMEND = (AMEND_DEFAULT, AMEND_MACOS)
MACOS_MINIMIZE = hotkey(Qt.CTRL | Qt.Key_M)
MERGE = hotkey(Qt.CTRL | Qt.SHIFT | Qt.Key_M)
PUSH = hotkey(Qt.CTRL | Qt.Key_P)
PULL = hotkey(Qt.CTRL | Qt.SHIFT | Qt.Key_P)
Expand Down
2 changes: 1 addition & 1 deletion cola/widgets/commitmsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, context, parent):
self.amend_action = self.actions_menu.addAction(N_('Amend Last Commit'))
self.amend_action.setIcon(icons.edit())
self.amend_action.setCheckable(True)
self.amend_action.setShortcut(hotkeys.AMEND)
self.amend_action.setShortcuts(hotkeys.AMEND)
self.amend_action.setShortcutContext(Qt.ApplicationShortcut)

# Bypass hooks
Expand Down
9 changes: 8 additions & 1 deletion cola/widgets/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,14 @@ def __init__(self, context, parent=None):
False,
)
self.commit_amend_action.setIcon(icons.edit())
self.commit_amend_action.setShortcut(hotkeys.AMEND)
self.commit_amend_action.setShortcuts(hotkeys.AMEND)
self.commit_amend_action.setShortcutContext(Qt.WidgetShortcut)

# Make Cmd-M minimize the window on macOS.
if utils.is_darwin():
self.minimize_action = add_action(
self, N_('Minimize Window'), self.showMinimized, hotkeys.MACOS_MINIMIZE
)
self.unstage_all_action = add_action(
self, N_('Unstage All'), cmds.run(cmds.UnstageAll, context)
)
Expand Down Expand Up @@ -981,6 +986,8 @@ def create_view_menu(self):

def build_view_menu(self, menu):
menu.clear()
if utils.is_darwin():
menu.addAction(self.minimize_action)
menu.addAction(self.browse_action)
menu.addAction(self.dag_action)
menu.addSeparator()
Expand Down
2 changes: 1 addition & 1 deletion docs/hotkeys.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<td>Merge branches</td>
</tr>
<tr>
<td class="shortcut">Ctrl + m</td>
<td class="shortcut">Alt + M</td>
<td>:</td>
<td>Amend last commit</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion docs/hotkeys_de.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<td>Merge branches</td>
</tr>
<tr>
<td class="shortcut">Ctrl + M</td>
<td class="shortcut">Alt + M</td>
<td>:</td>
<td>Letzte Version nachbessern</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion docs/hotkeys_zh_CN.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<td>Merge branches</td>
</tr>
<tr>
<td class="shortcut">Ctrl + M</td>
<td class="shortcut">Alt + M</td>
<td>:</td>
<td>修正前一次提交</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion docs/hotkeys_zh_TW.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<td>合併分支</td>
</tr>
<tr>
<td class="shortcut">Ctrl + M</td>
<td class="shortcut">Alt + M</td>
<td>:</td>
<td>修正前一次的版本提交</td>
</tr>
Expand Down

0 comments on commit e7edb2b

Please sign in to comment.