--- a/eric7/UI/VersionsDialog.py Sat Mar 05 18:10:28 2022 +0100 +++ b/eric7/UI/VersionsDialog.py Sun Mar 06 19:53:19 2022 +0100 @@ -7,10 +7,16 @@ Module implementing a dialog to show the versions of various components. """ -from PyQt6.QtCore import Qt +import sys + +from PyQt6.QtCore import pyqtSlot, Qt from PyQt6.QtGui import QGuiApplication from PyQt6.QtWidgets import QDialog, QDialogButtonBox +from EricGui.EricOverrideCursor import EricOverrideCursor +from EricWidgets.EricApplication import ericApp +from EricWidgets import EricMessageBox + from .Ui_VersionsDialog import Ui_VersionsDialog @@ -39,10 +45,11 @@ self.iconLabel.setPixmap(icon) self.textLabel.setText(text) - self.__upgradePyQtButton = self.buttonBox.addButton( - self.tr("Upgrade PyQt..."), QDialogButtonBox.ButtonRole.ActionRole + self.__checkUpdateButton = self.buttonBox.addButton( + self.tr("Check for Upgrades..."), + QDialogButtonBox.ButtonRole.ActionRole ) - self.__upgradePyQtButton.clicked.connect(parent.upgradePyQt) + self.__checkUpdateButton.clicked.connect(self.__checkForUpdate) self.buttonBox.button( QDialogButtonBox.StandardButton.Ok).setDefault(True) @@ -54,3 +61,70 @@ self.resize(max(self.width(), msh.width()), msh.height()) self.exec() + + @pyqtSlot() + def __checkForUpdate(self): + """ + Private slot to check, if updates of PyQt6 packages or the eric-ide + package are available. + """ + msg = "" + + pip = ericApp().getObject("Pip") + venvManager = ericApp().getObject("VirtualEnvManager") + + environmentName = ( + venvManager.environmentForInterpreter(sys.executable)[0] + # just the name is needed + ) + + if environmentName: + with EricOverrideCursor(): + pyqtUpdateAvailable = pip.checkPackageOutdated( + "pyqt6", environmentName)[0] + ericUpdateAvailable = pip.checkPackageOutdated( + "eric-ide", environmentName)[0] + + if pyqtUpdateAvailable or ericUpdateAvailable: + self.buttonBox.removeButton(self.__checkUpdateButton) + self.__checkUpdateButton = None + else: + msg = self.tr("No upgrades available.") + + if ericUpdateAvailable: + self.__upgradeEricButton = self.buttonBox.addButton( + self.tr("Upgrade eric7..."), + QDialogButtonBox.ButtonRole.ActionRole + ) + self.__upgradeEricButton.clicked.connect(self.__ui.upgradeEric) + msg += self.tr( + "<p>An upgrade of <b>eric7</b> is available.</p>") + + if pyqtUpdateAvailable: + self.__upgradePyQtButton = self.buttonBox.addButton( + self.tr("Upgrade PyQt6..."), + QDialogButtonBox.ButtonRole.ActionRole + ) + self.__upgradePyQtButton.clicked.connect(self.__ui.upgradePyQt) + msg += self.tr( + "<p>An upgrade of <b>PyQt6</b> is available.</p>") + + if ericUpdateAvailable and pyqtUpdateAvailable: + self.__upgradeBothButton = self.buttonBox.addButton( + self.tr("Upgrade Both..."), + QDialogButtonBox.ButtonRole.ActionRole + ) + self.__upgradeBothButton.clicked.connect( + self.__ui.upgradeEricPyQt) + + self.buttonBox.button( + QDialogButtonBox.StandardButton.Ok).setDefault(True) + self.buttonBox.button( + QDialogButtonBox.StandardButton.Ok).setFocus( + Qt.FocusReason.OtherFocusReason) + + EricMessageBox.information( + self, + self.tr("Check for Upgrades"), + msg + )