From b6d0d6095c7f569e0ff7d0fa31ef5c3930dfeff8 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sun, 28 Apr 2024 22:41:19 +0800 Subject: [PATCH] Fix QueryHotkeys not been initialized error --- .../wox/lib/entity/wox_setting.dart | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Wox.UI.Flutter/wox/lib/entity/wox_setting.dart b/Wox.UI.Flutter/wox/lib/entity/wox_setting.dart index f2dfaa369..f7fa563ac 100644 --- a/Wox.UI.Flutter/wox/lib/entity/wox_setting.dart +++ b/Wox.UI.Flutter/wox/lib/entity/wox_setting.dart @@ -13,20 +13,21 @@ class WoxSetting { late int appWidth; late String themeId; - WoxSetting( - {required this.mainHotkey, - required this.selectionHotkey, - required this.usePinYin, - required this.switchInputMethodABC, - required this.hideOnStart, - required this.hideOnLostFocus, - required this.showTray, - required this.langCode, - required this.queryHotkeys, - required this.queryShortcuts, - required this.lastQueryMode, - required this.appWidth, - required this.themeId}); + WoxSetting({ + required this.mainHotkey, + required this.selectionHotkey, + required this.usePinYin, + required this.switchInputMethodABC, + required this.hideOnStart, + required this.hideOnLostFocus, + required this.showTray, + required this.langCode, + required this.queryHotkeys, + required this.queryShortcuts, + required this.lastQueryMode, + required this.appWidth, + required this.themeId, + }); WoxSetting.fromJson(Map json) { mainHotkey = json['MainHotkey']; @@ -37,18 +38,25 @@ class WoxSetting { hideOnLostFocus = json['HideOnLostFocus']; showTray = json['ShowTray']; langCode = json['LangCode']; + if (json['QueryHotkeys'] != null) { queryHotkeys = []; json['QueryHotkeys'].forEach((v) { queryHotkeys.add(QueryHotkey.fromJson(v)); }); + } else { + queryHotkeys = []; } + if (json['QueryShortcuts'] != null) { queryShortcuts = []; json['QueryShortcuts'].forEach((v) { queryShortcuts.add(QueryShortcut.fromJson(v)); }); + } else { + queryShortcuts = []; } + lastQueryMode = json['LastQueryMode']; appWidth = json['AppWidth']; themeId = json['ThemeId'];