Use direct binding to set auto-startup

Also includes better messaging (single message for registry failure)
This commit is contained in:
Oren Nachman 2022-08-07 18:23:35 -07:00
parent c557031ef1
commit ebbd1daa39
26 changed files with 25 additions and 89 deletions

View file

@ -119,7 +119,7 @@ namespace Flow.Launcher
// but if it fails (permissions, etc) then don't keep retrying
// this also gives the user a visual indication in the Settings widget
_settings.StartFlowLauncherOnSystemStartup = false;
Notification.Show(InternationalizationManager.Instance.GetTranslation("registerAutoStartFailed"), e.Message);
Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"), e.Message);
}
}
}

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Portable Mode</system:String>
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Start Flow Launcher ved system start</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Skjul Flow Launcher ved mistet fokus</system:String>
<system:String x:Key="dontPromptUpdateMsg">Vis ikke notifikationer om nye versioner</system:String>
<system:String x:Key="rememberLastLocation">Husk seneste position</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Portabler Modus</system:String>
<system:String x:Key="portableModeToolTIp">Speichern Sie alle Einstellungen und Benutzerdaten in einem Ordner (nützlich bei Verwendung mit Wechseldatenträgern oder Clouddiensten).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Starte Flow Launcher bei Systemstart</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Verstecke Flow Launcher wenn der Fokus verloren geht</system:String>
<system:String x:Key="dontPromptUpdateMsg">Zeige keine Nachricht wenn eine neue Version vorhanden ist</system:String>
<system:String x:Key="rememberLastLocation">Merke letzte Ausführungsposition</system:String>

View file

