From 364cb141e3dddcb1ebeb6c83a364870dabc03910 Mon Sep 17 00:00:00 2001 From: Kristofer Berggren Date: Sun, 1 Sep 2024 11:23:28 +0800 Subject: [PATCH] add auto-move config option allowing to disable trash target --- README.md | 5 +++++ src/nmail.1 | 2 +- src/ui.cpp | 19 +++++++++++++++---- src/ui.h | 1 + src/version.cpp | 2 +- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3dd3c13..dbd174c 100644 --- a/README.md +++ b/README.md @@ -713,6 +713,7 @@ This configuration file controls the UI aspects of nmail. Default configuration file (platform-dependent defaults are left empty below): attachment_indicator=📎 + automove_trash_allow=1 bottom_reply=0 cancel_without_confirm=0 colors_enabled=1 @@ -821,6 +822,10 @@ file (platform-dependent defaults are left empty below): Controls which character to indicate that an email has attachments (default: `📎`). For a more plain layout one can use an ascii character: `+`. +### automove_trash_allow + +Specifies whether trash folder may be selected as automove target folder. + ### bottom_reply Controls whether to reply at the bottom of emails (default disabled). diff --git a/src/nmail.1 b/src/nmail.1 index 0f7a58b..cc7f139 100644 --- a/src/nmail.1 +++ b/src/nmail.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH NMAIL "1" "August 2024" "nmail 5.1.15" "User Commands" +.TH NMAIL "1" "August 2024" "nmail 5.1.16" "User Commands" .SH NAME nmail \- ncurses mail .SH SYNOPSIS diff --git a/src/ui.cpp b/src/ui.cpp index dc3e812..363a40b 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -159,6 +159,7 @@ void Ui::Init() { "terminal_title", "" }, { "top_bar_show_version", "0" }, { "unwrap_quoted_lines", "1" }, + { "automove_trash_allow", "1" }, }; const std::string configPath(Util::GetApplicationDir() + std::string("ui.conf")); m_Config = Config(configPath, defaultConfig); @@ -360,6 +361,7 @@ void Ui::Init() m_Signature = m_Config.Get("signature") == "1"; m_TopBarShowVersion = m_Config.Get("top_bar_show_version") == "1"; m_UnwrapQuotedLines = m_Config.Get("unwrap_quoted_lines") == "1"; + m_AutomoveTrashAllow = m_Config.Get("automove_trash_allow") == "1"; try { @@ -7120,12 +7122,13 @@ void Ui::AutoMoveSelectFolder() const std::string queryCommonAllowTrash = queryNotCurrent + queryNotSent; std::vector queryStrs; + std::vector queryStrsAllowTrash; if (!subject.empty()) { // full subject const std::string querySpecific = "subject:\"" + subject + "\""; queryStrs.push_back(querySpecific + queryCommon); - queryStrs.push_back(querySpecific + queryCommonAllowTrash); + queryStrsAllowTrash.push_back(querySpecific + queryCommonAllowTrash); } if (!subjectPrefix.empty() && !sender.empty()) @@ -7133,7 +7136,7 @@ void Ui::AutoMoveSelectFolder() // subject prefix and sender name const std::string querySpecific = "subject:\"" + subjectPrefix + "*\" AND from:\"" + sender + "\""; queryStrs.push_back(querySpecific + queryCommon); - queryStrs.push_back(querySpecific + queryCommonAllowTrash); + queryStrsAllowTrash.push_back(querySpecific + queryCommonAllowTrash); } if (!subjectPrefix.empty()) @@ -7141,7 +7144,12 @@ void Ui::AutoMoveSelectFolder() // subject prefix const std::string querySpecific = "subject:\"" + subjectPrefix + "*\""; queryStrs.push_back(querySpecific + queryCommon); - queryStrs.push_back(querySpecific + queryCommonAllowTrash); + queryStrsAllowTrash.push_back(querySpecific + queryCommonAllowTrash); + } + + if (m_AutomoveTrashAllow) + { + queryStrs.insert(queryStrs.end(), queryStrsAllowTrash.begin(), queryStrsAllowTrash.end()); } if (!sender.empty()) @@ -7149,7 +7157,10 @@ void Ui::AutoMoveSelectFolder() // sender name const std::string querySpecific = "from:\"" + sender + "\""; queryStrs.push_back(querySpecific + queryCommon); - queryStrs.push_back(querySpecific + queryCommonAllowTrash); + if (m_AutomoveTrashAllow) + { + queryStrs.push_back(querySpecific + queryCommonAllowTrash); + } } if (!queryStrs.empty()) diff --git a/src/ui.h b/src/ui.h index 9623b85..e4e3578 100644 --- a/src/ui.h +++ b/src/ui.h @@ -440,6 +440,7 @@ class Ui bool m_Signature = false; bool m_TopBarShowVersion = false; bool m_UnwrapQuotedLines = false; + bool m_AutomoveTrashAllow = false; std::string m_TerminalTitle; diff --git a/src/version.cpp b/src/version.cpp index 23d98bf..59a4509 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -7,7 +7,7 @@ #include "version.h" -#define NMAIL_VERSION "5.1.15" +#define NMAIL_VERSION "5.1.16" std::string Version::GetBuildOs() {