[PT Run][New Plugin] Time zone plugin (#11431)
* Initial commit - simple idea for a time zone plugin
* Translations, better search results, copy to clipboard, cleanup
* fix typo
* Add shortcut search and prepare JSON for later usage
* Fix typo
* Use timezone Data only from JSON
* Exclude json file from spell checker
* fix wrong dst
* Improved results (title, subtitle, tooltip) and fix namespace/class problem
* Always show full offset (-##:## and +##:##)
* Add and show timezone names (first pass)
* Fix typos
* fix build
* JSON: fix wrong minus sign and put extra country info the end
* Improved Subtitle for many matched countries and allow full offset search (+ and -)
* Allow more than one names for time zones and remove leftover
* Add military time zone names, and fix name result
* Only use one JSON entry for one time zone
* Use TimeSpan for offset, use build-in calculation for time in time zone
* add descriptions for JSON schema
* Fix typos
* Split out names in separate properties
* Add many time names, time zone names and shortcuts
* Add additional options and most code documentation
* Fix unreadable TimeSpans in JSON and rename helper class
* Fix not allowed commas in JSON file
* Cut to long time and time zone names in title
* Fix missing results for names and offsets
* Better result and show only one result when offset are identical (respect daylight saving time)
* Show generic name fot time zones without names
* Typo fixes
* Fix not working serach by shortcuts
* Fix german resx file -> english resx file
* Translate all names and countires
* Fix not working context menu
* Typo fixes, fix wrong shortcut in names, comments, few better variable names
* New symbols - thx to niels9001
* Search by shortcuts for time names
* update schema
* Add more time zone names and shortcuts (second pass), make spell checker happy
* Reduce matching checks
* Show shortcuts in tool-tips, avoid string converting
* Show only names that match the query
* Make all translatable (Part 1)
* Make all translatable (part 2 of 2)
* XML Doc
* Fix plugin name (type)
* Fix Typos
* Add TimeZone Plugint to WXS
* Add TimeZone plugin to sign pipeline
* Add Documentation
* Remove double spell entries
* Remove TODO leftovers
* Fix for results with no countries
* Fix typos
* fix typos
* Fix broken siolution after rebase
* Update target framework to make build happy
* fix wrong guid count in WXS
* fix wrong output folder (setup wasn’t found files)
* Address feedback from @jsoref - fix spell check
* typo fix - one leftover in expect.txt
* Switch to .NET6 and update dokumentation
* Address feedbacks, and fix search bug
* fix installer build error
* fix spellchecker
* Address feedback from @htcfreek
Co-authored-by: Sekan, Tobias <tobias.sekan@axp-consulting.de>
2022-02-23 14:26:48 +00:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Microsoft.PowerToys.Run.Plugin.TimeZone.Properties;
|
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Run.Plugin.TimeZone.Classes
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Additional settings for the time zone plugin.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal sealed class TimeZoneSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets a value indicating whether the time zone name of a time zone is shown in the results.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal bool ShowTimeZoneNames { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets a value indicating whether the time name of a time zone is shown in the results.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal bool ShowTimeNames { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets a value indicating whether the military name of a time zone is shown in the results.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal bool ShowMilitaryTimeZoneNames { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Return a list with all settings. Additional
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>A list with all settings.</returns>
|
|
|
|
|
|
internal static List<PluginAdditionalOption> GetAdditionalOptions()
|
|
|
|
|
|
{
|
|
|
|
|
|
var optionList = new List<PluginAdditionalOption>
|
|
|
|
|
|
{
|
|
|
|
|
|
new PluginAdditionalOption
|
|
|
|
|
|
{
|
|
|
|
|
|
Key = "ShowTimeZoneNames",
|
|
|
|
|
|
DisplayLabel = Resources.ShowTimeZoneNames,
|
|
|
|
|
|
Value = true,
|
|
|
|
|
|
},
|
|
|
|
|
|
new PluginAdditionalOption
|
|
|
|
|
|
{
|
|
|
|
|
|
Key = "ShowTimeNames",
|
|
|
|
|
|
DisplayLabel = Resources.ShowTimeNames,
|
|
|
|
|
|
Value = true,
|
|
|
|
|
|
},
|
|
|
|
|
|
new PluginAdditionalOption
|
|
|
|
|
|
{
|
|
|
|
|
|
Key = "ShowMilitaryTimeZoneNames",
|
|
|
|
|
|
DisplayLabel = Resources.ShowMilitaryTimeZoneNames,
|
|
|
|
|
|
Value = false,
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return optionList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Update this settings.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="settings">The settings for all power launcher plugin.</param>
|
|
|
|
|
|
internal void UpdateSettings(PowerLauncherPluginSettings settings)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (settings is null || settings.AdditionalOptions is null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ShowTimeZoneNames = GetSettingOrDefault(settings, "ShowTimeZoneNames");
|
|
|
|
|
|
ShowTimeNames = GetSettingOrDefault(settings, "ShowTimeNames");
|
|
|
|
|
|
ShowMilitaryTimeZoneNames = GetSettingOrDefault(settings, "ShowMilitaryTimeZoneNames");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Return one <see cref="bool"/> setting of the given settings list with the given name.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="settings">The object that contain all settings.</param>
|
|
|
|
|
|
/// <param name="name">The name of the setting.</param>
|
|
|
|
|
|
/// <returns>A settings value.</returns>
|
|
|
|
|
|
private static bool GetSettingOrDefault(PowerLauncherPluginSettings settings, string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
var option = settings.AdditionalOptions.FirstOrDefault(x => x.Key == name);
|
|
|
|
|
|
|
2022-06-24 12:00:46 +00:00
|
|
|
|
// As a fall-back if a setting isn't available, we use the value defined in the method GetAdditionalOptions()
|
[PT Run][New Plugin] Time zone plugin (#11431)
* Initial commit - simple idea for a time zone plugin
* Translations, better search results, copy to clipboard, cleanup
* fix typo
* Add shortcut search and prepare JSON for later usage
* Fix typo
* Use timezone Data only from JSON
* Exclude json file from spell checker
* fix wrong dst
* Improved results (title, subtitle, tooltip) and fix namespace/class problem
* Always show full offset (-##:## and +##:##)
* Add and show timezone names (first pass)
* Fix typos
* fix build
* JSON: fix wrong minus sign and put extra country info the end
* Improved Subtitle for many matched countries and allow full offset search (+ and -)
* Allow more than one names for time zones and remove leftover
* Add military time zone names, and fix name result
* Only use one JSON entry for one time zone
* Use TimeSpan for offset, use build-in calculation for time in time zone
* add descriptions for JSON schema
* Fix typos
* Split out names in separate properties
* Add many time names, time zone names and shortcuts
* Add additional options and most code documentation
* Fix unreadable TimeSpans in JSON and rename helper class
* Fix not allowed commas in JSON file
* Cut to long time and time zone names in title
* Fix missing results for names and offsets
* Better result and show only one result when offset are identical (respect daylight saving time)
* Show generic name fot time zones without names
* Typo fixes
* Fix not working serach by shortcuts
* Fix german resx file -> english resx file
* Translate all names and countires
* Fix not working context menu
* Typo fixes, fix wrong shortcut in names, comments, few better variable names
* New symbols - thx to niels9001
* Search by shortcuts for time names
* update schema
* Add more time zone names and shortcuts (second pass), make spell checker happy
* Reduce matching checks
* Show shortcuts in tool-tips, avoid string converting
* Show only names that match the query
* Make all translatable (Part 1)
* Make all translatable (part 2 of 2)
* XML Doc
* Fix plugin name (type)
* Fix Typos
* Add TimeZone Plugint to WXS
* Add TimeZone plugin to sign pipeline
* Add Documentation
* Remove double spell entries
* Remove TODO leftovers
* Fix for results with no countries
* Fix typos
* fix typos
* Fix broken siolution after rebase
* Update target framework to make build happy
* fix wrong guid count in WXS
* fix wrong output folder (setup wasn’t found files)
* Address feedback from @jsoref - fix spell check
* typo fix - one leftover in expect.txt
* Switch to .NET6 and update dokumentation
* Address feedbacks, and fix search bug
* fix installer build error
* fix spellchecker
* Address feedback from @htcfreek
Co-authored-by: Sekan, Tobias <tobias.sekan@axp-consulting.de>
2022-02-23 14:26:48 +00:00
|
|
|
|
var settingsValue = option?.Value
|
|
|
|
|
|
?? GetAdditionalOptions().FirstOrDefault(x => x.Key == name)?.Value
|
|
|
|
|
|
?? default;
|
|
|
|
|
|
|
|
|
|
|
|
return settingsValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|