Coverage for flogin/flow/settings.py: 100%

127 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-03 22:51 +0000

1from .base import Base, add_prop 

2from .enums import ( 

3 AnimationSpeeds, 

4 LastQueryMode, 

5 SearchPrecisionScore, 

6 SearchWindowAligns, 

7 SearchWindowScreens, 

8) 

9 

10Double = ( 

11 int | float 

12) # C# doubles are just floats in python, however there is some typemismatch, so some "doubles" are integers. 

13 

14__all__ = ( 

15 "CustomBrowser", 

16 "CustomFileManager", 

17 "CustomPluginHotkey", 

18 "CustomQueryShortcut", 

19 "FlowSettings", 

20 "HttpProxy", 

21 "PartialPlugin", 

22 "PluginsSettings", 

23) 

24 

25 

26class CustomFileManager(Base): 

27 """This is a replica of the ``CustomExplorerViewModel`` dataclass in flow. 

28 

29 This is an entry for a custom file manager, which is under the ``Default File Manager`` option in flow's ui settings. 

30 

31 Attributes 

32 ----------- 

33 name: :class:`str` 

34 The name of the filemanager 

35 path: :class:`str` 

36 The path to the filemanager 

37 file_argument: :class:`str` 

38 How to tell the filemanager which file to open 

39 directory_argument: :class:`str` 

40 How to tell the filemanager which directory to open 

41 editable: :class:`bool` 

42 Whether or not the user can edit this entry in the ui 

43 """ 

44 

45 name: str = add_prop("Name") 

46 path: str = add_prop("Path") 

47 file_argument: str = add_prop("FileArgument") 

48 directory_argument: str = add_prop("DirectoryArgument") 

49 editable: bool = add_prop("Editable") 

50 

51 

52class CustomBrowser(Base): 

53 """This is a replica of the ``CustomBrowserViewModel`` dataclass in flow. 

54 

55 This represents an entry for a custom browser, which is under the ``Default Web Browser`` option in flow's ui settings. 

56 

57 Attributes 

58 ----------- 

59 name: :class:`str` 

60 The name of the browser 

61 path: :class:`str` 

62 The path to the browser's executable 

63 private_arg: :class:`str` 

64 The argument that is used to tell the browser to open in incognito/private mode 

65 enable_private: :class:`bool` 

66 Whether or not to open the browser in private/incognito mode 

67 open_in_tab: :class:`bool` 

68 Whether to open the link in a new tab or browser window 

69 editable: :class:`bool` 

70 Whether the user can edit this entry in the ui 

71 """ 

72 

73 name: str = add_prop("Name") 

74 path: str = add_prop("Path") 

75 private_arg: str = add_prop("PrivateArg") 

76 enable_private: bool = add_prop("EnablePrivate") 

77 open_in_tab: bool = add_prop("OpenInTab") 

78 editable: bool = add_prop("Editable") 

79 

80 

81class CustomPluginHotkey(Base): 

82 """This is a replica of the ``CustomPluginHotkey`` dataclass in flow. 

83 

84 Attributes 

85 ----------- 

86 hotkey: :class:`str` 

87 keyword: :class:`str` 

88 """ 

89 

90 hotkey: str = add_prop("Hotkey") 

91 keyword: str = add_prop("ActionKeyword") 

92 

93 

94class CustomQueryShortcut(Base): 

95 """This is a replica of the ``CustomShortcutModel`` dataclass in flow. 

96 

97 This represents a custom shortcut in flow's config file. 

98 

99 Attributes 

100 ----------- 

101 value: :class:`str` 

102 The shortcut's value, which in the ui is called the ``Expansion`` 

103 key: :class:`str` 

104 The shortcut's key, which in the ui is called the `Shortcut`` 

105 """ 

106 

107 value: str = add_prop("Value") 

108 key: str = add_prop("Key") 

109 

110 

111class HttpProxy(Base): 

112 """This represents the user's proxy info 

113 

114 Attributes 

115 ----------- 

116 enabled: :class:`bool` 

117 Whether or not the proxy is active 

118 server: :class:`str` | ``None`` 

119 The proxy's server 

120 port: :class:`int` | ``None`` 

121 The proxy's port 

122 username: :class:`str` | ``None`` 

123 The proxy's username 

124 password: :class:`str` | ``None`` 

125 The proxy's password 

126 """ 

127 

128 enabled: bool = add_prop("Enabled") 

129 server: str | None = add_prop("Server") 

130 port: int | None = add_prop("Port") 

131 username: str | None = add_prop("UserName") 

132 password: str | None = add_prop("Password") 

133 

