summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/composewindow.cpp14
-rw-r--r--src/config.cpp22
-rw-r--r--src/mainwindow.cpp1
3 files changed, 35 insertions, 2 deletions
diff --git a/src/composewindow.cpp b/src/composewindow.cpp
index 6193e1c..5a92fa2 100644
--- a/src/composewindow.cpp
+++ b/src/composewindow.cpp
@@ -551,6 +551,20 @@ void ComposeWindow::buildFormatToolbar()
// Remove attachment moves to its own button beside the list it acts on.
m_detachButton->setDefaultAction(m_detachAction);
+
+ // Ctrl+W closes the composer (item 148), the way it closes a window in
+ // every other application. Parented to this window like the formatting
+ // shortcuts, so it is a WindowShortcut dispatched to the active composer
+ // only and the main window's own namespace is untouched.
+ //
+ // close() rather than anything of its own: closeEvent() already decides
+ // whether the draft is saved or discarded, and a second route out that
+ // skipped it would lose the message.
+ auto *closeAction = new QAction(tr("Close"), this);
+ closeAction->setObjectName(QStringLiteral("compose_close"));
+ closeAction->setShortcut(QKeySequence(QStringLiteral("Ctrl+W")));
+ connect(closeAction, &QAction::triggered, this, &ComposeWindow::close);
+ addAction(closeAction);
}
void ComposeWindow::seedFields()
diff --git a/src/config.cpp b/src/config.cpp
index b148102..cb6168f 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -63,11 +63,12 @@ const QStringList kQueryGenerators = { QStringLiteral("unread"),
QStringLiteral("inbox"),
QStringLiteral("flagged"),
QStringLiteral("sent"),
+ QStringLiteral("drafts"),
QStringLiteral("trash") };
/// The tag a generator matches, for the three filters that are a plain tag
-/// query. Empty for "sent", which composes from each account's folder instead
-/// and is handled separately.
+/// query. Empty for "sent", "drafts" and "trash", which compose from each
+/// account's folder instead and are handled separately.
QString generatorTag(const QString &generator)
{
if (generator == QStringLiteral("unread"))
@@ -986,6 +987,12 @@ SavedQuery Config::builtinFilter(const QString &generator)
// thread would fold the user's sent message back into the conversation
// it belongs to, which is item 63's finding.
filter.flat = true;
+ } else if (generator == QStringLiteral("drafts")) {
+ // The LABEL is translated; the generator stays `drafts`, which is what
+ // queries.json stores and what a closed set is matched against.
+ filter.name = tr("Drafts");
+ // NOT flat, like Trash and unlike Sent: a draft reply belongs with the
+ // conversation it answers.
} else if (generator == QStringLiteral("trash")) {
filter.name = tr("Trash");
// NOT flat, unlike Sent. A deleted message still belongs to its
@@ -1015,6 +1022,10 @@ QString Config::resolvedQuery(const SavedQuery &query,
const QString all = allSentQuery();
return all.isEmpty() ? matchNothingQuery() : all;
}
+ if (query.generated == QStringLiteral("drafts")) {
+ const QString all = allDraftsQuery();
+ return all.isEmpty() ? matchNothingQuery() : all;
+ }
if (query.generated == QStringLiteral("trash")) {
const QString all = allTrashQuery();
return all.isEmpty() ? matchNothingQuery() : all;
@@ -1039,6 +1050,13 @@ QString Config::resolvedQuery(const SavedQuery &query,
return sent.isEmpty() ? matchNothingQuery() : sent;
}
+ if (query.generated == QStringLiteral("drafts")) {
+ // The account's OWN drafts query, for the reason spelled out above the
+ // sent case.
+ const QString drafts = scope.draftsQuery();
+ return drafts.isEmpty() ? matchNothingQuery() : drafts;
+ }
+
if (query.generated == QStringLiteral("trash")) {
// The account's OWN trash query, for the reason spelled out above the
// sent case: wrapping the all-accounts query in this account's path
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 5cb1ab8..da18869 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2630,6 +2630,7 @@ void MainWindow::buildSavedQueryRow(QWidget *parent, QVBoxLayout *layout)
{ QStringLiteral("inbox"), QStringLiteral("mail-inbox") },
{ QStringLiteral("flagged"), QStringLiteral("starred") },
{ QStringLiteral("sent"), QStringLiteral("mail-folder-sent") },
+ { QStringLiteral("drafts"), QStringLiteral("document-edit") },
{ QStringLiteral("trash"), QStringLiteral("user-trash") },
};
button->setIcon(