fixed the save as case as well

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4242 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shatty
2003-08-08 05:36:15 +00:00
parent 82928e6a50
commit bed4e0fbf1
3 changed files with 20 additions and 8 deletions
+1
View File
@@ -62,5 +62,6 @@ const uint32 TEXT_CHANGED ='TEch';
// file panel constants // file panel constants
const uint32 OPEN_AS_ENCODING ='FPoe'; const uint32 OPEN_AS_ENCODING ='FPoe';
const uint32 SAVE_AS_ENCODING ='FPse'; const uint32 SAVE_AS_ENCODING ='FPse';
const uint32 SAVE_THEN_QUIT ='FPsq';
#endif // CONSTANTS_H #endif // CONSTANTS_H
+17 -6
View File
@@ -303,6 +303,12 @@ StyledEditWindow::MessageReceived(BMessage *message)
case B_SAVE_REQUESTED: case B_SAVE_REQUESTED:
Save(message); Save(message);
break; break;
case SAVE_THEN_QUIT:
if (Save(message) == B_OK) {
BAutolock lock(this);
Quit();
}
break;
case MENU_REVERT: case MENU_REVERT:
RevertToSaved(); RevertToSaved();
break; break;
@@ -764,10 +770,10 @@ StyledEditWindow::QuitRequested()
BAlert *saveAlert; BAlert *saveAlert;
BString alertText; BString alertText;
alertText.SetTo("Save changes to the document "); alertText.SetTo("Save changes to the document \"");
alertText<< Title(); alertText<< Title();
alertText<<"? "; alertText<<"\"? ";
saveAlert= new BAlert("savealert",alertText.String(), "Cancel", "Don't save","Save", saveAlert= new BAlert("savealert",alertText.String(), "Cancel", "Don't Save","Save",
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
saveAlert->SetShortcut(0, B_ESCAPE); saveAlert->SetShortcut(0, B_ESCAPE);
saveAlert->SetShortcut(1,'d'); saveAlert->SetShortcut(1,'d');
@@ -779,9 +785,11 @@ StyledEditWindow::QuitRequested()
} else if(buttonIndex==1) { // "don't save": just close the window } else if(buttonIndex==1) { // "don't save": just close the window
return true; return true;
} else if(!fSaveMessage) { //save as } else if(!fSaveMessage) { //save as
return SaveAs(); BMessage * message = new BMessage(SAVE_THEN_QUIT);
SaveAs(message);
return false;
} else { } else {
return (Save(fSaveMessage) == B_OK); return (Save() == B_OK);
} }
}/***QuitRequested()***/ }/***QuitRequested()***/
@@ -862,7 +870,7 @@ StyledEditWindow::Save(BMessage *message)
} /***Save()***/ } /***Save()***/
status_t status_t
StyledEditWindow::SaveAs() StyledEditWindow::SaveAs(BMessage *message)
{ {
if (fSavePanel == 0) { if (fSavePanel == 0) {
entry_ref * directory = 0; entry_ref * directory = 0;
@@ -911,6 +919,9 @@ StyledEditWindow::SaveAs()
fSavePanelTextView->SetText(Title()); fSavePanelTextView->SetText(Title());
} }
} }
if (message != 0) {
fSavePanel->SetMessage(message);
}
fSavePanel->Show(); fSavePanel->Show();
return B_OK; return B_OK;
} }
+2 -2
View File
@@ -24,8 +24,8 @@ public:
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
virtual void MenusBeginning(); virtual void MenusBeginning();
status_t Save(BMessage *message); status_t Save(BMessage *message = 0);
status_t SaveAs(); status_t SaveAs(BMessage *message = 0);
void OpenFile(entry_ref *ref); void OpenFile(entry_ref *ref);
status_t PageSetup(const char *documentname); status_t PageSetup(const char *documentname);
void Print(const char *documentname); void Print(const char *documentname);