Add 'Close tab' nav item and shortcut. Add extra newline after headings
This commit is contained in:
parent
243980e006
commit
cff5f864e4
4 changed files with 28 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
* Allow time log entries to be edited directly in their table cells
|
||||
* Miscellaneous bug fixes for editing (list cursor positions/text selectivity, alarm removing newline)
|
||||
* Add 'Close tab' nav item and shortcut
|
||||
|
||||
# 0.4
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
"behaviour": "Behaviour",
|
||||
"never": "Never",
|
||||
"browse": "Browse",
|
||||
"close_tab": "Close tab",
|
||||
"previous": "Previous",
|
||||
"previous_day": "Previous day",
|
||||
"next": "Next",
|
||||
|
|
|
|||
|
|
@ -260,6 +260,13 @@ class MainWindow(QMainWindow):
|
|||
nav_menu.addAction(act_today)
|
||||
self.addAction(act_today)
|
||||
|
||||
act_close_tab = QAction(strings._("close_tab"), self)
|
||||
act_close_tab.setShortcut("Ctrl+W")
|
||||
act_close_tab.setShortcutContext(Qt.ApplicationShortcut)
|
||||
act_close_tab.triggered.connect(self._close_current_tab)
|
||||
nav_menu.addAction(act_close_tab)
|
||||
self.addAction(act_close_tab)
|
||||
|
||||
act_find = QAction(strings._("find_on_page"), self)
|
||||
act_find.setShortcut(QKeySequence.Find)
|
||||
act_find.triggered.connect(self.findBar.show_bar)
|
||||
|
|
@ -520,6 +527,12 @@ class MainWindow(QMainWindow):
|
|||
|
||||
self.tab_widget.removeTab(index)
|
||||
|
||||
def _close_current_tab(self):
|
||||
"""Close the currently active tab via shortcuts (Ctrl+W)."""
|
||||
idx = self.tab_widget.currentIndex()
|
||||
if idx >= 0:
|
||||
self._close_tab(idx)
|
||||
|
||||
def _on_tab_changed(self, index: int):
|
||||
"""Handle tab change - reconnect toolbar and sync UI."""
|
||||
if index < 0:
|
||||
|
|
|
|||
|
|
@ -753,6 +753,19 @@ class MarkdownEditor(QTextEdit):
|
|||
super().keyPressEvent(event)
|
||||
return
|
||||
|
||||
# Auto-insert an extra blank line after headings (#, ##, ###)
|
||||
# when pressing Enter at the end of the line.
|
||||
if re.match(r"^#{1,3}\s+", stripped) and pos_in_block >= len(line_text):
|
||||
cursor.beginEditBlock()
|
||||
# First blank line: visual separator between heading and body
|
||||
cursor.insertBlock()
|
||||
# Second blank line: where body text will start (caret ends here)
|
||||
cursor.insertBlock()
|
||||
cursor.endEditBlock()
|
||||
|
||||
self.setTextCursor(cursor)
|
||||
return
|
||||
|
||||
# Check for list continuation
|
||||
list_type, prefix = self._detect_list_type(current_line)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue