From c72506d939ad576585b2d7a05d71620c89be7ef0 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 6 Nov 2024 10:36:10 +0800 Subject: [PATCH] code_style: simplify the way detacting system preferred command key Signed-off-by: leo --- src/Views/CommitMessageTextBox.axaml.cs | 2 +- src/Views/Histories.axaml.cs | 4 +--- src/Views/Launcher.axaml.cs | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Views/CommitMessageTextBox.axaml.cs b/src/Views/CommitMessageTextBox.axaml.cs index 6eec0379..91f8c47e 100644 --- a/src/Views/CommitMessageTextBox.axaml.cs +++ b/src/Views/CommitMessageTextBox.axaml.cs @@ -125,7 +125,7 @@ namespace SourceGit.Views DescriptionEditor.CaretIndex = 0; e.Handled = true; } - else if (e.Key == Key.V && ((OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Meta) || (!OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Control))) + else if (e.Key == Key.V && e.KeyModifiers == (OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control)) { e.Handled = true; diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs index e72888fe..9f436346 100644 --- a/src/Views/Histories.axaml.cs +++ b/src/Views/Histories.axaml.cs @@ -722,9 +722,7 @@ namespace SourceGit.Views private void OnCommitListKeyDown(object sender, KeyEventArgs e) { - bool isSystemCmdKeyDown = (OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Meta)) || - (!OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Control)); - if (!isSystemCmdKeyDown) + if (!e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control)) return; // These shortcuts are not mentioned in the Shortcut Reference window. Is this expected? diff --git a/src/Views/Launcher.axaml.cs b/src/Views/Launcher.axaml.cs index 99916da3..29d90e09 100644 --- a/src/Views/Launcher.axaml.cs +++ b/src/Views/Launcher.axaml.cs @@ -115,8 +115,7 @@ namespace SourceGit.Views return; } - if ((OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Meta)) || - (!OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Control))) + if (e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control)) { if (e.Key == Key.W) {