From dc8a8389a3cd8c533be97c61b592cc334d8164d8 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Sun, 26 Apr 2009 19:04:09 +0000 Subject: [PATCH] Add another option to the mail app. When you switch "Automaticly mark mail as readed" off a new Read / Unread button appears and a mail is only marked as readed when you push this button. On default the old behaviour is used. This is once again a opera feature I like very much and I haven't found in any other email client yet. E.g. you can start a query on unreaded mails and take a short look at the mails without the mails are disappearing from the query. If you read the mail you press "Readed" and the mail is gone from the query. This is e.g an advantage if you have less time, take a look at a mail and found that the mail is very long but potentially intressting. In this case you just press next or close the window and the mail is still in the unreaded query, ready to be readed at another time. The unreaded flag becomes something like a automatic important flag. You don't have to mark / unmark the mails as important and still don't forget to process any mail. I think this is a different way how most people read mails so I hope you like the patch. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30437 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mail/ButtonBar.cpp | 27 ++++++- src/apps/mail/ButtonBar.h | 5 +- src/apps/mail/MailApp.cpp | 36 ++++++--- src/apps/mail/MailApp.h | 4 +- src/apps/mail/MailWindow.cpp | 139 ++++++++++++++++++++++++++++------- src/apps/mail/MailWindow.h | 10 ++- src/apps/mail/Messages.h | 2 + src/apps/mail/Prefs.cpp | 39 ++++++++-- src/apps/mail/Prefs.h | 10 ++- 9 files changed, 221 insertions(+), 51 deletions(-) diff --git a/src/apps/mail/ButtonBar.cpp b/src/apps/mail/ButtonBar.cpp index cccdca4bd7..1a3d852136 100644 --- a/src/apps/mail/ButtonBar.cpp +++ b/src/apps/mail/ButtonBar.cpp @@ -76,19 +76,42 @@ ButtonBar::~ButtonBar() BmapButton* -ButtonBar::AddButton(const char *label, int32 baseID, BMessage *msg) +ButtonBar::AddButton(const char *label, int32 baseID, BMessage *msg, + int32 position) { BmapButton* button = new BmapButton(BRect(0, 0, 31, 31), label, label, baseID + fEnabledOffset, baseID + fDisabledOffset, baseID + fRollOffset, baseID + fPressedOffset, fShowLabels, msg, B_FOLLOW_LEFT | B_FOLLOW_TOP); - fButtonList.AddItem(button); + if (position > 0) + fButtonList.AddItem(button, position); + else + fButtonList.AddItem(button); AddChild(button); return button; } +bool +ButtonBar::RemoveButton(BmapButton *button) +{ + if (fButtonList.RemoveItem(button)) { + RemoveChild(button); + delete button; + return true; + } + return false; +} + + +int32 +ButtonBar::IndexOf(BmapButton *button) +{ + return fButtonList.IndexOf(button); +} + + void ButtonBar::Arrange(bool fixedWidth) { diff --git a/src/apps/mail/ButtonBar.h b/src/apps/mail/ButtonBar.h index be671155df..3350861ccf 100644 --- a/src/apps/mail/ButtonBar.h +++ b/src/apps/mail/ButtonBar.h @@ -57,7 +57,10 @@ public: void ShowLabels(bool show); void Arrange(bool fixedWidth = true); - BmapButton *AddButton(const char *label, int32 baseID, BMessage *msg); + BmapButton *AddButton(const char *label, int32 baseID, BMessage *msg, + int32 position = -1); + bool RemoveButton(BmapButton *button); + int32 IndexOf(BmapButton *button); void AddDivider(float vmargin); protected: diff --git a/src/apps/mail/MailApp.cpp b/src/apps/mail/MailApp.cpp index 46dacbba92..ee650c6087 100644 --- a/src/apps/mail/MailApp.cpp +++ b/src/apps/mail/MailApp.cpp @@ -130,6 +130,7 @@ TMailApp::TMailApp() { // set default values fContentFont.SetSize(12.0); + fAutoMarkReaded = true; fSignature = (char *)malloc(strlen(SIG_NONE) + 1); strcpy(fSignature, SIG_NONE); fReplyPreamble = (char *)malloc(1); @@ -348,24 +349,23 @@ TMailApp::MessageReceived(BMessage *msg) &fColoredQuotes, &fDefaultChain, &fUseAccountFrom, &fReplyPreamble, &fSignature, &fMailCharacterSet, &fWarnAboutUnencodableCharacters, - &fStartWithSpellCheckOn, &fShowButtonBar); + &fStartWithSpellCheckOn, &fAutoMarkReaded, + &fShowButtonBar); fPrefsWindow->Show(); - fPreviousShowButtonBar = fShowButtonBar; } break; case PREFS_CHANGED: { - // Do we need to update the state of the button bars? - if (fPreviousShowButtonBar != fShowButtonBar) { - // Notify all Mail windows - TMailWindow *window; - for (int32 i = 0; (window=(TMailWindow *)fWindowList.ItemAt(i)) != NULL; i++) { - window->Lock(); - window->UpdateViews(); - window->Unlock(); - } - fPreviousShowButtonBar = fShowButtonBar; + // Notify all Mail windows + TMailWindow *window; + for (int32 i = 0; (window=(TMailWindow *)fWindowList.ItemAt(i)) + != NULL; i++) + { + window->Lock(); + window->UpdatePreferences(); + window->UpdateViews(); + window->Unlock(); } break; } @@ -912,6 +912,7 @@ TMailApp::SaveSettings() settings.AddRect("SignatureWindowSize", fSignatureWindowFrame); settings.AddBool("WordWrapMode", fWrapMode); settings.AddPoint("PreferencesWindowLocation", fPrefsWindowPos); + settings.AddBool("AutoMarkReaded", fAutoMarkReaded); settings.AddString("SignatureText", fSignature); settings.AddInt32("CharacterSet", fMailCharacterSet); settings.AddString("FindString", FindWindow::GetFindString()); @@ -1000,6 +1001,9 @@ TMailApp::LoadSettings() if (settings.FindPoint("PreferencesWindowLocation", &point) == B_OK) fPrefsWindowPos = point; + if (settings.FindBool("AutoMarkReaded", &boolValue) == B_OK) + fAutoMarkReaded = boolValue; + const char *string; if (settings.FindString("SignatureText", &string) == B_OK) { free(fSignature); @@ -1137,6 +1141,14 @@ TMailApp::NewWindow(const entry_ref* ref, const char* to, bool resend, // #pragma mark - settings +bool +TMailApp::AutoMarkReaded() +{ + BAutolock _(this); + return fAutoMarkReaded; +} + + BString TMailApp::Signature() { diff --git a/src/apps/mail/MailApp.h b/src/apps/mail/MailApp.h index 3f16bc908a..67336217d5 100644 --- a/src/apps/mail/MailApp.h +++ b/src/apps/mail/MailApp.h @@ -73,6 +73,7 @@ class TMailApp : public BApplication { void SetLastWindowFrame(BRect frame); // TODO: move these into a MailSettings class + bool AutoMarkReaded(); BString Signature(); BString ReplyPreamble(); bool WrapMode(); @@ -103,8 +104,6 @@ class TMailApp : public BApplication { TPrefsWindow* fPrefsWindow; TSignatureWindow* fSigWindow; - uint8 fPreviousShowButtonBar; - BRect fMailWindowFrame; BRect fLastMailWindowFrame; BRect fSignatureWindowFrame; @@ -115,6 +114,7 @@ class TMailApp : public BApplication { bool fPrintHelpAndExit; // TODO: these should go into a settings class + bool fAutoMarkReaded; char* fSignature; char* fReplyPreamble; bool fWrapMode; diff --git a/src/apps/mail/MailWindow.cpp b/src/apps/mail/MailWindow.cpp index 8c48ce007b..307a8d0355 100644 --- a/src/apps/mail/MailWindow.cpp +++ b/src/apps/mail/MailWindow.cpp @@ -166,7 +166,9 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app, fDraft(false), fChanged(false), fStartingText(NULL), - fOriginatingWindow(NULL) + fOriginatingWindow(NULL), + fReadedButton(NULL), + fNextButton(NULL) { if (messenger != NULL) fTrackerMessenger = *messenger; @@ -192,6 +194,7 @@ TMailWindow::TMailWindow(BRect rect, const char* title, TMailApp* app, fIncoming = false; } + fAutoMarkReaded = fApp->AutoMarkReaded(); BRect r(0, 0, RIGHT_BOUNDARY, 15); fMenuBar = new BMenuBar(r, ""); @@ -585,46 +588,64 @@ TMailWindow::BuildButtonBar() { ButtonBar *bbar; - bbar = new ButtonBar(BRect(0, 0, 100, 100), "ButtonBar", 2, 3, 0, 1, 10, 2); + bbar = new ButtonBar(BRect(0, 0, 100, 100), "ButtonBar", 2, 3, 0, 1, 10, + 2); bbar->AddButton(MDR_DIALECT_CHOICE ("New","新規"), 28, new BMessage(M_NEW)); bbar->AddDivider(5); - + fButtonBar = bbar; + if (fResending) { - fSendButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Send","送信"), 8, new BMessage(M_SEND_NOW)); + fSendButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Send","送信"), 8, + new BMessage(M_SEND_NOW)); bbar->AddDivider(5); } else if (!fIncoming) { - fSendButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Send","送信"), 8, new BMessage(M_SEND_NOW)); + fSendButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Send","送信"), 8, + new BMessage(M_SEND_NOW)); fSendButton->SetEnabled(false); - fSigButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Signature","署名"), 4, new BMessage(M_SIG_MENU)); + fSigButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Signature","署名"), 4, + new BMessage(M_SIG_MENU)); fSigButton->InvokeOnButton(B_SECONDARY_MOUSE_BUTTON); - fSaveButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Save","保存"), 44, new BMessage(M_SAVE_AS_DRAFT)); + fSaveButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Save","保存"), 44, + new BMessage(M_SAVE_AS_DRAFT)); fSaveButton->SetEnabled(false); - fPrintButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Print","印刷"), 16, new BMessage(M_PRINT)); + fPrintButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Print","印刷"), 16, + new BMessage(M_PRINT)); fPrintButton->SetEnabled(false); - bbar->AddButton(MDR_DIALECT_CHOICE ("Trash","削除"), 0, new BMessage(M_DELETE)); + bbar->AddButton(MDR_DIALECT_CHOICE ("Trash","削除"), 0, + new BMessage(M_DELETE)); bbar->AddDivider(5); } else { - BmapButton *button = bbar->AddButton(MDR_DIALECT_CHOICE ("Reply","返信"), 12, new BMessage(M_REPLY)); + BmapButton *button = bbar->AddButton(MDR_DIALECT_CHOICE ("Reply","返信"), + 12, new BMessage(M_REPLY)); button->InvokeOnButton(B_SECONDARY_MOUSE_BUTTON); - button = bbar->AddButton(MDR_DIALECT_CHOICE ("Forward","転送"), 40, new BMessage(M_FORWARD)); + button = bbar->AddButton(MDR_DIALECT_CHOICE ("Forward","転送"), 40, + new BMessage(M_FORWARD)); button->InvokeOnButton(B_SECONDARY_MOUSE_BUTTON); - fPrintButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Print","印刷"), 16, new BMessage(M_PRINT)); - bbar->AddButton(MDR_DIALECT_CHOICE ("Trash","削除"), 0, new BMessage(M_DELETE_NEXT)); + fPrintButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Print","印刷"), 16, + new BMessage(M_PRINT)); + bbar->AddButton(MDR_DIALECT_CHOICE ("Trash","削除"), 0, + new BMessage(M_DELETE_NEXT)); if (fApp->ShowSpamGUI()) { button = bbar->AddButton("Spam", 48, new BMessage(M_SPAM_BUTTON)); button->InvokeOnButton(B_SECONDARY_MOUSE_BUTTON); } bbar->AddDivider(5); - bbar->AddButton(MDR_DIALECT_CHOICE ("Next","次へ"), 24, new BMessage(M_NEXTMSG)); - bbar->AddButton(MDR_DIALECT_CHOICE ("Previous","前へ"), 20, new BMessage(M_PREVMSG)); + fNextButton = bbar->AddButton(MDR_DIALECT_CHOICE ("Next","次へ"), 24, + new BMessage(M_NEXTMSG)); + bbar->AddButton(MDR_DIALECT_CHOICE ("Previous","前へ"), 20, + new BMessage(M_PREVMSG)); + if (!fAutoMarkReaded) { + _AddReadedButton(); + } } - bbar->AddButton(MDR_DIALECT_CHOICE ("Inbox","受信箱"), 36, new BMessage(M_OPEN_MAIL_BOX)); - bbar->AddButton(MDR_DIALECT_CHOICE ("Mail","メール"), 32, new BMessage(M_OPEN_MAIL_FOLDER)); + bbar->AddButton(MDR_DIALECT_CHOICE ("Inbox","受信箱"), 36, + new BMessage(M_OPEN_MAIL_BOX)); + bbar->AddButton(MDR_DIALECT_CHOICE ("Mail","メール"), 32, + new BMessage(M_OPEN_MAIL_FOLDER)); bbar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); bbar->Hide(); AddChild(bbar); - fButtonBar = bbar; } @@ -641,6 +662,7 @@ TMailWindow::UpdateViews() // Create the Button Bar if needed if (!fButtonBar) BuildButtonBar(); + fButtonBar->ShowLabels(showButtonBar); fButtonBar->Arrange(/* True for all buttons same size, false to just fit */ MDR_DIALECT_CHOICE (true, true)); @@ -652,6 +674,7 @@ TMailWindow::UpdateViews() fButtonBar->Show(); else fButtonBar->Invalidate(); + } else if (fButtonBar) fButtonBar->Hide(); @@ -670,6 +693,15 @@ TMailWindow::UpdateViews() } +void +TMailWindow::UpdatePreferences() +{ + fAutoMarkReaded = fApp->AutoMarkReaded(); + + _UpdateReadButton(); +} + + TMailWindow::~TMailWindow() { fApp->SetLastWindowFrame(Frame()); @@ -785,15 +817,20 @@ TMailWindow::SetTrackerSelectionToCurrent() void -TMailWindow::SetCurrentMessageRead() +TMailWindow::SetCurrentMessageRead(bool readed) { BNode node(fRef); if (node.InitCheck() == B_NO_ERROR) { BString status; - if (ReadAttrString(&node, B_MAIL_ATTR_STATUS, &status) == B_NO_ERROR - && !status.ICompare("New")) { - node.RemoveAttr(B_MAIL_ATTR_STATUS); - WriteAttrString(&node, B_MAIL_ATTR_STATUS, "Read"); + if (ReadAttrString(&node, B_MAIL_ATTR_STATUS, &status) == B_NO_ERROR) { + if (readed && !status.ICompare("New")) { + node.RemoveAttr(B_MAIL_ATTR_STATUS); + WriteAttrString(&node, B_MAIL_ATTR_STATUS, "Read"); + } + if (!readed && !status.ICompare("Read")) { + node.RemoveAttr(B_MAIL_ATTR_STATUS); + WriteAttrString(&node, B_MAIL_ATTR_STATUS, "New"); + } } } } @@ -1079,7 +1116,7 @@ TMailWindow::MessageReceived(BMessage *msg) foundRef = GetTrackerWindowFile(&nextRef, msg->what == M_DELETE_NEXT); } - if (fIncoming) + if (fIncoming && fAutoMarkReaded) SetCurrentMessageRead(); if (!fTrackerMessenger.IsValid() || !fIncoming) { @@ -1400,6 +1437,13 @@ TMailWindow::MessageReceived(BMessage *msg) // // Navigation Messages // + case M_UNREAD: + SetCurrentMessageRead(false); + _UpdateReadButton(); + break; + case M_READED: + SetCurrentMessageRead(); + msg->what = M_NEXTMSG; case M_PREVMSG: case M_NEXTMSG: if (fRef) @@ -1408,7 +1452,8 @@ TMailWindow::MessageReceived(BMessage *msg) if (GetTrackerWindowFile(&nextRef, (msg->what == M_NEXTMSG))) { TMailWindow *window = static_cast(be_app)->FindWindow(nextRef); if (window == NULL) { - SetCurrentMessageRead(); + if (fAutoMarkReaded) + SetCurrentMessageRead(); OpenMessage(&nextRef, fHeaderView->fCharacterSetUserSees); } else { window->Activate(); @@ -1662,7 +1707,8 @@ TMailWindow::QuitRequested() } } else if (fRef && !sKeepStatusOnQuit) { // ...Otherwise just set the message read - SetCurrentMessageRead(); + if (fAutoMarkReaded) + SetCurrentMessageRead(); } #ifdef __HAIKU__ @@ -2835,6 +2881,9 @@ TMailWindow::OpenMessage(entry_ref *ref, uint32 characterSetForDecoding) fContentView->fTextView->SetText("", (int32)0); fContentView->fTextView->LoadMessage(fMail, false, NULL); + + if (fApp->ShowButtonBar()) + _UpdateReadButton(); } return B_OK; @@ -3082,3 +3131,41 @@ TMailWindow::_BuildQueryString(BEntry* entry) const return strdup(queryString.String()); } + +void +TMailWindow::_AddReadedButton() +{ + bool newMail = false; + BNode node(fRef); + if (node.InitCheck() == B_NO_ERROR) { + BString status; + if (ReadAttrString(&node, B_MAIL_ATTR_STATUS, &status) == B_NO_ERROR + && !status.ICompare("New")) { + newMail = true; + } + } + + int32 buttonIndex = fButtonBar->IndexOf(fNextButton); + if (newMail) + fReadedButton = fButtonBar->AddButton( + MDR_DIALECT_CHOICE (" Read ", " Read "), 24, + new BMessage(M_READED), buttonIndex); + else + fReadedButton = fButtonBar->AddButton( + MDR_DIALECT_CHOICE ("Unread", "Unread"), 28, + new BMessage(M_UNREAD), buttonIndex); +} + + +void +TMailWindow::_UpdateReadButton() +{ + if (fApp->ShowButtonBar()) { + fButtonBar->RemoveButton(fReadedButton); + fReadedButton = NULL; + if (!fAutoMarkReaded && !fReadedButton) { + _AddReadedButton(); + } + } + UpdateViews(); +} diff --git a/src/apps/mail/MailWindow.h b/src/apps/mail/MailWindow.h index bcb26f6b5d..aa509c5a3d 100644 --- a/src/apps/mail/MailWindow.h +++ b/src/apps/mail/MailWindow.h @@ -107,10 +107,11 @@ class TMailWindow : public BWindow { void SaveTrackerPosition(entry_ref*); void SetOriginatingWindow(BWindow* window); - void SetCurrentMessageRead(); + void SetCurrentMessageRead(bool readed = true); void SetTrackerSelectionToCurrent(); TMailWindow* FrontmostWindow(); void UpdateViews(); + void UpdatePreferences(); protected: void SetTitleForMessage(); @@ -125,6 +126,9 @@ class TMailWindow : public BWindow { void _RebuildQueryMenu(bool firstTime = false); char* _BuildQueryString(BEntry* entry) const; + void _AddReadedButton(); + void _UpdateReadButton(); + TMailApp* fApp; BEmailMessage* fMail; @@ -193,6 +197,10 @@ class TMailWindow : public BWindow { char* fStartingText; entry_ref fRepliedMail; BMessenger* fOriginatingWindow; + + bool fAutoMarkReaded : 1; + BmapButton* fReadedButton; + BmapButton* fNextButton; }; #endif // _MAIL_WINDOW_H diff --git a/src/apps/mail/Messages.h b/src/apps/mail/Messages.h index 08c6f0f4e4..85b1262a73 100644 --- a/src/apps/mail/Messages.h +++ b/src/apps/mail/Messages.h @@ -113,6 +113,8 @@ enum MENUS { M_COPY, // nav + M_READED, + M_UNREAD, M_NEXTMSG, M_PREVMSG, M_SAVE_POSITION, diff --git a/src/apps/mail/Prefs.cpp b/src/apps/mail/Prefs.cpp index 7c34764956..aaece670c4 100644 --- a/src/apps/mail/Prefs.cpp +++ b/src/apps/mail/Prefs.cpp @@ -82,6 +82,7 @@ using namespace BPrivate; #define ENCODING_TEXT MDR_DIALECT_CHOICE ("Encoding:", "エンコード形式:") #define WARN_UNENCODABLE_TEXT MDR_DIALECT_CHOICE ("Warn Unencodable:", "警告: エンコードできません") #define SPELL_CHECK_START_ON_TEXT MDR_DIALECT_CHOICE ("Initial Spell Check Mode:", "編集時スペルチェック:") +#define AUTO_MARK_READED_TEXT MDR_DIALECT_CHOICE ("Automaticly mark mail as readed:", "Automaticly mark mail as readed:") #define BUTTONBAR_TEXT MDR_DIALECT_CHOICE ("Button Bar:", "ボタンバー:") @@ -99,7 +100,7 @@ enum P_MESSAGES {P_OK = 128, P_CANCEL, P_REVERT, P_FONT, P_SIG, P_ENC, P_WARN_UNENCODABLE, P_SPELL_CHECK_START_ON, P_BUTTON_BAR, P_ACCOUNT, P_REPLYTO, P_REPLY_PREAMBLE, - P_COLORED_QUOTES}; + P_COLORED_QUOTES, P_MARK_READED}; #define ICON_LABEL_TEXT MDR_DIALECT_CHOICE ("Show Icons & Labels", "アイコンとラベル") #define ICON_TEXT MDR_DIALECT_CHOICE ("Show Icons Only", "アイコンのみ") @@ -136,7 +137,7 @@ add_menu_to_layout(BMenuField* menu, BGridLayout* layout, int32& row) TPrefsWindow::TPrefsWindow(BRect rect, BFont* font, int32* level, bool* wrap, bool* attachAttributes, bool* cquotes, uint32* account, int32* replyTo, char** preamble, char** sig, uint32* encoding, bool* warnUnencodable, - bool* spellCheckStartOn, uint8* buttonBar) + bool* spellCheckStartOn, bool* autoMarkReaded, uint8* buttonBar) : #if USE_LAYOUT_MANAGEMENT BWindow(rect, MDR_DIALECT_CHOICE ("Mail Preferences", "Mailの設定"), @@ -180,7 +181,10 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont* font, int32* level, bool* wrap, fWarnUnencodable(*fNewWarnUnencodable), fNewSpellCheckStartOn(spellCheckStartOn), - fSpellCheckStartOn(*fNewSpellCheckStartOn) + fSpellCheckStartOn(*fNewSpellCheckStartOn), + + fNewAutoMarkReaded(autoMarkReaded), + fAutoMarkReaded(*fNewAutoMarkReaded) { strcpy(fSignature, *fNewSignature); @@ -242,7 +246,10 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont* font, int32* level, bool* wrap, fSpellCheckStartOnMenu, NULL); add_menu_to_layout(menu, interfaceLayout, layoutRow); - + fAutoMarkReadedMenu = _BuildAutoMarkReadedMenu(fAutoMarkReaded); + menu = new BMenuField("autoMarkReaded", AUTO_MARK_READED_TEXT, + fAutoMarkReadedMenu, NULL); + add_menu_to_layout(menu, interfaceLayout, layoutRow); // Mail Accounts layoutRow = 0; @@ -406,6 +413,13 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont* font, int32* level, bool* wrap, menu->SetAlignment(B_ALIGN_RIGHT); interfaceBox->AddChild(menu); + r.OffsetBy(0, height + ITEM_SPACE); + fAutoMarkReadedMenu = _BuildAutoMarkReadedMenu(fAutoMarkReaded); + menu = new BMenuField("autoMarkReaded", AUTO_MARK_READED_TEXT, + fAutoMarkReadedMenu, NULL); + menu->SetDivider(labelWidth); + menu->SetAlignment(B_ALIGN_RIGHT); + interfaceBox->AddChild(menu); // Mail Accounts @@ -579,6 +593,7 @@ TPrefsWindow::MessageReceived(BMessage* msg) *fNewEncoding = fEncoding; *fNewWarnUnencodable = fWarnUnencodable; *fNewSpellCheckStartOn = fSpellCheckStartOn; + *fNewAutoMarkReaded = fAutoMarkReaded; *fNewButtonBar = fButtonBar; be_app->PostMessage(PREFS_CHANGED); @@ -719,11 +734,15 @@ TPrefsWindow::MessageReceived(BMessage* msg) case P_SPELL_CHECK_START_ON: msg->FindBool("spellCheckStartOn", fNewSpellCheckStartOn); break; + case P_MARK_READED: + msg->FindBool("autoMarkReaded", fNewAutoMarkReaded); + be_app->PostMessage(PREFS_CHANGED); + break; case P_BUTTON_BAR: msg->FindInt8("bar", (int8 *)fNewButtonBar); be_app->PostMessage(PREFS_CHANGED); break; - + default: BWindow::MessageReceived(msg); } @@ -745,6 +764,7 @@ TPrefsWindow::MessageReceived(BMessage* msg) || fEncoding != *fNewEncoding || fWarnUnencodable != *fNewWarnUnencodable || fSpellCheckStartOn != *fNewSpellCheckStartOn + || fAutoMarkReaded != *fNewAutoMarkReaded || fButtonBar != *fNewButtonBar; fRevert->SetEnabled(changed); } @@ -1103,6 +1123,14 @@ TPrefsWindow::_BuildSpellCheckStartOnMenu(bool spellCheckStartOn) } +BPopUpMenu* +TPrefsWindow::_BuildAutoMarkReadedMenu(bool autoMarkReaded) +{ + return _BuildBoolMenu(P_MARK_READED, "autoMarkReaded", + autoMarkReaded); +} + + BPopUpMenu* TPrefsWindow::_BuildButtonBarMenu(uint8 show) { @@ -1130,3 +1158,4 @@ TPrefsWindow::_BuildButtonBarMenu(uint8 show) return menu; } + diff --git a/src/apps/mail/Prefs.h b/src/apps/mail/Prefs.h index 60f03a0f66..561a1a87d9 100644 --- a/src/apps/mail/Prefs.h +++ b/src/apps/mail/Prefs.h @@ -69,7 +69,8 @@ public: uint32* account, int32* replyTo, char** preamble, char** sig, uint32* encoding, bool* warnUnencodable, - bool* spellCheckStartOn, uint8* buttonBar); + bool* spellCheckStartOn, + bool* autoMarkReaded, uint8* buttonBar); virtual ~TPrefsWindow(); virtual void MessageReceived(BMessage* message); @@ -90,8 +91,10 @@ private: bool warnUnencodable); BPopUpMenu* _BuildSpellCheckStartOnMenu( bool spellCheckStartOn); + BPopUpMenu* _BuildAutoMarkReadedMenu( + bool autoMarkReaded); BPopUpMenu* _BuildButtonBarMenu(uint8 show); - + BPopUpMenu* _BuildBoolMenu(uint32 msg, const char* boolItem, bool isTrue); @@ -120,6 +123,8 @@ private: bool fWarnUnencodable; bool* fNewSpellCheckStartOn; bool fSpellCheckStartOn; + bool* fNewAutoMarkReaded; + bool fAutoMarkReaded; BButton* fRevert; @@ -137,6 +142,7 @@ private: BPopUpMenu* fWarnUnencodableMenu; BPopUpMenu* fSpellCheckStartOnMenu; BPopUpMenu* fButtonBarMenu; + BPopUpMenu* fAutoMarkReadedMenu; }; #endif /* _PREFS_H */