From 36f3c293f08f608d922477ffdc033670ad8db4fc Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sun, 13 Apr 2014 10:08:33 +0800 Subject: [PATCH] close #65 Hide when app loses focus --- .../Storage/UserSettings/UserSettingStorage.cs | 4 ++++ Wox/MainWindow.xaml | 1 + Wox/MainWindow.xaml.cs | 10 +++++++++- Wox/SettingWindow.xaml | 4 ++++ Wox/SettingWindow.xaml.cs | 13 +++++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs index ac8858f0df..da16cc9315 100644 --- a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs +++ b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs @@ -71,6 +71,9 @@ namespace Wox.Infrastructure.Storage.UserSettings [JsonProperty] public bool LeaveCmdOpen { get; set; } + [JsonProperty] + public bool HideWhenDeactive { get; set; } + public List LoadDefaultWebSearches() { List webSearches = new List(); @@ -142,6 +145,7 @@ namespace Wox.Infrastructure.Storage.UserSettings Opacity = 1; OpacityMode = OpacityMode.Normal; LeaveCmdOpen = false; + HideWhenDeactive = false; } } diff --git a/Wox/MainWindow.xaml b/Wox/MainWindow.xaml index 63c980ec70..db95e2c228 100644 --- a/Wox/MainWindow.xaml +++ b/Wox/MainWindow.xaml @@ -6,6 +6,7 @@ Loaded="MainWindow_OnLoaded" SizeToContent="Height" ResizeMode="NoResize" + Deactivated="MainWindow_OnDeactivated" WindowStyle="None" WindowStartupLocation="Manual" ShowInTaskbar="False" diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 014dd8abf1..762b1c338c 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -299,7 +299,13 @@ namespace Wox } } - + private void MainWindow_OnDeactivated(object sender, EventArgs e) + { + if (UserSettingStorage.Instance.HideWhenDeactive) + { + HideWox(); + } + } private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state) { @@ -554,5 +560,7 @@ namespace Wox } return false; } + + } } \ No newline at end of file diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 08b1be2d59..2ed8ada164 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -33,6 +33,10 @@ + + + + diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index d079fc9329..d20bf53779 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -87,6 +87,18 @@ namespace Wox UserSettingStorage.Instance.Save(); }; + cbHideWhenDeactive.Checked += (o, e) => + { + UserSettingStorage.Instance.HideWhenDeactive = true; + UserSettingStorage.Instance.Save(); + }; + + cbHideWhenDeactive.Unchecked += (o, e) => + { + UserSettingStorage.Instance.HideWhenDeactive = false; + UserSettingStorage.Instance.Save(); + }; + #region Load Theme Data if (!string.IsNullOrEmpty(UserSettingStorage.Instance.QueryBoxFont) && @@ -179,6 +191,7 @@ namespace Wox cbStartWithWindows.IsChecked = File.Exists(woxLinkPath); cbEnableBookmarkPlugin.IsChecked = UserSettingStorage.Instance.EnableBookmarkPlugin; cbLeaveCmdOpen.IsChecked = UserSettingStorage.Instance.LeaveCmdOpen; + cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive; var features = new CompositeCollection {