134 

135class PartialPlugin(Base): 

136 """This is a partial plugin from flow. 

137 

138 Attributes 

139 ----------- 

140 id: :class:`str` 

141 The plugin's ID 

142 name: :class:`str` 

143 The plugin's name 

144 version: :class:`str` 

145 The plugin's version 

146 priority: :class:`int` 

147 The plugin's priority 

148 disabled: :class:`bool` 

149 Whether or not the plugin is disabled 

150 keywords: list[:class:`str`] 

151 The plugin's keywords 

152 """ 

153 

154 id: str = add_prop("ID") 

155 name: str = add_prop("Name") 

156 version: str = add_prop("Version") 

157 priority: int = add_prop("Priority") 

158 disabled: bool = add_prop("Disabled") 

159 keywords: list[str] = add_prop("ActionKeywords") 

160 

161 

162class PluginsSettings(Base): 

163 """This represents the user's plugin settings from the general flow config file. 

164 

165 Attributes 

166 ----------- 

167 python_executable: :class:`str` 

168 The location of the user's python executable. If there is none, this attribute will be an empty string. 

169 node_executable: :class:`str` 

170 The location of the user's node executable. If there is none, this attribute will be an empty string. 

171 plugins: list[:class:`PartialPlugin`] 

172 A list of the user's plugins, in partial form. 

173 """ 

174 

175 python_executable: str = add_prop("PythonExecutablePath") 

176 node_executable: str = add_prop("NodeExecutablePath") 

177 plugins: dict[str, PartialPlugin] = add_prop( 

178 "Plugins", cls=lambda x: [PartialPlugin(value) for value in x.values()] 

179 ) 

180 

181 

182class FlowSettings(Base): 

183 """This is a class which represents the settings that flow launcher saves in config files. 

184 

185 Attributes 

186 ----------- 

187 hotkey: :class:`str` 

188 open_result_modifiers: :class:`str` 

189 color_scheme: :class:`str` 

190 show_open_result_gotkey: :class:`bool` 

191 window_size: :class:`int` | :class:`float` 

192 preview_hotkey: :class:`str` 

193 autocomplete_hotkey: :class:`str` 

194 autocomplete_hotkey_2: :class:`str` 

195 select_next_item_hotkey: :class:`str` 

196 select_next_item_hotkey_2: :class:`str` 

197 select_previous_item_hotkey: :class:`str` 

198 select_previous_item_hotkey_2: :class:`str` 

199 select_next_page_hotkey: :class:`str` 

200 select_previous_page_hotkey: :class:`str` 

201 open_context_menu_hotkey: :class:`str` 

202 setting_window_hotkey: :class:`str` 

203 cycle_history_up_hotkey: :class:`str` 

204 cycle_history_down_hotkey: :class:`str` 

205 language: :class:`str` 

206 theme: :class:`str` 

207 use_drop_shadow_effect: :class:`bool` 

208 window_height_size: :class:`int` | :class:`float` 

209 item_height_size: :class:`int` | :class:`float` 

210 query_box_font_size: :class:`int` | :class:`float` 

211 result_item_font_size: :class:`int` | :class:`float` 

212 result_sub_item_font_size: :class:`int` | :class:`float` 

213 query_box_font: :class:`str` | ``None`` 

214 query_box_font_style: :class:`str` | ``None`` 

215 query_box_font_weight: :class:`str` | ``None`` 

216 query_box_font_stretch: :class:`str` | ``None`` 

217 result_font: :class:`str` | ``None`` 

218 result_font_style: :class:`str` | ``None`` 

219 result_font_weight: :class:`str` | ``None`` 

220 result_font_stretch: :class:`str` | ``None`` 

221 result_sub_font: :class:`str` | ``None`` 

222 result_sub_font_style: :class:`str` | ``None`` 

223 result_sub_font_weight: :class:`str` | ``None`` 

224 result_sub_font_stretch: :class:`str` | ``None`` 

225 use_glyph_icons: :class:`bool` 

226 use_animation: :class:`bool` 

227 use_sound: :class:`bool` 

228 sound_volume: :class:`int` | :class:`float` 

229 use_clock: :class:`bool` 

230 use_date: :class:`bool` 

231 time_format: :class:`str` 

232 date_format: :class:`str` 

233 first_launch: :class:`bool` 

234 setting_window_width: :class:`int` | :class:`float` 

235 setting_window_height: :class:`int` | :class:`float` 

236 setting_window_top: :class:`int` | :class:`float` | None 

237 setting_window_left: :class:`int` | :class:`float` | None 

238 setting_window_state: :class:`int` 

239 custom_explorer_index: :class:`int` 

240 custom_explorer_list: list[:class:`CustomFileManager`] 

241 custom_browser_index: :class:`int` 

242 custom_browser_list: list[:class:`CustomBrowser`] 

243 should_use_pinyin: :class:`bool` 

244 always_preview: :class:`bool` 

245 always_start_en: :class:`bool` 

246 query_search_precision: :class:`SearchPrecisionScore` 

247 auto_updates: :class:`bool` 

248 window_left: :class:`int` | :class:`float` 

249 window_top: :class:`int` | :class:`float` 

250 custom_window_left: :class:`int` | :class:`float` 

251 custom_window_top: :class:`int` | :class:`float` 

252 keep_max_results: :class:`bool` 

253 max_results_to_show: :class:`int` 

254 activate_times: :class:`int` 

255 custom_plugin_hotkeys: list[:class:`CustomPluginHotkey`] 

256 custom_shortcuts: list[:class:`CustomQueryShortcut`] 

257 dont_prompt_update_msg: :class:`bool` 

258 enable_update_log: :class:`bool` 

259 start_flow_launcher_on_system_startup: :class:`bool` 

260 hide_on_startup: :class:`bool` 

261 hide_notify_icon: :class:`bool` 

262 leave_cmd_open: :class:`bool` 

263 hide_when_deactivated: :class:`bool` 

264 search_window_screen: :class:`SearchWindowScreens` 

265 search_window_align: :class:`SearchWindowAligns` 

266 custom_screen_number: :class:`int` 

267 ignore_hotkeys_on_fullscreen: :class:`bool` 

268 proxy: :class:`HttpProxy` 

269 last_query_mode: :class:`LastQueryMode` 

270 animation_speed: :class:`AnimationSpeeds` 

271 custom_animation_length: :class:`int` 

272 plugin_settings: :class:`PluginsSettings` 

273 """ 

