Skip to content

Commit e380706

Browse files
committed
用户可设置软件启动是否显示主窗口
1 parent 6ef6aff commit e380706

4 files changed

Lines changed: 77 additions & 5 deletions

File tree

app/Language/modules/basic_settings.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
"description": "设置软件是否随系统启动自动运行",
1414
"switchbutton_name": {"enable": "", "disable": ""},
1515
},
16+
"show_startup_window": {
17+
"name": "启动显示主窗口",
18+
"description": "设置软件启动时是否自动显示主窗口",
19+
"switchbutton_name": {"enable": "", "disable": ""},
20+
},
1621
"background_resident": {
1722
"name": "后台驻留",
1823
"description": "关闭所有窗口后是否仍在后台常驻",
@@ -92,6 +97,8 @@
9297
"import_failure_title": {"name": "导入设置"},
9398
"import_failure_content": {"name": "导入设置失败:\n{error}"},
9499
},
100+
"success_enable_content": {"name": "已开启启动显示主窗口"},
101+
"info_disable_content": {"name": "已关闭启动显示主窗口"},
95102
"data_import_export": {
96103
"export_success_title": {"name": "导出所有数据"},
97104
"export_success_content": {"name": "所有数据已成功导出到:\n{path}"},
@@ -158,14 +165,14 @@
158165
"name": "Start on boot",
159166
"description": "Set whether the software is running automatically with the system",
160167
},
168+
"show_startup_window": {
169+
"name": "Show main window on startup",
170+
"description": "Set whether to automatically display the main window when the software starts",
171+
},
161172
"check_update": {
162173
"name": "Check for updates on startup",
163174
"description": "Set whether new versions will be checked automatically on boot",
164175
},
165-
"show_startup_window": {
166-
"name": "Show splash screen",
167-
"description": "Set whether to show the splash screen on boot",
168-
},
169176
"export_diagnostic_data": {
170177
"name": "Export diagnostic data",
171178
"description": "Export Diagnostic Information on Exit",
@@ -287,6 +294,10 @@
287294
"name": "导入设置失败:\n{error}",
288295
},
289296
},
297+
"show_startup_window_notification": {
298+
"success_enable_content": {"name": "Startup main window display enabled"},
299+
"info_disable_content": {"name": "Startup main window display disabled"},
300+
},
290301
"data_import_export": {
291302
"export_success_title": {
292303
"name": "Export all data",

app/tools/settings_default_storage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"data_management": {"default_value": None},
3131
"personalised": {"default_value": None},
3232
"autostart": {"default_value": False},
33+
"show_startup_window": {"default_value": True},
3334
"background_resident": {"default_value": True},
3435
"url_protocol": {"default_value": False},
3536
"export_diagnostic_data": {"default_value": None},

app/view/settings/basic_settings.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,25 @@ def __init__(self, parent=None):
8787
)
8888
self.autostart_switch.checkedChanged.connect(self.__on_autostart_changed)
8989

90+
# 启动显示主窗口设置
91+
self.show_startup_window_switch = SwitchButton()
92+
self.show_startup_window_switch.setOffText(
93+
get_content_switchbutton_name_async(
94+
"basic_settings", "show_startup_window", "disable"
95+
)
96+
)
97+
self.show_startup_window_switch.setOnText(
98+
get_content_switchbutton_name_async(
99+
"basic_settings", "show_startup_window", "enable"
100+
)
101+
)
102+
self.show_startup_window_switch.setChecked(
103+
readme_settings_async("basic_settings", "show_startup_window")
104+
)
105+
self.show_startup_window_switch.checkedChanged.connect(
106+
self.__on_show_startup_window_changed
107+
)
108+
90109
# 后台驻留设置
91110
self.resident_switch = SwitchButton()
92111
self.resident_switch.setOffText(
@@ -131,6 +150,12 @@ def __init__(self, parent=None):
131150
get_content_description_async("basic_settings", "autostart"),
132151
self.autostart_switch,
133152
)
153+
self.addGroup(
154+
get_theme_icon("ic_fluent_window_20_filled"),
155+
get_content_name_async("basic_settings", "show_startup_window"),
156+
get_content_description_async("basic_settings", "show_startup_window"),
157+
self.show_startup_window_switch,
158+
)
134159
self.addGroup(
135160
get_theme_icon("ic_fluent_resize_20_filled"),
136161
get_content_name_async("basic_settings", "background_resident"),
@@ -176,6 +201,35 @@ def __on_autostart_changed(self, checked):
176201
parent=self.window(),
177202
)
178203

204+
def __on_show_startup_window_changed(self, checked):
205+
update_settings("basic_settings", "show_startup_window", checked)
206+
if checked:
207+
show_notification(
208+
NotificationType.SUCCESS,
209+
NotificationConfig(
210+
title=get_content_name_async(
211+
"basic_settings", "show_startup_window"
212+
),
213+
content=get_content_name_async(
214+
"basic_settings", "success_enable_content"
215+
),
216+
),
217+
parent=self.window(),
218+
)
219+
else:
220+
show_notification(
221+
NotificationType.INFO,
222+
NotificationConfig(
223+
title=get_content_name_async(
224+
"basic_settings", "show_startup_window"
225+
),
226+
content=get_content_name_async(
227+
"basic_settings", "info_disable_content"
228+
),
229+
),
230+
parent=self.window(),
231+
)
232+
179233
def __on_resident_changed(self, checked):
180234
update_settings("basic_settings", "background_resident", checked)
181235
try:

main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,13 @@ def start_main_window():
273273
)
274274
main_window.showSettingsRequestedAbout.connect(show_settings_window_about)
275275
main_window.showFloatWindowRequested.connect(show_float_window)
276-
main_window.show()
276+
277+
# 根据设置决定是否启动时显示主窗口
278+
show_startup_window = readme_settings_async(
279+
"basic_settings", "show_startup_window"
280+
)
281+
if show_startup_window:
282+
main_window.show()
277283

278284
# 连接 URLHandler 信号到 main_window 信号处理器
279285
global url_handler

0 commit comments

Comments
 (0)