Skip to content

Commit

Permalink
Shortcuts (#467)
Browse files Browse the repository at this point in the history
* Added q as a shortcut for zooming to this quarter (#462)

* Added keyhint for year, which was missing

* Added f as a shortcut for opening the search dialog
  • Loading branch information
Tagirijus authored Apr 19, 2024
1 parent 3a381b0 commit 2557637
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions timetagger/app/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ def open(self, callback=None):
presets.children[0].innerHTML += " <span class='keyhint'>d</span>"
presets.children[1].innerHTML += " <span class='keyhint'>w</span>"
presets.children[2].innerHTML += " <span class='keyhint'>m</span>"
presets.children[3].innerHTML += " <span class='keyhint'>q</span>"
presets.children[4].innerHTML += " <span class='keyhint'>y</span>"

for i in range(presets.children.length):
but = presets.children[i]
Expand Down Expand Up @@ -3765,6 +3767,7 @@ def open(self, callback=None):
"D": "Select today",
"W": "Select this week",
"M": "Select this month",
"Q": "Select this quarter",
"Y": "Select this year",
"↑/PageUp": "Step back in time",
"↓/PageDown": "Step forward in time",
Expand All @@ -3774,6 +3777,7 @@ def open(self, callback=None):
"S": "Start the timer or add an earlier record",
"Shift+S": "Resume the current/previous record",
"X": "Stop the timer",
"F": "Open search dialog",
"T": "Select time range",
"R": "Open report dialog",
"I": "Open the guide",
Expand Down
9 changes: 9 additions & 0 deletions timetagger/app/front.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,10 @@ def on_pointer(self, ev):
def _on_key(self, e):
if e.ctrlKey or e.metaKey or e.altKey:
return # don't fight with the browser
#
elif e.key.lower() == "f":
self._handle_button_press("search")
#
elif e.key.lower() == "arrowup" or e.key.lower() == "pageup":
self._handle_button_press("nav_backward")
elif e.key.lower() == "arrowdown" or e.key.lower() == "pagedown":
Expand All @@ -1466,6 +1470,8 @@ def _on_key(self, e):
self._handle_button_press("nav_snap_now1W")
elif e.key.lower() == "m":
self._handle_button_press("nav_snap_now1M")
elif e.key.lower() == "q":
self._handle_button_press("nav_snap_now3M")
elif e.key.lower() == "y":
self._handle_button_press("nav_snap_now1Y")
elif e.key.lower() == "t":
Expand All @@ -1492,6 +1498,9 @@ def _handle_button_press(self, action):
if action == "menu":
self._canvas.menu_dialog.open()

elif action == "search":
self._canvas.search_dialog.open()

elif action == "login":
window.location.href = "../login"

Expand Down

0 comments on commit 2557637

Please sign in to comment.