mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Make 'Close All Documents' not confirm if all open documents are already saved (#1423)
* Adding blank PortfolioMessage to close docs * Connected new PortfolioMessage to Menu Bar * Adding functionality to new PortfolioMessage * Amending outdated tests in color.rs
This commit is contained in:
@@ -71,8 +71,8 @@ impl LayoutHolder for MenuBarMessageHandler {
|
||||
},
|
||||
MenuBarEntry {
|
||||
label: "Close All".into(),
|
||||
shortcut: action_keys!(DialogMessageDiscriminant::CloseAllDocumentsWithConfirmation),
|
||||
action: MenuBarEntry::create_action(|_| DialogMessage::CloseAllDocumentsWithConfirmation.into()),
|
||||
shortcut: action_keys!(PortfolioMessageDiscriminant::CloseAllDocumentsWithConfirmation),
|
||||
action: MenuBarEntry::create_action(|_| PortfolioMessage::CloseAllDocumentsWithConfirmation.into()),
|
||||
disabled: no_active_document,
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
|
||||
@@ -31,6 +31,7 @@ pub enum PortfolioMessage {
|
||||
},
|
||||
CloseActiveDocumentWithConfirmation,
|
||||
CloseAllDocuments,
|
||||
CloseAllDocumentsWithConfirmation,
|
||||
CloseDocument {
|
||||
document_id: u64,
|
||||
},
|
||||
|
||||
@@ -105,6 +105,13 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
||||
responses.add(PortfolioMessage::DestroyAllDocuments);
|
||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||
}
|
||||
PortfolioMessage::CloseAllDocumentsWithConfirmation => {
|
||||
if self.unsaved_document_names().is_empty() {
|
||||
responses.add(PortfolioMessage::CloseAllDocuments)
|
||||
} else {
|
||||
responses.add(DialogMessage::CloseAllDocumentsWithConfirmation)
|
||||
}
|
||||
}
|
||||
PortfolioMessage::CloseDocument { document_id } => {
|
||||
// Is this the last document?
|
||||
if self.documents.len() == 1 && self.document_ids[0] == document_id {
|
||||
@@ -549,6 +556,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
||||
GraphViewOverlayToggleDisabled,
|
||||
CloseActiveDocumentWithConfirmation,
|
||||
CloseAllDocuments,
|
||||
CloseAllDocumentsWithConfirmation,
|
||||
Import,
|
||||
NextDocument,
|
||||
OpenDocument,
|
||||
|
||||
Reference in New Issue
Block a user