src/eric7/UI/VersionsDialog.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8972
54816b8f740f
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to show the versions of various components.
8 """
9
10 import sys
11
12 from PyQt6.QtCore import pyqtSlot, Qt
13 from PyQt6.QtGui import QGuiApplication
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
19
20 from .Ui_VersionsDialog import Ui_VersionsDialog
21
22
23 class VersionsDialog(QDialog, Ui_VersionsDialog):
24 """
25 Class implementing a dialog to show the versions of various components.
26 """
27 def __init__(self, parent, title, text):
28 """
29 Constructor
30
31 @param parent reference to the parent widget
32 @type UserInterface
33 @param title dialog title
34 @type str
35 @param text versions text to be shown
36 @type str
37 """
38 super().__init__(parent)
39 self.setupUi(self)
40
41 self.__ui = parent
42 icon = QGuiApplication.windowIcon().pixmap(64, 64)
43
44 self.setWindowTitle(title)
45 self.iconLabel.setPixmap(icon)
46 self.textLabel.setText(text)
47
48 self.__checkUpdateButton = self.buttonBox.addButton(
49 self.tr("Check for Upgrades..."),
50 QDialogButtonBox.ButtonRole.ActionRole
51 )
52 self.__checkUpdateButton.clicked.connect(self.__checkForUpdate)
53
54 self.buttonBox.button(
55 QDialogButtonBox.StandardButton.Ok).setDefault(True)
56 self.buttonBox.button(
57 QDialogButtonBox.StandardButton.Ok).setFocus(
58 Qt.FocusReason.OtherFocusReason)
59
60 msh = self.minimumSizeHint()
61 self.resize(max(self.width(), msh.width()), msh.height())
62
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