src/eric7/UI/UserInterface.py

branch
eric7-maintenance
changeset 10460
3b34efa2857c
parent 10349
df7edc29cbfb
parent 10439
21c28b0f9e41
child 10534
783d835d7fe4
equal deleted inserted replaced
10366:411df92e881f 10460:3b34efa2857c
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 2
3 # Copyright (c) 2002 - 2023 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2002 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the main user interface. 7 Module implementing the main user interface.
8 """ 8 """
136 def __nWrite(self, n): 136 def __nWrite(self, n):
137 """ 137 """
138 Private method used to write data. 138 Private method used to write data.
139 139
140 @param n max number of bytes to write 140 @param n max number of bytes to write
141 @type int
141 """ 142 """
142 if n: 143 if n:
143 line = self.buffer[:n] 144 line = self.buffer[:n]
144 if self.stderr: 145 if self.stderr:
145 self.appendStderr.emit(line) 146 self.appendStderr.emit(line)
150 def __bufferedWrite(self): 151 def __bufferedWrite(self):
151 """ 152 """
152 Private method returning number of characters to write. 153 Private method returning number of characters to write.
153 154
154 @return number of characters buffered or length of buffered line 155 @return number of characters buffered or length of buffered line
155 (integer) 156 @rtype int
156 """ 157 """
157 return self.buffer.rfind("\n") + 1 158 return self.buffer.rfind("\n") + 1
158 159
159 def flush(self): 160 def flush(self):
160 """ 161 """
165 def write(self, s): 166 def write(self, s):
166 """ 167 """
167 Public method used to write data. 168 Public method used to write data.
168 169
169 @param s data to be written (it must support the str-method) 170 @param s data to be written (it must support the str-method)
171 @type Any
170 """ 172 """
171 self.buffer += str(s) 173 self.buffer += str(s)
172 self.__nWrite(self.__bufferedWrite()) 174 self.__nWrite(self.__bufferedWrite())
173 175
174 176
1556 1558
1557 def __openOnStartup(self, startupType=None): 1559 def __openOnStartup(self, startupType=None):
1558 """ 1560 """
1559 Private method to open the last file, project or multiproject. 1561 Private method to open the last file, project or multiproject.
1560 1562
1561 @param startupType type of startup requested (string, one of 1563 @param startupType type of startup requested (one of
1562 "Nothing", "File", "Project", "MultiProject" or "Session") 1564 "Nothing", "File", "Project", "MultiProject" or "Session")
1565 @type str
1563 """ 1566 """
1564 startupTypeMapping = { 1567 startupTypeMapping = {
1565 "Nothing": 0, 1568 "Nothing": 0,
1566 "File": 1, 1569 "File": 1,
1567 "Project": 2, 1570 "Project": 2,
1742 1745
1743 def __createDockWindow(self, name): 1746 def __createDockWindow(self, name):
1744 """ 1747 """
1745 Private method to create a dock window with common properties. 1748 Private method to create a dock window with common properties.
1746 1749
1747 @param name object name of the new dock window (string) 1750 @param name object name of the new dock window
1748 @return the generated dock window (QDockWindow) 1751 @type str
1752 @return the generated dock window
1753 @rtype QDockWindow
1749 """ 1754 """
1750 dock = QDockWidget() 1755 dock = QDockWidget()
1751 dock.setObjectName(name) 1756 dock.setObjectName(name)
1752 dock.setFeatures( 1757 dock.setFeatures(
1753 QDockWidget.DockWidgetFeature.DockWidgetClosable 1758 QDockWidget.DockWidgetFeature.DockWidgetClosable
1759 def __setupDockWindow(self, dock, where, widget, caption): 1764 def __setupDockWindow(self, dock, where, widget, caption):
1760 """ 1765 """
1761 Private method to configure the dock window created with 1766 Private method to configure the dock window created with
1762 __createDockWindow(). 1767 __createDockWindow().
1763 1768
1764 @param dock the dock window (QDockWindow) 1769 @param dock the dock window
1765 @param where dock area to be docked to (Qt.DockWidgetArea) 1770 @type QDockWindow
1766 @param widget widget to be shown in the dock window (QWidget) 1771 @param where dock area to be docked to
1767 @param caption caption of the dock window (string) 1772 @type Qt.DockWidgetArea
1773 @param widget widget to be shown in the dock window
1774 @type QWidget
1775 @param caption caption of the dock window
1776 @type str
1768 """ 1777 """
1769 if caption is None: 1778 if caption is None:
1770 caption = "" 1779 caption = ""
1771 self.addDockWidget(where, dock) 1780 self.addDockWidget(where, dock)
1772 dock.setWidget(widget) 1781 dock.setWidget(widget)
1775 1784
1776 def __setWindowCaption(self, editor=None, project=None): 1785 def __setWindowCaption(self, editor=None, project=None):
1777 """ 1786 """
1778 Private method to set the caption of the Main Window. 1787 Private method to set the caption of the Main Window.
1779 1788
1780 @param editor filename to be displayed (string) 1789 @param editor filename to be displayed
1781 @param project project name to be displayed (string) 1790 @type str
1791 @param project project name to be displayed
1792 @type str
1782 """ 1793 """
1783 if editor is not None and self.captionShowsFilename: 1794 if editor is not None and self.captionShowsFilename:
1784 self.capEditor = FileSystemUtilities.compactPath( 1795 self.capEditor = FileSystemUtilities.compactPath(
1785 editor, self.maxFilePathLen 1796 editor, self.maxFilePathLen
1786 ) 1797 )
4565 4576
4566 def showEmailDialog(self, mode, attachFile=None, deleteAttachFile=False): 4577 def showEmailDialog(self, mode, attachFile=None, deleteAttachFile=False):
4567 """ 4578 """
4568 Public slot to show the email dialog in a given mode. 4579 Public slot to show the email dialog in a given mode.
4569 4580
4570 @param mode mode of the email dialog (string, "bug" or "feature") 4581 @param mode mode of the email dialog ("bug" or "feature")
4571 @param attachFile name of a file to attach to the email (string) 4582 @type str
4583 @param attachFile name of a file to attach to the email
4584 @type str
4572 @param deleteAttachFile flag indicating to delete the attached file 4585 @param deleteAttachFile flag indicating to delete the attached file
4573 after it has been sent (boolean) 4586 after it has been sent
4587 @type bool
4574 """ 4588 """
4575 from .EmailDialog import EmailDialog 4589 from .EmailDialog import EmailDialog
4576 4590
4577 if Preferences.getUser("UseSystemEmailClient"): 4591 if Preferences.getUser("UseSystemEmailClient"):
4578 self.__showSystemEmailClient(mode, attachFile, deleteAttachFile) 4592 self.__showSystemEmailClient(mode, attachFile, deleteAttachFile)
4600 4614
4601 def __showSystemEmailClient(self, mode, attachFile=None, deleteAttachFile=False): 4615 def __showSystemEmailClient(self, mode, attachFile=None, deleteAttachFile=False):
4602 """ 4616 """
4603 Private slot to show the system email dialog. 4617 Private slot to show the system email dialog.
4604 4618
4605 @param mode mode of the email dialog (string, "bug" or "feature") 4619 @param mode mode of the email dialog ("bug" or "feature")
4620 @type str
4606 @param attachFile name of a file to put into the body of the 4621 @param attachFile name of a file to put into the body of the
4607 email (string) 4622 email
4623 @type str
4608 @param deleteAttachFile flag indicating to delete the file after 4624 @param deleteAttachFile flag indicating to delete the file after
4609 it has been read (boolean) 4625 it has been read
4626 @type bool
4610 """ 4627 """
4611 address = FeatureAddress if mode == "feature" else BugAddress 4628 address = FeatureAddress if mode == "feature" else BugAddress
4612 subject = "[eric] " 4629 subject = "[eric] "
4613 if attachFile is not None: 4630 if attachFile is not None:
4614 with open(attachFile, "r", encoding="utf-8") as f: 4631 with open(attachFile, "r", encoding="utf-8") as f:
4644 4661
4645 def __hasErrorLog(self): 4662 def __hasErrorLog(self):
4646 """ 4663 """
4647 Private method to check, if an error log file exists. 4664 Private method to check, if an error log file exists.
4648 4665
4649 @return flag indicating the existence of an error log file (boolean) 4666 @return flag indicating the existence of an error log file
4667 @rtype bool
4650 """ 4668 """
4651 logFile = os.path.join(Globals.getConfigDir(), self.ErrorLogFileName) 4669 logFile = os.path.join(Globals.getConfigDir(), self.ErrorLogFileName)
4652 return os.path.exists(logFile) 4670 return os.path.exists(logFile)
4653 4671
4654 def __showErrorLog(self): 4672 def __showErrorLog(self):
4708 4726
4709 def addEricActions(self, actions, actionType): 4727 def addEricActions(self, actions, actionType):
4710 """ 4728 """
4711 Public method to add actions to the list of actions. 4729 Public method to add actions to the list of actions.
4712 4730
4713 @param actions list of actions to be added (list of EricAction) 4731 @param actions list of actions to be added
4732 @type list of EricAction
4714 @param actionType string denoting the action set to add to. 4733 @param actionType string denoting the action set to add to.
4715 It must be one of "ui" or "wizards". 4734 It must be one of "ui" or "wizards".
4735 @type str
4716 """ 4736 """
4717 if actionType == "ui": 4737 if actionType == "ui":
4718 self.actions.extend(actions) 4738 self.actions.extend(actions)
4719 elif actionType == "wizards": 4739 elif actionType == "wizards":
4720 self.wizardsActions.extend(actions) 4740 self.wizardsActions.extend(actions)
4721 4741
4722 def removeEricActions(self, actions, actionType="ui"): 4742 def removeEricActions(self, actions, actionType="ui"):
4723 """ 4743 """
4724 Public method to remove actions from the list of actions. 4744 Public method to remove actions from the list of actions.
4725 4745
4726 @param actions list of actions (list of EricAction) 4746 @param actions list of actions
4747 @type list of EricActio
4727 @param actionType string denoting the action set to remove from. 4748 @param actionType string denoting the action set to remove from.
4728 It must be one of "ui" or "wizards". 4749 It must be one of "ui" or "wizards".
4750 @type str
4729 """ 4751 """
4730 for act in actions: 4752 for act in actions:
4731 with contextlib.suppress(ValueError): 4753 with contextlib.suppress(ValueError):
4732 if actionType == "ui": 4754 if actionType == "ui":
4733 self.actions.remove(act) 4755 self.actions.remove(act)
4738 """ 4760 """
4739 Public method to get a list of all actions. 4761 Public method to get a list of all actions.
4740 4762
4741 @param actionType string denoting the action set to get. 4763 @param actionType string denoting the action set to get.
4742 It must be one of "ui" or "wizards". 4764 It must be one of "ui" or "wizards".
4743 @return list of all actions (list of EricAction) 4765 @type str
4766 @return list of all actions
4767 @rtype list of EricAction
4744 """ 4768 """
4745 if actionType == "ui": 4769 if actionType == "ui":
4746 return self.actions[:] 4770 return self.actions[:]
4747 elif actionType == "wizards": 4771 elif actionType == "wizards":
4748 return self.wizardsActions[:] 4772 return self.wizardsActions[:]
4751 4775
4752 def getMenuAction(self, menuName, actionName): 4776 def getMenuAction(self, menuName, actionName):
4753 """ 4777 """
4754 Public method to get a reference to an action of a menu. 4778 Public method to get a reference to an action of a menu.
4755 4779
4756 @param menuName name of the menu to search in (string) 4780 @param menuName name of the menu to search in
4781 @type str
4757 @param actionName object name of the action to search for 4782 @param actionName object name of the action to search for
4758 (string) 4783 @type str
4759 @return reference to the menu action (QAction) 4784 @return reference to the menu action
4785 @rtype QAction
4760 """ 4786 """
4761 try: 4787 try:
4762 menu = self.__menus[menuName] 4788 menu = self.__menus[menuName]
4763 except KeyError: 4789 except KeyError:
4764 return None 4790 return None
4771 4797
4772 def getMenuBarAction(self, menuName): 4798 def getMenuBarAction(self, menuName):
4773 """ 4799 """
4774 Public method to get a reference to an action of the main menu. 4800 Public method to get a reference to an action of the main menu.
4775 4801
4776 @param menuName name of the menu to search in (string) 4802 @param menuName name of the menu to search in
4777 @return reference to the menu bar action (QAction) 4803 @type str
4804 @return reference to the menu bar action
4805 @rtype QAction
4778 """ 4806 """
4779 try: 4807 try:
4780 menu = self.__menus[menuName] 4808 menu = self.__menus[menuName]
4781 except KeyError: 4809 except KeyError:
4782 return None 4810 return None
4785 4813
4786 def getMenu(self, name): 4814 def getMenu(self, name):
4787 """ 4815 """
4788 Public method to get a reference to a specific menu. 4816 Public method to get a reference to a specific menu.
4789 4817
4790 @param name name of the menu (string) 4818 @param name name of the menu
4791 @return reference to the menu (QMenu) 4819 @type str
4820 @return reference to the menu
4821 @rtype QMenu
4792 """ 4822 """
4793 try: 4823 try:
4794 return self.__menus[name] 4824 return self.__menus[name]
4795 except KeyError: 4825 except KeyError:
4796 return None 4826 return None
4836 4866
4837 def unregisterToolbar(self, name): 4867 def unregisterToolbar(self, name):
4838 """ 4868 """
4839 Public method to unregister a toolbar. 4869 Public method to unregister a toolbar.
4840 4870
4841 @param name name of the toolbar (string). 4871 @param name name of the toolbar
4872 @type str
4842 """ 4873 """
4843 if name in self.__toolbars: 4874 if name in self.__toolbars:
4844 del self.__toolbars[name] 4875 del self.__toolbars[name]
4845 4876
4846 def getToolbar(self, name): 4877 def getToolbar(self, name):
4847 """ 4878 """
4848 Public method to get a reference to a specific toolbar. 4879 Public method to get a reference to a specific toolbar.
4849 4880
4850 @param name name of the toolbar (string) 4881 @param name name of the toolbar
4851 @return reference to the toolbar entry (tuple of string and QToolBar) 4882 @type str
4883 @return reference to the toolbar entry
4884 @rtype tuple of (str, QToolBar)
4852 """ 4885 """
4853 try: 4886 try:
4854 return self.__toolbars[name] 4887 return self.__toolbars[name]
4855 except KeyError: 4888 except KeyError:
4856 return None 4889 return None
4875 4908
4876 def getLocale(self): 4909 def getLocale(self):
4877 """ 4910 """
4878 Public method to get the locale of the IDE. 4911 Public method to get the locale of the IDE.
4879 4912
4880 @return locale of the IDE (string or None) 4913 @return locale of the IDE
4914 @rtype str
4881 """ 4915 """
4882 return self.locale 4916 return self.locale
4883 4917
4884 def __quit(self): 4918 def __quit(self):
4885 """ 4919 """
5129 5163
5130 def __toolGroupSelected(self, act): 5164 def __toolGroupSelected(self, act):
5131 """ 5165 """
5132 Private slot to set the current tool group. 5166 Private slot to set the current tool group.
5133 5167
5134 @param act reference to the action that was triggered (QAction) 5168 @param act reference to the action that was triggered
5169 @type QAction
5135 """ 5170 """
5136 self.toolGroupsMenuTriggered = True 5171 self.toolGroupsMenuTriggered = True
5137 idx = act.data() 5172 idx = act.data()
5138 if idx is not None: 5173 if idx is not None:
5139 self.currentToolGroup = idx 5174 self.currentToolGroup = idx
5184 5219
5185 def __populateToolbarsMenu(self, menu): 5220 def __populateToolbarsMenu(self, menu):
5186 """ 5221 """
5187 Private method to populate a toolbars menu. 5222 Private method to populate a toolbars menu.
5188 5223
5189 @param menu reference to the menu to be populated (QMenu) 5224 @param menu reference to the menu to be populated
5225 @type QMenu
5190 """ 5226 """
5191 menu.clear() 5227 menu.clear()
5192 5228
5193 for name, (text, tb, _category) in sorted( 5229 for name, (text, tb, _category) in sorted(
5194 self.__toolbars.items(), key=lambda t: t[1][0] 5230 self.__toolbars.items(), key=lambda t: t[1][0]
5205 5241
5206 def createPopupMenu(self): 5242 def createPopupMenu(self):
5207 """ 5243 """
5208 Public method to create the toolbars menu for Qt. 5244 Public method to create the toolbars menu for Qt.
5209 5245
5210 @return toolbars menu (QMenu) 5246 @return toolbars menu
5247 @rtype QMenu
5211 """ 5248 """
5212 menu = QMenu(self) 5249 menu = QMenu(self)
5213 menu.triggered.connect(self.__TBPopupMenuTriggered) 5250 menu.triggered.connect(self.__TBPopupMenuTriggered)
5214 5251
5215 self.__populateToolbarsMenu(menu) 5252 self.__populateToolbarsMenu(menu)
5225 def __TBMenuTriggered(self, act): 5262 def __TBMenuTriggered(self, act):
5226 """ 5263 """
5227 Private method to handle the toggle of a toolbar via the Window-> 5264 Private method to handle the toggle of a toolbar via the Window->
5228 Toolbars submenu. 5265 Toolbars submenu.
5229 5266
5230 @param act reference to the action that was triggered (QAction) 5267 @param act reference to the action that was triggered
5268 @type QAction
5231 """ 5269 """
5232 name = act.data() 5270 name = act.data()
5233 if name: 5271 if name:
5234 if name == "__SHOW__": 5272 if name == "__SHOW__":
5235 for _text, tb, _category in self.__toolbars.values(): 5273 for _text, tb, _category in self.__toolbars.values():
5252 def __TBPopupMenuTriggered(self, act): 5290 def __TBPopupMenuTriggered(self, act):
5253 """ 5291 """
5254 Private method to handle the toggle of a toolbar via the QMainWindow 5292 Private method to handle the toggle of a toolbar via the QMainWindow
5255 Toolbars popup menu. 5293 Toolbars popup menu.
5256 5294
5257 @param act reference to the action that was triggered (QAction) 5295 @param act reference to the action that was triggered
5296 @type QAction
5258 """ 5297 """
5259 name = act.data() 5298 name = act.data()
5260 if name: 5299 if name:
5261 if name == "__SHOW__": 5300 if name == "__SHOW__":
5262 for _text, tb, _category in self.__toolbars.values(): 5301 for _text, tb, _category in self.__toolbars.values():
5277 def __saveCurrentViewProfile(self, save): 5316 def __saveCurrentViewProfile(self, save):
5278 """ 5317 """
5279 Private slot to save the window geometries of the active profile. 5318 Private slot to save the window geometries of the active profile.
5280 5319
5281 @param save flag indicating that the current profile should 5320 @param save flag indicating that the current profile should
5282 be saved (boolean) 5321 be saved
5322 @type bool
5283 """ 5323 """
5284 if self.currentProfile and save: 5324 if self.currentProfile and save:
5285 # step 1: save the window geometries of the active profile 5325 # step 1: save the window geometries of the active profile
5286 if self.__layoutType in ["Toolboxes", "Sidebars"]: 5326 if self.__layoutType in ["Toolboxes", "Sidebars"]:
5287 state = self.saveState() 5327 state = self.saveState()
5318 5358
5319 def __activateViewProfile(self, name, save=True): 5359 def __activateViewProfile(self, name, save=True):
5320 """ 5360 """
5321 Private slot to activate a view profile. 5361 Private slot to activate a view profile.
5322 5362
5323 @param name name of the profile to be activated (string) 5363 @param name name of the profile to be activated
5364 @type str
5324 @param save flag indicating that the current profile should 5365 @param save flag indicating that the current profile should
5325 be saved (boolean) 5366 be saved
5367 @type bool
5326 """ 5368 """
5327 if self.currentProfile != name or not save: 5369 if self.currentProfile != name or not save:
5328 # step 1: save the active profile 5370 # step 1: save the active profile
5329 self.__saveCurrentViewProfile(save) 5371 self.__saveCurrentViewProfile(save)
5330 5372
5438 def __setEditProfile(self, save=True): 5480 def __setEditProfile(self, save=True):
5439 """ 5481 """
5440 Private slot to activate the edit view profile. 5482 Private slot to activate the edit view profile.
5441 5483
5442 @param save flag indicating that the current profile should 5484 @param save flag indicating that the current profile should
5443 be saved (boolean) 5485 be saved
5486 @type bool
5444 """ 5487 """
5445 self.__activateViewProfile("edit", save) 5488 self.__activateViewProfile("edit", save)
5446 self.setEditProfileAct.setChecked(True) 5489 self.setEditProfileAct.setChecked(True)
5447 5490
5448 @pyqtSlot() 5491 @pyqtSlot()
5449 def setDebugProfile(self, save=True): 5492 def setDebugProfile(self, save=True):
5450 """ 5493 """
5451 Public slot to activate the debug view profile. 5494 Public slot to activate the debug view profile.
5452 5495
5453 @param save flag indicating that the current profile should 5496 @param save flag indicating that the current profile should
5454 be saved (boolean) 5497 be saved
5498 @type bool
5455 """ 5499 """
5456 self.viewmanager.searchReplaceWidget().hide() 5500 self.viewmanager.searchReplaceWidget().hide()
5457 self.__activateViewProfile("debug", save) 5501 self.__activateViewProfile("debug", save)
5458 self.setDebugProfileAct.setChecked(True) 5502 self.setDebugProfileAct.setChecked(True)
5459 5503
5460 def getViewProfile(self): 5504 def getViewProfile(self):
5461 """ 5505 """
5462 Public method to get the current view profile. 5506 Public method to get the current view profile.
5463 5507
5464 @return the name of the current view profile (string) 5508 @return the name of the current view profile
5509 @rtype str
5465 """ 5510 """
5466 return self.currentProfile 5511 return self.currentProfile
5467 5512
5468 def getLayoutType(self): 5513 def getLayoutType(self):
5469 """ 5514 """
5793 def __toggleWindow(self, w): 5838 def __toggleWindow(self, w):
5794 """ 5839 """
5795 Private method to toggle a workspace editor window. 5840 Private method to toggle a workspace editor window.
5796 5841
5797 @param w reference to the workspace editor window 5842 @param w reference to the workspace editor window
5798 @return flag indicating, if the window was shown (boolean) 5843 @type Editor
5844 @return flag indicating, if the window was shown
5845 @rtype bool
5799 """ 5846 """
5800 if w.isHidden(): 5847 if w.isHidden():
5801 w.show() 5848 w.show()
5802 return True 5849 return True
5803 else: 5850 else:
6096 6143
6097 def __customViewer(self, home=None): 6144 def __customViewer(self, home=None):
6098 """ 6145 """
6099 Private slot to start a custom viewer. 6146 Private slot to start a custom viewer.
6100 6147
6101 @param home full pathname of a file to display (string) 6148 @param home full pathname of a file to display
6149 @type str
6102 """ 6150 """
6103 customViewer = Preferences.getHelp("CustomViewer") 6151 customViewer = Preferences.getHelp("CustomViewer")
6104 if not customViewer: 6152 if not customViewer:
6105 EricMessageBox.information( 6153 EricMessageBox.information(
6106 self, 6154 self,
6129 6177
6130 def __chmViewer(self, home=None): 6178 def __chmViewer(self, home=None):
6131 """ 6179 """
6132 Private slot to start the win help viewer to show *.chm files. 6180 Private slot to start the win help viewer to show *.chm files.
6133 6181
6134 @param home full pathname of a file to display (string) 6182 @param home full pathname of a file to display
6183 @type str
6135 """ 6184 """
6136 if home: 6185 if home:
6137 proc = QProcess() 6186 proc = QProcess()
6138 args = [] 6187 args = []
6139 args.append(home) 6188 args.append(home)
6152 @pyqtSlot(str) 6201 @pyqtSlot(str)
6153 def __UIPreviewer(self, fn=None): 6202 def __UIPreviewer(self, fn=None):
6154 """ 6203 """
6155 Private slot to start the UI Previewer executable. 6204 Private slot to start the UI Previewer executable.
6156 6205
6157 @param fn filename of the form to be previewed (string) 6206 @param fn filename of the form to be previewed
6207 @type str
6158 """ 6208 """
6159 proc = QProcess() 6209 proc = QProcess()
6160 6210
6161 viewer = os.path.join(getConfig("ericDir"), "eric7_uipreviewer.py") 6211 viewer = os.path.join(getConfig("ericDir"), "eric7_uipreviewer.py")
6162 6212
6206 def __TRPreviewer(self, fileNames=None, ignore=False): 6256 def __TRPreviewer(self, fileNames=None, ignore=False):
6207 """ 6257 """
6208 Private slot to start the Translation Previewer executable. 6258 Private slot to start the Translation Previewer executable.
6209 6259
6210 @param fileNames filenames of forms and/or translations to be previewed 6260 @param fileNames filenames of forms and/or translations to be previewed
6211 (list of strings) 6261 @type list of str
6212 @param ignore flag indicating non existing files should be ignored 6262 @param ignore flag indicating non existing files should be ignored
6213 (boolean) 6263 @type bool
6214 """ 6264 """
6215 proc = QProcess() 6265 proc = QProcess()
6216 6266
6217 viewer = os.path.join(getConfig("ericDir"), "eric7_trpreviewer.py") 6267 viewer = os.path.join(getConfig("ericDir"), "eric7_trpreviewer.py")
6218 6268
6343 @pyqtSlot(str) 6393 @pyqtSlot(str)
6344 def __showSvg(self, fn): 6394 def __showSvg(self, fn):
6345 """ 6395 """
6346 Private slot to show a SVG file in a dialog. 6396 Private slot to show a SVG file in a dialog.
6347 6397
6348 @param fn filename of the file to show (string) 6398 @param fn filename of the file to show
6399 @type str
6349 """ 6400 """
6350 from eric7.Graphics.SvgDiagram import SvgDiagram 6401 from eric7.Graphics.SvgDiagram import SvgDiagram
6351 6402
6352 dlg = SvgDiagram(fn, self) 6403 dlg = SvgDiagram(fn, self)
6353 dlg.show() 6404 dlg.show()
6422 6473
6423 def __toolExecute(self, act): 6474 def __toolExecute(self, act):
6424 """ 6475 """
6425 Private slot to execute a particular tool. 6476 Private slot to execute a particular tool.
6426 6477
6427 @param act reference to the action that was triggered (QAction) 6478 @param act reference to the action that was triggered
6479 @type QAction
6428 """ 6480 """
6429 if self.toolGroupsMenuTriggered: 6481 if self.toolGroupsMenuTriggered:
6430 # ignore actions triggered from the select tool group submenu 6482 # ignore actions triggered from the select tool group submenu
6431 self.toolGroupsMenuTriggered = False 6483 self.toolGroupsMenuTriggered = False
6432 return 6484 return
6442 6494
6443 def __startToolProcess(self, tool): 6495 def __startToolProcess(self, tool):
6444 """ 6496 """
6445 Private slot to start an external tool process. 6497 Private slot to start an external tool process.
6446 6498
6447 @param tool list of tool entries 6499 @param tool dictionary of tool entries
6500 @type dict
6448 """ 6501 """
6449 proc = QProcess() 6502 proc = QProcess()
6450 procData = (None,) 6503 procData = (None,)
6451 program = tool["executable"] 6504 program = tool["executable"]
6452 args = [] 6505 args = []
6527 @pyqtSlot(int, QProcess.ExitStatus) 6580 @pyqtSlot(int, QProcess.ExitStatus)
6528 def __toolFinished(self, exitCode, exitStatus): 6581 def __toolFinished(self, exitCode, exitStatus):
6529 """ 6582 """
6530 Private slot to handle the finished signal of a tool process. 6583 Private slot to handle the finished signal of a tool process.
6531 6584
6532 @param exitCode exit code of the process (integer) 6585 @param exitCode exit code of the process
6533 @param exitStatus exit status of the process (QProcess.ExitStatus) 6586 @type int
6587 @param exitStatus exit status of the process
6588 @type QProcess.ExitStatus
6534 """ 6589 """
6535 exitedProcs = [] 6590 exitedProcs = []
6536 6591
6537 # loop through all running tool processes 6592 # loop through all running tool processes
6538 for program, toolProc, toolProcData in self.toolProcs: 6593 for program, toolProc, toolProcData in self.toolProcs:
7035 7090
7036 def __webBrowser(self, home=""): 7091 def __webBrowser(self, home=""):
7037 """ 7092 """
7038 Private slot to start the eric web browser. 7093 Private slot to start the eric web browser.
7039 7094
7040 @param home full pathname of a file to display (string) 7095 @param home full pathname of a file to display
7096 @type str
7041 """ 7097 """
7042 started = QDesktopServices.openUrl(QUrl(home)) 7098 started = QDesktopServices.openUrl(QUrl(home))
7043 if not started: 7099 if not started:
7044 EricMessageBox.critical( 7100 EricMessageBox.critical(
7045 self, self.tr("Open Browser"), self.tr("Could not start a web browser") 7101 self, self.tr("Open Browser"), self.tr("Could not start a web browser")
7049 @pyqtSlot(str) 7105 @pyqtSlot(str)
7050 def showPreferences(self, pageName=None): 7106 def showPreferences(self, pageName=None):
7051 """ 7107 """
7052 Public slot to set the preferences. 7108 Public slot to set the preferences.
7053 7109
7054 @param pageName name of the configuration page to show (string) 7110 @param pageName name of the configuration page to show
7111 @type str
7055 """ 7112 """
7056 from eric7.Preferences.ConfigurationDialog import ConfigurationDialog 7113 from eric7.Preferences.ConfigurationDialog import ConfigurationDialog
7057 7114
7058 if self.__configurationDialog is None: 7115 if self.__configurationDialog is None:
7059 # only one invocation at a time is allowed 7116 # only one invocation at a time is allowed
7437 """ 7494 """
7438 Private slot to handle the programChange signal. 7495 Private slot to handle the programChange signal.
7439 7496
7440 This primarily is here to set the currentProg variable. 7497 This primarily is here to set the currentProg variable.
7441 7498
7442 @param fn filename to be set as current prog (string) 7499 @param fn filename to be set as current prog
7500 @type str
7443 """ 7501 """
7444 # Delete the old program if there was one. 7502 # Delete the old program if there was one.
7445 if self.currentProg is not None: 7503 if self.currentProg is not None:
7446 del self.currentProg 7504 del self.currentProg
7447 7505
7461 7519
7462 def __editorOpened(self, fn): 7520 def __editorOpened(self, fn):
7463 """ 7521 """
7464 Private slot to handle the editorOpened signal. 7522 Private slot to handle the editorOpened signal.
7465 7523
7466 @param fn filename of the opened editor (string) 7524 @param fn filename of the opened editor
7525 @type str
7467 """ 7526 """
7468 self.wizardsMenuAct.setEnabled(len(self.__menus["wizards"].actions()) > 0) 7527 self.wizardsMenuAct.setEnabled(len(self.__menus["wizards"].actions()) > 0)
7469 7528
7470 if ( 7529 if (
7471 fn 7530 fn
7480 def __checkActions(self, editor): 7539 def __checkActions(self, editor):
7481 """ 7540 """
7482 Private slot to check some actions for their enable/disable status. 7541 Private slot to check some actions for their enable/disable status.
7483 7542
7484 @param editor editor window 7543 @param editor editor window
7544 @type Editor
7485 """ 7545 """
7486 fn = editor.getFileName() if editor else None 7546 fn = editor.getFileName() if editor else None
7487 7547
7488 if fn and Testing.isLanguageSupported(editor.getFileType()): 7548 if fn and Testing.isLanguageSupported(editor.getFileType()):
7489 self.testScriptAct.setEnabled(True) 7549 self.testScriptAct.setEnabled(True)
7877 7937
7878 def appendToStdout(self, s): 7938 def appendToStdout(self, s):
7879 """ 7939 """
7880 Public slot to append text to the stdout log viewer tab. 7940 Public slot to append text to the stdout log viewer tab.
7881 7941
7882 @param s output to be appended (string) 7942 @param s output to be appended
7943 @type str
7883 """ 7944 """
7884 self.appendStdout.emit(s) 7945 self.appendStdout.emit(s)
7885 7946
7886 def appendToStderr(self, s): 7947 def appendToStderr(self, s):
7887 """ 7948 """
7888 Public slot to append text to the stderr log viewer tab. 7949 Public slot to append text to the stderr log viewer tab.
7889 7950
7890 @param s output to be appended (string) 7951 @param s output to be appended
7952 @type str
7891 """ 7953 """
7892 self.appendStderr.emit(s) 7954 self.appendStderr.emit(s)
7893 7955
7894 ########################################################## 7956 ##########################################################
7895 ## Below are slots needed by the plugin menu 7957 ## Below are slots needed by the plugin menu
7908 def __installPlugins(self, pluginFileNames=None): 7970 def __installPlugins(self, pluginFileNames=None):
7909 """ 7971 """
7910 Private slot to show a dialog to install a new plugin. 7972 Private slot to show a dialog to install a new plugin.
7911 7973
7912 @param pluginFileNames list of plugin files suggested for 7974 @param pluginFileNames list of plugin files suggested for
7913 installation list of strings 7975 installation
7976 @type list of str
7914 """ 7977 """
7915 from eric7.PluginManager.PluginInstallDialog import PluginInstallDialog 7978 from eric7.PluginManager.PluginInstallDialog import PluginInstallDialog
7916 7979
7917 self.__pluginInstallDialog = PluginInstallDialog( 7980 self.__pluginInstallDialog = PluginInstallDialog(
7918 self.pluginManager, 7981 self.pluginManager,
8007 8070
8008 def dragEnterEvent(self, event): 8071 def dragEnterEvent(self, event):
8009 """ 8072 """
8010 Protected method to handle the drag enter event. 8073 Protected method to handle the drag enter event.
8011 8074
8012 @param event the drag enter event (QDragEnterEvent) 8075 @param event the drag enter event
8076 @type QDragEnterEvent
8013 """ 8077 """
8014 self.inDragDrop = event.mimeData().hasUrls() 8078 self.inDragDrop = event.mimeData().hasUrls()
8015 if self.inDragDrop: 8079 if self.inDragDrop:
8016 event.acceptProposedAction() 8080 event.acceptProposedAction()
8017 8081
8018 def dragMoveEvent(self, event): 8082 def dragMoveEvent(self, event):
8019 """ 8083 """
8020 Protected method to handle the drag move event. 8084 Protected method to handle the drag move event.
8021 8085
8022 @param event the drag move event (QDragMoveEvent) 8086 @param event the drag move event
8087 @type QDragMoveEvent
8023 """ 8088 """
8024 if self.inDragDrop: 8089 if self.inDragDrop:
8025 event.acceptProposedAction() 8090 event.acceptProposedAction()
8026 8091
8027 def dragLeaveEvent(self, event): 8092 def dragLeaveEvent(self, event):
8028 """ 8093 """
8029 Protected method to handle the drag leave event. 8094 Protected method to handle the drag leave event.
8030 8095
8031 @param event the drag leave event (QDragLeaveEvent) 8096 @param event the drag leave event
8097 @type QDragLeaveEvent
8032 """ 8098 """
8033 if self.inDragDrop: 8099 if self.inDragDrop:
8034 self.inDragDrop = False 8100 self.inDragDrop = False
8035 8101
8036 def dropEvent(self, event): 8102 def dropEvent(self, event):
8037 """ 8103 """
8038 Protected method to handle the drop event. 8104 Protected method to handle the drop event.
8039 8105
8040 @param event the drop event (QDropEvent) 8106 @param event the drop event
8107 @type QDropEvent
8041 """ 8108 """
8042 if event.mimeData().hasUrls(): 8109 if event.mimeData().hasUrls():
8043 event.acceptProposedAction() 8110 event.acceptProposedAction()
8044 for url in event.mimeData().urls(): 8111 for url in event.mimeData().urls():
8045 fname = url.toLocalFile() 8112 fname = url.toLocalFile()
8065 """ 8132 """
8066 Protected event handler for the close event. 8133 Protected event handler for the close event.
8067 8134
8068 This event handler saves the preferences. 8135 This event handler saves the preferences.
8069 8136
8070 @param event close event (QCloseEvent) 8137 @param event close event
8138 @type QCloseEvent
8071 """ 8139 """
8072 if self.__shutdown(): 8140 if self.__shutdown():
8073 event.accept() 8141 event.accept()
8074 if not self.inCloseEvent: 8142 if not self.inCloseEvent:
8075 self.inCloseEvent = True 8143 self.inCloseEvent = True
8252 8320
8253 def __sslErrors(self, reply, errors): 8321 def __sslErrors(self, reply, errors):
8254 """ 8322 """
8255 Private slot to handle SSL errors. 8323 Private slot to handle SSL errors.
8256 8324
8257 @param reply reference to the reply object (QNetworkReply) 8325 @param reply reference to the reply object
8258 @param errors list of SSL errors (list of QSslError) 8326 @type QNetworkReply
8327 @param errors list of SSL errors
8328 @type list of QSslError
8259 """ 8329 """
8260 ignored = self.__sslErrorHandler.sslErrorsReply(reply, errors)[0] 8330 ignored = self.__sslErrorHandler.sslErrorsReply(reply, errors)[0]
8261 if ignored == EricSslErrorState.NOT_IGNORED: 8331 if ignored == EricSslErrorState.NOT_IGNORED:
8262 self.__downloadCancelled = True 8332 self.__downloadCancelled = True
8263 8333
8322 def versionIsNewer(self, required, snapshot=None): 8392 def versionIsNewer(self, required, snapshot=None):
8323 """ 8393 """
8324 Public method to check, if the eric version is good compared to 8394 Public method to check, if the eric version is good compared to
8325 the required version. 8395 the required version.
8326 8396
8327 @param required required version (string) 8397 @param required required version
8328 @param snapshot required snapshot version (string) 8398 @type str
8329 @return flag indicating, that the version is newer than the required 8399 @param snapshot required snapshot version
8330 one (boolean) 8400 @type str
8401 @return flag indicating, that the version is newer than the required one
8402 @rtype bool
8331 """ 8403 """
8332 if VersionOnly.startswith("@@"): 8404 if VersionOnly.startswith("@@"):
8333 # development version, always newer 8405 # development version, always newer
8334 return True 8406 return True
8335 8407
8361 8433
8362 def __getFloatingGeometry(self, w): 8434 def __getFloatingGeometry(self, w):
8363 """ 8435 """
8364 Private method to get the geometry of a floating windows. 8436 Private method to get the geometry of a floating windows.
8365 8437
8366 @param w reference to the widget to be saved (QWidget) 8438 @param w reference to the widget to be saved
8439 @type QWidget
8367 @return list giving the widget's geometry and its visibility 8440 @return list giving the widget's geometry and its visibility
8441 @rtype list of [int, int, int, int, bool]
8368 """ 8442 """
8369 s = w.size() 8443 s = w.size()
8370 p = w.pos() 8444 p = w.pos()
8371 return [p.x(), p.y(), s.width(), s.height(), not w.isHidden()] 8445 return [p.x(), p.y(), s.width(), s.height(), not w.isHidden()]
8372 8446
8386 8460
8387 def showEvent(self, evt): 8461 def showEvent(self, evt):
8388 """ 8462 """
8389 Protected method to handle the show event. 8463 Protected method to handle the show event.
8390 8464
8391 @param evt reference to the show event (QShowEvent) 8465 @param evt reference to the show event
8466 @type QShowEvent
8392 """ 8467 """
8393 if self.__startup: 8468 if self.__startup:
8394 if Preferences.getGeometry("MainMaximized"): 8469 if Preferences.getGeometry("MainMaximized"):
8395 self.setWindowState(Qt.WindowState.WindowMaximized) 8470 self.setWindowState(Qt.WindowState.WindowMaximized)
8396 self.__startup = False 8471 self.__startup = False

eric ide

mercurial