274 

275 hotkey: str = add_prop("Hotkey") 

276 open_result_modifiers: str = add_prop("OpenResultModifiers") 

277 color_scheme: str = add_prop("ColorScheme") 

278 show_open_result_gotkey: bool = add_prop("ShowOpenResultHotkey") 

279 window_size: Double = add_prop("WindowSize") 

280 preview_hotkey: str = add_prop("PreviewHotkey") 

281 autocomplete_hotkey: str = add_prop("AutoCompleteHotkey") 

282 autocomplete_hotkey_2: str = add_prop("AutoCompleteHotkey2") 

283 select_next_item_hotkey: str = add_prop("SelectNextItemHotkey") 

284 select_next_item_hotkey_2: str = add_prop("SelectNextItemHotkey2") 

285 select_previous_item_hotkey: str = add_prop("SelectPrevItemHotkey") 

286 select_previous_item_hotkey_2: str = add_prop("SelectPrevItemHotkey2") 

287 select_next_page_hotkey: str = add_prop("SelectNextPageHotkey") 

288 select_previous_page_hotkey: str = add_prop("SelectPrevPageHotkey") 

289 open_context_menu_hotkey: str = add_prop("OpenContextMenuHotkey") 

290 setting_window_hotkey: str = add_prop("SettingWindowHotkey") 

291 cycle_history_up_hotkey: str = add_prop("CycleHistoryUpHotkey") 

292 cycle_history_down_hotkey: str = add_prop("CycleHistoryDownHotkey") 

293 language: str = add_prop("Language") 

294 theme: str = add_prop("Theme") 

295 use_drop_shadow_effect: bool = add_prop("UseDropShadowEffect") 

296 window_height_size: Double = add_prop("WindowHeightSize") 

297 item_height_size: Double = add_prop("ItemHeightSize") 

298 query_box_font_size: Double = add_prop("QueryBoxFontSize") 

299 result_item_font_size: Double = add_prop("ResultItemFontSize") 

300 result_sub_item_font_size: Double = add_prop("ResultSubItemFontSize") 

301 query_box_font: str | None = add_prop("QueryBoxFont") 

302 query_box_font_style: str | None = add_prop("QueryBoxFontStyle") 

303 query_box_font_weight: str | None = add_prop("QueryBoxFontWeight") 

304 query_box_font_stretch: str | None = add_prop("QueryBoxFontStretch") 

305 result_font: str | None = add_prop("ResultFont") 

306 result_font_style: str | None = add_prop("ResultFontStyle") 

307 result_font_weight: str | None = add_prop("ResultFontWeight") 

308 result_font_stretch: str | None = add_prop("ResultFontStretch") 

309 result_sub_font: str | None = add_prop("ResultSubFont") 

