mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 04:38:11 +08:00
Desktop: fix Mac restart dialog to show all changes to preferences requiring restart (#3903)
* Desktop: Fix restart dialog on Mac * Fix * Fix * Fix --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
+1
-1
@@ -114,7 +114,7 @@ pub fn start() {
|
|||||||
|
|
||||||
match exit_reason {
|
match exit_reason {
|
||||||
app::ExitReason::Restart | app::ExitReason::UiAccelerationFailure => {
|
app::ExitReason::Restart | app::ExitReason::UiAccelerationFailure => {
|
||||||
tracing::error!("Restarting application");
|
tracing::info!("Restarting application");
|
||||||
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
|
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
let _ = std::os::unix::process::CommandExt::exec(&mut command);
|
let _ = std::os::unix::process::CommandExt::exec(&mut command);
|
||||||
|
|||||||
@@ -37,5 +37,7 @@ pub enum DialogMessage {
|
|||||||
},
|
},
|
||||||
RequestNewDocumentDialog,
|
RequestNewDocumentDialog,
|
||||||
RequestPreferencesDialog,
|
RequestPreferencesDialog,
|
||||||
RequestConfirmRestartDialog,
|
RequestConfirmRestartDialog {
|
||||||
|
preferences_requiring_restart: Vec<String>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,11 +136,9 @@ impl MessageHandler<DialogMessage, DialogMessageContext<'_>> for DialogMessageHa
|
|||||||
self.on_dismiss = Some(PreferencesDialogMessage::Confirm.into());
|
self.on_dismiss = Some(PreferencesDialogMessage::Confirm.into());
|
||||||
self.preferences_dialog.send_dialog_to_frontend(responses, preferences);
|
self.preferences_dialog.send_dialog_to_frontend(responses, preferences);
|
||||||
}
|
}
|
||||||
DialogMessage::RequestConfirmRestartDialog => {
|
DialogMessage::RequestConfirmRestartDialog { preferences_requiring_restart } => {
|
||||||
self.on_dismiss = Some(DialogMessage::Close.into());
|
self.on_dismiss = Some(DialogMessage::Close.into());
|
||||||
let dialog = ConfirmRestartDialog {
|
let dialog = ConfirmRestartDialog { preferences_requiring_restart };
|
||||||
changed_settings: vec!["Disable UI Acceleration".into()],
|
|
||||||
};
|
|
||||||
dialog.send_dialog_to_frontend(responses);
|
dialog.send_dialog_to_frontend(responses);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ impl MessageHandler<PreferencesDialogMessage, PreferencesDialogMessageContext<'_
|
|||||||
}
|
}
|
||||||
PreferencesDialogMessage::Confirm => {
|
PreferencesDialogMessage::Confirm => {
|
||||||
if let Some(unmodified_preferences) = &self.unmodified_preferences
|
if let Some(unmodified_preferences) = &self.unmodified_preferences
|
||||||
&& unmodified_preferences.needs_restart(preferences)
|
&& let preferences_requiring_restart = unmodified_preferences.preferences_requiring_restart(preferences)
|
||||||
|
&& !preferences_requiring_restart.is_empty()
|
||||||
{
|
{
|
||||||
responses.add(DialogMessage::RequestConfirmRestartDialog);
|
responses.add(DialogMessage::RequestConfirmRestartDialog { preferences_requiring_restart });
|
||||||
} else {
|
} else {
|
||||||
responses.add(DialogMessage::Close);
|
responses.add(DialogMessage::Close);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::messages::prelude::*;
|
|||||||
|
|
||||||
/// A dialog for confirming the restart of the application when changing a preference that requires a restart to take effect.
|
/// A dialog for confirming the restart of the application when changing a preference that requires a restart to take effect.
|
||||||
pub struct ConfirmRestartDialog {
|
pub struct ConfirmRestartDialog {
|
||||||
pub changed_settings: Vec<String>,
|
pub preferences_requiring_restart: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DialogLayoutHolder for ConfirmRestartDialog {
|
impl DialogLayoutHolder for ConfirmRestartDialog {
|
||||||
@@ -30,7 +30,7 @@ impl DialogLayoutHolder for ConfirmRestartDialog {
|
|||||||
|
|
||||||
impl LayoutHolder for ConfirmRestartDialog {
|
impl LayoutHolder for ConfirmRestartDialog {
|
||||||
fn layout(&self) -> Layout {
|
fn layout(&self) -> Layout {
|
||||||
let changed_settings = "• ".to_string() + &self.changed_settings.join("\n• ");
|
let changed_settings = "• ".to_string() + &self.preferences_requiring_restart.join("\n• ");
|
||||||
|
|
||||||
Layout(vec![
|
Layout(vec![
|
||||||
LayoutGroup::row(vec![TextLabel::new("Restart to apply changes?").bold(true).multiline(true).widget_instance()]),
|
LayoutGroup::row(vec![TextLabel::new("Restart to apply changes?").bold(true).multiline(true).widget_instance()]),
|
||||||
|
|||||||
@@ -28,14 +28,16 @@ pub struct PreferencesMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PreferencesMessageHandler {
|
impl PreferencesMessageHandler {
|
||||||
#[cfg(not(target_os = "macos"))]
|
pub fn preferences_requiring_restart(&self, other: &Self) -> Vec<String> {
|
||||||
pub fn needs_restart(&self, other: &Self) -> bool {
|
let mut requiring_restart = Vec::new();
|
||||||
self.disable_ui_acceleration != other.disable_ui_acceleration
|
if self.disable_ui_acceleration != other.disable_ui_acceleration {
|
||||||
}
|
requiring_restart.push("Disable UI Acceleration");
|
||||||
|
}
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub fn needs_restart(&self, other: &Self) -> bool {
|
if self.vsync != other.vsync {
|
||||||
self.disable_ui_acceleration != other.disable_ui_acceleration || self.vsync != other.vsync
|
requiring_restart.push("Enable V-Sync");
|
||||||
|
}
|
||||||
|
requiring_restart.into_iter().map(String::from).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_selection_mode(&self) -> SelectionMode {
|
pub fn get_selection_mode(&self) -> SelectionMode {
|
||||||
|
|||||||
Reference in New Issue
Block a user