From 2d115700654a38a1d517fb4c5a9342906d1dd984 Mon Sep 17 00:00:00 2001 From: Humdinger Date: Fri, 23 May 2025 17:21:20 +0200 Subject: [PATCH] =?UTF-8?q?Mail:=20Fix=20"Close=20and=20set=20to=E2=80=A6"?= =?UTF-8?q?=20for=20multiple=20mails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before, when you got multiple emails open, doing e.g. a "Close and leave as New" (SHIFT + ALT + W) would correctly leave the active email with status "New", but the other open Mail windows were closed as well and got the status "Read"! Now we only close the current Mail window, not the whole app and with it all open email windows. The currently somewhat hidden command "SHIFT + ALT + Q" now issues a message to all open Mail windows to close and keep their mails' status, i.e. the same as invoking SHIFT + ALT + W in all open email windows. Change-Id: I0402a1e39ce58b53eca2c3bfe8f8becd5529c566 Reviewed-on: https://review.haiku-os.org/c/haiku/+/9305 Reviewed-by: waddlesplash Tested-by: Commit checker robot --- src/apps/mail/MailApp.cpp | 8 ++++++++ src/apps/mail/MailWindow.cpp | 22 +++++++++++++--------- src/apps/mail/MailWindow.h | 5 ++++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/apps/mail/MailApp.cpp b/src/apps/mail/MailApp.cpp index 0dc81a762a..9e4b5848a1 100644 --- a/src/apps/mail/MailApp.cpp +++ b/src/apps/mail/MailApp.cpp @@ -413,6 +413,14 @@ TMailApp::MessageReceived(BMessage *msg) be_app->PostMessage(B_QUIT_REQUESTED); break; + case kMsgQuitAndKeepAllStatus: + { + for (int32 i = 0; i < fWindowList.CountItems(); i++) { + TMailWindow* window = (TMailWindow*)fWindowList.ItemAt(i); + window->PostMessage(new BMessage(kMsgCloseAndKeepAllStatus)); + } + break; + } case B_REFS_RECEIVED: RefsReceived(msg); break; diff --git a/src/apps/mail/MailWindow.cpp b/src/apps/mail/MailWindow.cpp index cbe8dc6816..52adfb7f61 100644 --- a/src/apps/mail/MailWindow.cpp +++ b/src/apps/mail/MailWindow.cpp @@ -134,7 +134,6 @@ static const char* kSpamMenuItemTextArray[] = { "Mark as genuine" // M_TRAIN_GENUINE }; -static const uint32 kMsgQuitAndKeepAllStatus = 'Casm'; static const char* kQueriesDirectory = "mail/queries"; static const char* kAttrQueryInitialMode = "_trk/qryinitmode"; @@ -212,7 +211,7 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app, fDownloading(false) { - fKeepStatusOnQuit = false; + fKeepStatusOnClose = false; if (messenger != NULL) fTrackerMessenger = *messenger; @@ -273,7 +272,7 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app, subMenu->AddItem(new BMenuItem( B_TRANSLATE_COMMENT("Leave as 'New'", "Do not translate New - this is non-localizable e-mail status"), - new BMessage(kMsgQuitAndKeepAllStatus), 'W', B_SHIFT_KEY)); + new BMessage(kMsgCloseAndKeepAllStatus), 'W', B_SHIFT_KEY)); } else { BString status; file.ReadAttrString(B_MAIL_ATTR_STATUS, &status); @@ -288,7 +287,7 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app, subMenu->AddItem(new BMenuItem(label.String(), new BMessage(B_QUIT_REQUESTED), 'W')); AddShortcut('W', B_COMMAND_KEY | B_SHIFT_KEY, - new BMessage(kMsgQuitAndKeepAllStatus)); + new BMessage(kMsgCloseAndKeepAllStatus)); } subMenu->AddItem(new BMenuItem(B_TRANSLATE("Move to trash"), @@ -1025,7 +1024,7 @@ TMailWindow::MenusBeginning() BMenuItem* LeaveStatus = fLeaveStatusMenu->FindItem(B_QUIT_REQUESTED); if (LeaveStatus == NULL) - LeaveStatus = fLeaveStatusMenu->FindItem(kMsgQuitAndKeepAllStatus); + LeaveStatus = fLeaveStatusMenu->FindItem(kMsgCloseAndKeepAllStatus); if (LeaveStatus != NULL && status.Length() > 0) { BString label; @@ -1314,14 +1313,19 @@ TMailWindow::MessageReceived(BMessage* msg) } case M_CLOSE_SAVED: { - BMessage message(B_QUIT_REQUESTED); + BMessage message(B_CLOSE_REQUESTED); message.AddString("status", "Saved"); PostMessage(&message); break; } case kMsgQuitAndKeepAllStatus: - fKeepStatusOnQuit = true; - be_app->PostMessage(B_QUIT_REQUESTED); + { + be_app->PostMessage(msg); + break; + } + case kMsgCloseAndKeepAllStatus: + fKeepStatusOnClose = true; + PostMessage(B_CLOSE_REQUESTED); break; case M_CLOSE_CUSTOM: if (msg->HasString("status")) { @@ -1860,7 +1864,7 @@ TMailWindow::QuitRequested() } } } - } else if (fRef != NULL && !fKeepStatusOnQuit) { + } else if (fRef != NULL && !fKeepStatusOnClose) { // ...Otherwise just set the message read if (fAutoMarkRead == true) MarkMessageRead(fRef, B_READ); diff --git a/src/apps/mail/MailWindow.h b/src/apps/mail/MailWindow.h index bff48a66b7..45c73f86fe 100644 --- a/src/apps/mail/MailWindow.h +++ b/src/apps/mail/MailWindow.h @@ -65,6 +65,9 @@ class BMenuBar; class BMenuItem; class Words; +static const uint32 kMsgQuitAndKeepAllStatus = 'Qasm'; +static const uint32 kMsgCloseAndKeepAllStatus = 'Casm'; + class TMailWindow : public BWindow { public: @@ -216,7 +219,7 @@ private: BMessenger* fOriginatingWindow; bool fAutoMarkRead : 1; - bool fKeepStatusOnQuit; + bool fKeepStatusOnClose; bool fDownloading; };