mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
feat: add windowCloseHelper function and integrate it into keyboard interrupt handling
This commit is contained in:
@@ -18,7 +18,7 @@ from PySide6.QtWidgets import (
|
||||
QStyledItemDelegate,
|
||||
)
|
||||
|
||||
from PySide6.QtGui import QIcon, QCloseEvent, QImage, QPixmap, QContextMenuEvent
|
||||
from PySide6.QtGui import QIcon, QCloseEvent, QImage, QPixmap, QContextMenuEvent, QGuiApplication
|
||||
import darkdetect
|
||||
import threading
|
||||
import platform
|
||||
@@ -67,6 +67,9 @@ def download_update(latest_version):
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def windowCloseHelper():
|
||||
QGuiApplication.quit()
|
||||
|
||||
class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
log_signal = Signal(str) # Thread-safe signal for logging
|
||||
|
||||
|
||||
+5
-10
@@ -1,4 +1,4 @@
|
||||
from core.interface.gui import MainWindow
|
||||
from core.interface.gui import MainWindow, windowCloseHelper
|
||||
from core.utils.data.state import state
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from core.network.libtorrent_misc import send_notification, update_log
|
||||
@@ -14,15 +14,9 @@ import qdarktheme
|
||||
import threading
|
||||
import platform
|
||||
import signal
|
||||
import argparse
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--debug", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
def run_gui():
|
||||
app = QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv)
|
||||
qdarktheme.setup_theme("auto")
|
||||
@@ -39,14 +33,13 @@ def run_gui():
|
||||
|
||||
def keyboardinterrupthandler(signum, frame):
|
||||
closehelper()
|
||||
windowCloseHelper()
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
start_time = time.perf_counter()
|
||||
read_config()
|
||||
logs = get_download_logs()
|
||||
_, downloads = split_data(logs)
|
||||
if args.debug:
|
||||
state.debug = args.debug # override of read_config
|
||||
signal.signal(signal.SIGINT, keyboardinterrupthandler)
|
||||
consoleLog("Starting SoftwareManager...")
|
||||
consoleLog("Fetching Network Interfaces...")
|
||||
@@ -65,3 +58,5 @@ if __name__ == "__main__":
|
||||
consoleLog(f"Initialization completed in {elapsed:.2f}s. Launching GUI")
|
||||
run_gui()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user