PipxInterface/PipxDependenciesDialog.py

changeset 90
0949844ea0e3
parent 49
ec976c5b88ae
child 104
45c88e73e3dd
--- a/PipxInterface/PipxDependenciesDialog.py	Sun Sep 29 11:34:31 2024 +0200
+++ b/PipxInterface/PipxDependenciesDialog.py	Sun Sep 29 17:53:18 2024 +0200
@@ -6,8 +6,8 @@
 Module implementing a dialog to show the package dependencies.
 """
 
-from PyQt6.QtCore import Qt
-from PyQt6.QtWidgets import QDialog, QTreeWidgetItem
+from PyQt6.QtCore import Qt, pyqtSlot
+from PyQt6.QtWidgets import QAbstractButton, QDialog, QDialogButtonBox, QTreeWidgetItem
 
 from .Ui_PipxDependenciesDialog import Ui_PipxDependenciesDialog
 
@@ -25,6 +25,8 @@
     InstalledVersionColumn = 1
     AvailableVersionColumn = 2
 
+    UpgradeDependenciesAction = 10  # sent by done() when dependencies shall be upgraded
+
     def __init__(self, package, dependencies, mode, parent=None):
         """
         Constructor
@@ -41,6 +43,8 @@
         super().__init__(parent)
         self.setupUi(self)
 
+        self.__upgradeButton = None
+
         if mode != PipxDependenciesDialog.OutdatedMode:
             self.dependenciesList.hideColumn(
                 PipxDependenciesDialog.AvailableVersionColumn
@@ -48,6 +52,9 @@
 
         if mode == PipxDependenciesDialog.OutdatedMode:
             headerMsg = self.tr("Outdated Dependencies of package <b>{0}</b>")
+            self.__upgradeButton = self.buttonBox.addButton(
+                self.tr("Upgrade Dependencies"), QDialogButtonBox.ButtonRole.ActionRole
+            )
         elif mode == PipxDependenciesDialog.UptodateMode:
             headerMsg = self.tr("Up-to-date Dependencies of package <b>{0}</b>")
         else:
@@ -76,3 +83,14 @@
         self.dependenciesList.resizeColumnToContents(
             PipxDependenciesDialog.AvailableVersionColumn
         )
+
+    @pyqtSlot(QAbstractButton)
+    def on_buttonBox_clicked(self, button):
+        """
+        Private slot handling a button click of the button box.
+
+        @param button reference to the clicked button
+        @type QAbstractButton
+        """
+        if button == self.__upgradeButton:
+            self.done(PipxDependenciesDialog.UpgradeDependenciesAction)

eric ide

mercurial