mirror of
https://github.com/siddharthvaddem/openscreen.git
synced 2026-08-29 03:08:30 +08:00
fix: show error feedback when global shortcut registration fails
This commit is contained in:
Vendored
+1
-1
@@ -253,7 +253,7 @@ interface Window {
|
||||
ctrl?: boolean;
|
||||
shift?: boolean;
|
||||
alt?: boolean;
|
||||
}) => Promise<void>;
|
||||
}) => Promise<{ success: boolean }>;
|
||||
hudOverlayHide: () => void;
|
||||
hudOverlayClose: () => void;
|
||||
setHudOverlayIgnoreMouseEvents: (ignore: boolean) => void;
|
||||
|
||||
@@ -63,7 +63,6 @@ export async function loadAndRegisterGlobalShortcut(onTrigger: () => void): Prom
|
||||
const binding = shortcuts.openApp || DEFAULT_OPEN_APP_BINDING;
|
||||
registerOpenAppShortcut(binding, onTrigger);
|
||||
} catch {
|
||||
// File doesn't exist or parse error, use default
|
||||
registerOpenAppShortcut(DEFAULT_OPEN_APP_BINDING, onTrigger);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -523,7 +523,8 @@ app.whenReady().then(async () => {
|
||||
});
|
||||
|
||||
ipcMain.handle("update-global-shortcut", (_, binding: ShortcutBinding) => {
|
||||
registerOpenAppShortcut(binding, showMainWindow);
|
||||
const success = registerOpenAppShortcut(binding, showMainWindow);
|
||||
return { success };
|
||||
});
|
||||
|
||||
createTray();
|
||||
|
||||
@@ -103,8 +103,12 @@ export function ShortcutsConfigDialog() {
|
||||
|
||||
const handleSave = useCallback(async () => {
|
||||
setShortcuts(draft);
|
||||
await persistShortcuts(draft);
|
||||
toast.success(t("savedToast"));
|
||||
const success = await persistShortcuts(draft);
|
||||
if (success) {
|
||||
toast.success(t("savedToast"));
|
||||
} else {
|
||||
toast.error(t("registrationFailed"));
|
||||
}
|
||||
closeConfig();
|
||||
}, [draft, setShortcuts, persistShortcuts, closeConfig, t]);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ interface ShortcutsContextValue {
|
||||
shortcuts: ShortcutsConfig;
|
||||
isMac: boolean;
|
||||
setShortcuts: (config: ShortcutsConfig) => void;
|
||||
persistShortcuts: (config?: ShortcutsConfig) => Promise<void>;
|
||||
persistShortcuts: (config?: ShortcutsConfig) => Promise<boolean>;
|
||||
isConfigOpen: boolean;
|
||||
openConfig: () => void;
|
||||
closeConfig: () => void;
|
||||
@@ -56,7 +56,9 @@ export function ShortcutsProvider({ children }: { children: ReactNode }) {
|
||||
async (config?: ShortcutsConfig) => {
|
||||
const configToSave = config ?? shortcuts;
|
||||
await window.electronAPI.saveShortcuts?.(configToSave);
|
||||
await window.electronAPI.updateGlobalShortcut?.(configToSave.openApp);
|
||||
|
||||
const result = await window.electronAPI.updateGlobalShortcut?.(configToSave.openApp);
|
||||
return result ? result.success : true;
|
||||
},
|
||||
[shortcuts],
|
||||
);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "هذا الاختصار محجوز لـ \"{{label}}\" ولا يمكن إعادة تعيينه.",
|
||||
"savedToast": "تم حفظ اختصارات لوحة المفاتيح",
|
||||
"resetToast": "إعادة تعيين إلى الاختصارات الافتراضية — انقر فوق حفظ للتطبيق",
|
||||
"registrationFailed": "فشل في تسجيل الاختصار. قد يكون مستخدمًا من قبل تطبيق آخر. جرب مفتاحًا مختلفًا.",
|
||||
"actions": {
|
||||
"openApp": "فتح التطبيق",
|
||||
"addZoom": "إضافة تكبير",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "This shortcut is reserved for \"{{label}}\" and cannot be reassigned.",
|
||||
"savedToast": "Keyboard shortcuts saved",
|
||||
"resetToast": "Reset to default shortcuts — click Save to apply",
|
||||
"registrationFailed": "Failed to register shortcut. It may be in use by another app. Try a different key.",
|
||||
"actions": {
|
||||
"openApp": "Open App",
|
||||
"addZoom": "Add Zoom",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "Este atajo está reservado para \"{{label}}\" y no se puede reasignar.",
|
||||
"savedToast": "Atajos de teclado guardados",
|
||||
"resetToast": "Restablecido a los atajos predeterminados — haz clic en Guardar para aplicar",
|
||||
"registrationFailed": "Error al registrar el atajo. Puede estar en uso por otra aplicación. Prueba otra tecla.",
|
||||
"actions": {
|
||||
"openApp": "Abrir aplicación",
|
||||
"addZoom": "Agregar zoom",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "Ce raccourci est réservé pour « {{label}} » et ne peut pas être réassigné.",
|
||||
"savedToast": "Raccourcis clavier enregistrés",
|
||||
"resetToast": "Réinitialisé aux raccourcis par défaut — cliquez sur Enregistrer pour appliquer",
|
||||
"registrationFailed": "Échec de l'enregistrement du raccourci. Il est peut-être utilisé par une autre application. Essayez une autre touche.",
|
||||
"actions": {
|
||||
"openApp": "Ouvrir l'application",
|
||||
"addZoom": "Ajouter un zoom",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "Questa scorciatoia è riservata a \"{{label}}\" e non può essere riassegnata.",
|
||||
"savedToast": "Scorciatoie tastiera salvate",
|
||||
"resetToast": "Ripristino alle scorciatoie predefinite — clicca Salva per applicare",
|
||||
"registrationFailed": "Impossibile registrare la scorciatoia. Potrebbe essere in uso da un'altra applicazione. Prova un altro tasto.",
|
||||
"actions": {
|
||||
"openApp": "Apri applicazione",
|
||||
"addZoom": "Aggiungi zoom",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "このショートカットは \"{{label}}\" に予約されており、再割り当てできません。",
|
||||
"savedToast": "キーボードショートカットが保存されました",
|
||||
"resetToast": "デフォルトのショートカットにリセット — 保存をクリックして適用",
|
||||
"registrationFailed": "ショートカットの登録に失敗しました。他のアプリで使用中の可能性があります。別のキーをお試しください。",
|
||||
"actions": {
|
||||
"openApp": "アプリを開く",
|
||||
"addZoom": "ズームを追加",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "이 단축키는 \"{{label}}\"에 예약되어 있어 변경할 수 없습니다.",
|
||||
"savedToast": "키보드 단축키가 저장되었습니다",
|
||||
"resetToast": "기본 단축키로 초기화되었습니다 — 저장을 클릭해 적용하세요",
|
||||
"registrationFailed": "단축키 등록에 실패했습니다. 다른 앱에서 사용 중일 수 있습니다. 다른 키를 시도하세요.",
|
||||
"actions": {
|
||||
"openApp": "앱 열기",
|
||||
"addZoom": "줌 추가",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "Эта горячая клавиша зарезервирована для \"{{label}}\" и не может быть переназначена.",
|
||||
"savedToast": "Горячие клавиши сохранены",
|
||||
"resetToast": "Сброс к горячим клавишам по умолчанию — нажмите Сохранить для применения",
|
||||
"registrationFailed": "Не удалось зарегистрировать горячую клавишу. Возможно, она используется другим приложением. Попробуйте другую клавишу.",
|
||||
"actions": {
|
||||
"openApp": "Открыть приложение",
|
||||
"addZoom": "Добавить масштабирование",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "Bu kısayol \"{{label}}\" için ayrılmıştır ve yeniden atanamaz.",
|
||||
"savedToast": "Klavye kısayolları kaydedildi",
|
||||
"resetToast": "Varsayılan kısayollara sıfırlandı — uygulamak için Kaydet'e tıklayın",
|
||||
"registrationFailed": "Kısayol kaydedilemedi. Başka bir uygulama tarafından kullanılıyor olabilir. Farklı bir tuş deneyin.",
|
||||
"actions": {
|
||||
"openApp": "Uygulamayı Aç",
|
||||
"addZoom": "Yakınlaştırma Ekle",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "Phím tắt này được dành riêng cho \"{{label}}\" và không thể gán lại.",
|
||||
"savedToast": "Đã lưu phím tắt",
|
||||
"resetToast": "Đã đặt lại về phím tắt mặc định — nhấp Lưu để áp dụng",
|
||||
"registrationFailed": "Không thể đăng ký phím tắt. Có thể đang được sử dụng bởi ứng dụng khác. Hãy thử phím khác.",
|
||||
"actions": {
|
||||
"openApp": "Mở ứng dụng",
|
||||
"addZoom": "Thêm Thu phóng",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "此快捷键已保留给 \"{{label}}\",无法重新分配。",
|
||||
"savedToast": "键盘快捷键已保存",
|
||||
"resetToast": "已恢复默认快捷键 — 点击保存以应用",
|
||||
"registrationFailed": "快捷键注册失败。可能已被其他应用占用。请尝试其他按键。",
|
||||
"actions": {
|
||||
"openApp": "打开应用",
|
||||
"addZoom": "添加缩放",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"reservedShortcut": "此快捷鍵已保留給 \"{{label}}\",無法重新指定。",
|
||||
"savedToast": "鍵盤快捷鍵已儲存",
|
||||
"resetToast": "已還原預設快捷鍵 — 點擊儲存以套用",
|
||||
"registrationFailed": "快捷鍵註冊失敗。可能已被其他應用程式佔用。請嘗試其他按鍵。",
|
||||
"actions": {
|
||||
"openApp": "開啟應用程式",
|
||||
"addZoom": "新增縮放",
|
||||
|
||||
Reference in New Issue
Block a user