@ -30,8 +30,7 @@
<system:String x:Key="portableMode">Portable Mode</system:String>
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Start Flow Launcher on system startup</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<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="rememberLastLocation">Remember last launch location</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Modo portable</system:String>
<system:String x:Key="portableModeToolTIp">Almacena todos los ajustes y datos de usuario en una sola carpeta (útil cuando se utiliza con unidades extraíbles o servicios en la nube).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Iniciar Flow Launcher al arrancar el sistema</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Ocultar Flow Launcher cuando se pierde el enfoque</system:String>
<system:String x:Key="dontPromptUpdateMsg">No mostrar notificaciones de nuevas versiones</system:String>
<system:String x:Key="rememberLastLocation">Recordar última ubicación de inicio</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Modo Portable</system:String>
<system:String x:Key="portableModeToolTIp">Guarda toda la configuración y datos de usuario en una carpeta (Útil cuando se utiliza con unidades extraíbles o servicios en la nube).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Cargar Flow Launcher al iniciar el sistema</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Ocultar Flow Launcher cuando se pierda el foco</system:String>
<system:String x:Key="dontPromptUpdateMsg">No mostrar notificaciones de nuevas versiones</system:String>
<system:String x:Key="rememberLastLocation">Recordar última posición de Flow Launcher</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Mode Portable</system:String>
<system:String x:Key="portableModeToolTIp">Stocker tous les paramètres et données utilisateur dans un seul dossier (Pratique en cas d'utilisation de disques amovibles ou de services cloud).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Lancer Flow Launcher au démarrage du système</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Cacher Flow Launcher lors de la perte de focus</system:String>
<system:String x:Key="dontPromptUpdateMsg">Ne pas afficher les notifications lors d'une nouvelle version</system:String>
<system:String x:Key="rememberLastLocation">Se souvenir du dernier emplacement de la fenêtre</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Portable Mode</system:String>
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Avvia Wow all'avvio di Windows</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Nascondi Flow Launcher quando perde il focus</system:String>
<system:String x:Key="dontPromptUpdateMsg">Non mostrare le notifiche per una nuova versione</system:String>
<system:String x:Key="rememberLastLocation">Ricorda l'ultima posizione di avvio del launcher</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Portable Mode</system:String>
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">スタートアップ時にFlow Launcherを起動する</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">フォーカスを失った時にFlow Launcherを隠す</system:String>
<system:String x:Key="dontPromptUpdateMsg">最新版が入手可能であっても、アップグレードメッセージを表示しない</system:String>
<system:String x:Key="rememberLastLocation">前回のランチャーの位置を記憶</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">포터블 모드</system:String>
<system:String x:Key="portableModeToolTIp">모든 설정이 폴더안에 들어갑니다. USB 드라이브나 클라우드로 사용 가능합니다.</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">시스템 시작 시 Flow Launcher 실행</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">포커스 잃으면 Flow Launcher 숨김</system:String>
<system:String x:Key="dontPromptUpdateMsg">새 버전 알림 끄기</system:String>
<system:String x:Key="rememberLastLocation">마지막 실행 위치 기억</system:String>

View file

@ -18,8 +18,6 @@
<system:String x:Key="flowlauncher_settings">Flow Launcher-innstillinger</system:String>
<system:String x:Key="general">Generelt</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Start Flow Launcher ved systemstart</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Skjul Flow Launcher ved mistet fokus</system:String>
<system:String x:Key="dontPromptUpdateMsg">Ikke vis varsel om ny versjon</system:String>
<system:String x:Key="rememberLastLocation">Husk siste plassering</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Portable Mode</system:String>
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Start Flow Launcher on system startup</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling 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="rememberLastLocation">Remember last launch location</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Draagbare Modus</system:String>
<system:String x:Key="portableModeToolTIp">Alle instellingen en gebruikersgegevens opslaan in één map (Nuttig bij het gebruik van verwijderbare schijven of cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Start Flow Launcher als systeem opstart</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Verberg Flow Launcher als focus verloren is</system:String>
<system:String x:Key="dontPromptUpdateMsg">Laat geen nieuwe versie notificaties zien</system:String>
<system:String x:Key="rememberLastLocation">Herinner laatste opstart locatie</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Portable Mode</system:String>
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Uruchamiaj Flow Launcher przy starcie systemu</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Ukryj okno Flow Launcher kiedy przestanie ono być aktywne</system:String>
<system:String x:Key="dontPromptUpdateMsg">Nie pokazuj powiadomienia o nowej wersji</system:String>
<system:String x:Key="rememberLastLocation">Zapamiętaj ostatnią pozycję okna</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Portable Mode</system:String>
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Iniciar Flow Launcher com inicialização do sistema</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Esconder Flow Launcher quando foco for perdido</system:String>
<system:String x:Key="dontPromptUpdateMsg">Não mostrar notificações de novas versões</system:String>
<system:String x:Key="rememberLastLocation">Lembrar última localização de lançamento</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Modo portátil</system:String>
<system:String x:Key="portableModeToolTIp">Guardar todas as definições e dados do utilizador numa pasta (indicado se utilizar discos amovíveis ou serviços cloud)</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Iniciar Flow Launcher ao arrancar o sistema</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Ocultar Flow Launcher ao perder o foco</system:String>
<system:String x:Key="dontPromptUpdateMsg">Não notificar acerca de novas versões</system:String>
<system:String x:Key="rememberLastLocation">Memorizar localização anterior</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Portable Mode</system:String>
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Запускать Flow Launcher при запуске системы</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Скрывать Flow Launcher, если потерян фокуc</system:String>
<system:String x:Key="dontPromptUpdateMsg">Не отображать сообщение об обновлении, когда доступна новая версия</system:String>
<system:String x:Key="rememberLastLocation">Запомнить последнее место запуска</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Prenosný režim</system:String>
<system:String x:Key="portableModeToolTIp">Uloží všetky nastavenia a používateľské údaje do jedného priečinka (Užitočné pri vymeniteľných diskoch a cloudových službách).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Spustiť Flow Launcher pri spustení systému</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Schovať Flow Launcher po strate fokusu</system:String>
<system:String x:Key="dontPromptUpdateMsg">Nezobrazovať upozornenia na novú verziu</system:String>
<system:String x:Key="rememberLastLocation">Zapamätať si posledné umiestnenie</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Portable Mode</system:String>
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Pokreni Flow Launcher pri podizanju sistema</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Sakri Flow Launcher kada se izgubi fokus</system:String>
<system:String x:Key="dontPromptUpdateMsg">Ne prikazuj obaveštenje o novoj verziji</system:String>
<system:String x:Key="rememberLastLocation">Zapamti lokaciju poslednjeg pokretanja</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Taşınabilir Mod</system:String>
<system:String x:Key="portableModeToolTIp">Tüm ayarları ve kullanıcı verilerini tek bir klasörde saklayın (Çıkarılabilir sürücüler veya bulut hizmetleri ile kullanıldığında kullanışlıdır).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Flow Launcher'u başlangıçta başlat</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Odak pencereden ayrıldığında Flow Launcher'u gizle</system:String>
<system:String x:Key="dontPromptUpdateMsg">Güncelleme bildirimlerini gösterme</system:String>
<system:String x:Key="rememberLastLocation">Pencere konumunu hatırla</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Портативний режим</system:String>
<system:String x:Key="portableModeToolTIp">Зберігати всі налаштування і дані користувача в одній теці (буде корисно при видаленні дисків або хмарних сервісах).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">Запускати Flow Launcher при запуску системи</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Сховати Flow Launcher, якщо втрачено фокус</system:String>
<system:String x:Key="dontPromptUpdateMsg">Не повідомляти про доступні нові версії</system:String>
<system:String x:Key="rememberLastLocation">Запам'ятати останнє місце запуску</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">便携模式</system:String>
<system:String x:Key="portableModeToolTIp">将所有设置和用户数据存储在一个文件夹中 (可用于可移除驱动器或云服务)。</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">开机自启</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">失去焦点时自动隐藏 Flow Launcher</system:String>
<system:String x:Key="dontPromptUpdateMsg">不显示新版本提示</system:String>
<system:String x:Key="rememberLastLocation">记住上次启动位置</system:String>

View file

@ -28,8 +28,6 @@
<system:String x:Key="portableMode">Portable Mode</system:String>
<system:String x:Key="portableModeToolTIp">Store all settings and user data in one folder (Useful when used with removable drives or cloud services).</system:String>
<system:String x:Key="startFlowLauncherOnSystemStartup">開機時啟動</system:String>
<system:String x:Key="registerAutoStartFailed">Error enabling launch on startup</system:String>
<system:String x:Key="deregisterAutoStartFailed">Error disabling launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">失去焦點時自動隱藏 Flow Launcher</system:String>
<system:String x:Key="dontPromptUpdateMsg">不顯示新版本提示</system:String>
<system:String x:Key="rememberLastLocation">記住上次啟動位置</system:String>

View file

@ -598,10 +598,8 @@
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource startFlowLauncherOnSystemStartup}" />
</StackPanel>
<CheckBox
Checked="OnAutoStartupChecked"
IsChecked="{Binding Settings.StartFlowLauncherOnSystemStartup}"
Style="{DynamicResource SideControlCheckBox}"
Unchecked="OnAutoStartupUncheck" />
IsChecked="{Binding StartFlowLauncherOnSystemStartup}"
Style="{DynamicResource SideControlCheckBox}" />
<TextBlock Style="{StaticResource Glyph}">
&#xe8fc;
</TextBlock>

View file

@ -57,16 +57,6 @@ namespace Flow.Launcher
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
}
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
{
viewModel.SetStartup();
}
private void OnAutoStartupUncheck(object sender, RoutedEventArgs e)
{
viewModel.RemoveStartup();
}
private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e)
{
var dlg = new FolderBrowserDialog

View file

@ -64,6 +64,27 @@ namespace Flow.Launcher.ViewModel
}
}
public bool StartFlowLauncherOnSystemStartup
{
get => Settings.StartFlowLauncherOnSystemStartup;
set
{
Settings.StartFlowLauncherOnSystemStartup = value;
try
{
if (value)
AutoStartup.Enable();
else
AutoStartup.Disable();
}
catch (Exception e)
{
Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"), e.Message);
}
}
}
// This is only required to set at startup. When portable mode enabled/disabled a restart is always required
private bool _portableMode = DataLocation.PortableDataLocationInUse();
public bool PortableMode
@ -216,36 +237,6 @@ namespace Flow.Launcher.ViewModel
#endregion
#region startup
public void SetStartup()
{
try
{
AutoStartup.Enable();
}
catch (Exception e)
{
Notification.Show(InternationalizationManager.Instance.GetTranslation("registerAutoStartFailed"), e.Message);
}
}
public void RemoveStartup()
{
if (AutoStartup.IsEnabled)
{
try
{
AutoStartup.Disable();
}
catch (Exception e)
{
Notification.Show(InternationalizationManager.Instance.GetTranslation("deregisterAutoStartFailed"), e.Message);
}
}
}
#endregion
#region plugin
public static string Plugin => @"https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest";