Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public bool HideNotifyIcon
}
public bool LeaveCmdOpen { get; set; }
public bool HideWhenDeactive { get; set; } = true;
public bool RememberLastLaunchLocation { get; set; }
public SearchWindowPositions SearchWindowPosition { get; set; } = SearchWindowPositions.MouseScreenCenter;
public bool IgnoreHotkeysOnFullscreen { get; set; }

public HttpProxy Proxy { get; set; } = new HttpProxy();
Expand All @@ -225,4 +225,12 @@ public enum ColorSchemes
Light,
Dark
}
public enum SearchWindowPositions
{
RememberLastLaunchLocation,
MouseScreenCenter,
MouseScreenCenterTop,
MouseScreenLeftTop,
MouseScreenRightTop
}
}
8 changes: 8 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<system:String x:Key="textTitle">Text</system:String>
<system:String x:Key="GameMode">Game Mode</system:String>
<system:String x:Key="GameModeToolTip">Suspend the use of Hotkeys.</system:String>
<system:String x:Key="PositionReset">Position Reset</system:String>
<system:String x:Key="PositionResetToolTip">Reset search window position</system:String>

<!-- Setting General -->
<system:String x:Key="flowlauncher_settings">Flow Launcher Settings</system:String>
Expand All @@ -33,7 +35,13 @@
<system:String x:Key="setAutoStartFailed">Error setting launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Hide Flow Launcher when focus is lost</system:String>
<system:String x:Key="dontPromptUpdateMsg">Do not show new version notifications</system:String>
<system:String x:Key="SearchWindowPosition">Search Window Position</system:String>
<system:String x:Key="rememberLastLocation">Remember last launch location</system:String>
<system:String x:Key="SearchWindowPositionRememberLastLaunchLocation">Remember Last Location</system:String>
<system:String x:Key="SearchWindowPositionMouseScreenCenter">Mouse Focused Screen - Center</system:String>
<system:String x:Key="SearchWindowPositionMouseScreenCenterTop">Mouse Focused Screen - Center Top</system:String>
<system:String x:Key="SearchWindowPositionMouseScreenLeftTop">Mouse Focused Screen - Left Top</system:String>
<system:String x:Key="SearchWindowPositionMouseScreenRightTop">Mouse Focused Screen - Right Top</system:String>
<system:String x:Key="language">Language</system:String>
<system:String x:Key="lastQueryMode">Last Query Style</system:String>
<system:String x:Key="lastQueryModeToolTip">Show/Hide previous results when Flow Launcher is reactivated.</system:String>
Expand Down
22 changes: 10 additions & 12 deletions Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
WindowStartupLocation="Manual"
WindowStyle="None"
mc:Ignorable="d"
Left="{Binding Left, Mode=TwoWay}"
Top="{Binding Top, Mode=TwoWay}">
mc:Ignorable="d">
<Window.Resources>
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
<converters:BorderClipConverter x:Key="BorderClipConverter" />
Expand Down Expand Up @@ -88,20 +86,20 @@
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
<KeyBinding
Key="OemCloseBrackets"
Modifiers="Control"
Command="{Binding IncreaseWidthCommand}"/>
Command="{Binding IncreaseWidthCommand}"
Modifiers="Control" />
<KeyBinding
Key="OemOpenBrackets"
Modifiers="Control"
Command="{Binding DecreaseWidthCommand}"/>
Command="{Binding DecreaseWidthCommand}"
Modifiers="Control" />
<KeyBinding
Key="OemPlus"
Modifiers="Control"
Command="{Binding IncreaseMaxResultCommand}"/>
Command="{Binding IncreaseMaxResultCommand}"
Modifiers="Control" />
<KeyBinding
Key="OemMinus"
Modifiers="Control"
Command="{Binding DecreaseMaxResultCommand}"/>
Command="{Binding DecreaseMaxResultCommand}"
Modifiers="Control" />
<KeyBinding
Key="H"
Command="{Binding LoadHistoryCommand}"
Expand Down Expand Up @@ -195,9 +193,9 @@
AllowDrop="True"
Background="Transparent"
PreviewDragOver="OnPreviewDragOver"
PreviewKeyUp="QueryTextBox_KeyUp"
Style="{DynamicResource QueryBoxStyle}"
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
PreviewKeyUp="QueryTextBox_KeyUp"
Visibility="Visible">
<TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
Expand Down
95 changes: 68 additions & 27 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public MainWindow(Settings settings, MainViewModel mainVM)
_viewModel = mainVM;
_settings = settings;
InitializeComponent();
InitializePosition();
animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
}

Expand Down Expand Up @@ -108,7 +109,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
animationSound.Position = TimeSpan.Zero;
animationSound.Play();
}

UpdatePosition();
Activate();
QueryTextBox.Focus();
Expand Down Expand Up @@ -161,6 +161,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
_viewModel.QueryTextCursorMovedToEnd = false;
}
break;

}
};
_settings.PropertyChanged += (o, e) =>
Expand All @@ -176,17 +177,51 @@ private void OnLoaded(object sender, RoutedEventArgs _)
case nameof(Settings.Hotkey):
UpdateNotifyIconText();
break;
case nameof(Settings.WindowLeft):
Left = _settings.WindowLeft;
break;
case nameof(Settings.WindowTop):
Top = _settings.WindowTop;
break;
}
};
}

private void InitializePosition()
{
switch (_settings.SearchWindowPosition)
{
case SearchWindowPositions.RememberLastLaunchLocation:
Top = _settings.WindowTop;
Left = _settings.WindowLeft;
break;
case SearchWindowPositions.MouseScreenCenter:
Left = HorizonCenter();
Top = VerticalCenter();
break;
case SearchWindowPositions.MouseScreenCenterTop:
Left = HorizonCenter();
Top = 10;
break;
case SearchWindowPositions.MouseScreenLeftTop:
Left = 10;
Top = 10;
break;
case SearchWindowPositions.MouseScreenRightTop:
Left = HorizonRight();
Top = 10;
break;
}
}

