Mail: Fix "Close and set to…" for multiple mails

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 <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Humdinger
2025-05-29 16:40:53 +00:00
committed by waddlesplash
parent 67aa257da8
commit 2d11570065
3 changed files with 25 additions and 10 deletions
+8
View File
@@ -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;
+13 -9
View File
@@ -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);
+4 -1
View File
@@ -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;
};