From 1a9dc33926e2e88947b46ce89c2d6fc04414379b Mon Sep 17 00:00:00 2001 From: ema Date: Fri, 6 Dec 2024 16:21:42 +0800 Subject: [PATCH] Add the tray menu to restart QuickLook #1448 --- QuickLook/Translations.config | 27 +++++++++++++++++++++++++++ QuickLook/TrayIconManager.cs | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/QuickLook/Translations.config b/QuickLook/Translations.config index 4da1b1e..28fb2fb 100644 --- a/QuickLook/Translations.config +++ b/QuickLook/Translations.config @@ -16,6 +16,7 @@ تأكد من وجود أي تحديث للبرنامج إبحث عن إضافات جديدة افتح مجلد البيانات + إعادة تشغيل أغلق البرنامج أنت تمتلك النسخة الأحدث من البرنامج كويك لووك {0} تم إصداره. إنقر هنا لفتح صفحة التحميل @@ -42,6 +43,7 @@ Keressen új &Frissítést... Keressen új &Bővítményeket... Adatmappa Megnyitása + &Újraindítás &Kilépés A legújabb verziót használja. QuickLook {0} megjelent. Kattintson ide a letöltési oldal megnyitásához. @@ -67,6 +69,7 @@ QuickLook v{0} Skontrolovať &aktualizácie... Otvoriť Priečinok S Údajmi + &Reštart &Ukončiť Máte nainštalovanú najnovšiu verziu QuickLook {0} nie je v aktuálnej verzii. Kliknite sem na otvorenie stránky pre stiahnutie. @@ -93,6 +96,7 @@ Memeriksa &Pembaharuan... Cari Plug-ins &Baru... Buka Folder Data + &Mulai Ulang &Keluar Anda saat ini menggunakan versi terbaru. QuickLook v. {0} dirilis. Klik disini untuk membuka halaman unduhan. @@ -119,6 +123,7 @@ 업데이트 확인(&U) 새 플러그인 찾기(&P) 데이터 폴더 열기 + 다시 시작(&R) 종료(&Q) 최신 버전을 사용 중입니다. QuickLook {0} 버전이 출시되었습니다. 다운로드 페이지로 가려면 이곳을 클릭하십시오. @@ -143,6 +148,7 @@ QuickLook v{0} Cerca &actualitzacions... Obre La Carpeta De Dades + &Reinicia &Surt Ja teniu l'última versió. S'ha alliberat el QuickLook {0}. Feu clic aquí per a obrir la pàgina de baixada. @@ -174,6 +180,7 @@ Nach &Updates suchen &Plugins suchen (öffnet Browser) Datenspeicher Öffnen + &Neustart &Beenden Sie haben die neueste Version Update auf v{0} verfügbar, hier klicken um die Downloadseite zu öffnen @@ -205,6 +212,7 @@ Check for &Updates... Find new &Plugins... Open Data Folder + &Restart &Quit You are now on the latest version. QuickLook {0} is released. Click here to open the download page. @@ -236,6 +244,7 @@ Buscar &Actualizaciones... Buscar nuevos &Plugins... Abrir Carpeta De Datos + &Reiniciar &Salir Está usando la última versión. QuickLook {0} está disponible. Haga clic aquí para abrir la página de descarga. @@ -263,6 +272,7 @@ Vérifier s'il existe des &mises à jour... Trouver de nouveaux &plugins... Ouvrir Le Dossier De Données + &Redémarrer &Quitter Vous êtes maintenant sur la dernière version. QuickLook {0} est disponible. Cliquez ici pour ouvrir la page de téléchargement. @@ -290,6 +300,7 @@ Verifica &Aggiornamenti... Trova nuovi &Plugin... Apri Cartella Dati + &Riavvia &Esci Stai usando l'ultima versione. QuickLook {0} è disponibile. Fai click qui per aprire la pagina di download. @@ -315,6 +326,7 @@ 更新を確認する... (&U) 新しいプラグインを検索する... (&P) データフォルダを開く + 再起動(&R) 終了(&E) 最新版です QuickLook {0} がリリースされました。ここをクリックしてダウンロードページを開きます。 @@ -339,6 +351,7 @@ QuickLook v{0} Se etter &oppdateringer... Åpne Datamappen + &Start på nytt &Avslutt Du bruker nå siste versjon. QuickLook {0} er kommet ut. Klikk her for å åpne nedlastingssiden. @@ -363,6 +376,7 @@ QuickLook v{0} Controleren op &Updates... Open Gegevensmap + &Opnieuw starten &Sluiten U heeft de meest recente versie. QuickLook {0} is gereleased. Klik hier om de downloadpagina te openen. @@ -394,6 +408,7 @@ Sprawdź &aktualizacje... Dostępne &pluginy... Otwórz Folder Danych + &Uruchom ponownie &Zakończ Używasz już najnowszej wersji. QuickLook {0} jest dostępny. Kliknij tutaj, aby otworzyć stronę z aktualizacją do pobrania. @@ -421,6 +436,7 @@ Procurar por &Atualizações... Encontrar novos &Plugins... Abrir Pasta De Dados + &Reiniciar &Fechar Executando a versão mais recente. Nova versão disponível. QuickLook {0}. Clique aqui para abrir a página de download. @@ -445,6 +461,7 @@ QuickLook v{0} Procurar por &Atualizações... Abrir Pasta De Dados + &Reiniciar &Fechar Está a executar a versão mais recente. Está disponível o QuickLook {0}. Clique aqui para abrir a página de download. @@ -474,6 +491,7 @@ Проверить &обновления… Найти новые &Дополнения… Открыть Папку Данных + &Перезапуск &Выход Вы используете последнюю версию. Выпущен QuickLook {0}. Нажмите здесь для перехода на страницу загрузки. @@ -500,6 +518,7 @@ &Güncellemeleri denetle... &Yeni eklentiler bul... Veri Klasörünü Aç + Yeniden &Başlat Çı&kış Son sürümü kullanıyorsunuz. QuickLook {0} sürümü yayınladı. İndirme sayfasını açmak için buraya tıklayın. @@ -531,6 +550,7 @@ Перевірити наявність &оновлення… Знайти нові &Втулки… Відкрити Папку Даних + &Перезавантажити &Вийти Ви зараз на самій свіжій версії. Випущено QuickLook {0}. Натисніть тут, щоб відкрити сторінку завантаження. @@ -556,6 +576,7 @@ QuickLook v{0} &Kiểm tra cập nhật... Mở Thư Mục Dữ Liệu + &Khởi động lại &Thoát Bạn hiện đang sử dụng phiên bản mới nhất. Đã có phiên bản QuickLook {0}. Nhấp vào đây để mở trang tải xuống. @@ -583,6 +604,7 @@ 检查更新... (&U) 获取新插件... (&P) 打开数据文件夹 + 重启 (&R) 退出 (&Q) 您已使用了最新版本。 QuickLook {0} 已发布。点击这里打开下载页面。 @@ -610,6 +632,7 @@ 檢查更新... (&U) 取得新外掛... (&P) 開啟資料夾 + 重啟 (&R) 結束 Quicklook (&Q) 您正在使用最新版本。 QuickLook {0} 新版本已發布。請按一下此處開啟下載頁面。 @@ -636,6 +659,7 @@ &अद्यतनांसाठी तपासा... नवीन &प्लगइन्स शोधा... डेटा फोल्डर उघडा + &पुनः आरंभ &बंद करा आपण आता नवीनतम आवृत्ती वापरत आहात. QuickLook ची नवीन आवृत्ती {0} उपलब्ध आहे. डाउनलोड पृष्ठ उघडण्यासाठी येथे क्लिक करा. @@ -662,6 +686,7 @@ &अद्यतन के लिए जाँच करें... नए &प्लगइन्स खोजें... डेटा फ़ोल्डर खोलें + &पुनः प्रारंभ करें &बंद किजीए अब आप नवीनतम संस्करण पर हैं। QuickLook का नया संस्करण उपलब्ध है। डाउनलोड पेज खोलने के लिए यहां क्लिक करें। @@ -689,6 +714,7 @@ בדוק &עדכונים מצא &תוספים חדשים פתח את תיקיית הנתונים + &אתחול מחדש &צא אתה כעת על הגרסא האחרונה 'תצוגה מהירה' {0} שוחררה. לחץ כאן על מנת להוריד את העדכון @@ -716,6 +742,7 @@ Ελεγχος για &ενημερώσεις... Βρείτε νέα &πρόσθετα... Άνοιγμα Φακέλου Δεδομένων + &Επανεκκίνηση &Κλείσιμο Έχετε την πιο πρόσφατη έκδοση. Διαθέσιμη ενημέρωση {0} βρέθηκε. Κάντε κλικ εδώ για να ανοίξετε τη σελίδα λήψης. diff --git a/QuickLook/TrayIconManager.cs b/QuickLook/TrayIconManager.cs index a9db6a3..03ccfbb 100644 --- a/QuickLook/TrayIconManager.cs +++ b/QuickLook/TrayIconManager.cs @@ -16,8 +16,10 @@ // along with this program. If not, see . using System; +using System.ComponentModel; using System.Diagnostics; using System.Drawing; +using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; using QuickLook.Common.Helpers; @@ -78,11 +80,12 @@ namespace QuickLook [ new MenuItem($"v{Application.ProductVersion}{(App.IsUWP ? " (UWP)" : "")}") {Enabled = false}, new MenuItem("-"), - new MenuItem(TranslationHelper.Get("Icon_CheckUpdate"), (sender, e) => Updater.CheckForUpdates()), + new MenuItem(TranslationHelper.Get("Icon_CheckUpdate"), (_, _) => Updater.CheckForUpdates()), new MenuItem(TranslationHelper.Get("Icon_GetPlugin"), (sender, e) => Process.Start("https://github.com/QL-Win/QuickLook/wiki/Available-Plugins")), - new MenuItem(TranslationHelper.Get("Icon_OpenDataFolder"), (sender, e) => Process.Start("explorer.exe", SettingHelper.LocalDataPath)), + new MenuItem(TranslationHelper.Get("Icon_OpenDataFolder"), (_, _) => Process.Start("explorer.exe", SettingHelper.LocalDataPath)), _itemAutorun, + new MenuItem(TranslationHelper.Get("Icon_Restart"), (_, _) => Restart(forced: true)), new MenuItem(TranslationHelper.Get("Icon_Quit"), (sender, e) => System.Windows.Application.Current.Shutdown()) ]), @@ -97,6 +100,34 @@ namespace QuickLook _icon.Visible = false; } + public void Restart(string fileName = null, string dir = null, string args = null, int? exitCode = null, bool forced = false) + { + _ = args; // Currently there is no cli supported by QL + + try + { + using Process process = new() + { + StartInfo = new ProcessStartInfo() + { + FileName = fileName ?? Path.Combine(dir ?? AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName), + WorkingDirectory = dir ?? Environment.CurrentDirectory, + UseShellExecute = true, + }, + }; + process.Start(); + } + catch (Win32Exception) + { + return; + } + if (forced) + { + Process.GetCurrentProcess().Kill(); + } + Environment.Exit(exitCode ?? 'r' + 'e' + 's' + 't' + 'a' + 'r' + 't'); + } + private Icon GetTrayIconByDPI() { var scale = DisplayDeviceHelper.GetCurrentScaleFactor().Vertical;