310 result_sub_font_style: str | None = add_prop("ResultSubFontStyle") 

311 result_sub_font_weight: str | None = add_prop("ResultSubFontWeight") 

312 result_sub_font_stretch: str | None = add_prop("ResultSubFontStretch") 

313 use_glyph_icons: bool = add_prop("UseGlyphIcons") 

314 use_animation: bool = add_prop("UseAnimation") 

315 use_sound: bool = add_prop("UseSound") 

316 sound_volume: Double = add_prop("SoundVolume") 

317 use_clock: bool = add_prop("UseClock") 

318 use_date: bool = add_prop("UseDate") 

319 time_format: str = add_prop("TimeFormat") 

320 date_format: str = add_prop("DateFormat") 

321 first_launch: bool = add_prop("FirstLaunch") 

322 setting_window_width: Double = add_prop("SettingWindowWidth") 

323 setting_window_height: Double = add_prop("SettingWindowHeight") 

324 setting_window_top: Double | None = add_prop("SettingWindowTop", default=None) 

325 setting_window_left: Double | None = add_prop("SettingWindowLeft", default=None) 

326 setting_window_state: int = add_prop("SettingWindowState") 

327 custom_explorer_index: int = add_prop("CustomExplorerIndex") 

328 custom_explorer_list: list[CustomFileManager] = add_prop( 

329 "CustomExplorerList", cls=CustomFileManager, is_list=True 

330 ) 

331 custom_browser_index: int = add_prop("CustomBrowserIndex") 

332 custom_browser_list: list[CustomBrowser] = add_prop( 

333 "CustomBrowserList", cls=CustomBrowser, is_list=True 

334 ) 

335 should_use_pinyin: bool = add_prop("ShouldUsePinyin") 

336 always_preview: bool = add_prop("AlwaysPreview") 

337 always_start_en: bool = add_prop("AlwaysStartEn") 

338 query_search_precision: SearchPrecisionScore = add_prop( 

339 "QuerySearchPrecision", cls=lambda x: SearchPrecisionScore[x.lower()] 

340 ) 

341 auto_updates: bool = add_prop("AutoUpdates") 

342 window_left: Double = add_prop("WindowLeft") 

343 window_top: Double = add_prop("WindowTop") 

344 custom_window_left: Double = add_prop("CustomWindowLeft") 

345 custom_window_top: Double = add_prop("CustomWindowTop") 

346 keep_max_results: bool = add_prop("KeepMaxResults") 

347 max_results_to_show: int = add_prop("MaxResultsToShow") 

348 activate_times: int = add_prop("ActivateTimes") 

349 custom_plugin_hotkeys: list[CustomPluginHotkey] = add_prop( 

350 "CustomPluginHotkeys", cls=CustomPluginHotkey, is_list=True 

351 ) 

352 custom_shortcuts: list[CustomQueryShortcut] = add_prop( 

353 "CustomShortcuts", cls=CustomQueryShortcut, is_list=True 

354 ) 

355 dont_prompt_update_msg: bool = add_prop("DontPromptUpdateMsg") 

356 enable_update_log: bool = add_prop("EnableUpdateLog") 

357 start_flow_launcher_on_system_startup: bool = add_prop( 

358 "StartFlowLauncherOnSystemStartup" 

359 ) 

360 hide_on_startup: bool = add_prop("HideOnStartup") 

361 hide_notify_icon: bool = add_prop("HideNotifyIcon") 

362 leave_cmd_open: bool = add_prop("LeaveCmdOpen") 

363 hide_when_deactivated: bool = add_prop("HideWhenDeactivated") 

364 search_window_screen: SearchWindowScreens = add_prop( 

365 "SearchWindowScreen", cls=SearchWindowScreens 

366 ) 

367 search_window_align: SearchWindowAligns = add_prop( 

368 "SearchWindowAlign", cls=SearchWindowAligns 

369 ) 

370 custom_screen_number: int = add_prop("CustomScreenNumber") 

371 ignore_hotkeys_on_fullscreen: bool = add_prop("IgnoreHotkeysOnFullscreen") 

372 proxy: HttpProxy = add_prop("Proxy", cls=HttpProxy) 

373 last_query_mode: LastQueryMode = add_prop("LastQueryMode", cls=LastQueryMode) 

374 animation_speed: AnimationSpeeds = add_prop("AnimationSpeed", cls=AnimationSpeeds) 

375 custom_animation_length: int = add_prop("CustomAnimationLength") 

376 plugin_settings: PluginsSettings = add_prop("PluginSettings", cls=PluginsSettings)