mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
feat: properly utilize close to tray and quit action
This commit is contained in:
@@ -272,6 +272,11 @@ def settings_dialog(self):
|
|||||||
interface_layout.addWidget(interface_select)
|
interface_layout.addWidget(interface_select)
|
||||||
interface_container.setLayout(interface_layout)
|
interface_container.setLayout(interface_layout)
|
||||||
|
|
||||||
|
# Close To Tray
|
||||||
|
close_to_tray_container, close_to_tray_checkbox = create_widget(QCheckBox, "Close to Tray: ")
|
||||||
|
close_to_tray_checkbox.setChecked(state.close_to_tray)
|
||||||
|
close_to_tray_checkbox.toggled.connect(lambda checked: setattr(state, 'close_to_tray', checked))
|
||||||
|
|
||||||
|
|
||||||
# Save / Cancel buttons
|
# Save / Cancel buttons
|
||||||
layout = QHBoxLayout()
|
layout = QHBoxLayout()
|
||||||
@@ -297,7 +302,8 @@ def settings_dialog(self):
|
|||||||
image_opacity.value(),
|
image_opacity.value(),
|
||||||
image_as_wallpaper=image_mode_checkbox.isChecked(),
|
image_as_wallpaper=image_mode_checkbox.isChecked(),
|
||||||
image_position=image_position_combo.currentText(),
|
image_position=image_position_combo.currentText(),
|
||||||
accent_color=accent_color_input.text().strip()
|
accent_color=accent_color_input.text().strip(),
|
||||||
|
close_to_tray=close_to_tray_checkbox.isChecked()
|
||||||
)
|
)
|
||||||
|
|
||||||
cancel_btn.clicked.connect(dialog.reject)
|
cancel_btn.clicked.connect(dialog.reject)
|
||||||
@@ -305,7 +311,7 @@ def settings_dialog(self):
|
|||||||
layout.addWidget(save_btn)
|
layout.addWidget(save_btn)
|
||||||
|
|
||||||
tabs = QtWidgets.QTabWidget()
|
tabs = QtWidgets.QTabWidget()
|
||||||
create_tab("General", [autoresume_container, update_checkbox_container, transparent_window_container, accent_color_container], tabs=tabs, stretch=True)
|
create_tab("General", [autoresume_container, update_checkbox_container, transparent_window_container, accent_color_container, close_to_tray_container], tabs=tabs, stretch=True)
|
||||||
create_tab("Image", [enable_image_container, image_mode_container, image_position_container, image_width_container, image_offset_container, image_opacity_container], tabs=tabs, stretch=True)
|
create_tab("Image", [enable_image_container, image_mode_container, image_position_container, image_width_container, image_offset_container, image_opacity_container], tabs=tabs, stretch=True)
|
||||||
create_tab("Paths", [download_path_container, image_path_container], tabs=tabs, stretch=True)
|
create_tab("Paths", [download_path_container, image_path_container], tabs=tabs, stretch=True)
|
||||||
create_tab("Network", [interface_container, max_connections_container, max_downloads_container, up_speed_limit_container, down_speed_limit_container, api_url_container], tabs=tabs, stretch=True)
|
create_tab("Network", [interface_container, max_connections_container, max_downloads_container, up_speed_limit_container, down_speed_limit_container, api_url_container], tabs=tabs, stretch=True)
|
||||||
|
|||||||
@@ -388,6 +388,14 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
super().changeEvent(event)
|
super().changeEvent(event)
|
||||||
|
|
||||||
def closeEvent(self, event: QCloseEvent):
|
def closeEvent(self, event: QCloseEvent):
|
||||||
|
if state.close_to_tray is True:
|
||||||
|
event.ignore()
|
||||||
|
self.hide()
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
self.shutdown(event)
|
||||||
|
|
||||||
|
def shutdown(self, event: QCloseEvent):
|
||||||
closehelper()
|
closehelper()
|
||||||
event.accept()
|
event.accept()
|
||||||
from utils.general.shutdown import force_exit
|
from utils.general.shutdown import force_exit
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ def run_gui(app):
|
|||||||
menu = QMenu()
|
menu = QMenu()
|
||||||
|
|
||||||
quit = QAction("Quit")
|
quit = QAction("Quit")
|
||||||
quit.triggered.connect(app.quit)
|
quit.triggered.connect(lambda: (closehelper(), force_exit()))
|
||||||
menu.addAction(quit)
|
menu.addAction(quit)
|
||||||
|
|
||||||
tray.setContextMenu(menu)
|
tray.setContextMenu(menu)
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ def create_config():
|
|||||||
"ignore_updates": str(state.ignore_updates),
|
"ignore_updates": str(state.ignore_updates),
|
||||||
"autoresume": str(state.autoresume),
|
"autoresume": str(state.autoresume),
|
||||||
"window_transparency": str(state.window_transparency),
|
"window_transparency": str(state.window_transparency),
|
||||||
"accent_color": str(state.accent_color)
|
"accent_color": str(state.accent_color),
|
||||||
|
"close_to_tray": str(state.close_to_tray)
|
||||||
}
|
}
|
||||||
|
|
||||||
config["Network"] = {
|
config["Network"] = {
|
||||||
@@ -86,6 +87,7 @@ def read_config():
|
|||||||
state.autoresume = config.getboolean("General", "autoresume", fallback=state.autoresume)
|
state.autoresume = config.getboolean("General", "autoresume", fallback=state.autoresume)
|
||||||
state.window_transparency = config.getboolean("General", "window_transparency", fallback=state.window_transparency)
|
state.window_transparency = config.getboolean("General", "window_transparency", fallback=state.window_transparency)
|
||||||
state.accent_color = config.get("General", "accent_color", fallback=state.accent_color)
|
state.accent_color = config.get("General", "accent_color", fallback=state.accent_color)
|
||||||
|
state.close_to_tray = config.getboolean("General", "close_to_tray", fallback=state.close_to_tray)
|
||||||
|
|
||||||
# Network
|
# Network
|
||||||
state.api_url = config.get("Network", "api_url", fallback=state.api_url)
|
state.api_url = config.get("Network", "api_url", fallback=state.api_url)
|
||||||
@@ -147,4 +149,4 @@ def backup_config(config_path):
|
|||||||
os.replace(config_path, backup_path)
|
os.replace(config_path, backup_path)
|
||||||
consoleLog(f"Successfully created backup of corrupted config: {backup_path}")
|
consoleLog(f"Successfully created backup of corrupted config: {backup_path}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
consoleLog(f"Failed to create backup of corrupted config: {e}")
|
consoleLog(f"Failed to create backup of corrupted config: {e}")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from utils.data.state import state
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def save_settings(close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None, max_connections=None, max_downloads=None, bound_interface=None, image_width=None, image_offset=None, image_opacity=None, image_as_wallpaper=None, image_position=None, accent_color=None):
|
def save_settings(close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None, max_connections=None, max_downloads=None, bound_interface=None, image_width=None, image_offset=None, image_opacity=None, image_as_wallpaper=None, image_position=None, accent_color=None, close_to_tray=None):
|
||||||
if apiurl is not None:
|
if apiurl is not None:
|
||||||
state.api_url = apiurl
|
state.api_url = apiurl
|
||||||
if download_path is not None:
|
if download_path is not None:
|
||||||
@@ -36,6 +36,8 @@ def save_settings(close=lambda: None, apiurl=None, download_path=None, down_spee
|
|||||||
state.image_position = image_position
|
state.image_position = image_position
|
||||||
if accent_color is not None:
|
if accent_color is not None:
|
||||||
state.accent_color = accent_color
|
state.accent_color = accent_color
|
||||||
|
if close_to_tray is not None:
|
||||||
|
state.close_to_tray = close_to_tray
|
||||||
|
|
||||||
update_settings() # Update LibTorrent Session Settings
|
update_settings() # Update LibTorrent Session Settings
|
||||||
consoleLog("Saved Settings")
|
consoleLog("Saved Settings")
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class AppState(QObject):
|
|||||||
self.interfaces: List = []
|
self.interfaces: List = []
|
||||||
self.active_interfaces: List = []
|
self.active_interfaces: List = []
|
||||||
self.bound_interface: Any = None
|
self.bound_interface: Any = None
|
||||||
|
self.close_to_tray: bool = True
|
||||||
|
|
||||||
# Image
|
# Image
|
||||||
self._image_enabled: bool = False
|
self._image_enabled: bool = False
|
||||||
|
|||||||
Reference in New Issue
Block a user