mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix button text issue
This commit is contained in:
parent
3196dc559a
commit
dcec3611de
6 changed files with 35 additions and 27 deletions
|
|
@ -59,7 +59,7 @@
|
|||
Margin="0,0,0,0"
|
||||
FontSize="20"
|
||||
FontWeight="SemiBold"
|
||||
Text="{DynamicResource flowlauncher_plugin_program_edit_program_source}"
|
||||
Text="{DynamicResource flowlauncher_plugin_program_edit_program_source_title}"
|
||||
TextAlignment="Left" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
|
|
|
|||
|
|
@ -24,14 +24,15 @@ namespace Flow.Launcher.Plugin.Program
|
|||
tbDirectory.Focus();
|
||||
Chkbox.IsChecked = true;
|
||||
update = false;
|
||||
btnAdd.Content = _context.API.GetTranslation("flowlauncher_plugin_program_add");
|
||||
}
|
||||
|
||||
public AddProgramSource(Settings.ProgramSource source, Settings settings)
|
||||
{
|
||||
InitializeComponent();
|
||||
_updating = source;
|
||||
_settings = settings;
|
||||
update = true;
|
||||
InitializeComponent();
|
||||
Chkbox.IsChecked = _updating.Enabled;
|
||||
tbDirectory.Text = _updating.Location;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@
|
|||
<system:String x:Key="flowlauncher_plugin_program_pls_select_program_source">Please select a program source</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_delete_program_source">Are you sure you want to delete the selected program sources?</system:String>
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_program_edit_program_source">Edit Program Source</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_edit_program_source_title">Program Source</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_edit_program_source_tips">Edit directory and status of this program source.</system:String>
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_program_update">OK</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_update">Update</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_only_index_tip">Flow Launcher will only index files that end with the following suffixes. (Each suffix should split by ';' )</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_update_file_suffixes">Successfully updated file suffixes</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_program_suffixes_cannot_empty">File suffixes can't be empty</system:String>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Program
|
||||
{
|
||||
|
|
@ -41,6 +42,16 @@ namespace Flow.Launcher.Plugin.Program
|
|||
public string Name { get => name ?? new DirectoryInfo(Location).Name; set => name = value; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
public string UniqueIdentifier { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is ProgramSource other && other.UniqueIdentifier.ToLower() == this.UniqueIdentifier.ToLower();
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(UniqueIdentifier.ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
public class DisabledProgramSource : ProgramSource { }
|
||||
|
|
|
|||
|
|
@ -116,7 +116,8 @@
|
|||
Drop="programSourceView_Drop"
|
||||
GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"
|
||||
PreviewMouseRightButtonUp="ProgramSourceView_PreviewMouseRightButtonUp"
|
||||
MouseDoubleClick="ProgramSourceView_MouseDoubleClick"
|
||||
MouseDoubleClick="programSourceView_MouseDoubleClick"
|
||||
SelectionChanged="programSourceView_SelectionChanged"
|
||||
SelectionMode="Extended">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
|
|
|
|||
|
|
@ -235,18 +235,14 @@ namespace Flow.Launcher.Plugin.Program.Views
|
|||
.SelectedItems.Cast<ProgramSource>()
|
||||
.ToList();
|
||||
|
||||
if (selectedItems.Count() == 0)
|
||||
if (selectedItems.Count == 0)
|
||||
{
|
||||
string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source");
|
||||
MessageBox.Show(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedItems
|
||||
.Where(t1 => !_settings
|
||||
.ProgramSources
|
||||
.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
|
||||
.Count() == 0)
|
||||
if (IsAllItemsUserAdded(selectedItems))
|
||||
{
|
||||
var msg = string.Format(context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source"));
|
||||
|
||||
|
|
@ -257,7 +253,7 @@ namespace Flow.Launcher.Plugin.Program.Views
|
|||
|
||||
DeleteProgramSources(selectedItems);
|
||||
}
|
||||
else if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(selectedItems))
|
||||
else if (HasMoreOrEqualEnabledItems(selectedItems))
|
||||
{
|
||||
ProgramSettingDisplayList.SetProgramSourcesStatus(selectedItems, false);
|
||||
|
||||
|
|
@ -329,42 +325,36 @@ namespace Flow.Launcher.Plugin.Program.Views
|
|||
dataView.Refresh();
|
||||
}
|
||||
|
||||
private bool IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(List<ProgramSource> selectedItems)
|
||||
private static bool HasMoreOrEqualEnabledItems(List<ProgramSource> items)
|
||||
{
|
||||
return selectedItems.Where(x => x.Enabled).Count() >= selectedItems.Where(x => !x.Enabled).Count();
|
||||
return items.Where(x => x.Enabled).Count() >= items.Count / 2;
|
||||
}
|
||||
|
||||
private void Row_OnClick(object sender, RoutedEventArgs e)
|
||||
private void programSourceView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var selectedItems = programSourceView
|
||||
.SelectedItems.Cast<ProgramSource>()
|
||||
.ToList();
|
||||
|
||||
if (selectedItems
|
||||
.Where(t1 => !_settings
|
||||
.ProgramSources
|
||||
.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
|
||||
.Count() == 0)
|
||||
if (IsAllItemsUserAdded(selectedItems))
|
||||
{
|
||||
btnProgramSourceStatus.Content = context.API.GetTranslation("flowlauncher_plugin_program_delete");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(selectedItems))
|
||||
else if (HasMoreOrEqualEnabledItems(selectedItems))
|
||||
{
|
||||
btnProgramSourceStatus.Content = "Disable"; // todo
|
||||
btnProgramSourceStatus.Content = context.API.GetTranslation("flowlauncher_plugin_program_disable");
|
||||
}
|
||||
else
|
||||
{
|
||||
btnProgramSourceStatus.Content = "Enable";
|
||||
btnProgramSourceStatus.Content = context.API.GetTranslation("flowlauncher_plugin_program_enable");
|
||||
}
|
||||
}
|
||||
|
||||
private void ProgramSourceView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
private void programSourceView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var selectedProgramSource = programSourceView.SelectedItem as Settings.ProgramSource;
|
||||
if (selectedProgramSource != null)
|
||||
{
|
||||
{
|
||||
var add = new AddProgramSource(selectedProgramSource, _settings);
|
||||
if (add.ShowDialog() ?? false)
|
||||
{
|
||||
|
|
@ -372,5 +362,10 @@ namespace Flow.Launcher.Plugin.Program.Views
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsAllItemsUserAdded(List<ProgramSource> items)
|
||||
{
|
||||
return items.All(x => _settings.ProgramSources.Any(y => y == x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue