Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed closeEvent dialog, when ignore user choise if installation was … #934

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wingetui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down
6 changes: 2 additions & 4 deletions wingetui/customWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
63 changes: 18 additions & 45 deletions wingetui/mainWindow.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a needed restructuration, I still don't understand how my code turned up so messy...

Thanks!

Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion wingetui/storeEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down