src/eric7/UI/VersionsDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9308
110d32f96013
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
22 22
23 class VersionsDialog(QDialog, Ui_VersionsDialog): 23 class VersionsDialog(QDialog, Ui_VersionsDialog):
24 """ 24 """
25 Class implementing a dialog to show the versions of various components. 25 Class implementing a dialog to show the versions of various components.
26 """ 26 """
27
27 def __init__(self, parent, title, text): 28 def __init__(self, parent, title, text):
28 """ 29 """
29 Constructor 30 Constructor
30 31
31 @param parent reference to the parent widget 32 @param parent reference to the parent widget
32 @type UserInterface 33 @type UserInterface
33 @param title dialog title 34 @param title dialog title
34 @type str 35 @type str
35 @param text versions text to be shown 36 @param text versions text to be shown
36 @type str 37 @type str
37 """ 38 """
38 super().__init__(parent) 39 super().__init__(parent)
39 self.setupUi(self) 40 self.setupUi(self)
40 41
41 self.__ui = parent 42 self.__ui = parent
42 icon = QGuiApplication.windowIcon().pixmap(64, 64) 43 icon = QGuiApplication.windowIcon().pixmap(64, 64)
43 44
44 self.setWindowTitle(title) 45 self.setWindowTitle(title)
45 self.iconLabel.setPixmap(icon) 46 self.iconLabel.setPixmap(icon)
46 self.textLabel.setText(text) 47 self.textLabel.setText(text)
47 48
48 self.__checkUpdateButton = self.buttonBox.addButton( 49 self.__checkUpdateButton = self.buttonBox.addButton(
49 self.tr("Check for Upgrades..."), 50 self.tr("Check for Upgrades..."), QDialogButtonBox.ButtonRole.ActionRole
50 QDialogButtonBox.ButtonRole.ActionRole
51 ) 51 )
52 self.__checkUpdateButton.clicked.connect(self.__checkForUpdate) 52 self.__checkUpdateButton.clicked.connect(self.__checkForUpdate)
53 53
54 self.buttonBox.button( 54 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setDefault(True)
55 QDialogButtonBox.StandardButton.Ok).setDefault(True) 55 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setFocus(
56 self.buttonBox.button( 56 Qt.FocusReason.OtherFocusReason
57 QDialogButtonBox.StandardButton.Ok).setFocus( 57 )
58 Qt.FocusReason.OtherFocusReason) 58
59
60 msh = self.minimumSizeHint() 59 msh = self.minimumSizeHint()
61 self.resize(max(self.width(), msh.width()), msh.height()) 60 self.resize(max(self.width(), msh.width()), msh.height())
62 61
63 self.exec() 62 self.exec()
64 63
65 @pyqtSlot() 64 @pyqtSlot()
66 def __checkForUpdate(self): 65 def __checkForUpdate(self):
67 """ 66 """
68 Private slot to check, if updates of PyQt6 packages or the eric-ide 67 Private slot to check, if updates of PyQt6 packages or the eric-ide
69 package are available. 68 package are available.
70 """ 69 """
71 msg = "" 70 msg = ""
72 71
73 pip = ericApp().getObject("Pip") 72 pip = ericApp().getObject("Pip")
74 venvManager = ericApp().getObject("VirtualEnvManager") 73 venvManager = ericApp().getObject("VirtualEnvManager")
75 74
76 environmentName = ( 75 environmentName = (
77 venvManager.environmentForInterpreter(sys.executable)[0] 76 venvManager.environmentForInterpreter(sys.executable)[0]
78 # just the name is needed 77 # just the name is needed
79 ) 78 )
80 79
81 if environmentName: 80 if environmentName:
82 with EricOverrideCursor(): 81 with EricOverrideCursor():
83 pyqtUpdateAvailable = pip.checkPackageOutdated( 82 pyqtUpdateAvailable = pip.checkPackageOutdated(
84 "pyqt6", environmentName)[0] 83 "pyqt6", environmentName
84 )[0]
85 ericUpdateAvailable = pip.checkPackageOutdated( 85 ericUpdateAvailable = pip.checkPackageOutdated(
86 "eric-ide", environmentName)[0] 86 "eric-ide", environmentName
87 87 )[0]
88
88 if pyqtUpdateAvailable or ericUpdateAvailable: 89 if pyqtUpdateAvailable or ericUpdateAvailable:
89 self.buttonBox.removeButton(self.__checkUpdateButton) 90 self.buttonBox.removeButton(self.__checkUpdateButton)
90 self.__checkUpdateButton = None 91 self.__checkUpdateButton = None
91 else: 92 else:
92 msg = self.tr("No upgrades available.") 93 msg = self.tr("No upgrades available.")
93 94
94 if ericUpdateAvailable: 95 if ericUpdateAvailable:
95 self.__upgradeEricButton = self.buttonBox.addButton( 96 self.__upgradeEricButton = self.buttonBox.addButton(
96 self.tr("Upgrade eric7..."), 97 self.tr("Upgrade eric7..."), QDialogButtonBox.ButtonRole.ActionRole
97 QDialogButtonBox.ButtonRole.ActionRole
98 ) 98 )
99 self.__upgradeEricButton.clicked.connect(self.__ui.upgradeEric) 99 self.__upgradeEricButton.clicked.connect(self.__ui.upgradeEric)
100 msg += self.tr( 100 msg += self.tr("<p>An upgrade of <b>eric7</b> is available.</p>")
101 "<p>An upgrade of <b>eric7</b> is available.</p>") 101
102
103 if pyqtUpdateAvailable: 102 if pyqtUpdateAvailable:
104 self.__upgradePyQtButton = self.buttonBox.addButton( 103 self.__upgradePyQtButton = self.buttonBox.addButton(
105 self.tr("Upgrade PyQt6..."), 104 self.tr("Upgrade PyQt6..."), QDialogButtonBox.ButtonRole.ActionRole
106 QDialogButtonBox.ButtonRole.ActionRole
107 ) 105 )
108 self.__upgradePyQtButton.clicked.connect(self.__ui.upgradePyQt) 106 self.__upgradePyQtButton.clicked.connect(self.__ui.upgradePyQt)
109 msg += self.tr( 107 msg += self.tr("<p>An upgrade of <b>PyQt6</b> is available.</p>")
110 "<p>An upgrade of <b>PyQt6</b> is available.</p>") 108
111
112 if ericUpdateAvailable and pyqtUpdateAvailable: 109 if ericUpdateAvailable and pyqtUpdateAvailable:
113 self.__upgradeBothButton = self.buttonBox.addButton( 110 self.__upgradeBothButton = self.buttonBox.addButton(
114 self.tr("Upgrade Both..."), 111 self.tr("Upgrade Both..."), QDialogButtonBox.ButtonRole.ActionRole
115 QDialogButtonBox.ButtonRole.ActionRole
116 ) 112 )
117 self.__upgradeBothButton.clicked.connect( 113 self.__upgradeBothButton.clicked.connect(self.__ui.upgradeEricPyQt)
118 self.__ui.upgradeEricPyQt) 114
119 115 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setDefault(True)
120 self.buttonBox.button( 116 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setFocus(
121 QDialogButtonBox.StandardButton.Ok).setDefault(True) 117 Qt.FocusReason.OtherFocusReason
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 ) 118 )
119
120 EricMessageBox.information(self, self.tr("Check for Upgrades"), msg)

eric ide

mercurial