private void UpdateNotifyIconText()
{
var menu = contextMenu;
((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")";
((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("GameMode");
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("PositionReset");
((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
((MenuItem)menu.Items[5]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
}

private void InitializeNotifyIcon()
Expand All @@ -212,6 +247,10 @@ private void InitializeNotifyIcon()
{
Header = InternationalizationManager.Instance.GetTranslation("GameMode")
};
var positionreset = new MenuItem
{
Header = InternationalizationManager.Instance.GetTranslation("PositionReset")
};
var settings = new MenuItem
{
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings")
Expand All @@ -223,12 +262,15 @@ private void InitializeNotifyIcon()

open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
gamemode.Click += (o, e) => ToggleGameMode();
positionreset.Click += (o, e) => PositionReset();
settings.Click += (o, e) => App.API.OpenSettingDialog();
exit.Click += (o, e) => Close();
contextMenu.Items.Add(header);
contextMenu.Items.Add(open);
gamemode.ToolTip = InternationalizationManager.Instance.GetTranslation("GameModeToolTip");
positionreset.ToolTip = InternationalizationManager.Instance.GetTranslation("PositionResetToolTip");
contextMenu.Items.Add(gamemode);
contextMenu.Items.Add(positionreset);
contextMenu.Items.Add(settings);
contextMenu.Items.Add(exit);

Expand Down Expand Up @@ -275,10 +317,17 @@ private void ToggleGameMode()
_viewModel.GameModeStatus = true;
}
}
private async void PositionReset()
{
_viewModel.Show();
await Task.Delay(300); // If don't give a time, Positioning will be weird.
Left = HorizonCenter();
Top = VerticalCenter();
}
private void InitProgressbarAnimation()
{
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 150,
new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth + 50, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
Expand Down Expand Up @@ -382,6 +431,8 @@ private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs

private async void OnDeactivated(object sender, EventArgs e)
{
_settings.WindowLeft = Left;
_settings.WindowTop = Top;
//This condition stops extra hide call when animator is on,
// which causes the toggling to occasional hide instead of show.
if (_viewModel.MainWindowVisibilityStatus)
Expand All @@ -403,24 +454,14 @@ private void UpdatePosition()
{
if (_animating)
return;

if (_settings.RememberLastLaunchLocation)
{
Left = _settings.WindowLeft;
Top = _settings.WindowTop;
}
else
{
Left = WindowLeft();
Top = WindowTop();
}
InitializePosition();
}

private void OnLocationChanged(object sender, EventArgs e)
{
if (_animating)
return;
if (_settings.RememberLastLaunchLocation)
if (_settings.SearchWindowPosition == SearchWindowPositions.RememberLastLaunchLocation)
{
_settings.WindowLeft = Left;
_settings.WindowTop = Top;
Expand All @@ -439,17 +480,8 @@ public void HideStartup()
_viewModel.Show();
}
}

private void InitializePosition()
{
if (!_settings.RememberLastLaunchLocation)
{
Left = WindowLeft();
Top = WindowTop();
}
}

public double WindowLeft()
public double HorizonCenter()
{
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
Expand All @@ -458,7 +490,7 @@ public double WindowLeft()
return left;
}

public double WindowTop()
public double VerticalCenter()
{
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
Expand All @@ -467,6 +499,15 @@ public double WindowTop()
return top;
}

public double HorizonRight()
{
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
var left = (dip2.X - ActualWidth) - 10;
return left;
}

/// <summary>
/// Register up and down key
/// todo: any way to put this in xaml ?
Expand Down
19 changes: 16 additions & 3 deletions Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,25 @@
</ItemsControl>
</Border>

<Border Style="{DynamicResource SettingGroupBox}">
<Border Margin="0,30,0,0" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource rememberLastLocation}" />
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SearchWindowPosition}" />
</StackPanel>
<CheckBox IsChecked="{Binding Settings.RememberLastLaunchLocation}" Style="{DynamicResource SideControlCheckBox}" />
<ComboBox
x:Name="SearchWindowPosition"
Grid.Column="2"
MinWidth="220"
Margin="0,0,18,0"
VerticalAlignment="Center"
DisplayMemberPath="Display"
FontSize="14"
ItemsSource="{Binding SearchWindowPositions}"
SelectedValue="{Binding Settings.SearchWindowPosition}"
SelectedValuePath="Value" />
<TextBlock Style="{StaticResource Glyph}">
&#xe7f4;
</TextBlock>
</ItemsControl>
</Border>

Expand Down
23 changes: 2 additions & 21 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,25 +341,6 @@ public string QueryText
}


public double Top
{
get => _settings.WindowTop;
set
{
_settings.WindowTop = value;
OnPropertyChanged();
}
}
public double Left
{
get => _settings.WindowLeft;
set
{
_settings.WindowLeft = value;
OnPropertyChanged();
}
}

[RelayCommand]
private void IncreaseWidth()
{
Expand All @@ -370,7 +351,7 @@ private void IncreaseWidth()
else
{
_settings.WindowSize += 100;
Left -= 50;
_settings.WindowLeft -= 50;
}
OnPropertyChanged();
}
Expand All @@ -384,7 +365,7 @@ private void DecreaseWidth()
}
else
{
Left += 50;
_settings.WindowLeft += 50;
_settings.WindowSize -= 100;
}
OnPropertyChanged();
Expand Down
Loading