src/eric7/Preferences/ConfigurationDialog.py

branch
eric7
changeset 10428
a071d4065202
parent 10373
093dcebe5ecb
child 10439
21c28b0f9e41
equal deleted inserted replaced
10427:3733e2b23cf7 10428:a071d4065202
51 51
52 def __init__(self, parent, text, pageName, iconFile): 52 def __init__(self, parent, text, pageName, iconFile):
53 """ 53 """
54 Constructor 54 Constructor
55 55
56 @param parent parent widget of the item (QTreeWidget or 56 @param parent parent widget of the item
57 QTreeWidgetItem) 57 @type QTreeWidget or QTreeWidgetItem
58 @param text text to be displayed (string) 58 @param text text to be displayed
59 @param pageName name of the configuration page (string) 59 @type str
60 @param iconFile file name of the icon to be shown (string) 60 @param pageName name of the configuration page
61 @type str
62 @param iconFile file name of the icon to be shown
63 @type str
61 """ 64 """
62 super().__init__(parent, [text]) 65 super().__init__(parent, [text])
63 self.setIcon(0, EricPixmapCache.getIcon(iconFile)) 66 self.setIcon(0, EricPixmapCache.getIcon(iconFile))
64 67
65 self.__pageName = pageName 68 self.__pageName = pageName
66 69
67 def getPageName(self): 70 def getPageName(self):
68 """ 71 """
69 Public method to get the name of the associated configuration page. 72 Public method to get the name of the associated configuration page.
70 73
71 @return name of the configuration page (string) 74 @return name of the configuration page
75 @rtype str
72 """ 76 """
73 return self.__pageName 77 return self.__pageName
74 78
75 79
76 class ConfigurationMode(enum.Enum): 80 class ConfigurationMode(enum.Enum):
1251 1255
1252 def __searchTextChanged(self, text): 1256 def __searchTextChanged(self, text):
1253 """ 1257 """
1254 Private slot to handle a change of the search text. 1258 Private slot to handle a change of the search text.
1255 1259
1256 @param text text to search for (string) 1260 @param text text to search for
1261 @type str
1257 """ 1262 """
1258 self.__searchChildItems(self.configList.invisibleRootItem(), text) 1263 self.__searchChildItems(self.configList.invisibleRootItem(), text)
1259 1264
1260 def __searchChildItems(self, parent, text): 1265 def __searchChildItems(self, parent, text):
1261 """ 1266 """
1262 Private method to enable child items based on a search string. 1267 Private method to enable child items based on a search string.
1263 1268
1264 @param parent reference to the parent item (QTreeWidgetItem) 1269 @param parent reference to the parent item
1265 @param text text to search for (string) 1270 @type QTreeWidgetItem
1266 @return flag indicating an enabled child item (boolean) 1271 @param text text to search for
1272 @type str
1273 @return flag indicating an enabled child item
1274 @rtype bool
1267 """ 1275 """
1268 childEnabled = False 1276 childEnabled = False
1269 text = text.lower() 1277 text = text.lower()
1270 for index in range(parent.childCount()): 1278 for index in range(parent.childCount()):
1271 itm = parent.child(index) 1279 itm = parent.child(index)
1300 1308
1301 def __importConfigurationPage(self, name): 1309 def __importConfigurationPage(self, name):
1302 """ 1310 """
1303 Private method to import a configuration page module. 1311 Private method to import a configuration page module.
1304 1312
1305 @param name name of the configuration page module (string) 1313 @param name name of the configuration page module
1314 @type str
1306 @return reference to the configuration page module 1315 @return reference to the configuration page module
1316 @rtype Module
1307 """ 1317 """
1308 try: 1318 try:
1309 mod = importlib.import_module( 1319 mod = importlib.import_module(
1310 ".ConfigurationPages.{0}".format(name), __package__ 1320 ".ConfigurationPages.{0}".format(name), __package__
1311 ) 1321 )
1324 @pyqtSlot(QTreeWidgetItem) 1334 @pyqtSlot(QTreeWidgetItem)
1325 def __showConfigurationPage(self, itm): 1335 def __showConfigurationPage(self, itm):
1326 """ 1336 """
1327 Private slot to show a selected configuration page. 1337 Private slot to show a selected configuration page.
1328 1338
1329 @param itm reference to the selected item (QTreeWidgetItem) 1339 @param itm reference to the selected item
1340 @type QTreeWidgetItem
1330 """ 1341 """
1331 pageName = itm.getPageName() 1342 pageName = itm.getPageName()
1332 self.showConfigurationPageByName(pageName, setCurrent=False) 1343 self.showConfigurationPageByName(pageName, setCurrent=False)
1333 1344
1334 def __initPage(self, pageData): 1345 def __initPage(self, pageData):
1335 """ 1346 """
1336 Private method to initialize a configuration page. 1347 Private method to initialize a configuration page.
1337 1348
1338 @param pageData data structure for the page to initialize 1349 @param pageData data structure for the page to initialize
1350 @type list
1339 @return reference to the initialized page 1351 @return reference to the initialized page
1352 @rtype ConfigurationPageBase
1340 """ 1353 """
1341 page = None 1354 page = None
1342 if isinstance(pageData[2], types.FunctionType): 1355 if isinstance(pageData[2], types.FunctionType):
1343 page = pageData[2](self) 1356 page = pageData[2](self)
1344 else: 1357 else:
1354 1367
1355 def showConfigurationPageByName(self, pageName, setCurrent=True): 1368 def showConfigurationPageByName(self, pageName, setCurrent=True):
1356 """ 1369 """
1357 Public slot to show a named configuration page. 1370 Public slot to show a named configuration page.
1358 1371
1359 @param pageName name of the configuration page to show (string) 1372 @param pageName name of the configuration page to show
1360 @param setCurrent flag indicating to set the current item (boolean) 1373 @type str
1374 @param setCurrent flag indicating to set the current item
1375 @type bool
1361 """ 1376 """
1362 if pageName == "empty" or pageName not in self.configItems: 1377 if pageName == "empty" or pageName not in self.configItems:
1363 page = self.emptyPage 1378 page = self.emptyPage
1364 else: 1379 else:
1365 pageData = self.configItems[pageName] 1380 pageData = self.configItems[pageName]
1436 1451
1437 def getConfigurationPageName(self): 1452 def getConfigurationPageName(self):
1438 """ 1453 """
1439 Public method to get the page name of the current page. 1454 Public method to get the page name of the current page.
1440 1455
1441 @return page name of the current page (string) 1456 @return page name of the current page
1457 @rtype str
1442 """ 1458 """
1443 return self.__currentConfigurationPageName 1459 return self.__currentConfigurationPageName
1444 1460
1445 def calledFromEric(self): 1461 def calledFromEric(self):
1446 """ 1462 """
1447 Public method to check, if invoked from within eric. 1463 Public method to check, if invoked from within eric.
1448 1464
1449 @return flag indicating invocation from within eric (boolean) 1465 @return flag indicating invocation from within eric
1466 @rtype bool
1450 """ 1467 """
1451 return self.fromEric 1468 return self.fromEric
1452 1469
1453 def getPage(self, pageName): 1470 def getPage(self, pageName):
1454 """ 1471 """
1455 Public method to get a reference to the named page. 1472 Public method to get a reference to the named page.
1456 1473
1457 @param pageName name of the configuration page (string) 1474 @param pageName name of the configuration page
1475 @type str
1458 @return reference to the page or None, indicating page was 1476 @return reference to the page or None, indicating page was
1459 not loaded yet 1477 not loaded yet
1478 @rtype ConfigurationPageBase
1460 """ 1479 """
1461 return self.configItems[pageName][-1] 1480 return self.configItems[pageName][-1]
1462 1481
1463 def getLexers(self): 1482 def getLexers(self):
1464 """ 1483 """
1465 Public method to get a reference to the lexers dictionary. 1484 Public method to get a reference to the lexers dictionary.
1466 1485
1467 @return reference to the lexers dictionary 1486 @return reference to the lexers dictionary
1487 @rtype dict
1468 """ 1488 """
1469 return self.lexers 1489 return self.lexers
1470 1490
1471 def setPreferences(self): 1491 def setPreferences(self):
1472 """ 1492 """
1484 1504
1485 def on_buttonBox_clicked(self, button): 1505 def on_buttonBox_clicked(self, button):
1486 """ 1506 """
1487 Private slot called by a button of the button box clicked. 1507 Private slot called by a button of the button box clicked.
1488 1508
1489 @param button button that was clicked (QAbstractButton) 1509 @param button button that was clicked
1510 @type QAbstractButton
1490 """ 1511 """
1491 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Apply): 1512 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Apply):
1492 self.on_applyButton_clicked() 1513 self.on_applyButton_clicked()
1493 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Reset): 1514 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Reset):
1494 self.on_resetButton_clicked() 1515 self.on_resetButton_clicked()
1527 1548
1528 def getExpandedEntries(self): 1549 def getExpandedEntries(self):
1529 """ 1550 """
1530 Public method to get a list of expanded entries. 1551 Public method to get a list of expanded entries.
1531 1552
1532 @return list of expanded entries (list of string) 1553 @return list of expanded entries
1554 @rtype list of str
1533 """ 1555 """
1534 return self.__expandedEntries 1556 return self.__expandedEntries
1535 1557
1536 @pyqtSlot(QTreeWidgetItem) 1558 @pyqtSlot(QTreeWidgetItem)
1537 def on_configList_itemCollapsed(self, item): 1559 def on_configList_itemCollapsed(self, item):
1538 """ 1560 """
1539 Private slot handling a list entry being collapsed. 1561 Private slot handling a list entry being collapsed.
1540 1562
1541 @param item reference to the collapsed item (QTreeWidgetItem) 1563 @param item reference to the collapsed item
1564 @type QTreeWidgetItem
1542 """ 1565 """
1543 pageName = item.data(0, Qt.ItemDataRole.UserRole) 1566 pageName = item.data(0, Qt.ItemDataRole.UserRole)
1544 if pageName in self.__expandedEntries: 1567 if pageName in self.__expandedEntries:
1545 self.__expandedEntries.remove(pageName) 1568 self.__expandedEntries.remove(pageName)
1546 1569
1547 @pyqtSlot(QTreeWidgetItem) 1570 @pyqtSlot(QTreeWidgetItem)
1548 def on_configList_itemExpanded(self, item): 1571 def on_configList_itemExpanded(self, item):
1549 """ 1572 """
1550 Private slot handling a list entry being expanded. 1573 Private slot handling a list entry being expanded.
1551 1574
1552 @param item reference to the expanded item (QTreeWidgetItem) 1575 @param item reference to the expanded item
1576 @type QTreeWidgetItem
1553 """ 1577 """
1554 pageName = item.data(0, Qt.ItemDataRole.UserRole) 1578 pageName = item.data(0, Qt.ItemDataRole.UserRole)
1555 if pageName not in self.__expandedEntries: 1579 if pageName not in self.__expandedEntries:
1556 self.__expandedEntries.append(pageName) 1580 self.__expandedEntries.append(pageName)
1557 1581
1650 1674
1651 def showConfigurationPageByName(self, pageName): 1675 def showConfigurationPageByName(self, pageName):
1652 """ 1676 """
1653 Public slot to show a named configuration page. 1677 Public slot to show a named configuration page.
1654 1678
1655 @param pageName name of the configuration page to show (string) 1679 @param pageName name of the configuration page to show
1680 @type str
1656 """ 1681 """
1657 self.cw.showConfigurationPageByName(pageName) 1682 self.cw.showConfigurationPageByName(pageName)
1658 1683
1659 def getConfigurationPageName(self): 1684 def getConfigurationPageName(self):
1660 """ 1685 """
1661 Public method to get the page name of the current page. 1686 Public method to get the page name of the current page.
1662 1687
1663 @return page name of the current page (string) 1688 @return page name of the current page
1689 @rtype str
1664 """ 1690 """
1665 return self.cw.getConfigurationPageName() 1691 return self.cw.getConfigurationPageName()
1666 1692
1667 def getExpandedEntries(self): 1693 def getExpandedEntries(self):
1668 """ 1694 """
1669 Public method to get a list of expanded entries. 1695 Public method to get a list of expanded entries.
1670 1696
1671 @return list of expanded entries (list of string) 1697 @return list of expanded entries
1698 @rtype list of str
1672 """ 1699 """
1673 return self.cw.getExpandedEntries() 1700 return self.cw.getExpandedEntries()
1674 1701
1675 def setPreferences(self): 1702 def setPreferences(self):
1676 """ 1703 """
1693 1720
1694 def __init__(self, parent=None): 1721 def __init__(self, parent=None):
1695 """ 1722 """
1696 Constructor 1723 Constructor
1697 1724
1698 @param parent reference to the parent widget (QWidget) 1725 @param parent reference to the parent widget
1726 @type QWidget
1699 """ 1727 """
1700 super().__init__(parent) 1728 super().__init__(parent)
1701 1729
1702 self.cw = ConfigurationWidget(self, fromEric=False, withApply=False) 1730 self.cw = ConfigurationWidget(self, fromEric=False, withApply=False)
1703 size = self.cw.size() 1731 size = self.cw.size()
1715 1743
1716 def showConfigurationPageByName(self, pageName): 1744 def showConfigurationPageByName(self, pageName):
1717 """ 1745 """
1718 Public slot to show a named configuration page. 1746 Public slot to show a named configuration page.
1719 1747
1720 @param pageName name of the configuration page to show (string) 1748 @param pageName name of the configuration page to show
1749 @type str
1721 """ 1750 """
1722 self.cw.showConfigurationPageByName(pageName) 1751 self.cw.showConfigurationPageByName(pageName)
1723 1752
1724 def accept(self): 1753 def accept(self):
1725 """ 1754 """

eric ide

mercurial