Sat, 22 May 2021 18:51:46 +0200
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
--- a/eric7.epj Sat May 22 17:01:51 2021 +0200 +++ b/eric7.epj Sat May 22 18:51:46 2021 +0200 @@ -2,7 +2,7 @@ "header": { "comment": "eric project file for project eric7", "copyright": "Copyright (C) 2021 Detlev Offenbach, detlev@die-offenbachs.de", - "saved": "2021-05-22, 16:56:28" + "saved": "2021-05-22, 18:49:32" }, "project": { "AUTHOR": "Detlev Offenbach", @@ -285,15 +285,6 @@ "eric7/Debugger/StartRunDialog.ui", "eric7/Debugger/VariableDetailDialog.ui", "eric7/Debugger/VariablesFilterDialog.ui", - "eric7/E5Gui/E5ComboSelectionDialog.ui", - "eric7/E5Gui/E5ErrorMessageFilterDialog.ui", - "eric7/E5Gui/E5ListSelectionDialog.ui", - "eric7/E5Gui/E5PlainTextDialog.ui", - "eric7/E5Gui/E5ProcessDialog.ui", - "eric7/E5Gui/E5SimpleHelpDialog.ui", - "eric7/E5Gui/E5StringListEditWidget.ui", - "eric7/E5Gui/E5ToolBarDialog.ui", - "eric7/E5Gui/E5ZoomWidget.ui", "eric7/Graphics/UMLSceneSizeDialog.ui", "eric7/HexEdit/HexEditGotoWidget.ui", "eric7/HexEdit/HexEditReplaceWidget.ui", @@ -709,7 +700,16 @@ "eric7/EricNetwork/EricSslCertificateSelectionDialog.ui", "eric7/EricNetwork/EricSslCertificatesDialog.ui", "eric7/EricNetwork/EricSslCertificatesInfoDialog.ui", - "eric7/EricNetwork/EricSslCertificatesInfoWidget.ui" + "eric7/EricNetwork/EricSslCertificatesInfoWidget.ui", + "eric7/E5Gui/EricComboSelectionDialog.ui", + "eric7/E5Gui/EricErrorMessageFilterDialog.ui", + "eric7/E5Gui/EricListSelectionDialog.ui", + "eric7/E5Gui/EricPlainTextDialog.ui", + "eric7/E5Gui/EricProcessDialog.ui", + "eric7/E5Gui/EricSimpleHelpDialog.ui", + "eric7/E5Gui/EricStringListEditWidget.ui", + "eric7/E5Gui/EricToolBarDialog.ui", + "eric7/E5Gui/EricZoomWidget.ui" ], "HASH": "df7daa8781250f7664e6ecaeaf1361fa2efd39ee", "IDLPARAMS": { @@ -1072,54 +1072,6 @@ "eric7/DocumentationTools/TemplatesListsStyle.py", "eric7/DocumentationTools/TemplatesListsStyleCSS.py", "eric7/DocumentationTools/__init__.py", - "eric7/E5Gui/E5Action.py", - "eric7/E5Gui/E5AnimatedLabel.py", - "eric7/E5Gui/E5AnimatedWidget.py", - "eric7/E5Gui/E5Application.py", - "eric7/E5Gui/E5ClickableLabel.py", - "eric7/E5Gui/E5ComboSelectionDialog.py", - "eric7/E5Gui/E5Completers.py", - "eric7/E5Gui/E5ErrorMessage.py", - "eric7/E5Gui/E5ErrorMessageFilterDialog.py", - "eric7/E5Gui/E5FileDialog.py", - "eric7/E5Gui/E5FileSaveConfirmDialog.py", - "eric7/E5Gui/E5GenericDiffHighlighter.py", - "eric7/E5Gui/E5Led.py", - "eric7/E5Gui/E5LineEdit.py", - "eric7/E5Gui/E5LineEditButton.py", - "eric7/E5Gui/E5ListSelectionDialog.py", - "eric7/E5Gui/E5ListView.py", - "eric7/E5Gui/E5MainWindow.py", - "eric7/E5Gui/E5MapWidget.py", - "eric7/E5Gui/E5MessageBox.py", - "eric7/E5Gui/E5ModelMenu.py", - "eric7/E5Gui/E5ModelToolBar.py", - "eric7/E5Gui/E5OverrideCursor.py", - "eric7/E5Gui/E5PassivePopup.py", - "eric7/E5Gui/E5PasswordMeter.py", - "eric7/E5Gui/E5PathPicker.py", - "eric7/E5Gui/E5PathPickerDialog.py", - "eric7/E5Gui/E5PlainTextDialog.py", - "eric7/E5Gui/E5ProcessDialog.py", - "eric7/E5Gui/E5ProgressDialog.py", - "eric7/E5Gui/E5SideBar.py", - "eric7/E5Gui/E5SimpleHelpDialog.py", - "eric7/E5Gui/E5SingleApplication.py", - "eric7/E5Gui/E5SqueezeLabels.py", - "eric7/E5Gui/E5StringListEditWidget.py", - "eric7/E5Gui/E5TabWidget.py", - "eric7/E5Gui/E5TableView.py", - "eric7/E5Gui/E5TextEditSearchWidget.py", - "eric7/E5Gui/E5TextInputDialog.py", - "eric7/E5Gui/E5TextSpinBox.py", - "eric7/E5Gui/E5ToolBarDialog.py", - "eric7/E5Gui/E5ToolBarManager.py", - "eric7/E5Gui/E5ToolBox.py", - "eric7/E5Gui/E5ToolButton.py", - "eric7/E5Gui/E5TreeSortFilterProxyModel.py", - "eric7/E5Gui/E5TreeView.py", - "eric7/E5Gui/E5TreeWidget.py", - "eric7/E5Gui/E5ZoomWidget.py", "eric7/E5Gui/__init__.py", "eric7/Globals/AppInfo.py", "eric7/Globals/__init__.py", @@ -2264,7 +2216,55 @@ "eric7/EricNetwork/EricSslInfoWidget.py", "eric7/EricNetwork/EricSslUtilities.py", "eric7/EricNetwork/EricTldExtractor.py", - "eric7/EricNetwork/EricUrlInfo.py" + "eric7/EricNetwork/EricUrlInfo.py", + "eric7/E5Gui/EricAction.py", + "eric7/E5Gui/EricAnimatedLabel.py", + "eric7/E5Gui/EricAnimatedWidget.py", + "eric7/E5Gui/EricApplication.py", + "eric7/E5Gui/EricClickableLabel.py", + "eric7/E5Gui/EricComboSelectionDialog.py", + "eric7/E5Gui/EricCompleters.py", + "eric7/E5Gui/EricErrorMessage.py", + "eric7/E5Gui/EricErrorMessageFilterDialog.py", + "eric7/E5Gui/EricFileDialog.py", + "eric7/E5Gui/EricFileSaveConfirmDialog.py", + "eric7/E5Gui/EricGenericDiffHighlighter.py", + "eric7/E5Gui/EricLed.py", + "eric7/E5Gui/EricLineEdit.py", + "eric7/E5Gui/EricLineEditButton.py", + "eric7/E5Gui/EricListSelectionDialog.py", + "eric7/E5Gui/EricListView.py", + "eric7/E5Gui/EricMainWindow.py", + "eric7/E5Gui/EricMapWidget.py", + "eric7/E5Gui/EricMessageBox.py", + "eric7/E5Gui/EricModelMenu.py", + "eric7/E5Gui/EricModelToolBar.py", + "eric7/E5Gui/EricOverrideCursor.py", + "eric7/E5Gui/EricPassivePopup.py", + "eric7/E5Gui/EricPasswordMeter.py", + "eric7/E5Gui/EricPathPicker.py", + "eric7/E5Gui/EricPathPickerDialog.py", + "eric7/E5Gui/EricPlainTextDialog.py", + "eric7/E5Gui/EricProcessDialog.py", + "eric7/E5Gui/EricProgressDialog.py", + "eric7/E5Gui/EricSideBar.py", + "eric7/E5Gui/EricSimpleHelpDialog.py", + "eric7/E5Gui/EricSingleApplication.py", + "eric7/E5Gui/EricSqueezeLabels.py", + "eric7/E5Gui/EricStringListEditWidget.py", + "eric7/E5Gui/EricTabWidget.py", + "eric7/E5Gui/EricTableView.py", + "eric7/E5Gui/EricTextEditSearchWidget.py", + "eric7/E5Gui/EricTextInputDialog.py", + "eric7/E5Gui/EricTextSpinBox.py", + "eric7/E5Gui/EricToolBarDialog.py", + "eric7/E5Gui/EricToolBarManager.py", + "eric7/E5Gui/EricToolBox.py", + "eric7/E5Gui/EricToolButton.py", + "eric7/E5Gui/EricTreeSortFilterProxyModel.py", + "eric7/E5Gui/EricTreeView.py", + "eric7/E5Gui/EricTreeWidget.py", + "eric7/E5Gui/EricZoomWidget.py" ], "SPELLEXCLUDES": "Dictionaries/excludes.dic", "SPELLLANGUAGE": "en_US",
--- a/eric7/CondaInterface/Conda.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/CondaInterface/Conda.py Sat May 22 18:51:46 2021 +0200 @@ -14,7 +14,7 @@ from PyQt6.QtCore import pyqtSignal, QObject, QProcess, QCoreApplication from PyQt6.QtWidgets import QDialog -from E5Gui import E5MessageBox +from E5Gui import EricMessageBox import Globals import Preferences @@ -145,7 +145,7 @@ proc = QProcess() proc.start(exe, args) if not proc.waitForStarted(15000): - E5MessageBox.critical( + EricMessageBox.critical( self.__ui, self.tr("conda remove"), self.tr("""The conda executable could not be started.""")) @@ -158,14 +158,14 @@ try: jsonDict = json.loads(output) except Exception: - E5MessageBox.critical( + EricMessageBox.critical( self.__ui, self.tr("conda remove"), self.tr("""The conda executable returned invalid data.""")) return False if "error" in jsonDict: - E5MessageBox.critical( + EricMessageBox.critical( self.__ui, self.tr("conda remove"), self.tr("<p>The conda executable returned an error.</p>"
--- a/eric7/CondaInterface/CondaExecDialog.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/CondaInterface/CondaExecDialog.py Sat May 22 18:51:46 2021 +0200 @@ -12,7 +12,7 @@ from PyQt6.QtCore import pyqtSlot, QProcess, QTimer from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton -from E5Gui import E5MessageBox +from E5Gui import EricMessageBox from .Ui_CondaExecDialog import Ui_CondaExecDialog @@ -99,7 +99,7 @@ self.__process.start(self.__condaExe, arguments) procStarted = self.__process.waitForStarted(5000) if not procStarted: - E5MessageBox.critical( + EricMessageBox.critical( self, self.tr("Conda Execution"), self.tr("""The conda executable could not be started. Is it"""
--- a/eric7/CondaInterface/CondaExportDialog.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/CondaInterface/CondaExportDialog.py Sat May 22 18:51:46 2021 +0200 @@ -14,10 +14,10 @@ QDialog, QDialogButtonBox, QAbstractButton, QApplication ) -from E5Gui import E5MessageBox, E5FileDialog -from E5Gui.E5PathPicker import E5PathPickerModes -from E5Gui.E5Application import e5App -from E5Gui.E5OverrideCursor import E5OverrideCursor +from E5Gui import EricMessageBox, EricFileDialog +from E5Gui.EricPathPicker import EricPathPickerModes +from E5Gui.EricApplication import ericApp +from E5Gui.EricOverrideCursor import EricOverrideCursor from .Ui_CondaExportDialog import Ui_CondaExportDialog @@ -48,7 +48,7 @@ self.__refreshButton = self.buttonBox.addButton( self.tr("&Refresh"), QDialogButtonBox.ButtonRole.ActionRole) - self.requirementsFilePicker.setMode(E5PathPickerModes.SAVE_FILE_MODE) + self.requirementsFilePicker.setMode(EricPathPickerModes.SAVE_FILE_MODE) self.requirementsFilePicker.setFilters( self.tr("Text Files (*.txt);;All Files (*)")) @@ -108,7 +108,7 @@ Private slot to refresh the displayed list. """ ok = ( - E5MessageBox.yesNo( + EricMessageBox.yesNo( self, self.tr("Generate Requirements"), self.tr("""The requirements were changed. Do you want""" @@ -133,7 +133,7 @@ self.__prefix, ] - with E5OverrideCursor(): + with EricOverrideCursor(): success, output = self.__conda.runProcess(args) if success: @@ -158,7 +158,7 @@ self.saveToButton.setEnabled(self.__requirementsAvailable) self.copyButton.setEnabled(self.__requirementsAvailable) - aw = e5App().getObject("ViewManager").activeWindow() + aw = ericApp().getObject("ViewManager").activeWindow() if aw and self.__requirementsAvailable: self.insertButton.setEnabled(True) self.replaceAllButton.setEnabled(True) @@ -177,7 +177,7 @@ @type str """ if os.path.exists(fileName): - ok = E5MessageBox.warning( + ok = EricMessageBox.warning( self, self.tr("Generate Requirements"), self.tr("""The file <b>{0}</b> already exists. Do you want""" @@ -189,7 +189,7 @@ with open(fileName, "w") as f: f.write(self.requirementsEdit.toPlainText()) except OSError as err: - E5MessageBox.critical( + EricMessageBox.critical( self, self.tr("Generate Requirements"), self.tr("""<p>The requirements could not be written""" @@ -209,13 +209,13 @@ """ Private slot to write the requirements text to a new file. """ - fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( + fileName, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( self, self.tr("Generate Requirements"), os.path.expanduser("~"), self.tr("Text Files (*.txt);;All Files (*)"), None, - E5FileDialog.DontConfirmOverwrite + EricFileDialog.DontConfirmOverwrite ) if fileName: ext = os.path.splitext(fileName)[1] @@ -240,7 +240,7 @@ Private slot to insert the requirements text at the cursor position of the current editor. """ - aw = e5App().getObject("ViewManager").activeWindow() + aw = ericApp().getObject("ViewManager").activeWindow() if aw: aw.beginUndoAction() cline, cindex = aw.getCursorPosition() @@ -253,7 +253,7 @@ Private slot to replace the selected text of the current editor with the requirements text. """ - aw = e5App().getObject("ViewManager").activeWindow() + aw = ericApp().getObject("ViewManager").activeWindow() if aw: aw.beginUndoAction() aw.replaceSelectedText(self.requirementsEdit.toPlainText()) @@ -265,6 +265,6 @@ Private slot to replace the text of the current editor with the requirements text. """ - aw = e5App().getObject("ViewManager").activeWindow() + aw = ericApp().getObject("ViewManager").activeWindow() if aw: aw.setText(self.requirementsEdit.toPlainText())
--- a/eric7/CondaInterface/CondaExportDialog.ui Sat May 22 17:01:51 2021 +0200 +++ b/eric7/CondaInterface/CondaExportDialog.ui Sat May 22 18:51:46 2021 +0200 @@ -44,7 +44,7 @@ </widget> </item> <item row="1" column="1"> - <widget class="E5PathPicker" name="requirementsFilePicker" native="true"> + <widget class="EricPathPicker" name="requirementsFilePicker" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -156,9 +156,9 @@ </widget> <customwidgets> <customwidget> - <class>E5PathPicker</class> + <class>EricPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/E5PathPicker.h</header> + <header>E5Gui/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/CondaInterface/CondaNewEnvironmentDataDialog.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/CondaInterface/CondaNewEnvironmentDataDialog.py Sat May 22 18:51:46 2021 +0200 @@ -10,7 +10,7 @@ from PyQt6.QtCore import pyqtSlot from PyQt6.QtWidgets import QDialog, QDialogButtonBox -from E5Gui.E5PathPicker import E5PathPickerModes +from E5Gui.EricPathPicker import EricPathPickerModes from .Ui_CondaNewEnvironmentDataDialog import Ui_CondaNewEnvironmentDataDialog @@ -38,7 +38,7 @@ self.__requirementsMode = showRequirements - self.requirementsFilePicker.setMode(E5PathPickerModes.OPEN_FILE_MODE) + self.requirementsFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) self.requirementsFilePicker.setFilters( self.tr("Text Files (*.txt);;All Files (*)"))
--- a/eric7/CondaInterface/CondaNewEnvironmentDataDialog.ui Sat May 22 17:01:51 2021 +0200 +++ b/eric7/CondaInterface/CondaNewEnvironmentDataDialog.ui Sat May 22 18:51:46 2021 +0200 @@ -65,7 +65,7 @@ </widget> </item> <item row="2" column="1"> - <widget class="E5PathPicker" name="requirementsFilePicker" native="true"> + <widget class="EricPathPicker" name="requirementsFilePicker" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -91,9 +91,9 @@ </widget> <customwidgets> <customwidget> - <class>E5PathPicker</class> + <class>EricPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/E5PathPicker.h</header> + <header>E5Gui/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/CondaInterface/CondaPackagesWidget.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/CondaInterface/CondaPackagesWidget.py Sat May 22 18:51:46 2021 +0200 @@ -15,9 +15,9 @@ QDialog ) -from E5Gui import E5FileDialog, E5MessageBox, E5TextInputDialog -from E5Gui.E5Application import e5App -from E5Gui.E5OverrideCursor import E5OverrideCursor +from E5Gui import EricFileDialog, EricMessageBox, EricTextInputDialog +from E5Gui.EricApplication import ericApp +from E5Gui.EricOverrideCursor import EricOverrideCursor from .Ui_CondaPackagesWidget import Ui_CondaPackagesWidget @@ -222,7 +222,7 @@ self.statusLabel.show() self.statusLabel.setText(self.tr("Getting installed packages...")) - with E5OverrideCursor(): + with EricOverrideCursor(): # 1. populate with installed packages self.packagesList.setUpdatesEnabled(False) installedPackages = self.__conda.getInstalledPackages( @@ -287,7 +287,7 @@ self.environmentsComboBox.clear() self.packagesList.clear() - with E5OverrideCursor(): + with EricOverrideCursor(): self.__populateEnvironments() index = self.environmentsComboBox.findText( @@ -356,7 +356,7 @@ self.searchResultList.clear() pattern = self.searchEdit.text() if pattern: - with E5OverrideCursor(): + with EricOverrideCursor(): prefix = ( "" if CondaInterface.condaVersion() >= (4, 4, 0) else @@ -400,7 +400,7 @@ message = result["message"] except KeyError: message = result["error"] - E5MessageBox.warning( + EricMessageBox.warning( self, self.tr("Conda Search Package Error"), message) @@ -558,7 +558,7 @@ prefix = self.environmentsComboBox.itemData( self.environmentsComboBox.currentIndex()) if prefix: - ok, packageSpecs = E5TextInputDialog.getText( + ok, packageSpecs = EricTextInputDialog.getText( self, self.tr("Install Packages"), self.tr("Package Specifications (separated by whitespace):"), @@ -578,7 +578,7 @@ prefix = self.environmentsComboBox.itemData( self.environmentsComboBox.currentIndex()) if prefix: - requirements = E5FileDialog.getOpenFileNames( + requirements = EricFileDialog.getOpenFileNames( self, self.tr("Install Packages"), "", @@ -633,7 +633,7 @@ ok, prefix, interpreter = self.__conda.createCondaEnvironment( args) if ok: - e5App().getObject("VirtualEnvManager").addVirtualEnv( + ericApp().getObject("VirtualEnvManager").addVirtualEnv( virtEnvName, prefix, interpreter, isConda=True) @pyqtSlot() @@ -656,7 +656,7 @@ ] ok, prefix, interpreter = self.__conda.createCondaEnvironment(args) if ok: - e5App().getObject("VirtualEnvManager").addVirtualEnv( + ericApp().getObject("VirtualEnvManager").addVirtualEnv( virtEnvName, prefix, interpreter, isConda=True) @pyqtSlot() @@ -665,7 +665,7 @@ Private slot to delete a conda environment. """ envName = self.environmentsComboBox.currentText() - ok = E5MessageBox.yesNo( + ok = EricMessageBox.yesNo( self, self.tr("Delete Environment"), self.tr("""<p>Shall the environment <b>{0}</b> really be""" @@ -690,7 +690,7 @@ # check, if the destination is writeable if not os.access(cfgFile, os.W_OK): - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Edit Configuration"), self.tr("""The configuration file "{0}" does not exist""" @@ -705,7 +705,7 @@ """ Private slot to open the configuration page. """ - e5App().getObject("UserInterface").showPreferences("condaPage") + ericApp().getObject("UserInterface").showPreferences("condaPage") @pyqtSlot() def on_recheckButton_clicked(self):
--- a/eric7/CondaInterface/CondaPackagesWidget.ui Sat May 22 17:01:51 2021 +0200 +++ b/eric7/CondaInterface/CondaPackagesWidget.ui Sat May 22 18:51:46 2021 +0200 @@ -126,7 +126,7 @@ <widget class="QComboBox" name="environmentsComboBox"/> </item> <item> - <widget class="E5ToolButton" name="condaMenuButton"/> + <widget class="EricToolButton" name="condaMenuButton"/> </item> </layout> </item> @@ -431,9 +431,9 @@ </widget> <customwidgets> <customwidget> - <class>E5ToolButton</class> + <class>EricToolButton</class> <extends>QToolButton</extends> - <header>E5Gui/E5ToolButton.h</header> + <header>E5Gui/EricToolButton.h</header> </customwidget> </customwidgets> <tabstops>
--- a/eric7/Cooperation/ChatWidget.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Cooperation/ChatWidget.py Sat May 22 18:51:46 2021 +0200 @@ -11,8 +11,8 @@ from PyQt6.QtGui import QColor from PyQt6.QtWidgets import QWidget, QListWidgetItem, QMenu, QApplication -from E5Gui.E5Application import e5App -from E5Gui import E5MessageBox, E5FileDialog +from E5Gui.EricApplication import ericApp +from E5Gui import EricMessageBox, EricFileDialog from Globals import recentNameHosts @@ -348,7 +348,7 @@ self.sharingGroup.setEnabled(connected) if connected: - vm = e5App().getObject("ViewManager") + vm = ericApp().getObject("ViewManager") aw = vm.activeWindow() if aw: self.checkEditorActions(aw) @@ -404,7 +404,7 @@ from QScintilla.Editor import Editor if (message.startswith(Editor.StartEditToken + Editor.Separator) or message.startswith(Editor.EndEditToken + Editor.Separator)): - vm = e5App().getObject("ViewManager") + vm = ericApp().getObject("ViewManager") aw = vm.activeWindow() if aw: self.checkEditorActions(aw) @@ -550,13 +550,13 @@ """ txt = self.chatEdit.toPlainText() if txt: - fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( + fname, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( self, self.tr("Save Chat"), "", self.tr("Text Files (*.txt);;All Files (*)"), None, - E5FileDialog.DontConfirmOverwrite) + EricFileDialog.DontConfirmOverwrite) if fname: ext = QFileInfo(fname).suffix() if not ext: @@ -564,12 +564,12 @@ if ex: fname += ex if QFileInfo(fname).exists(): - res = E5MessageBox.yesNo( + res = EricMessageBox.yesNo( self, self.tr("Save Chat"), self.tr("<p>The file <b>{0}</b> already exists." " Overwrite it?</p>").format(fname), - icon=E5MessageBox.Warning) + icon=EricMessageBox.Warning) if not res: return fname = Utilities.toNativeSeparators(fname) @@ -578,7 +578,7 @@ with open(fname, "w", encoding="utf-8") as f: f.write(txt) except OSError as err: - E5MessageBox.critical( + EricMessageBox.critical( self, self.tr("Error saving Chat"), self.tr("""<p>The chat contents could not be"""
--- a/eric7/Cooperation/ChatWidget.ui Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Cooperation/ChatWidget.ui Sat May 22 18:51:46 2021 +0200 @@ -257,7 +257,7 @@ </widget> </item> <item> - <widget class="E5Led" name="connectionLed" native="true"> + <widget class="EricLed" name="connectionLed" native="true"> <property name="toolTip"> <string>Shows the connection status</string> </property> @@ -317,7 +317,7 @@ </widget> </item> <item> - <widget class="E5Led" name="serverLed" native="true"> + <widget class="EricLed" name="serverLed" native="true"> <property name="toolTip"> <string>Shows the status of the server</string> </property> @@ -330,9 +330,9 @@ </widget> <customwidgets> <customwidget> - <class>E5Led</class> + <class>EricLed</class> <extends>QWidget</extends> - <header>E5Gui/E5Led.h</header> + <header>E5Gui/EricLed.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Cooperation/Connection.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Cooperation/Connection.py Sat May 22 18:51:46 2021 +0200 @@ -10,8 +10,8 @@ from PyQt6.QtCore import pyqtSignal, QTimer, QTime, QByteArray from PyQt6.QtNetwork import QTcpSocket, QHostInfo -from E5Gui import E5MessageBox -from E5Gui.E5Application import e5App +from E5Gui import EricMessageBox +from E5Gui.EricApplication import ericApp import Preferences @@ -214,7 +214,7 @@ not Preferences.getCooperation("AutoAcceptConnections")): # don't ask for reverse connections or # if we shall accept automatically - res = E5MessageBox.yesNo( + res = EricMessageBox.yesNo( None, self.tr("New Connection"), self.tr("""<p>Accept connection from """ @@ -228,7 +228,7 @@ if self.__client is not None: chatWidget = self.__client.chatWidget() if chatWidget is not None and not chatWidget.isVisible(): - e5App().getObject( + ericApp().getObject( "UserInterface").activateCooperationViewer() if not self.__isGreetingMessageSent:
--- a/eric7/DataViews/PyCoverageDialog.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/DataViews/PyCoverageDialog.py Sat May 22 18:51:46 2021 +0200 @@ -16,9 +16,9 @@ QApplication ) -from E5Gui import E5MessageBox -from E5Gui.E5Application import e5App -from E5Gui.E5ProgressDialog import E5ProgressDialog +from E5Gui import EricMessageBox +from E5Gui.EricApplication import ericApp +from E5Gui.EricProgressDialog import EricProgressDialog from .Ui_PyCoverageDialog import Ui_PyCoverageDialog @@ -239,7 +239,7 @@ self.summaryGroup.hide() if total_exceptions: - E5MessageBox.warning( + EricMessageBox.warning( self, self.tr("Parse Error"), self.tr("""%n file(s) could not be parsed. Coverage""" @@ -308,7 +308,7 @@ itm = self.resultList.currentItem() fn = itm.text(0) - vm = e5App().getObject("ViewManager") + vm = ericApp().getObject("ViewManager") vm.openSourceFile(fn) editor = vm.getOpenEditor(fn) editor.codeCoverageShowAnnotations() @@ -350,7 +350,7 @@ cover.load() # now process them - progress = E5ProgressDialog( + progress = EricProgressDialog( self.tr("Annotating files..."), self.tr("Abort"), 0, len(files), self.tr("%v/%m Files"), self) progress.setMinimumDuration(0)
--- a/eric7/DataViews/PyProfileDialog.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/DataViews/PyProfileDialog.py Sat May 22 18:51:46 2021 +0200 @@ -16,7 +16,7 @@ QApplication ) -from E5Gui import E5MessageBox +from E5Gui import EricMessageBox from .Ui_PyProfileDialog import Ui_PyProfileDialog import Utilities @@ -239,7 +239,7 @@ fname = "{0}.profile".format(self.basename) if not os.path.exists(fname): - E5MessageBox.warning( + EricMessageBox.warning( self, self.tr("Profile Results"), self.tr("""<p>There is no profiling data""" @@ -251,7 +251,7 @@ with open(fname, 'rb') as f: self.stats = pickle.load(f) # secok except (OSError, pickle.PickleError, EOFError): - E5MessageBox.critical( + EricMessageBox.critical( self, self.tr("Loading Profiling Data"), self.tr("""<p>The profiling data could not be"""
--- a/eric7/Debugger/BreakPointViewer.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/BreakPointViewer.py Sat May 22 18:51:46 2021 +0200 @@ -14,7 +14,7 @@ QTreeView, QAbstractItemView, QHeaderView, QMenu, QDialog ) -from E5Gui.E5Application import e5App +from E5Gui.EricApplication import ericApp from Globals import recentNameBreakpointFiles, recentNameBreakpointConditions @@ -490,7 +490,7 @@ """ Private method to open the configuration dialog. """ - e5App().getObject("UserInterface").showPreferences( + ericApp().getObject("UserInterface").showPreferences( "debuggerGeneralPage") def __loadRecent(self):
--- a/eric7/Debugger/CallStackViewer.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/CallStackViewer.py Sat May 22 18:51:46 2021 +0200 @@ -12,8 +12,8 @@ QTreeWidget, QTreeWidgetItem, QMenu, QWidget, QVBoxLayout, QLabel ) -from E5Gui.E5Application import e5App -from E5Gui import E5FileDialog, E5MessageBox +from E5Gui.EricApplication import ericApp +from E5Gui import EricFileDialog, EricMessageBox import Utilities @@ -101,7 +101,7 @@ """ self.__projectMode = enabled if enabled and self.__project is None: - self.__project = e5App().getObject("Project") + self.__project = ericApp().getObject("Project") def __showContextMenu(self, coord): """ @@ -188,13 +188,13 @@ Private slot to save the stack trace info to a file. """ if self.__callStackList.topLevelItemCount() > 0: - fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( + fname, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( self, self.tr("Save Call Stack Info"), "", self.tr("Text Files (*.txt);;All Files (*)"), None, - E5FileDialog.DontConfirmOverwrite) + EricFileDialog.DontConfirmOverwrite) if fname: ext = QFileInfo(fname).suffix() if not ext: @@ -202,12 +202,12 @@ if ex: fname += ex if QFileInfo(fname).exists(): - res = E5MessageBox.yesNo( + res = EricMessageBox.yesNo( self, self.tr("Save Call Stack Info"), self.tr("<p>The file <b>{0}</b> already exists." " Overwrite it?</p>").format(fname), - icon=E5MessageBox.Warning) + icon=EricMessageBox.Warning) if not res: return fname = Utilities.toNativeSeparators(fname) @@ -224,7 +224,7 @@ f.write("{0}\n".format(78 * "=")) itm = self.__callStackList.itemBelow(itm) except OSError as err: - E5MessageBox.critical( + EricMessageBox.critical( self, self.tr("Error saving Call Stack Info"), self.tr("""<p>The call stack info could not be"""
--- a/eric7/Debugger/CallTraceViewer.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/CallTraceViewer.py Sat May 22 18:51:46 2021 +0200 @@ -12,8 +12,8 @@ from PyQt6.QtCore import pyqtSlot, pyqtSignal, Qt, QFileInfo from PyQt6.QtWidgets import QWidget, QTreeWidgetItem -from E5Gui.E5Application import e5App -from E5Gui import E5FileDialog, E5MessageBox +from E5Gui.EricApplication import ericApp +from E5Gui import EricFileDialog, EricMessageBox from .Ui_CallTraceViewer import Ui_CallTraceViewer @@ -152,13 +152,13 @@ Private slot to save the call trace info to a file. """ if self.callTrace.topLevelItemCount() > 0: - fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( + fname, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( self, self.tr("Save Call Trace Info"), "", self.tr("Text Files (*.txt);;All Files (*)"), None, - E5FileDialog.DontConfirmOverwrite) + EricFileDialog.DontConfirmOverwrite) if fname: ext = QFileInfo(fname).suffix() if not ext: @@ -166,12 +166,12 @@ if ex: fname += ex if QFileInfo(fname).exists(): - res = E5MessageBox.yesNo( + res = EricMessageBox.yesNo( self, self.tr("Save Call Trace Info"), self.tr("<p>The file <b>{0}</b> already exists." " Overwrite it?</p>").format(fname), - icon=E5MessageBox.Warning) + icon=EricMessageBox.Warning) if not res: return fname = Utilities.toNativeSeparators(fname) @@ -191,7 +191,7 @@ itm.text(1), itm.text(2))) itm = self.callTrace.itemBelow(itm) except OSError as err: - E5MessageBox.critical( + EricMessageBox.critical( self, self.tr("Error saving Call Trace Info"), self.tr("""<p>The call trace info could not""" @@ -242,7 +242,7 @@ """ self.__projectMode = enabled if enabled and self.__project is None: - self.__project = e5App().getObject("Project") + self.__project = ericApp().getObject("Project") def __addCallTraceInfo(self, isCall, fromFile, fromLine, fromFunction, toFile, toLine, toFunction, debuggerId):
--- a/eric7/Debugger/DebugServer.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/DebugServer.py Sat May 22 18:51:46 2021 +0200 @@ -16,8 +16,8 @@ QTcpServer, QHostAddress, QHostInfo, QNetworkInterface ) -from E5Gui.E5Application import e5App -from E5Gui import E5MessageBox +from E5Gui.EricApplication import ericApp +from E5Gui import EricMessageBox from .BreakPointModel import BreakPointModel from .WatchPointModel import WatchPointModel @@ -353,7 +353,7 @@ @type bool """ if interfaceName in self.__debuggerInterfaces and not reregister: - E5MessageBox.warning( + EricMessageBox.warning( None, self.tr("Register Debugger Interface"), self.tr("""<p>The debugger interface <b>{0}</b> has already""" @@ -534,7 +534,7 @@ self.__forProject = forProject self.__createDebuggerInterface() if forProject: - project = e5App().getObject("Project") + project = ericApp().getObject("Project") if not project.isDebugPropertiesLoaded(): self.clientProcess, isNetworked, clientInterpreter = ( self.debuggerInterface.startRemote( @@ -875,14 +875,14 @@ peerAddress = sock.peerAddress().toString() if peerAddress not in Preferences.getDebugger("AllowedHosts"): # the peer is not allowed to connect - res = E5MessageBox.yesNo( + res = EricMessageBox.yesNo( None, self.tr("Connection from illegal host"), self.tr( """<p>A connection was attempted by the illegal host""" """ <b>{0}</b>. Accept this connection?</p>""") .format(peerAddress), - icon=E5MessageBox.Warning) + icon=EricMessageBox.Warning) if not res: sock.abort() return @@ -993,7 +993,7 @@ if clientType not in self.getSupportedLanguages(): # a not supported client language was requested - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -1061,7 +1061,7 @@ self.__autoClearShell = autoClearShell if clientType not in self.getSupportedLanguages(): - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -1127,7 +1127,7 @@ if clientType not in self.getSupportedLanguages(): # a not supported client language was requested - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -1192,7 +1192,7 @@ if clientType not in self.getSupportedLanguages(): # a not supported client language was requested - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -1560,7 +1560,7 @@ """ if clientType and clientType not in self.getSupportedLanguages(): # a not supported client language was requested - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -1624,7 +1624,7 @@ """ if clientType and clientType not in self.getSupportedLanguages(): # a not supported client language was requested - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr(
--- a/eric7/Debugger/DebugUI.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/DebugUI.py Sat May 22 18:51:46 2021 +0200 @@ -15,8 +15,8 @@ from PyQt6.QtGui import QKeySequence from PyQt6.QtWidgets import QMenu, QToolBar, QApplication, QDialog -from E5Gui.E5Action import E5Action, createActionGroup -from E5Gui import E5MessageBox +from E5Gui.EricAction import EricAction, createActionGroup +from E5Gui import EricMessageBox from UI.Info import Program from UI.NotificationWidget import NotificationTypes @@ -205,7 +205,7 @@ """ self.actions = [] - self.runAct = E5Action( + self.runAct = EricAction( self.tr('Run Script'), UI.PixmapCache.getIcon("runScript"), self.tr('&Run Script...'), @@ -220,7 +220,7 @@ self.runAct.triggered.connect(self.__runScript) self.actions.append(self.runAct) - self.runProjectAct = E5Action( + self.runProjectAct = EricAction( self.tr('Run Project'), UI.PixmapCache.getIcon("runProject"), self.tr('Run &Project...'), @@ -237,7 +237,7 @@ self.runProjectAct.triggered.connect(self.__runProject) self.actions.append(self.runProjectAct) - self.coverageAct = E5Action( + self.coverageAct = EricAction( self.tr('Coverage run of Script'), UI.PixmapCache.getIcon("coverageScript"), self.tr('Coverage run of Script...'), 0, 0, self, @@ -253,7 +253,7 @@ self.coverageAct.triggered.connect(self.__coverageScript) self.actions.append(self.coverageAct) - self.coverageProjectAct = E5Action( + self.coverageProjectAct = EricAction( self.tr('Coverage run of Project'), UI.PixmapCache.getIcon("coverageProject"), self.tr('Coverage run of Project...'), 0, 0, self, @@ -270,7 +270,7 @@ self.coverageProjectAct.triggered.connect(self.__coverageProject) self.actions.append(self.coverageProjectAct) - self.profileAct = E5Action( + self.profileAct = EricAction( self.tr('Profile Script'), UI.PixmapCache.getIcon("profileScript"), self.tr('Profile Script...'), 0, 0, self, 'dbg_profile_script') @@ -283,7 +283,7 @@ self.profileAct.triggered.connect(self.__profileScript) self.actions.append(self.profileAct) - self.profileProjectAct = E5Action( + self.profileProjectAct = EricAction( self.tr('Profile Project'), UI.PixmapCache.getIcon("profileProject"), self.tr('Profile Project...'), 0, 0, self, @@ -299,7 +299,7 @@ self.profileProjectAct.triggered.connect(self.__profileProject) self.actions.append(self.profileProjectAct) - self.debugAct = E5Action( + self.debugAct = EricAction( self.tr('Debug Script'), UI.PixmapCache.getIcon("debugScript"), self.tr('&Debug Script...'), Qt.Key.Key_F5, 0, self, @@ -315,7 +315,7 @@ self.debugAct.triggered.connect(self.__debugScript) self.actions.append(self.debugAct) - self.debugProjectAct = E5Action( + self.debugProjectAct = EricAction( self.tr('Debug Project'), UI.PixmapCache.getIcon("debugProject"), self.tr('Debug &Project...'), @@ -333,7 +333,7 @@ self.debugProjectAct.triggered.connect(self.__debugProject) self.actions.append(self.debugProjectAct) - self.restartAct = E5Action( + self.restartAct = EricAction( self.tr('Restart'), UI.PixmapCache.getIcon("debugRestart"), self.tr('Restart'), Qt.Key.Key_F4, 0, self, 'dbg_restart_script') @@ -349,7 +349,7 @@ self.restartAct.triggered.connect(self.__doRestart) self.actions.append(self.restartAct) - self.stopAct = E5Action( + self.stopAct = EricAction( self.tr('Stop'), UI.PixmapCache.getIcon("stopScript"), self.tr('Stop'), @@ -366,7 +366,7 @@ self.debugActGrp = createActionGroup(self) - act = E5Action( + act = EricAction( self.tr('Continue'), UI.PixmapCache.getIcon("continue"), self.tr('&Continue'), Qt.Key.Key_F6, 0, @@ -382,7 +382,7 @@ act.triggered.connect(self.__continue) self.actions.append(act) - act = E5Action( + act = EricAction( self.tr('Continue to Cursor'), UI.PixmapCache.getIcon("continueToCursor"), self.tr('Continue &To Cursor'), @@ -399,7 +399,7 @@ act.triggered.connect(self.__runToCursor) self.actions.append(act) - act = E5Action( + act = EricAction( self.tr('Continue Until'), UI.PixmapCache.getIcon("continueUntil"), self.tr('Continue &Until'), @@ -418,7 +418,7 @@ act.triggered.connect(self.__runUntil) self.actions.append(act) - act = E5Action( + act = EricAction( self.tr('Move Instruction Pointer to Cursor'), UI.PixmapCache.getIcon("moveInstructionPointer"), self.tr('&Jump To Cursor'), Qt.Key.Key_F12, 0, @@ -438,7 +438,7 @@ act.triggered.connect(self.__moveInstructionPointer) self.actions.append(act) - act = E5Action( + act = EricAction( self.tr('Single Step'), UI.PixmapCache.getIcon("step"), self.tr('Sin&gle Step'), Qt.Key.Key_F7, 0, @@ -454,7 +454,7 @@ act.triggered.connect(self.__step) self.actions.append(act) - act = E5Action( + act = EricAction( self.tr('Step Over'), UI.PixmapCache.getIcon("stepOver"), self.tr('Step &Over'), Qt.Key.Key_F8, 0, @@ -473,7 +473,7 @@ act.triggered.connect(self.__stepOver) self.actions.append(act) - act = E5Action( + act = EricAction( self.tr('Step Out'), UI.PixmapCache.getIcon("stepOut"), self.tr('Step Ou&t'), Qt.Key.Key_F9, 0, @@ -492,7 +492,7 @@ act.triggered.connect(self.__stepOut) self.actions.append(act) - act = E5Action( + act = EricAction( self.tr('Stop'), UI.PixmapCache.getIcon("stepQuit"), self.tr('&Stop'), Qt.Key.Key_F10, 0, @@ -505,7 +505,7 @@ act.triggered.connect(self.__stepQuit) self.actions.append(act) - self.dbgFilterAct = E5Action( + self.dbgFilterAct = EricAction( self.tr('Variables Type Filter'), self.tr('Varia&bles Type Filter...'), 0, 0, self, 'dbg_variables_filter') @@ -521,7 +521,7 @@ self.__configureVariablesFilters) self.actions.append(self.dbgFilterAct) - self.excFilterAct = E5Action( + self.excFilterAct = EricAction( self.tr('Exceptions Filter'), self.tr('&Exceptions Filter...'), 0, 0, self, 'dbg_exceptions_filter') @@ -538,7 +538,7 @@ self.__configureExceptionsFilter) self.actions.append(self.excFilterAct) - self.excIgnoreFilterAct = E5Action( + self.excIgnoreFilterAct = EricAction( self.tr('Ignored Exceptions'), self.tr('&Ignored Exceptions...'), 0, 0, self, 'dbg_ignored_exceptions') @@ -557,7 +557,7 @@ self.dbgSetBpActGrp = createActionGroup(self) - self.dbgToggleBpAct = E5Action( + self.dbgToggleBpAct = EricAction( self.tr('Toggle Breakpoint'), UI.PixmapCache.getIcon("breakpointToggle"), self.tr('Toggle Breakpoint'), @@ -572,7 +572,7 @@ self.dbgToggleBpAct.triggered.connect(self.__toggleBreakpoint) self.actions.append(self.dbgToggleBpAct) - self.dbgEditBpAct = E5Action( + self.dbgEditBpAct = EricAction( self.tr('Edit Breakpoint'), UI.PixmapCache.getIcon("cBreakpointToggle"), self.tr('Edit Breakpoint...'), @@ -587,7 +587,7 @@ self.dbgEditBpAct.triggered.connect(self.__editBreakpoint) self.actions.append(self.dbgEditBpAct) - self.dbgNextBpAct = E5Action( + self.dbgNextBpAct = EricAction( self.tr('Next Breakpoint'), UI.PixmapCache.getIcon("breakpointNext"), self.tr('Next Breakpoint'), @@ -602,7 +602,7 @@ self.dbgNextBpAct.triggered.connect(self.__nextBreakpoint) self.actions.append(self.dbgNextBpAct) - self.dbgPrevBpAct = E5Action( + self.dbgPrevBpAct = EricAction( self.tr('Previous Breakpoint'), UI.PixmapCache.getIcon("breakpointPrevious"), self.tr('Previous Breakpoint'), @@ -617,7 +617,7 @@ self.dbgPrevBpAct.triggered.connect(self.__previousBreakpoint) self.actions.append(self.dbgPrevBpAct) - act = E5Action( + act = EricAction( self.tr('Clear Breakpoints'), self.tr('Clear Breakpoints'), 0, 0, @@ -690,7 +690,7 @@ Public slot to initialize the debug toolbars. @param toolbarManager reference to a toolbar manager object - (E5ToolBarManager) + (EricToolBarManager) @return the generated toolbars (list of QToolBar) """ starttb = QToolBar(self.tr("Start"), self.ui) @@ -1181,7 +1181,7 @@ self.ui.activateWindow() if message is None: - E5MessageBox.critical( + EricMessageBox.critical( self.ui, Program, self.tr( 'The program being debugged contains an unspecified' @@ -1200,7 +1200,7 @@ if os.path.exists(os.path.join(d, filename)): filename = os.path.join(d, filename) self.viewmanager.setFileLine(filename, lineNo, True, True) - E5MessageBox.critical( + EricMessageBox.critical( self.ui, Program, self.tr('<p>The file <b>{0}</b> contains the syntax error' ' <b>{1}</b> at line <b>{2}</b>, character <b>{3}</b>.' @@ -1224,7 +1224,7 @@ self.ui.raise_() QApplication.processEvents() if not exceptionType: - E5MessageBox.critical( + EricMessageBox.critical( self.ui, Program, self.tr('An unhandled exception occured.' ' See the shell window for details.')) @@ -1251,23 +1251,23 @@ lineFlags += Utilities.extractLineFlags( source[line].strip(), flagsLine=True) if "__IGNORE_EXCEPTION__" in lineFlags: - res = E5MessageBox.No - if res != E5MessageBox.No: + res = EricMessageBox.No + if res != EricMessageBox.No: self.viewmanager.setFileLine( stackTrace[0][0], stackTrace[0][1], True) - if res != E5MessageBox.No: + if res != EricMessageBox.No: self.ui.activateWindow() if Preferences.getDebugger("BreakAlways"): - res = E5MessageBox.Yes + res = EricMessageBox.Yes else: if stackTrace: if exceptionType.startswith('unhandled'): - buttons = E5MessageBox.No | E5MessageBox.Yes + buttons = EricMessageBox.No | EricMessageBox.Yes else: - buttons = (E5MessageBox.No | - E5MessageBox.Yes | - E5MessageBox.Ignore) - res = E5MessageBox.critical( + buttons = (EricMessageBox.No | + EricMessageBox.Yes | + EricMessageBox.Ignore) + res = EricMessageBox.critical( self.ui, Program, self.tr( '<p>The debugged program raised the exception' @@ -1280,9 +1280,9 @@ stackTrace[0][0], stackTrace[0][1]), buttons, - E5MessageBox.No) + EricMessageBox.No) else: - res = E5MessageBox.critical( + res = EricMessageBox.critical( self.ui, Program, self.tr( '<p>The debugged program raised the exception' @@ -1290,7 +1290,7 @@ .format( exceptionType, Utilities.html_encode(exceptionMessage))) - if res == E5MessageBox.Yes: + if res == EricMessageBox.Yes: self.debugServer.setDebugging(True) self.exceptionInterrupt.emit() stack = [] @@ -1303,7 +1303,7 @@ self.debugActGrp.setEnabled(True) return elif ( - res == E5MessageBox.Ignore and + res == EricMessageBox.Ignore and exceptionType not in self.excIgnoreList ): self.excIgnoreList.append(exceptionType) @@ -1338,7 +1338,7 @@ self.ui.activateWindow() QApplication.processEvents() self.viewmanager.setFileLine(filename, lineNo, True) - E5MessageBox.critical( + EricMessageBox.critical( self.ui, Program, self.tr("""<p>The program generate the signal "{0}".<br/>""" """File: <b>{1}</b>, Line: <b>{2}</b></p>""").format( @@ -1352,7 +1352,7 @@ """ self.__resetUI() if unplanned: - E5MessageBox.information( + EricMessageBox.information( self.ui, Program, self.tr('The program being debugged has terminated' ' unexpectedly.')) @@ -1459,7 +1459,7 @@ @param debuggerId ID of the debugger backend @type str """ - E5MessageBox.critical( + EricMessageBox.critical( self.ui, self.tr("Breakpoint Condition Error"), self.tr( @@ -1498,7 +1498,7 @@ @param debuggerId ID of the debugger backend @type str """ - E5MessageBox.critical( + EricMessageBox.critical( self.ui, self.tr("Watch Expression Error"), self.tr("""<p>The watch expression <b>{0}</b>""" @@ -1538,7 +1538,7 @@ """ for the variable <b>{1}</b> already""" """ exists.</p>""" ).format(special, Utilities.html_encode(cond)) - E5MessageBox.warning( + EricMessageBox.warning( self.ui, self.tr("Watch expression already exists"), msg) @@ -1707,7 +1707,7 @@ if runProject: fn = self.project.getMainScript(True) if fn is None: - E5MessageBox.critical( + EricMessageBox.critical( self.ui, self.tr("Coverage of Project"), self.tr( @@ -1852,7 +1852,7 @@ if runProject: fn = self.project.getMainScript(True) if fn is None: - E5MessageBox.critical( + EricMessageBox.critical( self.ui, self.tr("Profile of Project"), self.tr( @@ -1996,7 +1996,7 @@ if runProject: fn = self.project.getMainScript(True) if fn is None: - E5MessageBox.critical( + EricMessageBox.critical( self.ui, self.tr("Run Project"), self.tr( @@ -2142,7 +2142,7 @@ if debugProject: fn = self.project.getMainScript(True) if fn is None: - E5MessageBox.critical( + EricMessageBox.critical( self.ui, self.tr("Debug Project"), self.tr( @@ -2554,7 +2554,7 @@ """ Public method to get a list of all actions. - @return list of all actions (list of E5Action) + @return list of all actions (list of EricAction) """ return self.actions[:]
--- a/eric7/Debugger/DebugViewer.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/DebugViewer.py Sat May 22 18:51:46 2021 +0200 @@ -32,7 +32,7 @@ import UI.PixmapCache import Preferences -from E5Gui.E5TabWidget import E5TabWidget +from E5Gui.EricTabWidget import EricTabWidget class DebugViewer(QWidget): @@ -116,7 +116,7 @@ self.__debuggerSelected) # add the tab widget containing various debug related views - self.__tabWidget = E5TabWidget() + self.__tabWidget = EricTabWidget() self.__mainSplitter.addWidget(self.__tabWidget) from .VariablesViewer import VariablesViewer
--- a/eric7/Debugger/DebuggerInterfacePython.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/DebuggerInterfacePython.py Sat May 22 18:51:46 2021 +0200 @@ -17,8 +17,8 @@ QObject, QProcess, QProcessEnvironment, QTimer ) -from E5Gui.E5Application import e5App -from E5Gui import E5MessageBox +from E5Gui.EricApplication import ericApp +from E5Gui import EricMessageBox from . import DebugClientCapabilities @@ -180,14 +180,14 @@ if not venvName: venvName = Preferences.getDebugger("Python3VirtualEnv") - venvManager = e5App().getObject("VirtualEnvManager") + venvManager = ericApp().getObject("VirtualEnvManager") interpreter = venvManager.getVirtualenvInterpreter(venvName) execPath = venvManager.getVirtualenvExecPath(venvName) if interpreter == "": # use the interpreter used to run eric for identical variants interpreter = sys.executable.replace("w.exe", ".exe") if interpreter == "": - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -247,7 +247,7 @@ process = self.__startProcess(args[0], args[1:], workingDir=workingDir) if process is None: - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -305,7 +305,7 @@ process = self.__startProcess(args[0], args[1:], clientEnv, workingDir=workingDir) if process is None: - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -323,7 +323,7 @@ workingDir=workingDir) if process is None: self.__startedVenv = "" - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -359,7 +359,7 @@ """ global origPathEnv - project = e5App().getObject("Project") + project = ericApp().getObject("Project") if not project.isDebugPropertiesLoaded(): return None, self.__isNetworked, "" @@ -383,7 +383,7 @@ else '' ) - venvManager = e5App().getObject("VirtualEnvManager") + venvManager = ericApp().getObject("VirtualEnvManager") interpreter = venvManager.getVirtualenvInterpreter(venvName) execPath = venvManager.getVirtualenvExecPath(venvName) if ( @@ -392,7 +392,7 @@ ): interpreter = sys.executable.replace("w.exe", ".exe") if interpreter == "": - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -428,7 +428,7 @@ process = self.__startProcess(args[0], args[1:], workingDir=workingDir) if process is None: - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -488,7 +488,7 @@ process = self.__startProcess(args[0], args[1:], clientEnv, workingDir=workingDir) if process is None: - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -506,7 +506,7 @@ workingDir=workingDir) if process is None: self.__startedVenv = "" - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Start Debugger"), self.tr( @@ -1344,7 +1344,7 @@ try: commandDict = json.loads(jsonStr.strip()) except (TypeError, ValueError) as err: - E5MessageBox.critical( + EricMessageBox.critical( None, self.tr("Debug Protocol Error"), self.tr("""<p>The response received from the debugger""" @@ -1354,7 +1354,7 @@ """<p>Error: {0}</p>""" """<p>Data:<br/>{1}</p>""").format( str(err), Utilities.html_encode(jsonStr.strip())), - E5MessageBox.Ok) + EricMessageBox.Ok) return method = commandDict["method"]
--- a/eric7/Debugger/EditBreakpointDialog.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/EditBreakpointDialog.py Sat May 22 18:51:46 2021 +0200 @@ -11,7 +11,7 @@ from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QComboBox -from E5Gui.E5PathPicker import E5PathPickerModes +from E5Gui.EricPathPicker import EricPathPickerModes from .Ui_EditBreakpointDialog import Ui_EditBreakpointDialog @@ -43,7 +43,7 @@ self.setObjectName(name) self.setModal(modal) - self.filenamePicker.setMode(E5PathPickerModes.OPEN_FILE_MODE) + self.filenamePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) self.filenamePicker.setSizeAdjustPolicy( QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
--- a/eric7/Debugger/EditBreakpointDialog.ui Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/EditBreakpointDialog.ui Sat May 22 18:51:46 2021 +0200 @@ -25,7 +25,7 @@ </widget> </item> <item row="0" column="1" colspan="2"> - <widget class="E5ComboPathPicker" name="filenamePicker" native="true"> + <widget class="EricComboPathPicker" name="filenamePicker" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -173,9 +173,9 @@ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> <customwidgets> <customwidget> - <class>E5ComboPathPicker</class> + <class>EricComboPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/E5PathPicker.h</header> + <header>E5Gui/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Debugger/ExceptionLogger.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/ExceptionLogger.py Sat May 22 18:51:46 2021 +0200 @@ -12,7 +12,7 @@ from PyQt6.QtCore import pyqtSignal, Qt from PyQt6.QtWidgets import QTreeWidget, QTreeWidgetItem, QMenu -from E5Gui.E5Application import e5App +from E5Gui.EricApplication import ericApp class ExceptionLogger(QTreeWidget): @@ -150,5 +150,5 @@ """ Private method to open the configuration dialog. """ - e5App().getObject("UserInterface").showPreferences( + ericApp().getObject("UserInterface").showPreferences( "debuggerGeneralPage")
--- a/eric7/Debugger/StartCoverageDialog.ui Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/StartCoverageDialog.ui Sat May 22 18:51:46 2021 +0200 @@ -99,7 +99,7 @@ </widget> </item> <item row="2" column="1"> - <widget class="E5ComboPathPicker" name="workdirPicker" native="true"> + <widget class="EricComboPathPicker" name="workdirPicker" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -271,9 +271,9 @@ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> <customwidgets> <customwidget> - <class>E5ComboPathPicker</class> + <class>EricComboPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/E5PathPicker.h</header> + <header>E5Gui/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Debugger/StartDebugDialog.ui Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/StartDebugDialog.ui Sat May 22 18:51:46 2021 +0200 @@ -96,7 +96,7 @@ </widget> </item> <item row="2" column="1"> - <widget class="E5ComboPathPicker" name="workdirPicker" native="true"> + <widget class="EricComboPathPicker" name="workdirPicker" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -336,9 +336,9 @@ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> <customwidgets> <customwidget> - <class>E5ComboPathPicker</class> + <class>EricComboPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/E5PathPicker.h</header> + <header>E5Gui/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Debugger/StartDialog.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/StartDialog.py Sat May 22 18:51:46 2021 +0200 @@ -11,8 +11,8 @@ from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QComboBox, QInputDialog -from E5Gui.E5PathPicker import E5PathPickerModes -from E5Gui.E5Application import e5App +from E5Gui.EricPathPicker import EricPathPickerModes +from E5Gui.EricApplication import ericApp import Preferences @@ -99,10 +99,10 @@ self.ui.venvComboBox.addItem("") self.ui.venvComboBox.addItems( - sorted(e5App().getObject("VirtualEnvManager") + sorted(ericApp().getObject("VirtualEnvManager") .getVirtualenvNames())) - self.ui.workdirPicker.setMode(E5PathPickerModes.DIRECTORY_MODE) + self.ui.workdirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) self.ui.workdirPicker.setDefaultDirectory( Preferences.getMultiProject("Workspace")) self.ui.workdirPicker.setInsertPolicy(
--- a/eric7/Debugger/StartHistoryEditDialog.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/StartHistoryEditDialog.py Sat May 22 18:51:46 2021 +0200 @@ -10,7 +10,7 @@ from PyQt6.QtCore import pyqtSlot, Qt from PyQt6.QtWidgets import QDialog, QInputDialog, QLineEdit -from E5Gui import E5MessageBox +from E5Gui import EricMessageBox from .Ui_StartHistoryEditDialog import Ui_StartHistoryEditDialog @@ -75,7 +75,7 @@ """ Private slot to delete the selected entries. """ - yes = E5MessageBox.yesNo( + yes = EricMessageBox.yesNo( self, self.tr("Delete Selected Entries"), self.tr("""Do you really want to delete the selected""" @@ -91,7 +91,7 @@ """ Private slot to delete all entries. """ - yes = E5MessageBox.yesNo( + yes = EricMessageBox.yesNo( self, self.tr("Delete All Entries"), self.tr("""Do you really want to delete the shown history?"""))
--- a/eric7/Debugger/StartProfileDialog.ui Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/StartProfileDialog.ui Sat May 22 18:51:46 2021 +0200 @@ -96,7 +96,7 @@ </widget> </item> <item row="2" column="1"> - <widget class="E5ComboPathPicker" name="workdirPicker" native="true"> + <widget class="EricComboPathPicker" name="workdirPicker" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -268,9 +268,9 @@ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> <customwidgets> <customwidget> - <class>E5ComboPathPicker</class> + <class>EricComboPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/E5PathPicker.h</header> + <header>E5Gui/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Debugger/StartRunDialog.ui Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/StartRunDialog.ui Sat May 22 18:51:46 2021 +0200 @@ -96,7 +96,7 @@ </widget> </item> <item row="2" column="1"> - <widget class="E5ComboPathPicker" name="workdirPicker" native="true"> + <widget class="EricComboPathPicker" name="workdirPicker" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -251,9 +251,9 @@ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> <customwidgets> <customwidget> - <class>E5ComboPathPicker</class> + <class>EricComboPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/E5PathPicker.h</header> + <header>E5Gui/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Debugger/VariablesViewer.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/VariablesViewer.py Sat May 22 18:51:46 2021 +0200 @@ -18,7 +18,7 @@ from PyQt6.QtGui import QBrush, QFontMetrics from PyQt6.QtWidgets import QTreeView, QAbstractItemView, QToolTip, QMenu -from E5Gui.E5Application import e5App +from E5Gui.EricApplication import ericApp from .Config import ConfigVarTypeDispStrings from DebugClients.Python.DebugConfig import ConfigQtNames, ConfigKnownQtTypes @@ -778,10 +778,10 @@ # step 3: get a pathlist up to the requested variable pathlist = self.__buildTreePath(node) # step 4: request the variable from the debugger - variablesFilter = e5App().getObject("DebugUI").variablesFilter( + variablesFilter = ericApp().getObject("DebugUI").variablesFilter( self.__globalScope) - e5App().getObject("DebugServer").remoteClientVariable( - e5App().getObject("DebugUI").getSelectedDebuggerId(), + ericApp().getObject("DebugServer").remoteClientVariable( + ericApp().getObject("DebugUI").getSelectedDebuggerId(), self.__globalScope, variablesFilter, pathlist, self.framenr) def setExpanded(self, index, state): @@ -1194,14 +1194,14 @@ """ Private method to open the configuration dialog. """ - e5App().getObject("UserInterface").showPreferences( + ericApp().getObject("UserInterface").showPreferences( "debuggerGeneralPage") def __configureFilter(self): """ Private method to open the variables filter dialog. """ - e5App().getObject("DebugUI").dbgFilterAct.triggered.emit() + ericApp().getObject("DebugUI").dbgFilterAct.triggered.emit() # # eflag: noqa = M822
--- a/eric7/Debugger/WatchPointViewer.py Sat May 22 17:01:51 2021 +0200 +++ b/eric7/Debugger/WatchPointViewer.py Sat May 22 18:51:46 2021 +0200 @@ -14,8 +14,8 @@ QTreeView, QAbstractItemView, QMenu, QHeaderView, QDialog ) -from E5Gui.E5Application import e5App -from E5Gui import E5MessageBox +from E5Gui.EricApplication import ericApp +from E5Gui import EricMessageBox import Utilities @@ -249,7 +249,7 @@ """<p>A watch expression '<b>{0}</b>'""" """ for the variable <b>{1}</b> already exists.</p>""" ).format(special, Utilities.html_encode(cond)) - E5MessageBox.warning( + EricMessageBox.warning( self, self.tr("Watch expression already exists"), msg) @@ -443,5 +443,5 @@ """ Private method to open the configuration dialog. """ - e5App().getObject("UserInterface").showPreferences( + ericApp().getObject("UserInterface").showPreferences( "debuggerGeneralPage")
--- a/eric7/E5Gui/E5Action.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,223 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2006 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing an Action class extending QAction. - -This extension is necessary in order to support alternate keyboard -shortcuts. -""" - -from PyQt6.QtGui import QIcon, QKeySequence, QAction, QActionGroup - -from E5Gui.E5Application import e5App - - -class ArgumentsError(RuntimeError): - """ - Class implementing an exception, which is raised, if the wrong number of - arguments are given. - """ - def __init__(self, error): - """ - Constructor - - @param error error message of the exception (string) - """ - self.errorMessage = str(error) - - def __repr__(self): - """ - Special method returning a representation of the exception. - - @return string representing the error message - """ - return str(self.errorMessage) - - def __str__(self): - """ - Special method returning a string representation of the exception. - - @return string representing the error message - """ - return str(self.errorMessage) - - -class E5Action(QAction): - """ - Class implementing an Action class extending QAction. - """ - def __init__(self, *args): - """ - Constructor - - @param args argument list of the constructor. This list is one of - <ul> - <li>text (string), icon (QIcon), menu text (string), - accelarator (QKeySequence), alternative accelerator - (QKeySequence), parent (QObject), name (string), toggle - (boolean)</li> - <li>text (string), icon (QIcon), menu text (string), - accelarator (QKeySequence), alternative accelerator - (QKeySequence), parent (QObject), name (string)</li> - <li>text (string), menu text (string), - accelarator (QKeySequence), alternative accelerator - (QKeySequence), parent (QObject), name (string), toggle - (boolean)</li> - <li>text (string), menu text (string), - accelarator (QKeySequence), alternative accelerator - (QKeySequence), parent (QObject), name (string)</li> - </ul> - @exception ArgumentsError raised to indicate invalid arguments - """ - if isinstance(args[1], QIcon): - icon = args[1] - incr = 1 - else: - icon = None - incr = 0 - if len(args) < 6 + incr: - raise ArgumentsError( - "Not enough arguments, {0:d} expected, got {1:d}".format( - 6 + incr, len(args))) - elif len(args) > 7 + incr: - raise ArgumentsError( - "Too many arguments, max. {0:d} expected, got {1:d}".format( - 7 + incr, len(args))) - - parent = args[4 + incr] - super().__init__(parent) - name = args[5 + incr] - if name: - self.setObjectName(name) - - if args[1 + incr]: - self.setText(args[1 + incr]) - - if args[0]: - self.setIconText(args[0]) - if args[2 + incr]: - self.setShortcut(QKeySequence(args[2 + incr])) - - if args[3 + incr]: - self.setAlternateShortcut(QKeySequence(args[3 + incr])) - - if icon: - self.setIcon(icon) - - if len(args) == 7 + incr: - self.setCheckable(args[6 + incr]) - - self.__ammendToolTip() - - def setAlternateShortcut(self, shortcut, removeEmpty=False): - """ - Public slot to set the alternative keyboard shortcut. - - @param shortcut the alternative accelerator (QKeySequence) - @param removeEmpty flag indicating to remove the alternate shortcut, - if it is empty (boolean) - """ - if not shortcut.isEmpty(): - shortcuts = self.shortcuts() - if len(shortcuts) > 0: - if len(shortcuts) == 1: - shortcuts.append(shortcut) - else: - shortcuts[1] = shortcut - self.setShortcuts(shortcuts) - elif removeEmpty: - shortcuts = self.shortcuts() - if len(shortcuts) == 2: - del shortcuts[1] - self.setShortcuts(shortcuts) - - def alternateShortcut(self): - """ - Public method to retrieve the alternative keyboard shortcut. - - @return the alternative accelerator (QKeySequence) - """ - shortcuts = self.shortcuts() - if len(shortcuts) < 2: - return QKeySequence() - else: - return shortcuts[1] - - def setShortcut(self, shortcut): - """ - Public slot to set the keyboard shortcut. - - @param shortcut the accelerator (QKeySequence) - """ - super().setShortcut(shortcut) - self.__ammendToolTip() - - def setShortcuts(self, shortcuts): - """ - Public slot to set the list of keyboard shortcuts. - - @param shortcuts list of keyboard accelerators (list of QKeySequence) - or key for a platform dependent list of accelerators - (QKeySequence.StandardKey) - """ - super().setShortcuts(shortcuts) - self.__ammendToolTip() - - def setIconText(self, text): - """ - Public slot to set the icon text of the action. - - @param text new icon text (string) - """ - super().setIconText(text) - self.__ammendToolTip() - - def __ammendToolTip(self): - """ - Private slot to add the primary keyboard accelerator to the tooltip. - """ - shortcut = self.shortcut().toString( - QKeySequence.SequenceFormat.NativeText) - if shortcut: - if e5App().isLeftToRight(): - fmt = "{0} ({1})" - else: - fmt = "({1}) {0}" - self.setToolTip(fmt.format(self.iconText(), shortcut)) - - -def addActions(target, actions): - """ - Module function to add a list of actions to a widget. - - @param target reference to the target widget (QWidget) - @param actions list of actions to be added to the target. A - None indicates a separator (list of QActions) - """ - if target is None: - return - - for action in actions: - if action is None: - target.addSeparator() - else: - target.addAction(action) - - -def createActionGroup(parent, name=None, exclusive=False): - """ - Module function to create an action group. - - @param parent parent object of the action group (QObject) - @param name name of the action group object (string) - @param exclusive flag indicating an exclusive action group (boolean) - @return reference to the created action group (QActionGroup) - """ - actGrp = QActionGroup(parent) - if name: - actGrp.setObjectName(name) - actGrp.setExclusive(exclusive) - return actGrp
--- a/eric7/E5Gui/E5AnimatedLabel.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2020 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a label widget showing an animated pixmap. -""" - -from PyQt6.QtCore import pyqtSlot, QTimer -from PyQt6.QtGui import QPixmap -from PyQt6.QtWidgets import QLabel - -import UI.PixmapCache - - -class E5AnimatedLabel(QLabel): - """ - Class implementing a label widget showing an animated pixmap. - """ - def __init__(self, parent=None, *, animationFile="", interval=100): - """ - Constructor - - @param parent reference to the parent window - @type QWidget - @keyparam animationFile path to the file containing the animation data - @type str - @keyparam interval interval in milliseconds between animation frames - @type int - """ - super().__init__(parent) - - self.__timer = QTimer(self) - self.__timer.setInterval(interval) - self.__timer.timeout.connect(self.__animate) - - self.__currentFrame = 0 - self.__frames = 0 - self.__pixmap = None - self.__pixmapHeight = 0 - self.__animationFile = "" - self.__animationFileLoaded = False - - self.__loadAnimationFile(animationFile) - - def __loadAnimationFile(self, animationFile): - """ - Private method to load an animation file. - - @param animationFile path to the file containing the animation data - @type str - """ - self.__animationFile = animationFile - - pixmap = UI.PixmapCache.getPixmap(animationFile) - if not pixmap.isNull(): - self.__pixmap = pixmap - self.__pixmapHeight = pixmap.height() - self.__frames = pixmap.width() // pixmap.height() - # assume quadratic animation frames - self.__animationFileLoaded = True - else: - self.__pixmap = QPixmap() - self.__pixmapHeight = 0 - self.__frames = 0 - self.__animationFileLoaded = False - - self.reset() - - @pyqtSlot() - def __animate(self): - """ - Private slot to animate the pixmap. - """ - if self.__animationFileLoaded: - self.__currentFrame = (self.__currentFrame + 1) % self.__frames - super().setPixmap(self.__pixmap.copy( - self.__currentFrame * self.__pixmapHeight, - 0, - self.__pixmapHeight, - self.__pixmapHeight - )) - else: - self.clear() - - @pyqtSlot() - def reset(self): - """ - Public slot to reset the animation. - """ - self.__currentFrame = -1 - self.__animate() - - @pyqtSlot() - def start(self): - """ - Public slot to start the animation. - """ - if self.__animationFileLoaded: - self.__timer.start() - - @pyqtSlot() - def stop(self): - """ - Public slot to stop the animation. - """ - self.__timer.stop() - - def isActive(self): - """ - Public method to check, if the animation is active. - - @return flag indicating an active animation - @rtype bool - """ - return self.__timer.isActive() and self.__animationFileLoaded - - def setAnimationFile(self, animationFile): - """ - Public method to set the name of the animation file. - - @param animationFile path to the file containing the animation data - @type str - """ - active = self.__timer.isActive() - self.__timer.stop() - self.__loadAnimationFile(animationFile) - if active and self.__animationFileLoaded: - self.__timer.start() - - def getAnimationFile(self): - """ - Public method to get the name of the animation file. - - @return path to the file containing the animation data - @rtype str - """ - return self.__animationFile - - def isAnimationFileLoaded(self): - """ - Public method to check, if the animation file was loaded. - - @return flag indicating a successfully loaded animation file - @rtype bool - """ - return self.__animationFileLoaded - - def setInterval(self, interval): - """ - Public method to set the interval between the animated frames. - - @param interval interval in milliseconds between animation frames - @type int - """ - self.__timer.setInterval(interval) - - def getInterval(self): - """ - Public method to get the interval between the animated frames. - - @return interval in milliseconds between animation frames - @rtype int - """ - return self.__timer.interval() - - def setPixmap(self, pixmap): - """ - Public slot to set the pixmap of the label. - - Setting a standard pixmap will stop the animation and set the given - pixmap without animating it. Thereafter the animation has to be - restarted with the start() method. - - @param pixmap pixmap to be set - @type QPixmap - """ - self.stop() - super().setPixmap(pixmap)
--- a/eric7/E5Gui/E5AnimatedWidget.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing an animated widget. -""" - -# -# Code was inspired by qupzilla web browser -# - -from PyQt6.QtCore import pyqtSlot, QTimeLine, QPoint -from PyQt6.QtWidgets import QWidget - - -class E5AnimatedWidget(QWidget): - """ - Class implementing an animated widget. - """ - DirectionDown = 0 - DirectionUp = 1 - - def __init__(self, direction=DirectionDown, duration=300, parent=None): - """ - Constructor - - @param direction direction of the animation - @type int (one of DirectionDown or DirectionUp) - @param duration duration of the animation - @type int - @param parent reference to the parent widget - @type QWidget - """ - super().__init__(parent) - - self.__direction = direction - self.__stepHeight = 0.0 - self.__stepY = 0.0 - self.__startY = 0 - self.__widget = QWidget(self) - - self.__timeline = QTimeLine(duration) - self.__timeline.setFrameRange(0, 100) - self.__timeline.frameChanged.connect(self.__animateFrame) - - self.setMaximumHeight(0) - - def widget(self): - """ - Public method to get a reference to the animated widget. - - @return reference to the animated widget - @rtype QWidget - """ - return self.__widget - - @pyqtSlot() - def startAnimation(self): - """ - Public slot to start the animation. - """ - if self.__timeline.state() == QTimeLine.State.Running: - return - - shown = 0 - hidden = 0 - - if self.__direction == self.DirectionDown: - shown = 0 - hidden = -self.__widget.height() - - self.__widget.move(QPoint(self.__widget.pos().x(), hidden)) - - self.__stepY = (hidden - shown) / 100.0 - self.__startY = hidden - self.__stepHeight = self.__widget.height() / 100.0 - - self.__timeline.setDirection(QTimeLine.Direction.Forward) - self.__timeline.start() - - @pyqtSlot(int) - def __animateFrame(self, frame): - """ - Private slot to animate the next frame. - - @param frame frame number - @type int - """ - self.setFixedHeight(frame * self.__stepHeight) - self.__widget.move(self.pos().x(), - self.__startY - frame * self.__stepY) - - @pyqtSlot() - def hide(self): - """ - Public slot to hide the animated widget. - """ - if self.__timeline.state() == QTimeLine.State.Running: - return - - self.__timeline.setDirection(QTimeLine.Direction.Backward) - self.__timeline.finished.connect(self.close) - self.__timeline.start() - - p = self.parentWidget() - if p is not None: - p.setFocus() - - def resizeEvent(self, evt): - """ - Protected method to handle a resize event. - - @param evt reference to the event object - @type QResizeEvent - """ - if evt.size().width() != self.__widget.width(): - self.__widget.resize(evt.size().width(), self.__widget.height()) - - super().resizeEvent(evt)
--- a/eric7/E5Gui/E5Application.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,152 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2009 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Class implementing a specialized application class. -""" - -from PyQt6.QtCore import Qt, QCoreApplication -from PyQt6.QtGui import QPalette -from PyQt6.QtWidgets import QApplication - -QCoreApplication.setAttribute( - Qt.ApplicationAttribute.AA_ShareOpenGLContexts, True) - - -class E5Application(QApplication): - """ - Eric application class with an object registry. - """ - def __init__(self, argv): - """ - Constructor - - @param argv command line arguments - @type list - """ - super().__init__(argv) - - QCoreApplication.setAttribute( - Qt.ApplicationAttribute.AA_DontCreateNativeWidgetSiblings, True) - - self.__objectRegistry = {} - self.__pluginObjectRegistry = {} - - def registerObject(self, name, objectRef): - """ - Public method to register an object in the object registry. - - @param name name of the object - @type str - @param objectRef reference to the object - @type any - @exception KeyError raised when the given name is already in use - """ - if name in self.__objectRegistry: - raise KeyError('Object "{0}" already registered.'.format(name)) - else: - self.__objectRegistry[name] = objectRef - - def getObject(self, name): - """ - Public method to get a reference to a registered object. - - @param name name of the object - @type str - @return reference to the registered object - @rtype any - @exception KeyError raised when the given name is not known - """ - if name not in self.__objectRegistry: - raise KeyError('Object "{0}" is not registered.'.format(name)) - - return self.__objectRegistry[name] - - def registerPluginObject(self, name, objectRef, pluginType=None): - """ - Public method to register a plugin object in the object registry. - - @param name name of the plugin object - @type str - @param objectRef reference to the plugin object - @type any - @param pluginType type of the plugin object - @type str - @exception KeyError raised when the given name is already in use - """ - if name in self.__pluginObjectRegistry: - raise KeyError( - 'Pluginobject "{0}" already registered.'.format(name)) - else: - self.__pluginObjectRegistry[name] = (objectRef, pluginType) - - def unregisterPluginObject(self, name): - """ - Public method to unregister a plugin object in the object registry. - - @param name name of the plugin object - @type str - """ - if name in self.__pluginObjectRegistry: - del self.__pluginObjectRegistry[name] - - def getPluginObject(self, name): - """ - Public method to get a reference to a registered plugin object. - - @param name name of the plugin object - @type str - @return reference to the registered plugin object - @rtype any - @exception KeyError raised when the given name is not known - """ - if name not in self.__pluginObjectRegistry: - raise KeyError( - 'Pluginobject "{0}" is not registered.'.format(name)) - - return self.__pluginObjectRegistry[name][0] - - def getPluginObjects(self): - """ - Public method to get a list of (name, reference) pairs of all - registered plugin objects. - - @return list of (name, reference) pairs - @rtype list of (str, any) - """ - objects = [] - for name in self.__pluginObjectRegistry: - objects.append((name, self.__pluginObjectRegistry[name][0])) - return objects - - def getPluginObjectType(self, name): - """ - Public method to get the type of a registered plugin object. - - @param name name of the plugin object - @type str - @return type of the plugin object - @rtype str - @exception KeyError raised when the given name is not known - """ - if name not in self.__pluginObjectRegistry: - raise KeyError( - 'Pluginobject "{0}" is not registered.'.format(name)) - - return self.__pluginObjectRegistry[name][1] - - def usesDarkPalette(self): - """ - Public method to check, if the application uses a palette with a dark - background. - - @return flag indicating the use of a palette with a dark background - @rtype bool - """ - palette = self.palette() - lightness = palette.color(QPalette.ColorRole.Window).lightness() - return lightness <= 128 - -e5App = QCoreApplication.instance
--- a/eric7/E5Gui/E5ClickableLabel.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a clickable label. -""" - -from PyQt6.QtCore import pyqtSignal, Qt, QPoint -from PyQt6.QtWidgets import QLabel - - -class E5ClickableLabel(QLabel): - """ - Class implementing a clickable label. - - @signal clicked(QPoint) emitted upon a click on the label - with the left button - @signal middleClicked(QPoint) emitted upon a click on the label - with the middle button or CTRL and left button - """ - clicked = pyqtSignal(QPoint) - middleClicked = pyqtSignal(QPoint) - - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - - self.setCursor(Qt.CursorShape.PointingHandCursor) - - def mouseReleaseEvent(self, evt): - """ - Protected method handling mouse release events. - - @param evt mouse event (QMouseEvent) - """ - if ( - evt.button() == Qt.MouseButton.LeftButton and - self.rect().contains(evt.position().toPoint()) - ): - if evt.modifiers() == Qt.KeyboardModifier.ControlModifier: - self.middleClicked.emit(evt.globalPosition().toPoint()) - else: - self.clicked.emit(evt.globalPosition().toPoint()) - elif ( - evt.button() == Qt.MouseButton.MiddleButton and - self.rect().contains(evt.position().toPoint()) - ): - self.middleClicked.emit(evt.globalPosition().toPoint()) - else: - super().mouseReleaseEvent(evt)
--- a/eric7/E5Gui/E5ComboSelectionDialog.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a dialog to select one entry from a list of strings. -""" - -from PyQt6.QtCore import pyqtSlot -from PyQt6.QtWidgets import QDialog, QDialogButtonBox - -from .Ui_E5ComboSelectionDialog import Ui_E5ComboSelectionDialog - - -class E5ComboSelectionDialog(QDialog, Ui_E5ComboSelectionDialog): - """ - Class implementing a dialog to select one entry from a list of strings. - """ - def __init__(self, entries, title="", message="", parent=None): - """ - Constructor - - @param entries list of entries to select from - @type list of str or list of tuples of (str, any) - @param title title of the dialog (defaults to "") - @type str (optional) - @param message message to be show in the dialog (defaults to "") - @type str (optional) - @param parent reference to the parent widget (defaults to None) - @type QWidget (optional) - """ - super().__init__(parent) - self.setupUi(self) - - for entry in entries: - if isinstance(entry, tuple): - self.selectionComboBox.addItem(*entry) - else: - self.selectionComboBox.addItem(entry) - - self.on_selectionComboBox_currentTextChanged( - self.selectionComboBox.itemText(0)) - - msh = self.minimumSizeHint() - self.resize(max(self.width(), msh.width()), msh.height()) - - @pyqtSlot(str) - def on_selectionComboBox_currentTextChanged(self, txt): - """ - Private slot to react upon changes of the selected entry. - - @param txt text of the selected entry - @type str - """ - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt)) - - def getSelection(self): - """ - Public method to retrieve the selected item and its data. - - @return tuple containing the selected entry and its associated data - @rtype tuple of (str, any) - """ - return ( - self.selectionComboBox.currentText(), - self.selectionComboBox.currentData() - )
--- a/eric7/E5Gui/E5ComboSelectionDialog.ui Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>E5ComboSelectionDialog</class> - <widget class="QDialog" name="E5ComboSelectionDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>100</height> - </rect> - </property> - <property name="windowTitle"> - <string>Select from List</string> - </property> - <property name="sizeGripEnabled"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="messageLabel"> - <property name="text"> - <string>Select from the list below:</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="selectionComboBox"/> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>E5ComboSelectionDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>E5ComboSelectionDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui>
--- a/eric7/E5Gui/E5Completers.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,156 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2007 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing various kinds of completers. -""" - -import os - -from PyQt6.QtCore import QDir, Qt, QStringListModel -from PyQt6.QtGui import QFileSystemModel -from PyQt6.QtWidgets import QCompleter - -from Globals import isWindowsPlatform - - -class E5FileCompleter(QCompleter): - """ - Class implementing a completer for file names. - """ - def __init__(self, parent=None, - completionMode=QCompleter.CompletionMode.PopupCompletion, - showHidden=False): - """ - Constructor - - @param parent parent widget of the completer (QWidget) - @param completionMode completion mode of the - completer (QCompleter.CompletionMode) - @param showHidden flag indicating to show hidden entries as well - (boolean) - """ - super().__init__(parent) - self.__model = QFileSystemModel(self) - if showHidden: - self.__model.setFilter( - QDir.Filter.Dirs | - QDir.Filter.Files | - QDir.Filter.Drives | - QDir.Filter.AllDirs | - QDir.Filter.Hidden) - else: - self.__model.setFilter( - QDir.Filter.Dirs | - QDir.Filter.Files | - QDir.Filter.Drives | - QDir.Filter.AllDirs) - self.__model.setRootPath("") - self.setModel(self.__model) - self.setCompletionMode(completionMode) - if isWindowsPlatform(): - self.setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive) - if parent: - parent.setCompleter(self) - - def setRootPath(self, path): - """ - Public method to set the root path of the model. - - @param path root path for the model - @type str - """ - if not os.path.isdir(path): - path = os.path.dirname(path) - self.__model.setRootPath(path) - - def rootPath(self): - """ - Public method to get the root path of the model. - - @return root path of the model - @rtype str - """ - return self.__model.rootPath() - - -class E5DirCompleter(QCompleter): - """ - Class implementing a completer for directory names. - """ - def __init__(self, parent=None, - completionMode=QCompleter.CompletionMode.PopupCompletion, - showHidden=False): - """ - Constructor - - @param parent parent widget of the completer (QWidget) - @param completionMode completion mode of the - completer (QCompleter.CompletionMode) - @param showHidden flag indicating to show hidden entries as well - (boolean) - """ - super().__init__(parent) - self.__model = QFileSystemModel(self) - if showHidden: - self.__model.setFilter( - QDir.Filter.Drives | - QDir.Filter.AllDirs | - QDir.Filter.Hidden) - else: - self.__model.setFilter( - QDir.Filter.Drives | QDir.Filter.AllDirs) - self.__model.setRootPath("") - self.setModel(self.__model) - self.setCompletionMode(completionMode) - if isWindowsPlatform(): - self.setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive) - if parent: - parent.setCompleter(self) - - def setRootPath(self, path): - """ - Public method to set the root path of the model. - - @param path root path for the model - @type str - """ - if not os.path.isdir(path): - path = os.path.dirname(path) - self.__model.setRootPath(path) - - def rootPath(self): - """ - Public method to get the root path of the model. - - @return root path of the model - @rtype str - """ - return self.__model.rootPath() - - -class E5StringListCompleter(QCompleter): - """ - Class implementing a completer for string lists. - """ - def __init__(self, parent=None, strings=None, - completionMode=QCompleter.CompletionMode.PopupCompletion): - """ - Constructor - - @param parent parent widget of the completer (QWidget) - @param strings list of string to load into the completer - (list of strings) - @param completionMode completion mode of the - completer (QCompleter.CompletionMode) - """ - super().__init__(parent) - self.__model = QStringListModel( - [] if strings is None else strings[:], - parent) - self.setModel(self.__model) - self.setCompletionMode(completionMode) - if parent: - parent.setCompleter(self)
--- a/eric7/E5Gui/E5ErrorMessage.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,220 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2013 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a specialized error message dialog. -""" - -import contextlib - -from PyQt6.QtCore import ( - qInstallMessageHandler, Qt, Q_ARG, QSettings, QtMsgType, QThread, - QMetaObject -) -from PyQt6.QtWidgets import QErrorMessage, QDialog - -from E5Gui.E5Application import e5App - -import Globals -import Utilities -import Preferences - - -_msgHandlerDialog = None -_origMsgHandler = None - -_filterSettings = QSettings( - QSettings.Format.IniFormat, - QSettings.Scope.UserScope, - Globals.settingsNameOrganization, - "eric7messagefilters") -_defaultFilters = [ - "QFont::", - "QCocoaMenu::removeMenuItem", - "QCocoaMenu::insertNative", - ",type id:", - "Remote debugging server started successfully", - "Uncaught SecurityError:", - "Content Security Policy", - "QXcbClipboard:", - "QXcbConnection: XCB error", - "libpng warning: iCCP:", - "Uncaught ReferenceError: $ is not defined", -] - - -def filterMessage(message): - """ - Module function to filter messages. - - @param message message to be checked - @type str - @return flag indicating that the message should be filtered out - @rtype bool - """ - return any( - filterStr in message - for filterStr in Globals.toList(_filterSettings.value( - "MessageFilters", [])) + _defaultFilters - ) - - -class E5ErrorMessage(QErrorMessage): - """ - Class implementing a specialized error message dialog. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget - @type QWidget - """ - super().__init__(parent) - - def showMessage(self, message, msgType=""): - """ - Public method to show a message. - - @param message error message to be shown - @type str - @param msgType type of the error message - @type str - """ - if not filterMessage(message): - if msgType: - super().showMessage(message, msgType) - else: - super().showMessage(message) - - def editMessageFilters(self): - """ - Public method to edit the list of message filters. - """ - from .E5ErrorMessageFilterDialog import E5ErrorMessageFilterDialog - dlg = E5ErrorMessageFilterDialog( - Globals.toList(_filterSettings.value( - "MessageFilters", []))) - if dlg.exec() == QDialog.DialogCode.Accepted: - filters = dlg.getFilters() - _filterSettings.setValue("MessageFilters", filters) - - -def messageHandler(msgType, context, message): - """ - Module function handling messages. - - @param msgType type of the message - @type int, QtMsgType - @param context context information - @type QMessageLogContext - @param message message to be shown - @type bytes - """ - if _msgHandlerDialog: - if msgType.value < Preferences.getUI("MinimumMessageTypeSeverity"): - # severity is lower than configured - # just ignore the message - return - - with contextlib.suppress(RuntimeError): - if msgType == QtMsgType.QtDebugMsg: - messageType = "Debug Message:" - elif msgType == QtMsgType.QtInfoMsg: - messageType = "Info Message:" - elif msgType == QtMsgType.QtWarningMsg: - messageType = "Warning:" - elif msgType == QtMsgType.QtCriticalMsg: - messageType = "Critical:" - elif msgType == QtMsgType.QtFatalMsg: - messageType = "Fatal Error:" - if isinstance(message, bytes): - message = Utilities.decodeBytes(message) - if filterMessage(message): - return - message = ( - message.replace("\r\n", "<br/>") - .replace("\n", "<br/>") - .replace("\r", "<br/>") - ) - msg = ( - ( - "<p><b>{0}</b></p><p>{1}</p><p>File: {2}</p>" - "<p>Line: {3}</p><p>Function: {4}</p>" - ).format(messageType, Utilities.html_uencode(message), - context.file, context.line, context.function) - if context.file is not None else - "<p><b>{0}</b></p><p>{1}</p>".format( - messageType, Utilities.html_uencode(message)) - ) - if QThread.currentThread() == e5App().thread(): - _msgHandlerDialog.showMessage(msg) - else: - QMetaObject.invokeMethod( - _msgHandlerDialog, - "showMessage", - Qt.ConnectionType.QueuedConnection, - Q_ARG(str, msg)) - return - elif _origMsgHandler: - _origMsgHandler(msgType, message) - return - - if msgType == QtMsgType.QtDebugMsg: - messageType = "Debug Message" - elif msgType == QtMsgType.QtInfoMsg: - messageType = "Info Message:" - elif msgType == QtMsgType.QtWarningMsg: - messageType = "Warning" - elif msgType == QtMsgType.QtCriticalMsg: - messageType = "Critical" - elif msgType == QtMsgType.QtFatalMsg: - messageType = "Fatal Error" - if isinstance(message, bytes): - message = message.decode() - print("{0}: {1} in {2} at line {3} ({4})".format( - messageType, message, context.file, context.line, - context.function)) - - -def qtHandler(): - """ - Module function to install an E5ErrorMessage dialog as the global - message handler. - - @return reference to the message handler dialog - @rtype E5ErrorMessage - """ - global _msgHandlerDialog, _origMsgHandler - - if _msgHandlerDialog is None: - # Install an E5ErrorMessage dialog as the global message handler. - _msgHandlerDialog = E5ErrorMessage() - _origMsgHandler = qInstallMessageHandler(messageHandler) - - return _msgHandlerDialog - - -def editMessageFilters(): - """ - Module function to edit the list of message filters. - """ - if _msgHandlerDialog: - _msgHandlerDialog.editMessageFilters() - else: - print("No message handler installed.") - - -def messageHandlerInstalled(): - """ - Module function to check, if a message handler was installed. - - @return flag indicating an installed message handler - @rtype bool - """ - return _msgHandlerDialog is not None - -# -# eflag: noqa = M801
--- a/eric7/E5Gui/E5ErrorMessageFilterDialog.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2013 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a dialog to manage the list of messages to be ignored. -""" - -from PyQt6.QtWidgets import QDialog - -from .Ui_E5ErrorMessageFilterDialog import Ui_E5ErrorMessageFilterDialog - - -class E5ErrorMessageFilterDialog(QDialog, Ui_E5ErrorMessageFilterDialog): - """ - Class implementing a dialog to manage the list of messages to be ignored. - """ - def __init__(self, messageFilters, parent=None): - """ - Constructor - - @param messageFilters list of message filters to be edited - @type list of str - @param parent reference to the parent widget - @type QWidget - """ - super().__init__(parent) - self.setupUi(self) - - self.filtersEditWidget.setList(messageFilters) - self.filtersEditWidget.setListWhatsThis(self.tr( - "<b>Error Message Filters</b>" - "<p>This list shows the configured message filters used to" - " suppress error messages from within Qt.</p>" - "<p>A default list of message filters is added to this" - " user list.</p>" - )) - - def getFilters(self): - """ - Public method to get the list of message filters. - - @return error message filters (list of strings) - """ - return self.filtersEditWidget.getList()
--- a/eric7/E5Gui/E5ErrorMessageFilterDialog.ui Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>E5ErrorMessageFilterDialog</class> - <widget class="QDialog" name="E5ErrorMessageFilterDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>500</width> - <height>350</height> - </rect> - </property> - <property name="windowTitle"> - <string>Error Messages Filter</string> - </property> - <property name="sizeGripEnabled"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="E5StringListEditWidget" name="filtersEditWidget" native="true"/> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>E5StringListEditWidget</class> - <extends>QWidget</extends> - <header>E5Gui/E5StringListEditWidget.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <tabstops> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>E5ErrorMessageFilterDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>227</x> - <y>329</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>E5ErrorMessageFilterDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>295</x> - <y>335</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui>
--- a/eric7/E5Gui/E5FileDialog.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,197 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing alternative functions for the QFileDialog static methods -to cope with distributor's usage of KDE wrapper dialogs for Qt file dialogs. -""" - -from PyQt6.QtWidgets import QFileDialog - -import Globals - -##Options = QFileDialog.Options -Option = QFileDialog.Option - -ShowDirsOnly = QFileDialog.Option.ShowDirsOnly -DontResolveSymlinks = QFileDialog.Option.DontResolveSymlinks -DontConfirmOverwrite = QFileDialog.Option.DontConfirmOverwrite -DontUseNativeDialog = QFileDialog.Option.DontUseNativeDialog -ReadOnly = QFileDialog.Option.ReadOnly -HideNameFilterDetails = QFileDialog.Option.HideNameFilterDetails -##DontUseSheet = QFileDialog.Option.DontUseSheet -DontUseCustomDirectoryIcons = QFileDialog.Option.DontUseCustomDirectoryIcons - - -def __reorderFilter(filterStr, initialFilter=""): - """ - Private function to reorder the file filter to cope with a KDE issue - introduced by distributor's usage of KDE file dialogs. - - @param filterStr Qt file filter (string) - @param initialFilter initial filter (string) - @return the rearranged Qt file filter (string) - """ - if initialFilter and not Globals.isMacPlatform(): - fileFilters = filterStr.split(';;') - if len(fileFilters) < 10 and initialFilter in fileFilters: - fileFilters.remove(initialFilter) - fileFilters.insert(0, initialFilter) - return ";;".join(fileFilters) - else: - return filterStr - - -def getOpenFileName(parent=None, caption="", directory="", - filterStr="", options=None): - """ - Module function to get the name of a file for opening it. - - @param parent parent widget of the dialog (QWidget) - @param caption window title of the dialog (string) - @param directory working directory of the dialog (string) - @param filterStr filter string for the dialog (string) - @param options various options for the dialog (QFileDialog.Options) - @return name of file to be opened (string) - """ - if options is None: - options = QFileDialog.Option(0) - if Globals.isLinuxPlatform(): - options |= QFileDialog.Option.DontUseNativeDialog - return QFileDialog.getOpenFileName( - parent, caption, directory, filterStr, "", options)[0] - - -def getOpenFileNameAndFilter(parent=None, caption="", directory="", - filterStr="", initialFilter="", - options=None): - """ - Module function to get the name of a file for opening it and the selected - file name filter. - - @param parent parent widget of the dialog (QWidget) - @param caption window title of the dialog (string) - @param directory working directory of the dialog (string) - @param filterStr filter string for the dialog (string) - @param initialFilter initial filter for the dialog (string) - @param options various options for the dialog (QFileDialog.Options) - @return name of file to be opened and selected filter (string, string) - """ - if options is None: - options = QFileDialog.Option(0) - if Globals.isLinuxPlatform(): - options |= QFileDialog.Option.DontUseNativeDialog - newfilter = __reorderFilter(filterStr, initialFilter) - return QFileDialog.getOpenFileName( - parent, caption, directory, newfilter, initialFilter, options) - - -def getOpenFileNames(parent=None, caption="", directory="", - filterStr="", options=None): - """ - Module function to get a list of names of files for opening. - - @param parent parent widget of the dialog (QWidget) - @param caption window title of the dialog (string) - @param directory working directory of the dialog (string) - @param filterStr filter string for the dialog (string) - @param options various options for the dialog (QFileDialog.Options) - @return list of file names to be opened (list of string) - """ - if options is None: - options = QFileDialog.Option(0) - if Globals.isLinuxPlatform(): - options |= QFileDialog.Option.DontUseNativeDialog - return QFileDialog.getOpenFileNames( - parent, caption, directory, filterStr, "", options)[0] - - -def getOpenFileNamesAndFilter(parent=None, caption="", directory="", - filterStr="", initialFilter="", - options=None): - """ - Module function to get a list of names of files for opening and the - selected file name filter. - - @param parent parent widget of the dialog (QWidget) - @param caption window title of the dialog (string) - @param directory working directory of the dialog (string) - @param filterStr filter string for the dialog (string) - @param initialFilter initial filter for the dialog (string) - @param options various options for the dialog (QFileDialog.Options) - @return list of file names to be opened and selected filter - (list of string, string) - """ - if options is None: - options = QFileDialog.Option(0) - if Globals.isLinuxPlatform(): - options |= QFileDialog.Option.DontUseNativeDialog - newfilter = __reorderFilter(filterStr, initialFilter) - return QFileDialog.getOpenFileNames( - parent, caption, directory, newfilter, initialFilter, options) - - -def getSaveFileName(parent=None, caption="", directory="", - filterStr="", options=None): - """ - Module function to get the name of a file for saving it. - - @param parent parent widget of the dialog (QWidget) - @param caption window title of the dialog (string) - @param directory working directory of the dialog (string) - @param filterStr filter string for the dialog (string) - @param options various options for the dialog (QFileDialog.Options) - @return name of file to be saved (string) - """ - if options is None: - options = QFileDialog.Option(0) - if Globals.isLinuxPlatform(): - options |= QFileDialog.Option.DontUseNativeDialog - return QFileDialog.getSaveFileName( - parent, caption, directory, filterStr, "", options)[0] - - -def getSaveFileNameAndFilter(parent=None, caption="", directory="", - filterStr="", initialFilter="", - options=None): - """ - Module function to get the name of a file for saving it and the selected - file name filter. - - @param parent parent widget of the dialog (QWidget) - @param caption window title of the dialog (string) - @param directory working directory of the dialog (string) - @param filterStr filter string for the dialog (string) - @param initialFilter initial filter for the dialog (string) - @param options various options for the dialog (QFileDialog.Options) - @return name of file to be saved and selected filter (string, string) - """ - if options is None: - options = QFileDialog.Option(0) - if Globals.isLinuxPlatform(): - options |= QFileDialog.Option.DontUseNativeDialog - newfilter = __reorderFilter(filterStr, initialFilter) - return QFileDialog.getSaveFileName( - parent, caption, directory, newfilter, initialFilter, options) - - -def getExistingDirectory(parent=None, caption="", - directory="", - options=QFileDialog.Option.ShowDirsOnly): - """ - Module function to get the name of a directory. - - @param parent parent widget of the dialog (QWidget) - @param caption window title of the dialog (string) - @param directory working directory of the dialog (string) - @param options various options for the dialog (QFileDialog.Options) - @return name of selected directory (string) - """ - if options is None: - options = QFileDialog.Option(0) - if Globals.isLinuxPlatform(): - options |= QFileDialog.Option.DontUseNativeDialog - return QFileDialog.getExistingDirectory(parent, caption, directory, - options)
--- a/eric7/E5Gui/E5FileSaveConfirmDialog.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2018 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a dialog to enter a file system path using a file picker. -""" - -import os - -from PyQt6.QtWidgets import ( - QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QLineEdit -) - -from .E5PathPicker import E5PathPicker, E5PathPickerModes - - -class E5FileSaveConfirmDialog(QDialog): - """ - Class implementing a dialog to enter a file system path using a file - picker. - """ - def __init__(self, filename, title, message="", picker=True, parent=None): - """ - Constructor - - @param filename file name to be shown - @type str - @param title title for the dialog - @type str - @param message message to be shown - @type str - @param picker flag indicating to use a path picker - @type bool - @param parent reference to the parent widget - @type QWidget - """ - super().__init__(parent) - - self.setMinimumWidth(400) - - self.__selectedAction = "cancel" - self.__filename = filename - - self.__layout = QVBoxLayout(self) - - self.__label = QLabel(self) - self.__label.setWordWrap(True) - if message: - self.__label.setText(message) - else: - self.__label.setText(self.tr("The given file exists already.")) - - if picker: - self.__pathPicker = E5PathPicker(self) - self.__pathPicker.setMode(E5PathPickerModes.SAVE_FILE_MODE) - else: - self.__pathPicker = QLineEdit(self) - self.__pathPicker.setClearButtonEnabled(True) - - self.__buttonBox = QDialogButtonBox(self) - self.__cancelButton = self.__buttonBox.addButton( - QDialogButtonBox.StandardButton.Cancel) - self.__overwriteButton = self.__buttonBox.addButton( - self.tr("Overwrite"), QDialogButtonBox.ButtonRole.AcceptRole) - self.__renameButton = self.__buttonBox.addButton( - self.tr("Rename"), QDialogButtonBox.ButtonRole.AcceptRole) - - self.__layout.addWidget(self.__label) - self.__layout.addWidget(self.__pathPicker) - self.__layout.addWidget(self.__buttonBox) - - # set values and states - self.__pathPicker.setText(filename) - if picker: - self.__pathPicker.setDefaultDirectory(os.path.dirname(filename)) - self.__renameButton.setEnabled(False) - self.__cancelButton.setDefault(True) - - self.__buttonBox.clicked.connect(self.__buttonBoxClicked) - self.__pathPicker.textChanged.connect(self.__filenameChanged) - - def __buttonBoxClicked(self, button): - """ - Private slot to handle the user clicking a button. - - @param button reference to the clicked button - @type QAbstractButton - """ - if button == self.__cancelButton: - self.__selectedAction = "cancel" - self.reject() - elif button == self.__renameButton: - self.__selectedAction = "rename" - self.accept() - elif button == self.__overwriteButton: - self.__selectedAction = "overwrite" - self.accept() - - def __filenameChanged(self, text): - """ - Private slot to handle a change of the file name. - - @param text new file name - @type str - """ - self.__renameButton.setEnabled(text != self.__filename) - - def selectedAction(self): - """ - Public method to get the selected action and associated data. - - @return tuple containing the selected action (cancel, rename, - overwrite) and the filename (in case of 'rename' or 'overwrite') - @rtype tuple of (str, str) - """ - if self.__selectedAction == "rename": - filename = self.__pathPicker.text() - elif self.__selectedAction == "overwrite": - filename = self.__filename - else: - filename = "" - return self.__selectedAction, filename - - -def confirmOverwrite(filename, title, message="", picker=True, parent=None): - """ - Function to confirm that a file shall be overwritten. - - @param filename file name to be shown - @type str - @param title title for the dialog - @type str - @param message message to be shown - @type str - @param picker flag indicating to use a path picker - @type bool - @param parent reference to the parent widget - @type QWidget - @return tuple containing the selected action (cancel, rename, - overwrite) and the filename (in case of 'rename' or 'overwrite') - @rtype tuple of (str, str) - """ - dlg = E5FileSaveConfirmDialog(filename, title, message=message, - picker=picker, parent=parent) - dlg.exec() - return dlg.selectedAction()
--- a/eric7/E5Gui/E5GenericDiffHighlighter.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,172 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a syntax highlighter for diff outputs. -""" - -import re - -from PyQt6.QtGui import QSyntaxHighlighter, QTextCharFormat, QFont - -import Preferences - - -def TERMINAL(pattern): - """ - Function to mark a pattern as the final one to search for. - - @param pattern pattern to be marked (string) - @return marked pattern (string) - """ - return "__TERMINAL__:{0}".format(pattern) - -# Cache the results of re.compile for performance reasons -_REGEX_CACHE = {} - - -class E5GenericDiffHighlighter(QSyntaxHighlighter): - """ - Class implementing a generic diff highlighter. - """ - def __init__(self, doc): - """ - Constructor - - @param doc reference to the text document (QTextDocument) - """ - super().__init__(doc) - - self.regenerateRules() - - def __initColours(self): - """ - Private method to initialize the highlighter colours. - """ - self.textColor = Preferences.getDiffColour("TextColor") - self.addedColor = Preferences.getDiffColour("AddedColor") - self.removedColor = Preferences.getDiffColour("RemovedColor") - self.replacedColor = Preferences.getDiffColour("ReplacedColor") - self.contextColor = Preferences.getDiffColour("ContextColor") - self.headerColor = Preferences.getDiffColour("HeaderColor") - self.whitespaceColor = Preferences.getDiffColour("BadWhitespaceColor") - - def createRules(self, *rules): - """ - Public method to create the highlighting rules. - - @param rules set of highlighting rules (list of tuples of rule - pattern (string) and highlighting format (QTextCharFormat)) - """ - for _idx, ruleFormat in enumerate(rules): - rule, formats = ruleFormat - terminal = rule.startswith(TERMINAL('')) - if terminal: - rule = rule[len(TERMINAL('')):] - try: - regex = _REGEX_CACHE[rule] - except KeyError: - regex = _REGEX_CACHE[rule] = re.compile(rule) - self._rules.append((regex, formats, terminal)) - - def formats(self, line): - """ - Public method to determine the highlighting formats for a line of - text. - - @param line text line to be highlighted (string) - @return list of matched highlighting rules (list of tuples of match - object and format (QTextCharFormat)) - """ - matched = [] - for rx, formats, terminal in self._rules: - match = rx.match(line) - if not match: - continue - matched.append([match, formats]) - if terminal: - return matched - - return matched - - def makeFormat(self, fg=None, bg=None, bold=False): - """ - Public method to generate a format definition. - - @param fg foreground color (QColor) - @param bg background color (QColor) - @param bold flag indicating bold text (boolean) - @return format definiton (QTextCharFormat) - """ - font = Preferences.getEditorOtherFonts("MonospacedFont") - charFormat = QTextCharFormat() - charFormat.setFontFamilies([font.family()]) - charFormat.setFontPointSize(font.pointSize()) - - if fg: - charFormat.setForeground(fg) - - if bg: - charFormat.setBackground(bg) - - if bold: - charFormat.setFontWeight(QFont.Weight.Bold) - - return charFormat - - def highlightBlock(self, text): - """ - Public method to highlight a block of text. - - @param text text to be highlighted (string) - """ - formats = self.formats(text) - if not formats: - # nothing matched - self.setFormat(0, len(text), self.normalFormat) - return - - for match, formatStr in formats: - start = match.start() - groups = match.groups() - - # No groups in the regex, assume this is a single rule - # that spans the entire line - if not groups: - self.setFormat(0, len(text), formatStr) - continue - - # Groups exist, rule is a tuple corresponding to group - for groupIndex, group in enumerate(groups): - if not group: - # empty match - continue - - # allow None as a no-op format - length = len(group) - if formatStr[groupIndex]: - self.setFormat(start, start + length, - formatStr[groupIndex]) - start += length - - def regenerateRules(self): - """ - Public method to initialize or regenerate the syntax highlighter rules. - """ - self.normalFormat = self.makeFormat() - - self.__initColours() - - self._rules = [] - self.generateRules() - - def generateRules(self): - """ - Public method to generate the rule set. - - Note: This method must me implemented by derived syntax - highlighters. - """ - pass
--- a/eric7/E5Gui/E5Led.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,336 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2006 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a LED widget. - -It was inspired by KLed. -""" - -import enum - -from PyQt6.QtCore import pyqtSignal, Qt, QSize, QPoint -from PyQt6.QtGui import QColor, QRadialGradient, QPalette, QPainter, QBrush -from PyQt6.QtWidgets import QWidget - - -class E5LedType(enum.Enum): - """ - Class defining the LED types. - """ - RECTANGULAR = 0 - CIRCULAR = 1 - - -class E5Led(QWidget): - """ - Class implementing a LED widget. - """ - def __init__(self, parent=None, color=None, shape=E5LedType.CIRCULAR, - rectRatio=1): - """ - Constructor - - @param parent reference to parent widget - @type QWidget - @param color color of the LED - @type QColor - @param shape shape of the LED - @type E5LedType - @param rectRatio ratio width to height, if shape is rectangular - @type float - """ - super().__init__(parent) - - if color is None: - color = QColor("green") - - self.__led_on = True - self.__dark_factor = 300 - self.__offcolor = color.darker(self.__dark_factor) - self.__led_color = color - self.__framedLed = True - self.__shape = shape - self.__rectRatio = rectRatio - - self.setColor(color) - - def paintEvent(self, evt): - """ - Protected slot handling the paint event. - - @param evt paint event object - @type QPaintEvent - """ - if self.__shape == E5LedType.CIRCULAR: - self.__paintRound() - elif self.__shape == E5LedType.RECTANGULAR: - self.__paintRectangular() - - def __getBestRoundSize(self): - """ - Private method to calculate the width of the LED. - - @return new width of the LED (integer) - """ - width = min(self.width(), self.height()) - width -= 2 # leave one pixel border - return width > -1 and width or 0 - - def __paintRound(self): - """ - Private method to paint a round raised LED. - """ - # Initialize coordinates, width and height of the LED - width = self.__getBestRoundSize() - - # Calculate the gradient for the LED - wh = width / 2 - color = self.__led_on and self.__led_color or self.__offcolor - gradient = QRadialGradient(wh, wh, wh, 0.8 * wh, 0.8 * wh) - gradient.setColorAt(0.0, color.lighter(200)) - gradient.setColorAt(0.6, color) - if self.__framedLed: - gradient.setColorAt(0.9, color.darker()) - gradient.setColorAt( - 1.0, self.palette().color(QPalette.ColorRole.Dark)) - else: - gradient.setColorAt(1.0, color.darker()) - - # now do the drawing - paint = QPainter(self) - paint.setRenderHint(QPainter.RenderHint.Antialiasing, True) - paint.setBrush(QBrush(gradient)) - paint.setPen(Qt.PenStyle.NoPen) - paint.drawEllipse(1, 1, width, width) - paint.end() - - def __paintRectangular(self): - """ - Private method to paint a rectangular raised LED. - """ - # Initialize coordinates, width and height of the LED - width = self.height() * self.__rectRatio - left = max(0, int((self.width() - width) / 2) - 1) - right = min(int((self.width() + width) / 2), self.width()) - height = self.height() - - # now do the drawing - painter = QPainter(self) - painter.setRenderHint(QPainter.RenderHint.Antialiasing, True) - color = self.__led_on and self.__led_color or self.__offcolor - - painter.setPen(color.lighter(200)) - painter.drawLine(left, 0, left, height - 1) - painter.drawLine(left + 1, 0, right - 1, 0) - if self.__framedLed: - painter.setPen(self.palette().color(QPalette.ColorRole.Dark)) - else: - painter.setPen(color.darker()) - painter.drawLine(left + 1, height - 1, right - 1, height - 1) - painter.drawLine(right - 1, 1, right - 1, height - 1) - painter.fillRect(left + 1, 1, right - 2, height - 2, QBrush(color)) - painter.end() - - def isOn(self): - """ - Public method to return the LED state. - - @return flag indicating the light state (boolean) - """ - return self.__led_on - - def shape(self): - """ - Public method to return the LED shape. - - @return LED shape - @rtype E5LedType - """ - return self.__shape - - def ratio(self): - """ - Public method to return the LED rectangular ratio [= width / height]. - - @return LED rectangular ratio (float) - """ - return self.__rectRatio - - def color(self): - """ - Public method to return the LED color. - - @return color of the LED (QColor) - """ - return self.__led_color - - def setOn(self, state): - """ - Public method to set the LED to on. - - @param state new state of the LED (boolean) - """ - if self.__led_on != state: - self.__led_on = state - self.update() - - def setShape(self, shape): - """ - Public method to set the LED shape. - - @param shape new LED shape - @type E5LedType - """ - if self.__shape != shape: - self.__shape = shape - self.update() - - def setRatio(self, ratio): - """ - Public method to set the LED rectangular ratio (width / height). - - @param ratio new LED rectangular ratio (float) - """ - if self.__rectRatio != ratio: - self.__rectRatio = ratio - self.update() - - def setColor(self, color): - """ - Public method to set the LED color. - - @param color color for the LED (QColor) - """ - if self.__led_color != color: - self.__led_color = color - self.__offcolor = color.darker(self.__dark_factor) - self.update() - - def setDarkFactor(self, darkfactor): - """ - Public method to set the dark factor. - - @param darkfactor value to set for the dark factor (integer) - """ - if self.__dark_factor != darkfactor: - self.__dark_factor = darkfactor - self.__offcolor = self.__led_color.darker(darkfactor) - self.update() - - def darkFactor(self): - """ - Public method to return the dark factor. - - @return the current dark factor (integer) - """ - return self.__dark_factor - - def toggle(self): - """ - Public slot to toggle the LED state. - """ - self.setOn(not self.__led_on) - - def on(self): - """ - Public slot to set the LED to on. - """ - self.setOn(True) - - def off(self): - """ - Public slot to set the LED to off. - """ - self.setOn(False) - - def setFramed(self, framed): - """ - Public slot to set the __framedLed attribute. - - @param framed flag indicating the framed state (boolean) - """ - if self.__framedLed != framed: - self.__framedLed = framed - self.__off_map = None - self.__on_map = None - self.update() - - def isFramed(self): - """ - Public method to return the framed state. - - @return flag indicating the current framed state (boolean) - """ - return self.__framedLed - - def sizeHint(self): - """ - Public method to give a hint about our desired size. - - @return size hint (QSize) - """ - return QSize(18, 18) - - def minimumSizeHint(self): - """ - Public method to give a hint about our minimum size. - - @return size hint (QSize) - """ - return QSize(18, 18) - - -class E5ClickableLed(E5Led): - """ - Class implementing a clickable LED widget. - - @signal clicked(QPoint) emitted upon a click on the LED with the - left button - @signal middleClicked(QPoint) emitted upon a click on the LED with - the middle button or CTRL and left button - """ - clicked = pyqtSignal(QPoint) - middleClicked = pyqtSignal(QPoint) - - def __init__(self, parent=None, color=None, shape=E5LedType.CIRCULAR, - rectRatio=1): - """ - Constructor - - @param parent reference to parent widget - @type QWidget - @param color color of the LED - @type QColor - @param shape shape of the LED - @type E5LedType - @param rectRatio ratio width to height, if shape is rectangular - @type float - """ - super().__init__(parent, color, shape, rectRatio) - - self.setCursor(Qt.CursorShape.PointingHandCursor) - - def mouseReleaseEvent(self, evt): - """ - Protected method handling mouse release events. - - @param evt mouse event (QMouseEvent) - """ - if ( - evt.button() == Qt.MouseButton.LeftButton and - self.rect().contains(evt.position().toPoint()) - ): - if evt.modifiers() == Qt.KeyboardModifier.ControlModifier: - self.middleClicked.emit(evt.globalPosition().toPoint()) - else: - self.clicked.emit(evt.globalPosition().toPoint()) - elif ( - evt.button() == Qt.MouseButton.MiddleButton and - self.rect().contains(evt.position().toPoint()) - ): - self.middleClicked.emit(evt.globalPosition().toPoint()) - else: - super().mouseReleaseEvent(evt)
--- a/eric7/E5Gui/E5LineEdit.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,264 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2009 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing specialized line edits. -""" - -import enum - -from PyQt6.QtCore import pyqtSignal, Qt, QEvent -from PyQt6.QtWidgets import ( - QLineEdit, QWidget, QHBoxLayout, QBoxLayout, QLayout, QApplication, - QSpacerItem, QSizePolicy -) - - -class E5LineEditSideWidget(QWidget): - """ - Class implementing the side widgets for the line edit class. - - @signal sizeHintChanged() emitted to indicate a change of the size hint - """ - sizeHintChanged = pyqtSignal() - - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - - def event(self, evt): - """ - Public method to handle events. - - @param evt reference to the event (QEvent) - @return flag indicating, whether the event was recognized (boolean) - """ - if evt.type() == QEvent.Type.LayoutRequest: - self.sizeHintChanged.emit() - return QWidget.event(self, evt) - - -class E5LineEditSide(enum.Enum): - """ - Class defining the line edit sides. - """ - LEFT = 0 - RIGHT = 1 - - -class E5LineEdit(QLineEdit): - """ - Class implementing a line edit widget showing some inactive text. - """ - def __init__(self, parent=None, placeholderText=""): - """ - Constructor - - @param parent reference to the parent widget - @type QWidget - @param placeholderText text to be shown on inactivity - @type str - """ - super().__init__(parent) - - self.setMinimumHeight(22) - - self.setPlaceholderText(placeholderText) - - self.__mainLayout = QHBoxLayout(self) - self.__mainLayout.setContentsMargins(0, 0, 0, 0) - self.__mainLayout.setSpacing(0) - - self.__leftMargin = 0 - self.__leftWidget = E5LineEditSideWidget(self) - self.__leftWidget.resize(0, 0) - self.__leftLayout = QHBoxLayout(self.__leftWidget) - self.__leftLayout.setContentsMargins(0, 0, 2, 0) - if QApplication.isRightToLeft(): - self.__leftLayout.setDirection(QBoxLayout.Direction.RightToLeft) - else: - self.__leftLayout.setDirection(QBoxLayout.Direction.LeftToRight) - self.__leftLayout.setSizeConstraint( - QLayout.SizeConstraint.SetFixedSize) - - self.__rightWidget = E5LineEditSideWidget(self) - self.__rightWidget.resize(0, 0) - self.__rightLayout = QHBoxLayout(self.__rightWidget) - self.__rightLayout.setContentsMargins(0, 0, 2, 0) - if self.isRightToLeft(): - self.__rightLayout.setDirection(QBoxLayout.Direction.RightToLeft) - else: - self.__rightLayout.setDirection(QBoxLayout.Direction.LeftToRight) - - horizontalSpacer = QSpacerItem( - 0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) - self.__mainLayout.addWidget( - self.__leftWidget, 0, - Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignLeft) - self.__mainLayout.addItem(horizontalSpacer) - self.__mainLayout.addWidget( - self.__rightWidget, 0, - Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignRight) - if self.isRightToLeft(): - self.__mainLayout.setDirection(QBoxLayout.Direction.RightToLeft) - else: - self.__mainLayout.setDirection(QBoxLayout.Direction.LeftToRight) - - self.setWidgetSpacing(3) - self.__leftWidget.sizeHintChanged.connect(self._updateTextMargins) - self.__rightWidget.sizeHintChanged.connect(self._updateTextMargins) - - def setLeftMargin(self, margin): - """ - Public method to set the left margin. - - @param margin left margin in pixel (integer) - """ - self.__leftMargin = margin - - def leftMargin(self): - """ - Public method to get the size of the left margin. - - @return left margin in pixel (integer) - """ - return self.__leftMargin - - def event(self, evt): - """ - Public method to handle events. - - @param evt reference to the event (QEvent) - @return flag indicating, whether the event was recognized (boolean) - """ - if evt.type() == QEvent.Type.LayoutDirectionChange: - if self.isRightToLeft(): - self.__mainLayout.setDirection( - QBoxLayout.Direction.RightToLeft) - self.__leftLayout.setDirection( - QBoxLayout.Direction.RightToLeft) - self.__rightLayout.setDirection( - QBoxLayout.Direction.RightToLeft) - else: - self.__mainLayout.setDirection( - QBoxLayout.Direction.LeftToRight) - self.__leftLayout.setDirection( - QBoxLayout.Direction.LeftToRight) - self.__rightLayout.setDirection( - QBoxLayout.Direction.LeftToRight) - return QLineEdit.event(self, evt) - - def _updateTextMargins(self): - """ - Protected slot to update the text margins. - """ - left = ( - self.__leftWidget.sizeHint().width() - if self.__leftMargin == 0 else - self.__leftMargin - ) - right = self.__rightWidget.sizeHint().width() - top = 0 - bottom = 0 - self.setTextMargins(left, top, right, bottom) - - def addWidget(self, widget, position): - """ - Public method to add a widget to a side. - - @param widget reference to the widget to add - @type QWidget - @param position position to add to - @type E5LineEditSide - """ - if widget is None: - return - - if self.isRightToLeft(): - if position == E5LineEditSide.LEFT: - position = E5LineEditSide.RIGHT - else: - position = E5LineEditSide.LEFT - if position == E5LineEditSide.LEFT: - self.__leftLayout.addWidget(widget) - else: - self.__rightLayout.insertWidget(1, widget) - - def removeWidget(self, widget): - """ - Public method to remove a widget from a side. - - @param widget reference to the widget to remove - @type QWidget - """ - if widget is None: - return - - self.__leftLayout.removeWidget(widget) - self.__rightLayout.removeWidget(widget) - widget.hide() - - def widgetSpacing(self): - """ - Public method to get the side widget spacing. - - @return side widget spacing (integer) - """ - return self.__leftLayout.spacing() - - def setWidgetSpacing(self, spacing): - """ - Public method to set the side widget spacing. - - @param spacing side widget spacing (integer) - """ - self.__leftLayout.setSpacing(spacing) - self.__rightLayout.setSpacing(spacing) - self._updateTextMargins() - - def textMargin(self, position): - """ - Public method to get the text margin for a side. - - @param position side to get margin for - @type E5LineEditSide - @return text margin - @rtype int - """ - spacing = self.__rightLayout.spacing() - w = 0 - w = ( - self.__leftWidget.sizeHint().width() - if position == E5LineEditSide.LEFT else - self.__rightWidget.sizeHint().width() - ) - if w == 0: - return 0 - return w + spacing * 2 - -class E5ClearableLineEdit(E5LineEdit): - """ - Class implementing a line edit widget showing some inactive text and a - clear button, if it has some contents. - """ - def __init__(self, parent=None, placeholderText="", - side=E5LineEditSide.RIGHT): - """ - Constructor - - @param parent reference to the parent widget - @type QWidget - @param placeholderText text to be shown on inactivity - @type str - @param side side the clear button should be shown at - @type E5LineEditSide - """ - super().__init__(parent, placeholderText) - - self.setClearButtonEnabled(True)
--- a/eric7/E5Gui/E5LineEditButton.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a button class to be used with E5LineEdit. -""" - -from PyQt6.QtCore import Qt, QPoint, QPointF -from PyQt6.QtGui import QPainter, QPainterPath -from PyQt6.QtWidgets import QAbstractButton - - -# TODO: Get rid of this -class E5LineEditButton(QAbstractButton): - """ - Class implementing a button to be used with E5LineEdit. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - - self.__menu = None - self.__image = None - - self.setFocusPolicy(Qt.FocusPolicy.NoFocus) - self.setCursor(Qt.CursorShape.ArrowCursor) - self.setMinimumSize(16, 16) - - self.clicked.connect(self.__clicked) - - def setMenu(self, menu): - """ - Public method to set the button menu. - - @param menu reference to the menu (QMenu) - """ - self.__menu = menu - self.update() - - def menu(self): - """ - Public method to get a reference to the menu. - - @return reference to the associated menu (QMenu) - """ - return self.__menu - - def setIcon(self, icon): - """ - Public method to set the button icon. - - @param icon icon to be set (QIcon) - """ - if icon.isNull(): - self.__image = None - else: - self.__image = icon.pixmap(16, 16).toImage() - super().setIcon(icon) - - def __clicked(self): - """ - Private slot to handle a button click. - """ - if self.__menu: - pos = self.mapToGlobal(QPoint(0, self.height())) - self.__menu.exec(pos) - - def paintEvent(self, evt): - """ - Protected method handling a paint event. - - @param evt reference to the paint event (QPaintEvent) - """ - painter = QPainter(self) - - if self.__image is not None and not self.__image.isNull(): - x = (self.width() - self.__image.width()) // 2 - 1 - y = (self.height() - self.__image.height()) // 2 - 1 - painter.drawImage(x, y, self.__image) - - if self.__menu is not None: - triagPath = QPainterPath() - startPos = QPointF(self.width() - 5, self.height() - 3) - triagPath.moveTo(startPos) - triagPath.lineTo(startPos.x() + 4, startPos.y()) - triagPath.lineTo(startPos.x() + 2, startPos.y() + 2) - triagPath.closeSubpath() - painter.setPen(Qt.GlobalColor.black) - painter.setBrush(Qt.GlobalColor.black) - painter.setRenderHint(QPainter.RenderHint.Antialiasing, False) - painter.drawPath(triagPath)
--- a/eric7/E5Gui/E5ListSelectionDialog.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a dialog to select from a list of strings. -""" - -from PyQt6.QtCore import pyqtSlot, Qt -from PyQt6.QtWidgets import ( - QDialog, QDialogButtonBox, QAbstractItemView, QListWidgetItem -) - -from .Ui_E5ListSelectionDialog import Ui_E5ListSelectionDialog - - -class E5ListSelectionDialog(QDialog, Ui_E5ListSelectionDialog): - """ - Class implementing a dialog to select from a list of strings. - """ - def __init__(self, entries, - selectionMode=QAbstractItemView.SelectionMode - .ExtendedSelection, - title="", message="", checkBoxSelection=False, parent=None): - """ - Constructor - - @param entries list of entries to select from - @type list of str - @param selectionMode selection mode for the list - @type QAbstractItemView.SelectionMode - @param title title of the dialog - @type str - @param message message to be show in the dialog - @type str - @param checkBoxSelection flag indicating to select items via their - checkbox - @type bool - @param parent reference to the parent widget - @type QWidget - """ - super().__init__(parent) - self.setupUi(self) - - if title: - self.setWindowTitle(title) - if message: - self.messageLabel.setText(message) - - self.__checkCount = 0 - self.__isCheckBoxSelection = checkBoxSelection - if self.__isCheckBoxSelection: - self.selectionList.setSelectionMode( - QAbstractItemView.SelectionMode.NoSelection) - for entry in entries: - itm = QListWidgetItem(entry) - itm.setFlags(Qt.ItemFlag.ItemIsUserCheckable | - Qt.ItemFlag.ItemIsEnabled) - itm.setCheckState(Qt.CheckState.Unchecked) - self.selectionList.addItem(itm) - else: - self.selectionList.setSelectionMode(selectionMode) - self.selectionList.addItems(entries) - - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled(False) - - @pyqtSlot() - def on_selectionList_itemSelectionChanged(self): - """ - Private slot handling a change of the selection. - """ - if not self.__isCheckBoxSelection: - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled( - len(self.selectionList.selectedItems()) > 0) - - def on_selectionList_itemChanged(self, itm): - """ - Private slot handling a change of an item. - - @param itm reference to the changed item - @type QListWidgetItem - """ - if self.__isCheckBoxSelection: - if itm.checkState() == Qt.CheckState.Checked: - self.__checkCount += 1 - else: - self.__checkCount -= 1 - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled( - self.__checkCount > 0) - - def getSelection(self): - """ - Public method to retrieve the selected items. - - @return selected entries - @rtype list of str - """ - entries = [] - if self.__isCheckBoxSelection: - for row in range(self.selectionList.count()): - item = self.selectionList.item(row) - if item.checkState() == Qt.CheckState.Checked: - entries.append(item.text()) - else: - for item in self.selectionList.selectedItems(): - entries.append(item.text()) - return entries
--- a/eric7/E5Gui/E5ListSelectionDialog.ui Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>E5ListSelectionDialog</class> - <widget class="QDialog" name="E5ListSelectionDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>500</height> - </rect> - </property> - <property name="windowTitle"> - <string>Select from List</string> - </property> - <property name="sizeGripEnabled"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="messageLabel"> - <property name="text"> - <string>Select from the list below:</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QListWidget" name="selectionList"> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>E5ListSelectionDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>E5ListSelectionDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui>
--- a/eric7/E5Gui/E5ListView.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2009 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing specialized list views. -""" - -from PyQt6.QtCore import Qt, QItemSelectionModel -from PyQt6.QtWidgets import QListView - - -class E5ListView(QListView): - """ - Class implementing a list view supporting removal of entries. - """ - def keyPressEvent(self, evt): - """ - Protected method implementing special key handling. - - @param evt reference to the event (QKeyEvent) - """ - if ( - evt.key() in [Qt.Key.Key_Delete, Qt.Key.Key_Backspace] and - self.model() is not None - ): - self.removeSelected() - evt.setAccepted(True) - else: - super().keyPressEvent(evt) - - def removeSelected(self): - """ - Public method to remove the selected entries. - """ - if self.model() is None or self.selectionModel() is None: - # no models available - return - - row = 0 - selectedRows = self.selectionModel().selectedRows() - for selectedRow in reversed(selectedRows): - row = selectedRow.row() - self.model().removeRow(row, self.rootIndex()) - - idx = self.model().index(row, 0, self.rootIndex()) - if not idx.isValid(): - idx = self.model().index(row - 1, 0, self.rootIndex()) - self.selectionModel().select( - idx, - QItemSelectionModel.SelectionFlag.SelectCurrent | - QItemSelectionModel.SelectionFlag.Rows) - self.setCurrentIndex(idx) - - def removeAll(self): - """ - Public method to clear the view. - """ - if self.model() is not None: - self.model().removeRows(0, self.model().rowCount(self.rootIndex()), - self.rootIndex())
--- a/eric7/E5Gui/E5MainWindow.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a main window class with styling support. -""" - -from PyQt6.QtCore import QCoreApplication -from PyQt6.QtWidgets import QMainWindow, QStyleFactory, QApplication - -from .E5Application import e5App -from . import E5MessageBox - - -class E5MainWindow(QMainWindow): - """ - Class implementing a main window with styling support. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - - self.defaultStyleName = QApplication.style().objectName() - - def setStyle(self, styleName, styleSheetFile): - """ - Public method to set the style of the interface. - - @param styleName name of the style to set (string) - @param styleSheetFile name of a style sheet file to read to overwrite - defaults of the given style (string) - """ - # step 1: set the style - style = None - if styleName != "System" and styleName in QStyleFactory.keys(): - # __IGNORE_WARNING_Y118__ - style = QStyleFactory.create(styleName) - if style is None: - style = QStyleFactory.create(self.defaultStyleName) - if style is not None: - QApplication.setStyle(style) - - # step 2: set a style sheet - if styleSheetFile: - try: - with open(styleSheetFile, "r", encoding="utf-8") as f: - styleSheet = f.read() - except OSError as msg: - E5MessageBox.warning( - self, - QCoreApplication.translate( - "E5MainWindow", "Loading Style Sheet"), - QCoreApplication.translate( - "E5MainWindow", - """<p>The Qt Style Sheet file <b>{0}</b> could""" - """ not be read.<br>Reason: {1}</p>""") - .format(styleSheetFile, str(msg))) - return - else: - styleSheet = "" - - e5App().setStyleSheet(styleSheet)
--- a/eric7/E5Gui/E5MapWidget.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,352 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a base class for showing a document map. -""" - -from PyQt6.QtCore import Qt, QSize, QRect, QCoreApplication -from PyQt6.QtGui import QColor, QBrush, QPainter -from PyQt6.QtWidgets import QWidget, QAbstractScrollArea - - -class E5MapWidget(QWidget): - """ - Class implementing a base class for showing a document map. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - self.setAttribute(Qt.WidgetAttribute.WA_OpaquePaintEvent) - - self.__width = 14 - self.__lineBorder = 1 - self.__lineHeight = 2 - self.__backgroundColor = QColor("#e7e7e7") - self.__setSliderColor() - - self._master = None - self.__enabled = False - self.__rightSide = True - - if parent is not None and isinstance(parent, QAbstractScrollArea): - self.setMaster(parent) - - def __setSliderColor(self): - """ - Private method to set the slider color depending upon the background - color. - """ - if self.__backgroundColor.toHsv().value() < 128: - # dark background, use white slider - self.__sliderColor = Qt.GlobalColor.white - else: - # light background, use black slider - self.__sliderColor = Qt.GlobalColor.black - - def __updateMasterViewportWidth(self): - """ - Private method to update the master's viewport width. - """ - if self._master: - if self.__enabled: - width = self.__width - else: - width = 0 - if self.__rightSide: - self._master.setViewportMargins(0, 0, width, 0) - else: - self._master.setViewportMargins(width, 0, 0, 0) - - def setMaster(self, master): - """ - Public method to set the map master widget. - - @param master map master widget (QAbstractScrollArea) - """ - self._master = master - self._master.setVerticalScrollBarPolicy( - Qt.ScrollBarPolicy.ScrollBarAlwaysOn) - self._master.verticalScrollBar().valueChanged.connect(self.update) - self._master.verticalScrollBar().rangeChanged.connect(self.update) - self.__updateMasterViewportWidth() - - def setWidth(self, width): - """ - Public method to set the widget width. - - @param width widget width (integer) - """ - if width != self.__width: - self.__width = max(6, width) # minimum width 6 pixels - self.__updateMasterViewportWidth() - self.update() - - def width(self): - """ - Public method to get the widget's width. - - @return widget width (integer) - """ - return self.__width - - def setMapPosition(self, onRight): - """ - Public method to set, whether the map should be shown to the right or - left of the master widget. - - @param onRight flag indicating to show the map on the right side of - the master widget - @type bool - """ - if onRight != self.__rightSide: - self.__rightSide = onRight - self.__updateMasterViewportWidth() - self.update() - - def isOnRightSide(self): - """ - Public method to test, if the map is shown on the right side of the - master widget. - - @return flag indicating that the map is to the right of the master - widget - @rtype bool - """ - return self.__rightSide - - def setLineDimensions(self, border, height): - """ - Public method to set the line (indicator) dimensions. - - @param border border width on each side in x-direction (integer) - @param height height of the line in pixels (integer) - """ - if border != self.__lineBorder or height != self.__lineHeight: - self.__lineBorder = max(1, border) # min border 1 pixel - self.__lineHeight = max(1, height) # min height 1 pixel - self.update() - - def lineDimensions(self): - """ - Public method to get the line (indicator) dimensions. - - @return tuple with border width (integer) and line height (integer) - """ - return self.__lineBorder, self.__lineHeight - - def setEnabled(self, enable): - """ - Public method to set the enabled state. - - @param enable flag indicating the enabled state (boolean) - """ - if enable != self.__enabled: - self.__enabled = enable - self.setVisible(enable) - self.__updateMasterViewportWidth() - - def isEnabled(self): - """ - Public method to check the enabled state. - - @return flag indicating the enabled state (boolean) - """ - return self.__enabled - - def setBackgroundColor(self, color): - """ - Public method to set the widget background color. - - @param color color for the background (QColor) - """ - if color != self.__backgroundColor: - self.__backgroundColor = color - self.__setSliderColor() - self.update() - - def backgroundColor(self): - """ - Public method to get the background color. - - @return background color (QColor) - """ - return QColor(self.__backgroundColor) - - def sizeHint(self): - """ - Public method to give an indication about the preferred size. - - @return preferred size (QSize) - """ - return QSize(self.__width, 0) - - def paintEvent(self, event): - """ - Protected method to handle a paint event. - - @param event paint event (QPaintEvent) - """ - # step 1: fill the whole painting area - painter = QPainter(self) - painter.fillRect(event.rect(), self.__backgroundColor) - - # step 2: paint the indicators - self._paintIt(painter) - - # step 3: paint the slider - if self._master: - penColor = self.__sliderColor - painter.setPen(penColor) - brushColor = Qt.GlobalColor.transparent - painter.setBrush(QBrush(brushColor)) - painter.drawRect(self.__generateSliderRange( - self._master.verticalScrollBar())) - - def _paintIt(self, painter): - """ - Protected method for painting the widget's indicators. - - Note: This method should be implemented by subclasses. - - @param painter reference to the painter object (QPainter) - """ - pass - - def mousePressEvent(self, event): - """ - Protected method to handle a mouse button press. - - @param event reference to the mouse event (QMouseEvent) - """ - if event.button() == Qt.MouseButton.LeftButton and self._master: - vsb = self._master.verticalScrollBar() - value = self.position2Value(event.position().toPoint().y() - 1) - vsb.setValue(value - 0.5 * vsb.pageStep()) # center on page - self.__mousePressPos = None - - def mouseMoveEvent(self, event): - """ - Protected method to handle a mouse moves. - - @param event reference to the mouse event (QMouseEvent) - """ - if event.buttons() & Qt.MouseButton.LeftButton and self._master: - vsb = self._master.verticalScrollBar() - value = self.position2Value(event.position().toPoint().y() - 1) - vsb.setValue(value - 0.5 * vsb.pageStep()) # center on page - - def wheelEvent(self, event): - """ - Protected slot handling mouse wheel events. - - @param event reference to the wheel event (QWheelEvent) - """ - isVertical = event.angleDelta().x() == 0 - if ( - self._master and - event.modifiers() == Qt.KeyboardModifier.NoModifier and - isVertical - ): - QCoreApplication.sendEvent(self._master.verticalScrollBar(), event) - - def calculateGeometry(self): - """ - Public method to recalculate the map widget's geometry. - """ - if self._master: - cr = self._master.contentsRect() - vsb = self._master.verticalScrollBar() - if vsb.isVisible(): - vsbw = vsb.contentsRect().width() - else: - vsbw = 0 - margins = self._master.contentsMargins() - if margins.right() > vsbw: - vsbw = 0 - if self.__rightSide: - self.setGeometry( - QRect(cr.right() - self.__width - vsbw, cr.top(), - self.__width, cr.height())) - else: - self.setGeometry( - QRect(0, cr.top(), self.__width, cr.height())) - self.update() - - def scaleFactor(self, slider=False): - """ - Public method to determine the scrollbar's scale factor. - - @param slider flag indicating to calculate the result for the slider - (boolean) - @return scale factor (float) - """ - if self._master: - delta = 0 if slider else 2 - vsb = self._master.verticalScrollBar() - posHeight = vsb.height() - delta - 1 - valHeight = vsb.maximum() - vsb.minimum() + vsb.pageStep() - return float(posHeight) / valHeight - else: - return 1.0 - - def value2Position(self, value, slider=False): - """ - Public method to convert a scrollbar value into a position. - - @param value value to convert (integer) - @param slider flag indicating to calculate the result for the slider - (boolean) - @return position (integer) - """ - if self._master: - offset = 0 if slider else 1 - vsb = self._master.verticalScrollBar() - return (value - vsb.minimum()) * self.scaleFactor(slider) + offset - else: - return value - - def position2Value(self, position, slider=False): - """ - Public method to convert a position into a scrollbar value. - - @param position scrollbar position to convert (integer) - @param slider flag indicating to calculate the result for the slider - (boolean) - @return scrollbar value (integer) - """ - if self._master: - offset = 0 if slider else 1 - vsb = self._master.verticalScrollBar() - return vsb.minimum() + max( - 0, (position - offset) / self.scaleFactor(slider)) - else: - return position - - def generateIndicatorRect(self, position): - """ - Public method to generate an indicator rectangle. - - @param position indicator position (integer) - @return indicator rectangle (QRect) - """ - return QRect(self.__lineBorder, position - self.__lineHeight // 2, - self.__width - self.__lineBorder, self.__lineHeight) - - def __generateSliderRange(self, scrollbar): - """ - Private method to generate the slider rectangle. - - @param scrollbar reference to the vertical scrollbar (QScrollBar) - @return slider rectangle (QRect) - """ - pos1 = self.value2Position(scrollbar.value(), slider=True) - pos2 = self.value2Position(scrollbar.value() + scrollbar.pageStep(), - slider=True) - return QRect(0, pos1, self.__width - 1, pos2 - pos1)
--- a/eric7/E5Gui/E5MessageBox.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,305 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing QMessageBox replacements and more convenience function. -""" - -from PyQt6.QtCore import Qt -from PyQt6.QtWidgets import QMessageBox, QApplication - -############################################################################### -## Mappings to standard QMessageBox ## -############################################################################### - -# QMessageBox.Icon -NoIcon = QMessageBox.Icon.NoIcon -Critical = QMessageBox.Icon.Critical -Information = QMessageBox.Icon.Information -Question = QMessageBox.Icon.Question -Warning = QMessageBox.Icon.Warning # __IGNORE_WARNING_M131__ - -##StandardButtons = QMessageBox.StandardButtons -## -# QMessageBox.StandardButton -Abort = QMessageBox.StandardButton.Abort -Apply = QMessageBox.StandardButton.Apply -Cancel = QMessageBox.StandardButton.Cancel -Close = QMessageBox.StandardButton.Close -Discard = QMessageBox.StandardButton.Discard -Help = QMessageBox.StandardButton.Help -Ignore = QMessageBox.StandardButton.Ignore -No = QMessageBox.StandardButton.No -NoToAll = QMessageBox.StandardButton.NoToAll -Ok = QMessageBox.StandardButton.Ok -Open = QMessageBox.StandardButton.Open -Reset = QMessageBox.StandardButton.Reset -RestoreDefaults = QMessageBox.StandardButton.RestoreDefaults -Retry = QMessageBox.StandardButton.Retry -Save = QMessageBox.StandardButton.Save -SaveAll = QMessageBox.StandardButton.SaveAll -Yes = QMessageBox.StandardButton.Yes -YesToAll = QMessageBox.StandardButton.YesToAll -NoButton = QMessageBox.StandardButton.NoButton - -# QMessageBox.ButtonRole -AcceptRole = QMessageBox.ButtonRole.AcceptRole -ActionRole = QMessageBox.ButtonRole.ActionRole -ApplyRole = QMessageBox.ButtonRole.ApplyRole -DestructiveRole = QMessageBox.ButtonRole.DestructiveRole -InvalidRole = QMessageBox.ButtonRole.InvalidRole -HelpRole = QMessageBox.ButtonRole.HelpRole -NoRole = QMessageBox.ButtonRole.NoRole -RejectRole = QMessageBox.ButtonRole.RejectRole -ResetRole = QMessageBox.ButtonRole.ResetRole -YesRole = QMessageBox.ButtonRole.YesRole - -############################################################################### -## Replacement for the QMessageBox class ## -############################################################################### - - -class E5MessageBox(QMessageBox): - """ - Class implementing a replacement for QMessageBox. - """ - def __init__(self, icon, title, text, modal=False, - buttons=QMessageBox.StandardButton.NoButton, - parent=None): - """ - Constructor - - @param icon type of icon to be shown (QMessageBox.Icon) - @param title caption of the message box (string) - @param text text to be shown by the message box (string) - @param modal flag indicating a modal dialog (boolean) - @param buttons set of standard buttons to generate (StandardButtons) - @param parent parent widget of the message box (QWidget) - """ - super().__init__(parent) - self.setIcon(icon) - if modal: - if parent is not None: - self.setWindowModality(Qt.WindowModality.WindowModal) - else: - self.setWindowModality(Qt.WindowModality.ApplicationModal) - else: - self.setWindowModality(Qt.WindowModality.NonModal) - if title == "": - self.setWindowTitle("{0}".format( - QApplication.applicationName())) - else: - self.setWindowTitle("{0} - {1}".format( - QApplication.applicationName(), title)) - self.setText(text) - self.setStandardButtons(buttons) - -############################################################################### -## Replacements for QMessageBox static methods ## -############################################################################### - - -def __messageBox(parent, title, text, icon, - buttons=QMessageBox.StandardButton.Ok, - defaultButton=QMessageBox.StandardButton.NoButton, - textFormat=Qt.TextFormat.AutoText): - """ - Private module function to show a modal message box. - - @param parent parent widget of the message box (QWidget) - @param title caption of the message box (string) - @param text text to be shown by the message box (string) - @param icon type of icon to be shown (QMessageBox.Icon) - @param buttons flags indicating which buttons to show - (QMessageBox.StandardButtons) - @param defaultButton flag indicating the default button - (QMessageBox.StandardButton) - @param textFormat format of the text (Qt.TextFormat) - @return button pressed by the user (QMessageBox.StandardButton) - """ - messageBox = QMessageBox(parent) - messageBox.setIcon(icon) - if parent is not None: - messageBox.setWindowModality(Qt.WindowModality.WindowModal) - if title == "": - messageBox.setWindowTitle("{0}".format( - QApplication.applicationName())) - else: - messageBox.setWindowTitle("{0} - {1}".format( - QApplication.applicationName(), title)) - messageBox.setTextFormat(textFormat) - messageBox.setText(text) - messageBox.setStandardButtons(buttons) - messageBox.setDefaultButton(defaultButton) - messageBox.exec() - clickedButton = messageBox.clickedButton() - if clickedButton is None: - return QMessageBox.StandardButton.NoButton - else: - return messageBox.standardButton(clickedButton) - -# the about functions are here for consistancy -about = QMessageBox.about -aboutQt = QMessageBox.aboutQt - - -def critical(parent, title, text, - buttons=QMessageBox.StandardButton.Ok, - defaultButton=QMessageBox.StandardButton.NoButton): - """ - Function to show a modal critical message box. - - @param parent parent widget of the message box (QWidget) - @param title caption of the message box (string) - @param text text to be shown by the message box (string) - @param buttons flags indicating which buttons to show - (QMessageBox.StandardButtons) - @param defaultButton flag indicating the default button - (QMessageBox.StandardButton) - @return button pressed by the user (QMessageBox.StandardButton) - """ - return __messageBox(parent, title, text, QMessageBox.Icon.Critical, - buttons, defaultButton) - - -def information(parent, title, text, - buttons=QMessageBox.StandardButton.Ok, - defaultButton=QMessageBox.StandardButton.NoButton): - """ - Function to show a modal information message box. - - @param parent parent widget of the message box (QWidget) - @param title caption of the message box (string) - @param text text to be shown by the message box (string) - @param buttons flags indicating which buttons to show - (QMessageBox.StandardButtons) - @param defaultButton flag indicating the default button - (QMessageBox.StandardButton) - @return button pressed by the user (QMessageBox.StandardButton) - """ - return __messageBox(parent, title, text, QMessageBox.Icon.Information, - buttons, defaultButton) - - -def question(parent, title, text, - buttons=QMessageBox.StandardButton.Ok, - defaultButton=QMessageBox.StandardButton.NoButton): - """ - Function to show a modal question message box. - - @param parent parent widget of the message box (QWidget) - @param title caption of the message box (string) - @param text text to be shown by the message box (string) - @param buttons flags indicating which buttons to show - (QMessageBox.StandardButtons) - @param defaultButton flag indicating the default button - (QMessageBox.StandardButton) - @return button pressed by the user (QMessageBox.StandardButton) - """ - return __messageBox(parent, title, text, QMessageBox.Icon.Question, - buttons, defaultButton) - - -def warning(parent, title, text, - buttons=QMessageBox.StandardButton.Ok, - defaultButton=QMessageBox.StandardButton.NoButton): - """ - Function to show a modal warning message box. - - @param parent parent widget of the message box (QWidget) - @param title caption of the message box (string) - @param text text to be shown by the message box (string) - @param buttons flags indicating which buttons to show - (QMessageBox.StandardButtons) - @param defaultButton flag indicating the default button - (QMessageBox.StandardButton) - @return button pressed by the user (QMessageBox.StandardButton) - """ - return __messageBox(parent, title, text, QMessageBox.Icon.Warning, - buttons, defaultButton) - -############################################################################### -## Additional convenience functions ## -############################################################################### - - -def yesNo(parent, title, text, icon=Question, yesDefault=False, - textFormat=Qt.TextFormat.AutoText): - """ - Function to show a model yes/no message box. - - @param parent parent widget of the message box (QWidget) - @param title caption of the message box (string) - @param text text to be shown by the message box (string) - @param icon icon for the dialog (Critical, Information, Question or - Warning) - @param yesDefault flag indicating that the Yes button should be the - default button (boolean) - @param textFormat format of the text (Qt.TextFormat) - @return flag indicating the selection of the Yes button (boolean) - @exception ValueError raised to indicate a bad parameter value - """ - if icon not in [Critical, Information, Question, Warning]: - raise ValueError("Bad value for 'icon' parameter.") - - res = __messageBox( - parent, title, text, icon, - QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, - yesDefault and QMessageBox.StandardButton.Yes or - QMessageBox.StandardButton.No, - textFormat) - return res == QMessageBox.StandardButton.Yes - - -def retryAbort(parent, title, text, icon=Question, - textFormat=Qt.TextFormat.AutoText): - """ - Function to show a model abort/retry message box. - - @param parent parent widget of the message box (QWidget) - @param title caption of the message box (string) - @param text text to be shown by the message box (string) - @param icon icon for the dialog (Critical, Information, Question or - Warning) - @param textFormat format of the text (Qt.TextFormat) - @return flag indicating the selection of the Retry button (boolean) - @exception ValueError raised to indicate a bad parameter value - """ - if icon not in [Critical, Information, Question, Warning]: - raise ValueError("Bad value for 'icon' parameter.") - - res = __messageBox( - parent, title, text, icon, - QMessageBox.StandardButton.Retry | QMessageBox.StandardButton.Abort, - QMessageBox.StandardButton.Retry, - textFormat) - return res == QMessageBox.StandardButton.Retry - - -def okToClearData(parent, title, text, saveFunc, - textFormat=Qt.TextFormat.AutoText): - """ - Function to show a model message box to ask for clearing the data. - - @param parent parent widget of the message box (QWidget) - @param title caption of the message box (string) - @param text text to be shown by the message box (string) - @param saveFunc reference to a function performing the save action. It - must be a parameterless function returning a flag indicating success. - @param textFormat format of the text (Qt.TextFormat) - @return flag indicating that it is ok to clear the data (boolean) - """ - res = __messageBox( - parent, title, text, QMessageBox.Icon.Warning, - (QMessageBox.StandardButton.Abort | - QMessageBox.StandardButton.Discard | - QMessageBox.StandardButton.Save), - QMessageBox.StandardButton.Save, - textFormat) - if res == QMessageBox.StandardButton.Abort: - return False - if res == QMessageBox.StandardButton.Save: - return saveFunc() - return True
--- a/eric7/E5Gui/E5ModelMenu.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,441 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2009 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a menu populated from a QAbstractItemModel. -""" - -from PyQt6.QtCore import pyqtSignal, Qt, QModelIndex, QPoint -from PyQt6.QtGui import QFontMetrics, QDrag, QAction -from PyQt6.QtWidgets import QMenu, QApplication - -import UI.PixmapCache - - -class E5ModelMenu(QMenu): - """ - Class implementing a menu populated from a QAbstractItemModel. - - @signal activated(QModelIndex) emitted when an action has been triggered - """ - activated = pyqtSignal(QModelIndex) - - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - - self.__maxRows = -1 - self.__firstSeparator = -1 - self.__maxWidth = -1 - self.__statusBarTextRole = 0 - self.__separatorRole = 0 - self.__model = None - self.__root = QModelIndex() - self.__dragStartPosition = QPoint() - - self.setAcceptDrops(True) - - self._mouseButton = Qt.MouseButton.NoButton - self._keyboardModifiers = Qt.KeyboardModifier.NoModifier - self.__dropRow = -1 - self.__dropIndex = None - - # This is to ensure it will be shown on Mac OS X - self.addAction("--not populated--") - - self.aboutToShow.connect(self.__aboutToShow) - self.triggered.connect(self.__actionTriggered) - - def prePopulated(self): - """ - Public method to add any actions before the tree. - - @return flag indicating if any actions were added - """ - return False - - def postPopulated(self): - """ - Public method to add any actions after the tree. - """ - pass - - def setModel(self, model): - """ - Public method to set the model for the menu. - - @param model reference to the model (QAbstractItemModel) - """ - self.__model = model - - def model(self): - """ - Public method to get a reference to the model. - - @return reference to the model (QAbstractItemModel) - """ - return self.__model - - def setMaxRows(self, rows): - """ - Public method to set the maximum number of entries to show. - - @param rows maximum number of entries to show (integer) - """ - self.__maxRows = rows - - def maxRows(self): - """ - Public method to get the maximum number of entries to show. - - @return maximum number of entries to show (integer) - """ - return self.__maxRows - - def setFirstSeparator(self, offset): - """ - Public method to set the first separator. - - @param offset row number of the first separator (integer) - """ - self.__firstSeparator = offset - - def firstSeparator(self): - """ - Public method to get the first separator. - - @return row number of the first separator (integer) - """ - return self.__firstSeparator - - def setRootIndex(self, index): - """ - Public method to set the index of the root item. - - @param index index of the root item (QModelIndex) - """ - self.__root = index - - def rootIndex(self): - """ - Public method to get the index of the root item. - - @return index of the root item (QModelIndex) - """ - return self.__root - - def setStatusBarTextRole(self, role): - """ - Public method to set the role of the status bar text. - - @param role role of the status bar text (integer) - """ - self.__statusBarTextRole = role - - def statusBarTextRole(self): - """ - Public method to get the role of the status bar text. - - @return role of the status bar text (integer) - """ - return self.__statusBarTextRole - - def setSeparatorRole(self, role): - """ - Public method to set the role of the separator. - - @param role role of the separator (integer) - """ - self.__separatorRole = role - - def separatorRole(self): - """ - Public method to get the role of the separator. - - @return role of the separator (integer) - """ - return self.__separatorRole - - def __aboutToShow(self): - """ - Private slot to show the menu. - """ - self.clear() - - if self.prePopulated(): - self.addSeparator() - max_ = self.__maxRows - if max_ != -1: - max_ += self.__firstSeparator - self.createMenu(self.__root, max_, self, self) - self.postPopulated() - - def createBaseMenu(self): - """ - Public method to get the menu that is used to populate sub menu's. - - @return reference to the menu (E5ModelMenu) - """ - return E5ModelMenu(self) - - def createMenu(self, parent, max_, parentMenu=None, menu=None): - """ - Public method to put all the children of a parent into a menu of a - given length. - - @param parent index of the parent item (QModelIndex) - @param max_ maximum number of entries (integer) - @param parentMenu reference to the parent menu (QMenu) - @param menu reference to the menu to be populated (QMenu) - """ - if menu is None: - v = parent - - title = parent.data() - modelMenu = self.createBaseMenu() - # triggered goes all the way up the menu structure - modelMenu.triggered.disconnect(modelMenu.__actionTriggered) - modelMenu.setTitle(title) - - icon = parent.data(Qt.ItemDataRole.DecorationRole) - if icon == NotImplemented or icon is None: - icon = UI.PixmapCache.getIcon("defaultIcon") - modelMenu.setIcon(icon) - if parentMenu is not None: - parentMenu.addMenu(modelMenu).setData(v) - modelMenu.setRootIndex(parent) - modelMenu.setModel(self.__model) - return - - if self.__model is None: - return - - end = self.__model.rowCount(parent) - if max_ != -1: - end = min(max_, end) - - for i in range(end): - idx = self.__model.index(i, 0, parent) - if self.__model.hasChildren(idx): - self.createMenu(idx, -1, menu) - else: - if ( - self.__separatorRole != 0 and - idx.data(self.__separatorRole) - ): - self.addSeparator() - else: - menu.addAction(self.__makeAction(idx)) - - if menu == self and i == self.__firstSeparator - 1: - self.addSeparator() - - def __makeAction(self, idx): - """ - Private method to create an action. - - @param idx index of the item to create an action for (QModelIndex) - @return reference to the created action (QAction) - """ - icon = idx.data(Qt.ItemDataRole.DecorationRole) - if icon == NotImplemented or icon is None: - icon = UI.PixmapCache.getIcon("defaultIcon") - action = self.makeAction(icon, idx.data(), self) - action.setStatusTip(idx.data(self.__statusBarTextRole)) - - v = idx - action.setData(v) - - return action - - def makeAction(self, icon, text, parent): - """ - Public method to create an action. - - @param icon icon of the action (QIcon) - @param text text of the action (string) - @param parent reference to the parent object (QObject) - @return reference to the created action (QAction) - """ - fm = QFontMetrics(self.font()) - if self.__maxWidth == -1: - try: - self.__maxWidth = fm.horizontalAdvance("m") * 30 - except AttributeError: - self.__maxWidth = fm.width('m') * 30 - smallText = fm.elidedText(text, Qt.TextElideMode.ElideMiddle, - self.__maxWidth) - - return QAction(icon, smallText, parent) - - def __actionTriggered(self, action): - """ - Private slot to handle the triggering of an action. - - @param action reference to the action that was triggered (QAction) - """ - idx = self.index(action) - if idx.isValid(): - self._keyboardModifiers = QApplication.keyboardModifiers() - self.activated[QModelIndex].emit(idx) - - def index(self, action): - """ - Public method to get the index of an action. - - @param action reference to the action to get the index for (QAction) - @return index of the action (QModelIndex) - """ - if action is None: - return QModelIndex() - - idx = action.data() - if idx is None: - return QModelIndex() - - if not isinstance(idx, QModelIndex): - return QModelIndex() - - return idx - - def dragEnterEvent(self, evt): - """ - Protected method to handle drag enter events. - - @param evt reference to the event (QDragEnterEvent) - """ - if self.__model is not None: - mimeTypes = self.__model.mimeTypes() - for mimeType in mimeTypes: - if evt.mimeData().hasFormat(mimeType): - evt.acceptProposedAction() - - super().dragEnterEvent(evt) - - def dropEvent(self, evt): - """ - Protected method to handle drop events. - - @param evt reference to the event (QDropEvent) - """ - if self.__model is not None: - act = self.actionAt(evt.position().toPoint()) - parentIndex = self.__root - if act is None: - row = self.__model.rowCount(self.__root) - else: - idx = self.index(act) - if not idx.isValid(): - super().dropEvent(evt) - return - - row = idx.row() - if self.__model.hasChildren(idx): - parentIndex = idx - row = self.__model.rowCount(idx) - - self.__dropRow = row - self.__dropIndex = parentIndex - evt.acceptProposedAction() - self.__model.dropMimeData(evt.mimeData(), evt.dropAction(), - row, 0, parentIndex) - self.close() - - super().dropEvent(evt) - - def mousePressEvent(self, evt): - """ - Protected method handling mouse press events. - - @param evt reference to the event object (QMouseEvent) - """ - if evt.button() == Qt.MouseButton.LeftButton: - self.__dragStartPosition = evt.position().toPoint() - super().mousePressEvent(evt) - - def mouseMoveEvent(self, evt): - """ - Protected method to handle mouse move events. - - @param evt reference to the event (QMouseEvent) - """ - if self.__model is None: - super().mouseMoveEvent(evt) - return - - if not (evt.buttons() & Qt.MouseButton.LeftButton): - super().mouseMoveEvent(evt) - return - - if self.__dragStartPosition.isNull(): - super().mouseMoveEvent(evt) - return - - manhattanLength = (evt.position().toPoint() - - self.__dragStartPosition).manhattanLength() - if manhattanLength <= QApplication.startDragDistance(): - super().mouseMoveEvent(evt) - return - - act = self.actionAt(self.__dragStartPosition) - if act is None: - super().mouseMoveEvent(evt) - return - - idx = self.index(act) - if not idx.isValid(): - super().mouseMoveEvent(evt) - return - - drag = QDrag(self) - drag.setMimeData(self.__model.mimeData([idx])) - actionRect = self.actionGeometry(act) - drag.setPixmap(self.grab(actionRect)) - - if drag.exec() == Qt.DropAction.MoveAction: - row = idx.row() - if self.__dropIndex == idx.parent() and self.__dropRow <= row: - row += 1 - self.__model.removeRow(row, self.__root) - - if not self.isAncestorOf(drag.target()): - self.close() - else: - self.aboutToShow.emit() - - def mouseReleaseEvent(self, evt): - """ - Protected method handling mouse release events. - - @param evt reference to the event object (QMouseEvent) - """ - self._mouseButton = evt.button() - self._keyboardModifiers = evt.modifiers() - - if evt.button() == Qt.MouseButton.LeftButton: - self.__dragStartPosition = QPoint() - - super().mouseReleaseEvent(evt) - - def resetFlags(self): - """ - Public method to reset the saved internal state. - """ - self._mouseButton = Qt.MouseButton.NoButton - self._keyboardModifiers = Qt.KeyboardModifier.NoModifier - - def removeEntry(self, idx): - """ - Public method to remove a menu entry. - - @param idx index of the entry to be removed (QModelIndex) - """ - row = idx.row() - self.__model.removeRow(row, self.__root) - self.aboutToShow.emit()
--- a/eric7/E5Gui/E5ModelToolBar.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,293 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2009 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a tool bar populated from a QAbstractItemModel. -""" - -from PyQt6.QtCore import pyqtSignal, Qt, QModelIndex, QPoint, QEvent -from PyQt6.QtGui import QDrag, QIcon -from PyQt6.QtWidgets import QApplication, QToolBar, QToolButton - - -class E5ModelToolBar(QToolBar): - """ - Class implementing a tool bar populated from a QAbstractItemModel. - - @signal activated(QModelIndex) emitted when an action has been triggered - """ - activated = pyqtSignal(QModelIndex) - - def __init__(self, title=None, parent=None): - """ - Constructor - - @param title title for the tool bar (string) - @param parent reference to the parent widget (QWidget) - """ - if title is not None: - super().__init__(title, parent) - else: - super().__init__(parent) - - self.__model = None - - self.__root = QModelIndex() - self.__dragStartPosition = QPoint() - - if self.isVisible(): - self._build() - - self.setAcceptDrops(True) - - self._mouseButton = Qt.MouseButton.NoButton - self._keyboardModifiers = Qt.KeyboardModifier.NoModifier - self.__dropRow = -1 - self.__dropIndex = None - - def setModel(self, model): - """ - Public method to set the model for the tool bar. - - @param model reference to the model (QAbstractItemModel) - """ - if self.__model is not None: - self.__model.modelReset.disconnect(self._build) - self.__model.rowsInserted[QModelIndex, int, int].disconnect( - self._build) - self.__model.rowsRemoved[QModelIndex, int, int].disconnect( - self._build) - self.__model.dataChanged.disconnect( - self._build) - - self.__model = model - - if self.__model is not None: - self.__model.modelReset.connect(self._build) - self.__model.rowsInserted[QModelIndex, int, int].connect( - self._build) - self.__model.rowsRemoved[QModelIndex, int, int].connect( - self._build) - self.__model.dataChanged.connect( - self._build) - - def model(self): - """ - Public method to get a reference to the model. - - @return reference to the model (QAbstractItemModel) - """ - return self.__model - - def setRootIndex(self, idx): - """ - Public method to set the root index. - - @param idx index to be set as the root index (QModelIndex) - """ - self.__root = idx - - def rootIndex(self): - """ - Public method to get the root index. - - @return root index (QModelIndex) - """ - return self.__root - - def _build(self): - """ - Protected slot to build the tool bar. - """ - if self.__model is None: - return - - self.clear() - - for i in range(self.__model.rowCount(self.__root)): - idx = self.__model.index(i, 0, self.__root) - - title = idx.data(Qt.ItemDataRole.DisplayRole) - icon = idx.data(Qt.ItemDataRole.DecorationRole) - if icon == NotImplemented or icon is None: - icon = QIcon() - folder = self.__model.hasChildren(idx) - - act = self.addAction(icon, title) - act.setData(idx) - - button = self.widgetForAction(act) - button.installEventFilter(self) - - if folder: - menu = self._createMenu() - menu.setModel(self.__model) - menu.setRootIndex(idx) - button.setMenu(menu) - button.setPopupMode( - QToolButton.ToolButtonPopupMode.InstantPopup) - button.setToolButtonStyle( - Qt.ToolButtonStyle.ToolButtonTextBesideIcon) - - def index(self, action): - """ - Public method to get the index of an action. - - @param action reference to the action to get the index for (QAction) - @return index of the action (QModelIndex) - """ - if action is None: - return QModelIndex() - - idx = action.data() - if idx is None: - return QModelIndex() - - if not isinstance(idx, QModelIndex): - return QModelIndex() - - return idx - - def _createMenu(self): - """ - Protected method to create the menu for a tool bar action. - - @return menu for a tool bar action (E5ModelMenu) - """ - from .E5ModelMenu import E5ModelMenu - return E5ModelMenu(self) - - def eventFilter(self, obj, evt): - """ - Public method to handle event for other objects. - - @param obj reference to the object (QObject) - @param evt reference to the event (QEvent) - @return flag indicating that the event should be filtered out (boolean) - """ - if evt.type() == QEvent.Type.MouseButtonRelease: - self._mouseButton = evt.button() - self._keyboardModifiers = evt.modifiers() - act = obj.defaultAction() - idx = self.index(act) - if idx.isValid(): - self.activated[QModelIndex].emit(idx) - elif ( - evt.type() == QEvent.Type.MouseButtonPress and - evt.buttons() & Qt.MouseButton.LeftButton - ): - self.__dragStartPosition = self.mapFromGlobal(evt.globalPosition().toPoint()) - - return False - - def dragEnterEvent(self, evt): - """ - Protected method to handle drag enter events. - - @param evt reference to the event (QDragEnterEvent) - """ - if self.__model is not None: - mimeTypes = self.__model.mimeTypes() - for mimeType in mimeTypes: - if evt.mimeData().hasFormat(mimeType): - evt.acceptProposedAction() - - super().dragEnterEvent(evt) - - def dropEvent(self, evt): - """ - Protected method to handle drop events. - - @param evt reference to the event (QDropEvent) - @exception RuntimeError raised to indicate an invalid model index - """ - if self.__model is not None: - act = self.actionAt(evt.position().toPoint()) - parentIndex = self.__root - if act is None: - row = self.__model.rowCount(self.__root) - else: - idx = self.index(act) - if not idx.isValid(): - raise RuntimeError("invalid index") - row = idx.row() - if self.__model.hasChildren(idx): - parentIndex = idx - row = self.__model.rowCount(idx) - - self.__dropRow = row - self.__dropIndex = parentIndex - evt.acceptProposedAction() - self.__model.dropMimeData(evt.mimeData(), evt.dropAction(), - row, 0, parentIndex) - - super().dropEvent(evt) - - def mouseMoveEvent(self, evt): - """ - Protected method to handle mouse move events. - - @param evt reference to the event (QMouseEvent) - @exception RuntimeError raised to indicate an invalid model index - """ - if self.__model is None: - super().mouseMoveEvent(evt) - return - - if not (evt.buttons() & Qt.MouseButton.LeftButton): - super().mouseMoveEvent(evt) - return - - manhattanLength = (evt.position().toPoint() - - self.__dragStartPosition).manhattanLength() - if manhattanLength <= QApplication.startDragDistance(): - super().mouseMoveEvent(evt) - return - - act = self.actionAt(self.__dragStartPosition) - if act is None: - super().mouseMoveEvent(evt) - return - - idx = self.index(act) - if not idx.isValid(): - raise RuntimeError("invalid index") - - drag = QDrag(self) - drag.setMimeData(self.__model.mimeData([idx])) - actionRect = self.actionGeometry(act) - drag.setPixmap(self.grab(actionRect)) - - if drag.exec() == Qt.DropAction.MoveAction: - row = idx.row() - if self.__dropIndex == idx.parent() and self.__dropRow <= row: - row += 1 - self.__model.removeRow(row, self.__root) - - def hideEvent(self, evt): - """ - Protected method to handle hide events. - - @param evt reference to the hide event (QHideEvent) - """ - self.clear() - super().hideEvent(evt) - - def showEvent(self, evt): - """ - Protected method to handle show events. - - @param evt reference to the hide event (QHideEvent) - """ - if len(self.actions()) == 0: - self._build() - super().showEvent(evt) - - def resetFlags(self): - """ - Public method to reset the saved internal state. - """ - self._mouseButton = Qt.MouseButton.NoButton - self._keyboardModifiers = Qt.KeyboardModifier.NoModifier
--- a/eric7/E5Gui/E5OverrideCursor.py Sat May 22 17:01:51 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2020 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a context manager class for an override cursor and a -QProcess class controlling an override cursor. -""" - -import contextlib - -from PyQt6.QtCore import pyqtSlot, Qt, QProcess, QEventLoop -from PyQt6.QtGui import QCursor, QGuiApplication - - -class E5OverrideCursor(contextlib.AbstractContextManager): - """ - Class implementing a context manager class for an override cursor. - """ - def __init__(self, cursorShape=Qt.CursorShape.WaitCursor): - """ - Constructor - - @param cursorShape shape of the override cursor - @type Qt.CursorShape - """ - self.__cursorShape = cursorShape - - def __enter__(self): - """ - Special method called when entering the runtime ccontext. - - @return reference to the context manager object - @rtype E5OverrideCursor - """