diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-24 18:56:08 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-24 18:56:08 +0200 |
| commit | 35b136944656c9ff9c3b064f47be08224f76c1f9 (patch) | |
| tree | 1668716a498c5d292dec57ea0710f454193c5ce9 /src | |
| parent | ab785283e6abd1730efd4499ba4bc436a3de2665 (diff) | |
| download | qtmaildir-35b136944656c9ff9c3b064f47be08224f76c1f9.tar.gz qtmaildir-35b136944656c9ff9c3b064f47be08224f76c1f9.zip | |
feat: close the calendar's event pane with Escape
Escape was scoped to the pane and only cancelled an edit, so once an
event was selected nothing closed the pane again. It is a window shortcut
now, labelled Close event: with no edit open it clears the selection and
the pane hides. With an edit open it cancels only when focus is inside
the pane, so a stray Escape after clicking the grid cannot discard the
form.
That guard needed the month grid to take focus on a click, which it never
did; the view-scoped PgUp/PgDn, Delete and Ctrl+Z were likewise reachable
only by Tab until now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/calendarwindow.cpp | 22 | ||||
| -rw-r--r-- | src/monthview.cpp | 3 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/calendarwindow.cpp b/src/calendarwindow.cpp index d9c1da2..4a07b89 100644 --- a/src/calendarwindow.cpp +++ b/src/calendarwindow.cpp @@ -25,6 +25,7 @@ #include "monthview.h" #include <QAction> +#include <QApplication> #include <QButtonGroup> #include <QCloseEvent> #include <QComboBox> @@ -276,8 +277,10 @@ void CalendarWindow::buildActions() QKeySequence(Qt::CTRL | Qt::Key_E), nullptr, &CalendarWindow::startEdit); QAction *del = make(QStringLiteral("deleteEvent"), tr("&Delete event"), QKeySequence(Qt::Key_Delete), m_views, &CalendarWindow::deleteSelected); - QAction *cancel = make(QStringLiteral("cancelEdit"), tr("Cancel &editing"), - QKeySequence(Qt::Key_Escape), m_pane, &CalendarWindow::cancelEdit); + // Window-wide, so Escape closes the details pane from the grid too; the + // combo and spin box popups take their own Escape first. + QAction *cancel = make(QStringLiteral("cancelEdit"), tr("C&lose event"), + QKeySequence(Qt::Key_Escape), nullptr, &CalendarWindow::cancelEdit); QAction *undo = m_undo.createUndoAction(this, tr("&Undo")); undo->setShortcut(QKeySequence::Undo); @@ -619,9 +622,18 @@ bool CalendarWindow::save() void CalendarWindow::cancelEdit() { - if (!m_pane->isEditing()) - return; - m_pane->stopEdit(); + // Cancelling an edit returns to the details; with no edit, closing the + // details clears the selection, which hides the pane. + if (m_pane->isEditing()) { + // Escape used to be scoped to the pane; keep a stray one from the + // grid from throwing away an edit. + if (!m_pane->isAncestorOf(QApplication::focusWidget())) + return; + m_pane->stopEdit(); + } else { + m_selectedUid.clear(); + m_selectedStart = {}; + } rebuildItems(); } diff --git a/src/monthview.cpp b/src/monthview.cpp index 202ef4a..5b56ee4 100644 --- a/src/monthview.cpp +++ b/src/monthview.cpp @@ -28,6 +28,9 @@ MonthView::MonthView(QWidget *parent) m_year(QDate::currentDate().year()), m_month(QDate::currentDate().month()) { setMinimumSize(420, 320); + // A click must move focus here, or it stays in the edit form and the + // view-scoped shortcuts and the Escape guard read the wrong widget. + setFocusPolicy(Qt::StrongFocus); } void MonthView::setMonth(int year, int month) |
