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:
Vlad Rakhmanin 2023-09-21 22:02:18 +01:00 committed by GitHub
parent 9667e5173b
commit b9027883a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 4 deletions

View File

@ -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()
},

View File

@ -31,6 +31,7 @@ pub enum PortfolioMessage {
},
CloseActiveDocumentWithConfirmation,
CloseAllDocuments,
CloseAllDocumentsWithConfirmation,
CloseDocument {
document_id: u64,
},

View File

@ -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,

View File

@ -739,7 +739,7 @@ impl Color {
/// ```
/// use graphene_core::raster::color::Color;
/// let color = Color::from_rgba8_srgb(0x52, 0x67, 0xFA, 0x61).to_gamma_srgb();
/// assert_eq!("5267FA61", color.rgba_hex())
/// assert_eq!("3240A261", color.rgba_hex())
/// ```
#[cfg(feature = "std")]
pub fn rgba_hex(&self) -> String {
@ -756,7 +756,7 @@ impl Color {
/// ```
/// use graphene_core::raster::color::Color;
/// let color = Color::from_rgba8_srgb(0x52, 0x67, 0xFA, 0x61).to_gamma_srgb();
/// assert_eq!("5267FA", color.rgb_hex())
/// assert_eq!("3240A2", color.rgb_hex())
/// ```
#[cfg(feature = "std")]
pub fn rgb_hex(&self) -> String {