diff --git a/wingetui/__init__.py b/wingetui/__init__.py index 6d1c93aa1..7b4275529 100644 --- a/wingetui/__init__.py +++ b/wingetui/__init__.py @@ -459,7 +459,7 @@ def loadMainUI(self): self.quitAction = QAction(menu) self.quitAction.setIcon(QIcon(getMedia("menu_close"))) self.quitAction.setText(_("Quit")) - self.quitAction.triggered.connect(lambda: (self.quit(), sys.exit(0))) + self.quitAction.triggered.connect(lambda: self.quit()) menu.addAction(self.quitAction) self.updatePackages.setIcon(QIcon(getMedia("alert_laptop"))) diff --git a/wingetui/customWidgets.py b/wingetui/customWidgets.py index a397d8a2c..3f8361183 100644 --- a/wingetui/customWidgets.py +++ b/wingetui/customWidgets.py @@ -1134,10 +1134,8 @@ class NotClosableWidget(QWidget): def closeEvent(self, event: QCloseEvent) -> None: if event.spontaneous(): event.ignore() - return False - else: - event.accept() - return super().closeEvent(event) + return + return super().closeEvent(event) class PackageManager(QWidget): def __init__(self, text, description, image) -> None: diff --git a/wingetui/mainWindow.py b/wingetui/mainWindow.py index d88d87feb..b369d6f58 100644 --- a/wingetui/mainWindow.py +++ b/wingetui/mainWindow.py @@ -208,11 +208,7 @@ def warnAboutAdmin(self): self.err.showErrorMessage(errorData, showNotification=False) def isAdmin(self) -> bool: - try: - is_admin = (os.getuid() == 0) - except AttributeError: - is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0 - return is_admin + return ctypes.windll.shell32.IsUserAnAdmin() != 0 def deleteChildren(self) -> None: try: @@ -223,53 +219,30 @@ def deleteChildren(self) -> None: report(e) def closeEvent(self, event): + event.ignore() self.closedpos = self.pos() setSettingsValue("OldWindowGeometry", f"{self.closedpos.x()},{self.closedpos.y()+30},{self.width()},{self.height()}") - if(globals.themeChanged): + if globals.themeChanged: globals.themeChanged = False self.deleteChildren() event.accept() - if(globals.pending_programs != []): - if getSettings("DisablesystemTray"): - if(QMessageBox.question(self, _("Warning"), _("There is an installation in progress. If you close WingetUI, the installation may fail and have unexpected results. Do you still want to quit WingetUI?"), QMessageBox.No | QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes): - if globals.updatesAvailable: - self.hide() - globals.canUpdate = True - globals.trayIcon.showMessage(_("Updating WingetUI"), _("WingetUI is being updated. When finished, WingetUI will restart itself"), QIcon(getMedia("notif_info"))) - event.ignore() - else: - self.deleteChildren() - event.accept() - globals.app.quit() - sys.exit(0) - else: - event.ignore() - else: - if globals.updatesAvailable: - self.hide() - globals.canUpdate = True - globals.trayIcon.showMessage(_("Updating WingetUI"), _("WingetUI is being updated. When finished, WingetUI will restart itself"), QIcon(getMedia("notif_info"))) - event.ignore() - else: - self.hide() - globals.lastFocusedWindow = 0 + if getSettings("DisablesystemTray"): + if globals.pending_programs != []: + retValue = QMessageBox.question(self, _("Warning"), _("There is an installation in progress. If you close WingetUI, the installation may fail and have unexpected results. Do you still want to quit WingetUI?"), buttons = QMessageBox.StandardButton.No | QMessageBox.StandardButton.Yes, defaultButton = QMessageBox.StandardButton.No) + if retValue == QMessageBox.StandardButton.No: event.ignore() + return + self.hide() + if globals.updatesAvailable: + globals.canUpdate = True + globals.trayIcon.showMessage(_("Updating WingetUI"), _("WingetUI is being updated. When finished, WingetUI will restart itself"), QIcon(getMedia("notif_info"))) else: - if globals.updatesAvailable: - self.hide() - globals.canUpdate = True - globals.trayIcon.showMessage(_("Updating WingetUI"), _("WingetUI is being updated. When finished, WingetUI will restart itself"), QIcon(getMedia("notif_info"))) - event.ignore() - else: - if getSettings("DisablesystemTray"): - self.deleteChildren() - event.accept() - globals.app.quit() - sys.exit(0) - else: - self.hide() - globals.lastFocusedWindow = 0 - event.ignore() + globals.lastFocusedWindow = 0 + if getSettings("DisablesystemTray"): + self.deleteChildren() + event.accept() + globals.app.quit() + sys.exit(0) def resizeEvent(self, event: QResizeEvent) -> None: try: diff --git a/wingetui/storeEngine.py b/wingetui/storeEngine.py index 04b4fb930..4e13975b2 100644 --- a/wingetui/storeEngine.py +++ b/wingetui/storeEngine.py @@ -442,7 +442,7 @@ class PackageUninstallerWidget(PackageInstallerWidget): finishInstallation = Signal(int, str) counterSignal = Signal(int) changeBarOrientation = Signal() - def __init__(self, title: str, store: str, useId=False, packageId = "", packageItem: TreeWidgetItemWithQAction = None, admin: bool = False, removeData: bool = False, args: list = [], customCommand: list = []): + def __init__(self, title: str, store: str, useId=False, packageId = "", packageItem: TreeWidgetItemWithQAction = None, admin: bool = False, removeData: bool = False, args: list = [], customCommand = ""): self.packageItem = packageItem self.programName = title self.packageId = packageId