eric7/UI/VersionsDialog.py

branch
eric7
changeset 8972
54816b8f740f
parent 8971
0a846d71f27c
equal deleted inserted replaced
8971:0a846d71f27c 8972:54816b8f740f
5 5
6 """ 6 """
7 Module implementing a dialog to show the versions of various components. 7 Module implementing a dialog to show the versions of various components.
8 """ 8 """
9 9
10 from PyQt6.QtCore import Qt 10 import sys
11
12 from PyQt6.QtCore import pyqtSlot, Qt
11 from PyQt6.QtGui import QGuiApplication 13 from PyQt6.QtGui import QGuiApplication
12 from PyQt6.QtWidgets import QDialog, QDialogButtonBox 14 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
15
16 from EricGui.EricOverrideCursor import EricOverrideCursor
17 from EricWidgets.EricApplication import ericApp
18 from EricWidgets import EricMessageBox
13 19
14 from .Ui_VersionsDialog import Ui_VersionsDialog 20 from .Ui_VersionsDialog import Ui_VersionsDialog
15 21
16 22
17 class VersionsDialog(QDialog, Ui_VersionsDialog): 23 class VersionsDialog(QDialog, Ui_VersionsDialog):
37 43
38 self.setWindowTitle(title) 44 self.setWindowTitle(title)
39 self.iconLabel.setPixmap(icon) 45 self.iconLabel.setPixmap(icon)
40 self.textLabel.setText(text) 46 self.textLabel.setText(text)
41 47
42 self.__upgradePyQtButton = self.buttonBox.addButton( 48 self.__checkUpdateButton = self.buttonBox.addButton(
43 self.tr("Upgrade PyQt..."), QDialogButtonBox.ButtonRole.ActionRole 49 self.tr("Check for Upgrades..."),
50 QDialogButtonBox.ButtonRole.ActionRole
44 ) 51 )
45 self.__upgradePyQtButton.clicked.connect(parent.upgradePyQt) 52 self.__checkUpdateButton.clicked.connect(self.__checkForUpdate)
46 53
47 self.buttonBox.button( 54 self.buttonBox.button(
48 QDialogButtonBox.StandardButton.Ok).setDefault(True) 55 QDialogButtonBox.StandardButton.Ok).setDefault(True)
49 self.buttonBox.button( 56 self.buttonBox.button(
50 QDialogButtonBox.StandardButton.Ok).setFocus( 57 QDialogButtonBox.StandardButton.Ok).setFocus(
52 59
53 msh = self.minimumSizeHint() 60 msh = self.minimumSizeHint()
54 self.resize(max(self.width(), msh.width()), msh.height()) 61 self.resize(max(self.width(), msh.width()), msh.height())
55 62
56 self.exec() 63 self.exec()
64
65 @pyqtSlot()
66 def __checkForUpdate(self):
67 """
68 Private slot to check, if updates of PyQt6 packages or the eric-ide
69 package are available.
70 """
71 msg = ""
72
73 pip = ericApp().getObject("Pip")
74 venvManager = ericApp().getObject("VirtualEnvManager")
75
76 environmentName = (
77 venvManager.environmentForInterpreter(sys.executable)[0]
78 # just the name is needed
79 )
80
81 if environmentName:
82 with EricOverrideCursor():
83 pyqtUpdateAvailable = pip.checkPackageOutdated(
84 "pyqt6", environmentName)[0]
85 ericUpdateAvailable = pip.checkPackageOutdated(
86 "eric-ide", environmentName)[0]
87
88 if pyqtUpdateAvailable or ericUpdateAvailable:
89 self.buttonBox.removeButton(self.__checkUpdateButton)
90 self.__checkUpdateButton = None
91 else:
92 msg = self.tr("No upgrades available.")
93
94 if ericUpdateAvailable:
95 self.__upgradeEricButton = self.buttonBox.addButton(
96 self.tr("Upgrade eric7..."),
97 QDialogButtonBox.ButtonRole.ActionRole
98 )
99 self.__upgradeEricButton.clicked.connect(self.__ui.upgradeEric)
100 msg += self.tr(
101 "<p>An upgrade of <b>eric7</b> is available.</p>")
102
103 if pyqtUpdateAvailable:
104 self.__upgradePyQtButton = self.buttonBox.addButton(
105 self.tr("Upgrade PyQt6..."),
106 QDialogButtonBox.ButtonRole.ActionRole
107 )
108 self.__upgradePyQtButton.clicked.connect(self.__ui.upgradePyQt)
109 msg += self.tr(
110 "<p>An upgrade of <b>PyQt6</b> is available.</p>")
111
112 if ericUpdateAvailable and pyqtUpdateAvailable:
113 self.__upgradeBothButton = self.buttonBox.addButton(
114 self.tr("Upgrade Both..."),
115 QDialogButtonBox.ButtonRole.ActionRole
116 )
117 self.__upgradeBothButton.clicked.connect(
118 self.__ui.upgradeEricPyQt)
119
120 self.buttonBox.button(
121 QDialogButtonBox.StandardButton.Ok).setDefault(True)
122 self.buttonBox.button(
123 QDialogButtonBox.StandardButton.Ok).setFocus(
124 Qt.FocusReason.OtherFocusReason)
125
126 EricMessageBox.information(
127 self,
128 self.tr("Check for Upgrades"),
129 msg
130 )

eric ide

mercurial