Sat, 22 May 2021 19:58:24 +0200
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
--- a/eric7.epj Sat May 22 19:52:34 2021 +0200 +++ b/eric7.epj Sat May 22 19:58:24 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, 18:49:32" + "saved": "2021-05-22, 19:54:46" }, "project": { "AUTHOR": "Detlev Offenbach", @@ -701,15 +701,15 @@ "eric7/EricNetwork/EricSslCertificatesDialog.ui", "eric7/EricNetwork/EricSslCertificatesInfoDialog.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" + "eric7/EricWidgets/EricComboSelectionDialog.ui", + "eric7/EricWidgets/EricErrorMessageFilterDialog.ui", + "eric7/EricWidgets/EricListSelectionDialog.ui", + "eric7/EricWidgets/EricPlainTextDialog.ui", + "eric7/EricWidgets/EricProcessDialog.ui", + "eric7/EricWidgets/EricSimpleHelpDialog.ui", + "eric7/EricWidgets/EricStringListEditWidget.ui", + "eric7/EricWidgets/EricToolBarDialog.ui", + "eric7/EricWidgets/EricZoomWidget.ui" ], "HASH": "df7daa8781250f7664e6ecaeaf1361fa2efd39ee", "IDLPARAMS": { @@ -1072,7 +1072,6 @@ "eric7/DocumentationTools/TemplatesListsStyle.py", "eric7/DocumentationTools/TemplatesListsStyleCSS.py", "eric7/DocumentationTools/__init__.py", - "eric7/E5Gui/__init__.py", "eric7/Globals/AppInfo.py", "eric7/Globals/__init__.py", "eric7/Graphics/ApplicationDiagramBuilder.py", @@ -2217,54 +2216,57 @@ "eric7/EricNetwork/EricSslUtilities.py", "eric7/EricNetwork/EricTldExtractor.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" + "eric7/EricCore/__init__.py", + "eric7/EricCore/EricTreeSortFilterProxyModel.py", + "eric7/EricGui/__init__.py", + "eric7/EricGui/EricAction.py", + "eric7/EricGui/EricGenericDiffHighlighter.py", + "eric7/EricGui/EricOverrideCursor.py", + "eric7/EricWidgets/__init__.py", + "eric7/EricWidgets/EricAnimatedLabel.py", + "eric7/EricWidgets/EricAnimatedWidget.py", + "eric7/EricWidgets/EricApplication.py", + "eric7/EricWidgets/EricClickableLabel.py", + "eric7/EricWidgets/EricComboSelectionDialog.py", + "eric7/EricWidgets/EricCompleters.py", + "eric7/EricWidgets/EricErrorMessage.py", + "eric7/EricWidgets/EricErrorMessageFilterDialog.py", + "eric7/EricWidgets/EricFileDialog.py", + "eric7/EricWidgets/EricFileSaveConfirmDialog.py", + "eric7/EricWidgets/EricLed.py", + "eric7/EricWidgets/EricLineEdit.py", + "eric7/EricWidgets/EricLineEditButton.py", + "eric7/EricWidgets/EricListSelectionDialog.py", + "eric7/EricWidgets/EricListView.py", + "eric7/EricWidgets/EricMainWindow.py", + "eric7/EricWidgets/EricMapWidget.py", + "eric7/EricWidgets/EricMessageBox.py", + "eric7/EricWidgets/EricModelMenu.py", + "eric7/EricWidgets/EricModelToolBar.py", + "eric7/EricWidgets/EricPassivePopup.py", + "eric7/EricWidgets/EricPasswordMeter.py", + "eric7/EricWidgets/EricPathPicker.py", + "eric7/EricWidgets/EricPathPickerDialog.py", + "eric7/EricWidgets/EricPlainTextDialog.py", + "eric7/EricWidgets/EricProcessDialog.py", + "eric7/EricWidgets/EricProgressDialog.py", + "eric7/EricWidgets/EricSideBar.py", + "eric7/EricWidgets/EricSimpleHelpDialog.py", + "eric7/EricWidgets/EricSingleApplication.py", + "eric7/EricWidgets/EricSqueezeLabels.py", + "eric7/EricWidgets/EricStringListEditWidget.py", + "eric7/EricWidgets/EricTabWidget.py", + "eric7/EricWidgets/EricTableView.py", + "eric7/EricWidgets/EricTextEditSearchWidget.py", + "eric7/EricWidgets/EricTextInputDialog.py", + "eric7/EricWidgets/EricTextSpinBox.py", + "eric7/EricWidgets/EricToolBarDialog.py", + "eric7/EricWidgets/EricToolBarManager.py", + "eric7/EricWidgets/EricToolBox.py", + "eric7/EricWidgets/EricToolButton.py", + "eric7/EricWidgets/EricTreeView.py", + "eric7/EricWidgets/EricTreeWidget.py", + "eric7/EricWidgets/EricZoomWidget.py" ], "SPELLEXCLUDES": "Dictionaries/excludes.dic", "SPELLLANGUAGE": "en_US",
--- a/eric7/CondaInterface/Conda.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/CondaInterface/Conda.py Sat May 22 19:58:24 2021 +0200 @@ -14,7 +14,7 @@ from PyQt6.QtCore import pyqtSignal, QObject, QProcess, QCoreApplication from PyQt6.QtWidgets import QDialog -from E5Gui import EricMessageBox +from EricWidgets import EricMessageBox import Globals import Preferences
--- a/eric7/CondaInterface/CondaExecDialog.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/CondaInterface/CondaExecDialog.py Sat May 22 19:58:24 2021 +0200 @@ -12,7 +12,7 @@ from PyQt6.QtCore import pyqtSlot, QProcess, QTimer from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton -from E5Gui import EricMessageBox +from EricWidgets import EricMessageBox from .Ui_CondaExecDialog import Ui_CondaExecDialog
--- a/eric7/CondaInterface/CondaExportDialog.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/CondaInterface/CondaExportDialog.py Sat May 22 19:58:24 2021 +0200 @@ -14,10 +14,10 @@ QDialog, QDialogButtonBox, QAbstractButton, QApplication ) -from E5Gui import EricMessageBox, EricFileDialog -from E5Gui.EricPathPicker import EricPathPickerModes -from E5Gui.EricApplication import ericApp -from E5Gui.EricOverrideCursor import EricOverrideCursor +from EricWidgets import EricMessageBox, EricFileDialog +from EricWidgets.EricPathPicker import EricPathPickerModes +from EricWidgets.EricApplication import ericApp +from EricGui.EricOverrideCursor import EricOverrideCursor from .Ui_CondaExportDialog import Ui_CondaExportDialog
--- a/eric7/CondaInterface/CondaExportDialog.ui Sat May 22 19:52:34 2021 +0200 +++ b/eric7/CondaInterface/CondaExportDialog.ui Sat May 22 19:58:24 2021 +0200 @@ -158,7 +158,7 @@ <customwidget> <class>EricPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/EricPathPicker.h</header> + <header>EricWidgets/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/CondaInterface/CondaNewEnvironmentDataDialog.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/CondaInterface/CondaNewEnvironmentDataDialog.py Sat May 22 19:58:24 2021 +0200 @@ -10,7 +10,7 @@ from PyQt6.QtCore import pyqtSlot from PyQt6.QtWidgets import QDialog, QDialogButtonBox -from E5Gui.EricPathPicker import EricPathPickerModes +from EricWidgets.EricPathPicker import EricPathPickerModes from .Ui_CondaNewEnvironmentDataDialog import Ui_CondaNewEnvironmentDataDialog
--- a/eric7/CondaInterface/CondaNewEnvironmentDataDialog.ui Sat May 22 19:52:34 2021 +0200 +++ b/eric7/CondaInterface/CondaNewEnvironmentDataDialog.ui Sat May 22 19:58:24 2021 +0200 @@ -93,7 +93,7 @@ <customwidget> <class>EricPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/EricPathPicker.h</header> + <header>EricWidgets/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/CondaInterface/CondaPackagesWidget.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/CondaInterface/CondaPackagesWidget.py Sat May 22 19:58:24 2021 +0200 @@ -15,9 +15,9 @@ QDialog ) -from E5Gui import EricFileDialog, EricMessageBox, EricTextInputDialog -from E5Gui.EricApplication import ericApp -from E5Gui.EricOverrideCursor import EricOverrideCursor +from EricWidgets import EricFileDialog, EricMessageBox, EricTextInputDialog +from EricWidgets.EricApplication import ericApp +from EricGui.EricOverrideCursor import EricOverrideCursor from .Ui_CondaPackagesWidget import Ui_CondaPackagesWidget
--- a/eric7/CondaInterface/CondaPackagesWidget.ui Sat May 22 19:52:34 2021 +0200 +++ b/eric7/CondaInterface/CondaPackagesWidget.ui Sat May 22 19:58:24 2021 +0200 @@ -433,7 +433,7 @@ <customwidget> <class>EricToolButton</class> <extends>QToolButton</extends> - <header>E5Gui/EricToolButton.h</header> + <header>EricWidgets/EricToolButton.h</header> </customwidget> </customwidgets> <tabstops>
--- a/eric7/Cooperation/ChatWidget.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Cooperation/ChatWidget.py Sat May 22 19:58:24 2021 +0200 @@ -11,8 +11,8 @@ from PyQt6.QtGui import QColor from PyQt6.QtWidgets import QWidget, QListWidgetItem, QMenu, QApplication -from E5Gui.EricApplication import ericApp -from E5Gui import EricMessageBox, EricFileDialog +from EricWidgets.EricApplication import ericApp +from EricWidgets import EricMessageBox, EricFileDialog from Globals import recentNameHosts
--- a/eric7/Cooperation/ChatWidget.ui Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Cooperation/ChatWidget.ui Sat May 22 19:58:24 2021 +0200 @@ -332,7 +332,7 @@ <customwidget> <class>EricLed</class> <extends>QWidget</extends> - <header>E5Gui/EricLed.h</header> + <header>EricWidgets/EricLed.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Cooperation/Connection.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Cooperation/Connection.py Sat May 22 19:58:24 2021 +0200 @@ -10,8 +10,8 @@ from PyQt6.QtCore import pyqtSignal, QTimer, QTime, QByteArray from PyQt6.QtNetwork import QTcpSocket, QHostInfo -from E5Gui import EricMessageBox -from E5Gui.EricApplication import ericApp +from EricWidgets import EricMessageBox +from EricWidgets.EricApplication import ericApp import Preferences
--- a/eric7/DataViews/PyCoverageDialog.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/DataViews/PyCoverageDialog.py Sat May 22 19:58:24 2021 +0200 @@ -16,9 +16,9 @@ QApplication ) -from E5Gui import EricMessageBox -from E5Gui.EricApplication import ericApp -from E5Gui.EricProgressDialog import EricProgressDialog +from EricWidgets import EricMessageBox +from EricWidgets.EricApplication import ericApp +from EricWidgets.EricProgressDialog import EricProgressDialog from .Ui_PyCoverageDialog import Ui_PyCoverageDialog
--- a/eric7/DataViews/PyProfileDialog.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/DataViews/PyProfileDialog.py Sat May 22 19:58:24 2021 +0200 @@ -16,7 +16,7 @@ QApplication ) -from E5Gui import EricMessageBox +from EricWidgets import EricMessageBox from .Ui_PyProfileDialog import Ui_PyProfileDialog import Utilities
--- a/eric7/Debugger/BreakPointViewer.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/BreakPointViewer.py Sat May 22 19:58:24 2021 +0200 @@ -14,7 +14,7 @@ QTreeView, QAbstractItemView, QHeaderView, QMenu, QDialog ) -from E5Gui.EricApplication import ericApp +from EricWidgets.EricApplication import ericApp from Globals import recentNameBreakpointFiles, recentNameBreakpointConditions
--- a/eric7/Debugger/CallStackViewer.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/CallStackViewer.py Sat May 22 19:58:24 2021 +0200 @@ -12,8 +12,8 @@ QTreeWidget, QTreeWidgetItem, QMenu, QWidget, QVBoxLayout, QLabel ) -from E5Gui.EricApplication import ericApp -from E5Gui import EricFileDialog, EricMessageBox +from EricWidgets.EricApplication import ericApp +from EricWidgets import EricFileDialog, EricMessageBox import Utilities
--- a/eric7/Debugger/CallTraceViewer.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/CallTraceViewer.py Sat May 22 19:58:24 2021 +0200 @@ -12,8 +12,8 @@ from PyQt6.QtCore import pyqtSlot, pyqtSignal, Qt, QFileInfo from PyQt6.QtWidgets import QWidget, QTreeWidgetItem -from E5Gui.EricApplication import ericApp -from E5Gui import EricFileDialog, EricMessageBox +from EricWidgets.EricApplication import ericApp +from EricWidgets import EricFileDialog, EricMessageBox from .Ui_CallTraceViewer import Ui_CallTraceViewer
--- a/eric7/Debugger/DebugServer.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/DebugServer.py Sat May 22 19:58:24 2021 +0200 @@ -16,8 +16,8 @@ QTcpServer, QHostAddress, QHostInfo, QNetworkInterface ) -from E5Gui.EricApplication import ericApp -from E5Gui import EricMessageBox +from EricWidgets.EricApplication import ericApp +from EricWidgets import EricMessageBox from .BreakPointModel import BreakPointModel from .WatchPointModel import WatchPointModel
--- a/eric7/Debugger/DebugUI.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/DebugUI.py Sat May 22 19:58:24 2021 +0200 @@ -15,8 +15,8 @@ from PyQt6.QtGui import QKeySequence from PyQt6.QtWidgets import QMenu, QToolBar, QApplication, QDialog -from E5Gui.EricAction import EricAction, createActionGroup -from E5Gui import EricMessageBox +from EricGui.EricAction import EricAction, createActionGroup +from EricWidgets import EricMessageBox from UI.Info import Program from UI.NotificationWidget import NotificationTypes
--- a/eric7/Debugger/DebugViewer.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/DebugViewer.py Sat May 22 19:58:24 2021 +0200 @@ -32,7 +32,7 @@ import UI.PixmapCache import Preferences -from E5Gui.EricTabWidget import EricTabWidget +from EricWidgets.EricTabWidget import EricTabWidget class DebugViewer(QWidget):
--- a/eric7/Debugger/DebuggerInterfacePython.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/DebuggerInterfacePython.py Sat May 22 19:58:24 2021 +0200 @@ -17,8 +17,8 @@ QObject, QProcess, QProcessEnvironment, QTimer ) -from E5Gui.EricApplication import ericApp -from E5Gui import EricMessageBox +from EricWidgets.EricApplication import ericApp +from EricWidgets import EricMessageBox from . import DebugClientCapabilities
--- a/eric7/Debugger/EditBreakpointDialog.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/EditBreakpointDialog.py Sat May 22 19:58:24 2021 +0200 @@ -11,7 +11,7 @@ from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QComboBox -from E5Gui.EricPathPicker import EricPathPickerModes +from EricWidgets.EricPathPicker import EricPathPickerModes from .Ui_EditBreakpointDialog import Ui_EditBreakpointDialog
--- a/eric7/Debugger/EditBreakpointDialog.ui Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/EditBreakpointDialog.ui Sat May 22 19:58:24 2021 +0200 @@ -175,7 +175,7 @@ <customwidget> <class>EricComboPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/EricPathPicker.h</header> + <header>EricWidgets/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Debugger/ExceptionLogger.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/ExceptionLogger.py Sat May 22 19:58:24 2021 +0200 @@ -12,7 +12,7 @@ from PyQt6.QtCore import pyqtSignal, Qt from PyQt6.QtWidgets import QTreeWidget, QTreeWidgetItem, QMenu -from E5Gui.EricApplication import ericApp +from EricWidgets.EricApplication import ericApp class ExceptionLogger(QTreeWidget):
--- a/eric7/Debugger/StartCoverageDialog.ui Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/StartCoverageDialog.ui Sat May 22 19:58:24 2021 +0200 @@ -273,7 +273,7 @@ <customwidget> <class>EricComboPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/EricPathPicker.h</header> + <header>EricWidgets/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Debugger/StartDebugDialog.ui Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/StartDebugDialog.ui Sat May 22 19:58:24 2021 +0200 @@ -338,7 +338,7 @@ <customwidget> <class>EricComboPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/EricPathPicker.h</header> + <header>EricWidgets/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Debugger/StartDialog.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/StartDialog.py Sat May 22 19:58:24 2021 +0200 @@ -11,8 +11,8 @@ from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QComboBox, QInputDialog -from E5Gui.EricPathPicker import EricPathPickerModes -from E5Gui.EricApplication import ericApp +from EricWidgets.EricPathPicker import EricPathPickerModes +from EricWidgets.EricApplication import ericApp import Preferences
--- a/eric7/Debugger/StartHistoryEditDialog.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/StartHistoryEditDialog.py Sat May 22 19:58:24 2021 +0200 @@ -10,7 +10,7 @@ from PyQt6.QtCore import pyqtSlot, Qt from PyQt6.QtWidgets import QDialog, QInputDialog, QLineEdit -from E5Gui import EricMessageBox +from EricWidgets import EricMessageBox from .Ui_StartHistoryEditDialog import Ui_StartHistoryEditDialog
--- a/eric7/Debugger/StartProfileDialog.ui Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/StartProfileDialog.ui Sat May 22 19:58:24 2021 +0200 @@ -270,7 +270,7 @@ <customwidget> <class>EricComboPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/EricPathPicker.h</header> + <header>EricWidgets/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Debugger/StartRunDialog.ui Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/StartRunDialog.ui Sat May 22 19:58:24 2021 +0200 @@ -253,7 +253,7 @@ <customwidget> <class>EricComboPathPicker</class> <extends>QWidget</extends> - <header>E5Gui/EricPathPicker.h</header> + <header>EricWidgets/EricPathPicker.h</header> <container>1</container> </customwidget> </customwidgets>
--- a/eric7/Debugger/VariablesViewer.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/VariablesViewer.py Sat May 22 19:58:24 2021 +0200 @@ -18,7 +18,7 @@ from PyQt6.QtGui import QBrush, QFontMetrics from PyQt6.QtWidgets import QTreeView, QAbstractItemView, QToolTip, QMenu -from E5Gui.EricApplication import ericApp +from EricWidgets.EricApplication import ericApp from .Config import ConfigVarTypeDispStrings from DebugClients.Python.DebugConfig import ConfigQtNames, ConfigKnownQtTypes
--- a/eric7/Debugger/WatchPointViewer.py Sat May 22 19:52:34 2021 +0200 +++ b/eric7/Debugger/WatchPointViewer.py Sat May 22 19:58:24 2021 +0200 @@ -14,8 +14,8 @@ QTreeView, QAbstractItemView, QMenu, QHeaderView, QDialog ) -from E5Gui.EricApplication import ericApp -from E5Gui import EricMessageBox +from EricWidgets.EricApplication import ericApp +from EricWidgets import EricMessageBox import Utilities
--- a/eric7/E5Gui/EricAction.py Sat May 22 19:52:34 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.EricApplication import ericApp - - -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 EricAction(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 ericApp().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/EricAnimatedLabel.py Sat May 22 19:52:34 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 EricAnimatedLabel(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/EricAnimatedWidget.py Sat May 22 19:52:34 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 EricAnimatedWidget(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/EricApplication.py Sat May 22 19:52:34 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 EricApplication(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 - -ericApp = QCoreApplication.instance
--- a/eric7/E5Gui/EricClickableLabel.py Sat May 22 19:52:34 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 EricClickableLabel(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/EricComboSelectionDialog.py Sat May 22 19:52:34 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 EricComboSelectionDialog(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/EricComboSelectionDialog.ui Sat May 22 19:52:34 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>EricComboSelectionDialog</class> - <widget class="QDialog" name="EricComboSelectionDialog"> - <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>EricComboSelectionDialog</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>EricComboSelectionDialog</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/EricCompleters.py Sat May 22 19:52:34 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 EricFileCompleter(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 EricDirCompleter(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 EricStringListCompleter(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/EricErrorMessage.py Sat May 22 19:52:34 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.EricApplication import ericApp - -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 EricErrorMessage(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 .EricErrorMessageFilterDialog import EricErrorMessageFilterDialog - dlg = EricErrorMessageFilterDialog( - 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() == ericApp().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 EricErrorMessage dialog as the global - message handler. - - @return reference to the message handler dialog - @rtype EricErrorMessage - """ - global _msgHandlerDialog, _origMsgHandler - - if _msgHandlerDialog is None: - # Install an EricErrorMessage dialog as the global message handler. - _msgHandlerDialog = EricErrorMessage() - _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/EricErrorMessageFilterDialog.py Sat May 22 19:52:34 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_EricErrorMessageFilterDialog import Ui_EricErrorMessageFilterDialog - - -class EricErrorMessageFilterDialog(QDialog, Ui_EricErrorMessageFilterDialog): - """ - 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/EricErrorMessageFilterDialog.ui Sat May 22 19:52:34 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>EricErrorMessageFilterDialog</class> - <widget class="QDialog" name="EricErrorMessageFilterDialog"> - <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="EricStringListEditWidget" 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>EricStringListEditWidget</class> - <extends>QWidget</extends> - <header>E5Gui/EricStringListEditWidget.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <tabstops> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>EricErrorMessageFilterDialog</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>EricErrorMessageFilterDialog</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/EricFileDialog.py Sat May 22 19:52:34 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/EricFileSaveConfirmDialog.py Sat May 22 19:52:34 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 .EricPathPicker import EricPathPicker, EricPathPickerModes - - -class EricFileSaveConfirmDialog(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 = EricPathPicker(self) - self.__pathPicker.setMode(EricPathPickerModes.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 = EricFileSaveConfirmDialog(filename, title, message=message, - picker=picker, parent=parent) - dlg.exec() - return dlg.selectedAction()
--- a/eric7/E5Gui/EricGenericDiffHighlighter.py Sat May 22 19:52:34 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 EricGenericDiffHighlighter(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/EricLed.py Sat May 22 19:52:34 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 EricLedType(enum.Enum): - """ - Class defining the LED types. - """ - RECTANGULAR = 0 - CIRCULAR = 1 - - -class EricLed(QWidget): - """ - Class implementing a LED widget. - """ - def __init__(self, parent=None, color=None, shape=EricLedType.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 EricLedType - @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 == EricLedType.CIRCULAR: - self.__paintRound() - elif self.__shape == EricLedType.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 EricLedType - """ - 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 EricLedType - """ - 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 EricClickableLed(EricLed): - """ - 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=EricLedType.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 EricLedType - @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/EricLineEdit.py Sat May 22 19:52:34 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 EricLineEditSideWidget(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 EricLineEditSide(enum.Enum): - """ - Class defining the line edit sides. - """ - LEFT = 0 - RIGHT = 1 - - -class EricLineEdit(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 = EricLineEditSideWidget(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 = EricLineEditSideWidget(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 EricLineEditSide - """ - if widget is None: - return - - if self.isRightToLeft(): - if position == EricLineEditSide.LEFT: - position = EricLineEditSide.RIGHT - else: - position = EricLineEditSide.LEFT - if position == EricLineEditSide.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 EricLineEditSide - @return text margin - @rtype int - """ - spacing = self.__rightLayout.spacing() - w = 0 - w = ( - self.__leftWidget.sizeHint().width() - if position == EricLineEditSide.LEFT else - self.__rightWidget.sizeHint().width() - ) - if w == 0: - return 0 - return w + spacing * 2 - -class EricClearableLineEdit(EricLineEdit): - """ - 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=EricLineEditSide.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 EricLineEditSide - """ - super().__init__(parent, placeholderText) - - self.setClearButtonEnabled(True)
--- a/eric7/E5Gui/EricLineEditButton.py Sat May 22 19:52:34 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 EricLineEdit. -""" - -from PyQt6.QtCore import Qt, QPoint, QPointF -from PyQt6.QtGui import QPainter, QPainterPath -from PyQt6.QtWidgets import QAbstractButton - - -# TODO: Get rid of this -class EricLineEditButton(QAbstractButton): - """ - Class implementing a button to be used with EricLineEdit. - """ - 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/EricListSelectionDialog.py Sat May 22 19:52:34 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_EricListSelectionDialog import Ui_EricListSelectionDialog - - -class EricListSelectionDialog(QDialog, Ui_EricListSelectionDialog): - """ - 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/EricListSelectionDialog.ui Sat May 22 19:52:34 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>EricListSelectionDialog</class> - <widget class="QDialog" name="EricListSelectionDialog"> - <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>EricListSelectionDialog</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>EricListSelectionDialog</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/EricListView.py Sat May 22 19:52:34 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 EricListView(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/EricMainWindow.py Sat May 22 19:52:34 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 .EricApplication import ericApp -from . import EricMessageBox - - -class EricMainWindow(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: - EricMessageBox.warning( - self, - QCoreApplication.translate( - "EricMainWindow", "Loading Style Sheet"), - QCoreApplication.translate( - "EricMainWindow", - """<p>The Qt Style Sheet file <b>{0}</b> could""" - """ not be read.<br>Reason: {1}</p>""") - .format(styleSheetFile, str(msg))) - return - else: - styleSheet = "" - - ericApp().setStyleSheet(styleSheet)
--- a/eric7/E5Gui/EricMapWidget.py Sat May 22 19:52:34 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 EricMapWidget(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/EricMessageBox.py Sat May 22 19:52:34 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,303 +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__ - -# 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 EricMessageBox(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/EricModelMenu.py Sat May 22 19:52:34 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 EricModelMenu(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 (EricModelMenu) - """ - return EricModelMenu(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/EricModelToolBar.py Sat May 22 19:52:34 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 EricModelToolBar(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 (EricModelMenu) - """ - from .EricModelMenu import EricModelMenu - return EricModelMenu(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/EricOverrideCursor.py Sat May 22 19:52:34 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 EricOverrideCursor(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 EricOverrideCursor - """ - QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape)) - QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) - - return self - - def __exit__(self, exc_type, exc_value, traceback): - """ - Special method called when exiting the runtime ccontext. - - @param exc_type type of an exception raised in the runtime context - @param exc_value value of an exception raised in the runtime context - @param traceback traceback of an exception raised in the runtime - context - @return always returns None to not suppress any exception - @rtype None - """ - QGuiApplication.restoreOverrideCursor() - QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) - - return None # __IGNORE_WARNING_M831__ - - -class EricOverridenCursor(contextlib.AbstractContextManager): - """ - Class implementing a context manager class for an overriden cursor. - - The cursor is reset upon entering the runtime context and restored - upon exiting it. - """ - def __init__(self): - """ - Constructor - """ - self.__cursorShape = None - - def __enter__(self): - """ - Special method called when entering the runtime ccontext. - - @return reference to the context manager object - @rtype EricOverrideCursor - """ - cursor = QGuiApplication.overrideCursor() - if cursor is not None: - self.__cursorShape = cursor.shape() - QGuiApplication.restoreOverrideCursor() - QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) - - return self - - def __exit__(self, exc_type, exc_value, traceback): - """ - Special method called when exiting the runtime ccontext. - - @param exc_type type of an exception raised in the runtime context - @param exc_value value of an exception raised in the runtime context - @param traceback traceback of an exception raised in the runtime - context - @return always returns None to not suppress any exception - @rtype None - """ - if self.__cursorShape is not None: - QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape)) - QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) - - return None # __IGNORE_WARNING_M831__ - - -class EricOverrideCursorProcess(QProcess): - """ - Class implementing a QProcess subclass controlling an override cursor. - """ - def __init__(self, parent=None, cursorShape=Qt.CursorShape.WaitCursor): - """ - Constructor - - @param parent reference to the parent object - @type QObject - @param cursorShape shape of the override cursor - @type Qt.CursorShape - """ - super().__init__(parent) - - self.__cursorShape = cursorShape - - self.started.connect(self.__processStarted) - self.finished.connect(self.__processFinished) - - @pyqtSlot() - def __processStarted(self): - """ - Private slot setting the cursor after the process has started. - """ - QGuiApplication.setOverrideCursor(QCursor(self.__cursorShape)) - QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) - - @pyqtSlot() - def __processFinished(self): - """ - Private slot resetting the cursor when the process finished. - """ - QGuiApplication.restoreOverrideCursor() - QGuiApplication.processEvents( - QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents)
--- a/eric7/E5Gui/EricPassivePopup.py Sat May 22 19:52:34 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,254 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing dialog-like popup that displays messages without -interrupting the user. -""" - -import enum - -from PyQt6.QtCore import pyqtSignal, Qt, QTimer, QPoint, QRect -from PyQt6.QtWidgets import QFrame, QVBoxLayout, QApplication - - -class EricPassivePopupStyle(enum.Enum): - """ - Class defining the popup styles. - """ - BOXED = 0 # box with no shadow - STYLED = 1 # styled panel with no shadow - CUSTOM = 128 # reserved for extensions - - -class EricPassivePopup(QFrame): - """ - Class implementing dialog-like popup that displays messages without - interrupting the user. - - @signal clicked emitted to indicate a mouse button click - """ - DefaultPopupTime = 6 * 1000 # time im milliseconds - - clicked = pyqtSignal((), (QPoint, )) - - def __init__(self, style=EricPassivePopupStyle.BOXED, parent=None): - """ - Constructor - - @param style style of the popup - @type EricPassivePopupStyle - @param parent reference to the parent widget - @type QWidget - """ - super().__init__(None) - - self.__msgView = None - self.__topLayout = None - self.__hideDelay = EricPassivePopup.DefaultPopupTime - self.__hideTimer = QTimer(self) - self.__autoDelete = False - self.__fixedPosition = QPoint() - - self.setWindowFlags( - Qt.WindowType.Tool | - Qt.WindowType.X11BypassWindowManagerHint | - Qt.WindowType.WindowStaysOnTopHint | - Qt.WindowType.FramelessWindowHint - ) - if style == EricPassivePopupStyle.STYLED: - self.setFrameStyle(QFrame.Shape.StyledPanel | QFrame.Shadow.Plain) - else: - # default style is Boxed - Plain - self.setFrameStyle(QFrame.Shape.Box | QFrame.Shadow.Plain) - self.setLineWidth(2) - self.__hideTimer.timeout.connect(self.hide) - self.clicked.connect(self.hide) - - self.__customData = {} # dictionary to store some custom data - - def setView(self, child): - """ - Public method to set the message view. - - @param child reference to the widget to set as the message view - (QWidget) - """ - self.__msgView = child - self.__topLayout = QVBoxLayout(self) - self.__topLayout.addWidget(self.__msgView) - self.__topLayout.activate() - - def view(self): - """ - Public method to get a reference to the message view. - - @return reference to the message view (QWidget) - """ - return self.__msgView - - def setVisible(self, visible): - """ - Public method to show or hide the popup. - - @param visible flag indicating the visibility status (boolean) - """ - if not visible: - super().setVisible(visible) - return - - if self.size() != self.sizeHint(): - self.resize(self.sizeHint()) - - if self.__fixedPosition.isNull(): - self.__positionSelf() - else: - self.move(self.__fixedPosition) - super().setVisible(True) - - delay = self.__hideDelay - if delay < 0: - delay = EricPassivePopup.DefaultPopupTime - if delay > 0: - self.__hideTimer.start(delay) - - def show(self, p=None): - """ - Public slot to show the popup. - - @param p position for the popup (QPoint) - """ - if p is not None: - self.__fixedPosition = p - super().show() - - def setTimeout(self, delay): - """ - Public method to set the delay for the popup is removed automatically. - - Setting the delay to 0 disables the timeout. If you're doing this, you - may want to connect the clicked() signal to the hide() slot. Setting - the delay to -1 makes it use the default value. - - @param delay value for the delay in milliseconds (integer) - """ - self.__hideDelay = delay - if self.__hideTimer.isActive(): - if delay: - if delay == -1: - delay = EricPassivePopup.DefaultPopupTime - self.__hideTimer.start(delay) - else: - self.__hideTimer.stop() - - def timeout(self): - """ - Public method to get the delay before the popup is removed - automatically. - - @return the delay before the popup is removed automatically (integer) - """ - return self.__hideDelay - - def mouseReleaseEvent(self, evt): - """ - Protected method to handle a mouse release event. - - @param evt reference to the mouse event (QMouseEvent) - """ - self.clicked.emit() - self.clicked.emit(evt.position().toPoint()) - - def hideEvent(self, evt): - """ - Protected method to handle the hide event. - - @param evt reference to the hide event (QHideEvent) - """ - self.__hideTimer.stop() - - def __defaultArea(self): - """ - Private method to determine the default rectangle to be passed to - moveNear(). - - @return default rectangle (QRect) - """ - return QRect(100, 100, 200, 200) - - def __positionSelf(self): - """ - Private method to position the popup. - """ - self.__moveNear(self.__defaultArea()) - - def __moveNear(self, target): - """ - Private method to move the popup to be adjacent to the specified - rectangle. - - @param target rectangle to be placed at (QRect) - """ - pos = self.__calculateNearbyPoint(target) - self.move(pos.x(), pos.y()) - - def __calculateNearbyPoint(self, target): - """ - Private method to calculate the position to place the popup near the - specified rectangle. - - @param target rectangle to be placed at (QRect) - @return position to place the popup (QPoint) - """ - pos = target.topLeft() - x = pos.x() - y = pos.y() - w = self.minimumSizeHint().width() - h = self.minimumSizeHint().height() - - r = QApplication.screenAt(QPoint(x + w // 2, y + h // 2)).geometry() - - if x < r.center().x(): - x += target.width() - else: - x -= w - - # It's apparently trying to go off screen, so display it ALL at the - # bottom. - if (y + h) > r.bottom(): - y = r.bottom() - h - - if (x + w) > r.right(): - x = r.right() - w - - if y < r.top(): - y = r.top() - - if x < r.left(): - x = r.left() - - return QPoint(x, y) - - def setCustomData(self, key, data): - """ - Public method to set some custom data. - - @param key key for the custom data - @type str - @param data data to be stored - @type any - """ - self.__customData[key] = data - - def getCustomData(self, key): - """ - Public method to get some custom data. - - @param key key for the custom data - @type str - @return stored data - @rtype any - """ - return self.__customData[key]
--- a/eric7/E5Gui/EricPasswordMeter.py Sat May 22 19:52:34 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a custom widget indicating the strength of a password. -""" - -from PyQt6.QtWidgets import QProgressBar - -from Utilities.PasswordChecker import PasswordChecker - - -class EricPasswordMeter(QProgressBar): - """ - Class implementing a custom widget indicating the strength of a password. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - - super().setTextVisible(False) - super().setMaximum(100) - self.__increment = 100 // (PasswordChecker.Complexity_VeryStrong + 1) - - self.__indicatorColors = [ - "#ff0000", # red - "#ff8800", # orange - "#ffff00", # yellow - "#ccff00", # yellow green - "#00ff00", # green - ] - self.__noIndicator = "#ffffff" - - self.__styleSheetTemplate = ( - "QProgressBar {{" - " border: 2px solid black;" - " border-radius: 5px;" - " text-align: center; }}" - "QProgressBar::chunk:horizontal {{" - " background-color: {0}; }}" - ) - self.setStyleSheet( - self.__styleSheetTemplate.format(self.__noIndicator)) - - def checkPasswordStrength(self, password): - """ - Public slot to check the password strength and update the - progress bar accordingly. - - @param password password to be checked (string) - """ - strength = PasswordChecker().checkPassword(password) - self.setStyleSheet(self.__styleSheetTemplate.format( - self.__indicatorColors[strength])) - super().setValue( - (strength + 1) * self.__increment) - - def setValue(self, value): - """ - Public method to set the value. - - Overwritten to do nothing. - - @param value value (integer) - """ - pass - - def setMaximum(self, value): - """ - Public method to set the maximum value. - - Overwritten to do nothing. - - @param value maximum value (integer) - """ - pass - - def setMinimum(self, value): - """ - Public method to set the minimal value. - - Overwritten to do nothing. - - @param value minimum value (integer) - """ - pass - -if __name__ == "__main__": - import sys - from PyQt6.QtWidgets import QApplication - - app = QApplication(sys.argv) - meter = EricPasswordMeter() - meter.show() - meter.checkPasswordStrength("Blah2+") - app.exec()
--- a/eric7/E5Gui/EricPathPicker.py Sat May 22 19:52:34 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,718 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> -# - -""" -Module implementing a path picker widget. -""" - -import enum -import os - -from PyQt6.QtCore import pyqtSignal, Qt, QFileInfo, QCoreApplication, QDir -from PyQt6.QtWidgets import ( - QWidget, QHBoxLayout, QToolButton, QSizePolicy, QLineEdit, QComboBox -) - -from . import EricFileDialog -from .EricCompleters import EricFileCompleter, EricDirCompleter - -import UI.PixmapCache - - -class EricPathPickerModes(enum.Enum): - """ - Class implementing the path picker modes. - """ - OPEN_FILE_MODE = 0 - OPEN_FILES_MODE = 1 - SAVE_FILE_MODE = 2 - SAVE_FILE_ENSURE_EXTENSION_MODE = 3 - SAVE_FILE_OVERWRITE_MODE = 4 - DIRECTORY_MODE = 5 - DIRECTORY_SHOW_FILES_MODE = 6 - CUSTOM_MODE = 99 - NO_MODE = 100 - - -class EricPathPickerBase(QWidget): - """ - Class implementing the base of a path picker widget consisting of a - line edit or combo box and a tool button to open a file dialog. - - @signal textChanged(path) emitted when the entered path has changed - (line edit based widget) - @signal editTextChanged(path) emitted when the entered path has changed - (combo box based widget) - @signal pathSelected(path) emitted after a path has been selected via the - file dialog - @signal aboutToShowPathPickerDialog emitted before the file dialog is shown - @signal pickerButtonClicked emitted when the picker button was pressed and - the widget mode is custom - """ - DefaultMode = EricPathPickerModes.NO_MODE - - textChanged = pyqtSignal(str) - editTextChanged = pyqtSignal(str) - pathSelected = pyqtSignal(str) - aboutToShowPathPickerDialog = pyqtSignal() - pickerButtonClicked = pyqtSignal() - - def __init__(self, parent=None, useLineEdit=True): - """ - Constructor - - @param parent reference to the parent widget - @type QWidget - @param useLineEdit flag indicating the use of a line edit - @type bool - """ - super().__init__(parent) - - self.__lineEditKind = useLineEdit - - self.__mode = EricPathPicker.DefaultMode - self.__editorEnabled = True - - self._completer = None - self.__filters = "" - self.__defaultDirectory = "" - self.__windowTitle = "" - - self.__layout = QHBoxLayout(self) - self.__layout.setSpacing(0) - self.__layout.setContentsMargins(0, 0, 0, 0) - self.setLayout(self.__layout) - - if useLineEdit: - self._editor = QLineEdit(self) - self._editor.setPlaceholderText(QCoreApplication.translate( - "EricPathPickerBase", "Enter Path Name")) - self._editor.setClearButtonEnabled(True) - else: - self._editor = QComboBox(self) - self._editor.setEditable(True) - self._editor.lineEdit().setPlaceholderText( - QCoreApplication.translate( - "EricPathPickerBase", "Enter Path Name")) - self._editor.lineEdit().setClearButtonEnabled(True) - - self.__button = QToolButton(self) - self.__button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly) - self.__button.setIcon(UI.PixmapCache.getIcon("open")) - - self.__layout.addWidget(self._editor) - self.__layout.addWidget(self.__button) - - self.__button.clicked.connect(self.__showPathPickerDialog) - if useLineEdit: - self._editor.textEdited.connect(self.__pathEdited) - self._editor.textChanged.connect(self.textChanged) - else: - self._editor.editTextChanged.connect(self.editTextChanged) - - self.setFocusProxy(self._editor) - self.setFocusPolicy(Qt.FocusPolicy.StrongFocus) - self.setSizePolicy(QSizePolicy.Policy.Expanding, - QSizePolicy.Policy.Preferred) - - self.__button.setEnabled(self.__mode != EricPathPickerModes.NO_MODE) - - def __pathEdited(self, path): - """ - Private slot handling editing of the path. - - @param path current text of the path line edit - @type str - """ - if self._completer and not self._completer.popup().isVisible(): - self._completer.setRootPath(QDir.toNativeSeparators(path)) - - def setMode(self, mode): - """ - Public method to set the path picker mode. - - @param mode picker mode - @type EricPathPickerModes - @exception ValueError raised to indicate a bad parameter value - """ - if mode not in EricPathPickerModes: - raise ValueError("Bad value for 'mode' parameter.") - - oldMode = self.__mode - self.__mode = mode - - if mode != oldMode or (self.__lineEditKind and not self._completer): - if self.__lineEditKind and self._completer: - # Remove current completer - self._editor.setCompleter(None) - self._completer = None - - if mode != EricPathPickerModes.NO_MODE: - if self.__lineEditKind: - # Set a new completer - if mode == EricPathPickerModes.DIRECTORY_MODE: - self._completer = EricDirCompleter(self._editor) - else: - self._completer = EricFileCompleter(self._editor) - - # set inactive text - if mode == EricPathPickerModes.OPEN_FILES_MODE: - self._editor.setPlaceholderText( - self.tr("Enter Path Names separated by ';'")) - else: - self._editor.setPlaceholderText( - self.tr("Enter Path Name")) - self.__button.setEnabled(self.__mode != EricPathPickerModes.NO_MODE) - - def mode(self): - """ - Public method to get the path picker mode. - - @return path picker mode - @rtype EricPathPickerModes - """ - return self.__mode - - def setPickerEnabled(self, enable): - """ - Public method to set the enabled state of the file dialog button. - - @param enable flag indicating the enabled state - @type bool - """ - self.__button.setEnabled(enable) - - def isPickerEnabled(self): - """ - Public method to get the file dialog button enabled state. - - @return flag indicating the enabled state - @rtype bool - """ - return self.__button.isEnabled() - - def clear(self): - """ - Public method to clear the current path or list of paths. - """ - self._editor.clear() - - def clearEditText(self): - """ - Public method to clear the current path. - """ - if not self.__lineEditKind: - self._editor.clearEditText() - - def _setEditorText(self, text): - """ - Protected method to set the text of the editor. - - @param text text to set - @type str - """ - if self.__lineEditKind: - self._editor.setText(text) - else: - self._editor.setEditText(text) - if text and self._editor.findText(text) == -1: - self._editor.insertItem(0, text) - - def _editorText(self): - """ - Protected method to get the text of the editor. - - @return text of the editor - @rtype str - """ - if self.__lineEditKind: - return self._editor.text() - else: - return self._editor.currentText() - - def setText(self, path, toNative=True): - """ - Public method to set the current path. - - @param path path to be set - @type str - @param toNative flag indicating to convert the path into - a native format - @type bool - """ - if self.__mode == EricPathPickerModes.OPEN_FILES_MODE: - self._setEditorText(path) - else: - if toNative: - path = QDir.toNativeSeparators(path) - self._setEditorText(path) - if self._completer: - self._completer.setRootPath(path) - - def text(self, toNative=True): - """ - Public method to get the current path. - - @param toNative flag indicating to convert the path into - a native format - @type bool - @return current path - @rtype str - """ - if self.__mode == EricPathPickerModes.OPEN_FILES_MODE: - if toNative: - return ";".join( - [QDir.toNativeSeparators(path) - for path in self._editorText().split(";")]) - else: - return self._editorText() - else: - if toNative: - return os.path.expanduser( - QDir.toNativeSeparators(self._editorText())) - else: - return os.path.expanduser(self._editorText()) - - def setEditText(self, path, toNative=True): - """ - Public method to set the current path. - - @param path path to be set - @type str - @param toNative flag indicating to convert the path into - a native format - @type bool - """ - self.setText(path, toNative=toNative) - - def currentText(self, toNative=True): - """ - Public method to get the current path. - - @param toNative flag indicating to convert the path into - a native format - @type bool - @return current path - @rtype str - """ - return self.text(toNative=toNative) - - def setPath(self, path, toNative=True): - """ - Public method to set the current path. - - @param path path to be set - @type str - @param toNative flag indicating to convert the path into - a native format - @type bool - """ - self.setText(path, toNative=toNative) - - def path(self, toNative=True): - """ - Public method to get the current path. - - @param toNative flag indicating to convert the path into - a native format - @type bool - @return current path - @rtype str - """ - return self.text(toNative=toNative) - - def paths(self, toNative=True): - """ - Public method to get the list of entered paths. - - @param toNative flag indicating to convert the path into - a native format - @type bool - @return entered paths - @rtype list of str - """ - if self.__mode == EricPathPickerModes.OPEN_FILES_MODE: - return self.path(toNative=toNative).split(";") - else: - return [self.path(toNative=toNative)] - - def firstPath(self, toNative=True): - """ - Public method to get the first path of a list of entered paths. - - @param toNative flag indicating to convert the path into - a native format - @type bool - @return first path - @rtype str - """ - return self.paths(toNative=toNative)[0] - - def lastPath(self, toNative=True): - """ - Public method to get the last path of a list of entered paths. - - @param toNative flag indicating to convert the path into - a native format - @type bool - @return last path - @rtype str - """ - return self.paths(toNative=toNative)[-1] - - def setEditorEnabled(self, enable): - """ - Public method to set the path editor's enabled state. - - @param enable flag indicating the enable state - @type bool - """ - if enable != self._editorEnabled: - self._editorEnabled = enable - self._editor.setEnabled(enable) - - def editorEnabled(self): - """ - Public method to get the path editor's enabled state. - - @return flag indicating the enabled state - @rtype bool - """ - return self._editorEnabled - - def setDefaultDirectory(self, directory): - """ - Public method to set the default directory. - - @param directory default directory - @type str - """ - self.__defaultDirectory = directory - - def defaultDirectory(self): - """ - Public method to get the default directory. - - @return default directory - @rtype str - """ - return self.__defaultDirectory - - def setWindowTitle(self, title): - """ - Public method to set the path picker dialog window title. - - @param title window title - @type str - """ - self.__windowTitle = title - - def windowTitle(self): - """ - Public method to get the path picker dialog's window title. - - @return window title - @rtype str - """ - return self.__windowTitle - - def setFilters(self, filters): - """ - Public method to set the filters for the path picker dialog. - - Note: Multiple filters must be separated by ';;'. - - @param filters string containing the file filters - @type str - """ - self.__filters = filters - - def filters(self): - """ - Public methods to get the filter string. - - @return filter string - @rtype str - """ - return self.__filters - - def setNameFilters(self, filters): - """ - Public method to set the name filters for the completer. - - @param filters list of file name filters - @type list of str - """ - if self._completer: - self._completer.model().setNameFilters(filters) - - def setButtonToolTip(self, tooltip): - """ - Public method to set the tool button tool tip. - - @param tooltip text to be set as a tool tip - @type str - """ - self.__button.setToolTip(tooltip) - - def buttonToolTip(self): - """ - Public method to get the tool button tool tip. - - @return tool tip text - @rtype str - """ - return self.__button.toolTip() - - def setEditorToolTip(self, tooltip): - """ - Public method to set the editor tool tip. - - @param tooltip text to be set as a tool tip - @type str - """ - self._editor.setToolTip(tooltip) - - def editorToolTip(self): - """ - Public method to get the editor tool tip. - - @return tool tip text - @rtype str - """ - return self._editor.toolTip() - - def __showPathPickerDialog(self): - """ - Private slot to show the path picker dialog. - """ - if self.__mode == EricPathPickerModes.NO_MODE: - return - - if self.__mode == EricPathPickerModes.CUSTOM_MODE: - self.pickerButtonClicked.emit() - return - - self.aboutToShowPathPickerDialog.emit() - - windowTitle = self.__windowTitle - if not windowTitle: - if self.__mode == EricPathPickerModes.OPEN_FILE_MODE: - windowTitle = self.tr("Choose a file to open") - elif self.__mode == EricPathPickerModes.OPEN_FILES_MODE: - windowTitle = self.tr("Choose files to open") - elif self.__mode in [ - EricPathPickerModes.SAVE_FILE_MODE, - EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE, - EricPathPickerModes.SAVE_FILE_OVERWRITE_MODE]: - windowTitle = self.tr("Choose a file to save") - elif self.__mode == EricPathPickerModes.DIRECTORY_MODE: - windowTitle = self.tr("Choose a directory") - - directory = self._editorText() - if not directory and self.__defaultDirectory: - directory = self.__defaultDirectory - directory = ( - os.path.expanduser(directory.split(";")[0]) - if self.__mode == EricPathPickerModes.OPEN_FILES_MODE else - os.path.expanduser(directory) - ) - if not os.path.isabs(directory) and self.__defaultDirectory: - directory = os.path.join(self.__defaultDirectory, directory) - directory = QDir.fromNativeSeparators(directory) - - if self.__mode == EricPathPickerModes.OPEN_FILE_MODE: - path = EricFileDialog.getOpenFileName( - self, - windowTitle, - directory, - self.__filters) - path = QDir.toNativeSeparators(path) - elif self.__mode == EricPathPickerModes.OPEN_FILES_MODE: - paths = EricFileDialog.getOpenFileNames( - self, - windowTitle, - directory, - self.__filters) - path = ";".join([QDir.toNativeSeparators(path) - for path in paths]) - elif self.__mode == EricPathPickerModes.SAVE_FILE_MODE: - path = EricFileDialog.getSaveFileName( - self, - windowTitle, - directory, - self.__filters, - EricFileDialog.DontConfirmOverwrite) - path = QDir.toNativeSeparators(path) - elif self.__mode == EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE: - path, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( - self, - windowTitle, - directory, - self.__filters, - None, - EricFileDialog.DontConfirmOverwrite) - path = QDir.toNativeSeparators(path) - if path: - ext = QFileInfo(path).suffix() - if not ext: - ex = selectedFilter.split("(*")[1].split(")")[0] - if ex: - path += ex - elif self.__mode == EricPathPickerModes.SAVE_FILE_OVERWRITE_MODE: - path = EricFileDialog.getSaveFileName( - self, - windowTitle, - directory, - self.__filters) - path = QDir.toNativeSeparators(path) - elif self.__mode == EricPathPickerModes.DIRECTORY_MODE: - path = EricFileDialog.getExistingDirectory( - self, - windowTitle, - directory, - EricFileDialog.ShowDirsOnly) - path = QDir.toNativeSeparators(path) - while path.endswith(os.sep): - path = path[:-1] - elif self.__mode == EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE: - path = EricFileDialog.getExistingDirectory( - self, - windowTitle, - directory, - EricFileDialog.DontUseNativeDialog) - path = QDir.toNativeSeparators(path) - while path.endswith(os.sep): - path = path[:-1] - - if path: - self._setEditorText(path) - self.pathSelected.emit(path) - - def setReadOnly(self, readOnly): - """ - Public method to set the path picker to read only mode. - - @param readOnly flag indicating read only mode - @type bool - """ - try: - self._editor.setReadOnly(readOnly) - except AttributeError: - self._editor.setEditable(not readOnly) - self.setPickerEnabled(not readOnly) - - def isReadOnly(self): - """ - Public method to check the path picker for read only mode. - - @return flg indicating read only mode - @rtype bool - """ - try: - return self._editor.isReadOnly() - except AttributeError: - return not self._editor.isEditable() - - ################################################################## - ## Methods below emulate some of the QComboBox API - ################################################################## - - def addItems(self, pathsList): - """ - Public method to add paths to the current list. - - @param pathsList list of paths to add - @type list of str - """ - self._editor.addItems(pathsList) - - def addItem(self, path): - """ - Public method to add a paths to the current list. - - @param path path to add - @type str - """ - self._editor.addItem(path) - - def setPathsList(self, pathsList): - """ - Public method to set the paths list. - - @param pathsList list of paths - @type list of str - """ - self.clear() - self.addItems(pathsList) - - def setCurrentIndex(self, index): - """ - Public slot to set the current index. - - @param index index of the item to set current - @type int - """ - self._editor.setCurrentIndex(index) - - def setInsertPolicy(self, policy): - """ - Public method to set the insertion policy of the combo box. - - @param policy insertion policy - @type QComboBox.InsertPolicy - """ - self._editor.setInsertPolicy(policy) - - def setSizeAdjustPolicy(self, policy): - """ - Public method to set the size adjust policy of the combo box. - - @param policy size adjust policy - @type QComboBox.SizeAdjustPolicy - """ - self._editor.setSizeAdjustPolicy(policy) - - -class EricPathPicker(EricPathPickerBase): - """ - Class implementing a path picker widget consisting of a line edit and a - tool button to open a file dialog. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget - @type QWidget - """ - super().__init__(parent, useLineEdit=True) - - -class EricComboPathPicker(EricPathPickerBase): - """ - Class implementing a path picker widget consisting of a combobox and a - tool button to open a file dialog. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget - @type QWidget - """ - super().__init__(parent, useLineEdit=False) - - def getPathItems(self): - """ - Public method to get the list of remembered paths. - - @return list od remembered paths - @rtype list of str - """ - paths = [] - for index in range(self._editor.count()): - paths.append(self._editor.itemText(index)) - return paths
--- a/eric7/E5Gui/EricPathPickerDialog.py Sat May 22 19:52:34 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +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. -""" - -from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel - -from .EricPathPicker import EricPathPicker, EricPathPickerModes - - -class EricPathPickerDialog(QDialog): - """ - Class implementing a dialog to enter a file system path using a file - picker. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget