eric6/Preferences/ConfigurationDialog.py

changeset 8143
2c730d5fd177
parent 8069
1176a936efa4
child 8176
31965986ecd1
child 8205
4a0f1f896341
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
442 continue 442 continue
443 else: 443 else:
444 pitm = self.configList 444 pitm = self.configList
445 self.itmDict[key] = ConfigurationPageItem(pitm, pageData[0], key, 445 self.itmDict[key] = ConfigurationPageItem(pitm, pageData[0], key,
446 pageData[1]) 446 pageData[1])
447 self.itmDict[key].setData(0, Qt.UserRole, key) 447 self.itmDict[key].setData(0, Qt.ItemDataRole.UserRole, key)
448 if (not self.fromEric or 448 if (not self.fromEric or
449 displayMode != ConfigurationWidget.DefaultMode or 449 displayMode != ConfigurationWidget.DefaultMode or
450 key in expandedEntries): 450 key in expandedEntries):
451 self.itmDict[key].setExpanded(True) 451 self.itmDict[key].setExpanded(True)
452 self.configList.sortByColumn(0, Qt.AscendingOrder) 452 self.configList.sortByColumn(0, Qt.SortOrder.AscendingOrder)
453 453
454 # set the initial size of the splitter 454 # set the initial size of the splitter
455 self.configSplitter.setSizes([200, 600]) 455 self.configSplitter.setSizes([200, 600])
456 self.configSplitter.splitterMoved.connect(self.__resizeConfigStack) 456 self.configSplitter.splitterMoved.connect(self.__resizeConfigStack)
457 457
492 self.verticalLayout_2.setSpacing(6) 492 self.verticalLayout_2.setSpacing(6)
493 self.verticalLayout_2.setContentsMargins(6, 6, 6, 6) 493 self.verticalLayout_2.setContentsMargins(6, 6, 6, 6)
494 self.verticalLayout_2.setObjectName("verticalLayout_2") 494 self.verticalLayout_2.setObjectName("verticalLayout_2")
495 495
496 self.configSplitter = QSplitter(self) 496 self.configSplitter = QSplitter(self)
497 self.configSplitter.setOrientation(Qt.Horizontal) 497 self.configSplitter.setOrientation(Qt.Orientation.Horizontal)
498 self.configSplitter.setObjectName("configSplitter") 498 self.configSplitter.setObjectName("configSplitter")
499 499
500 self.configListWidget = QWidget(self.configSplitter) 500 self.configListWidget = QWidget(self.configSplitter)
501 self.leftVBoxLayout = QVBoxLayout(self.configListWidget) 501 self.leftVBoxLayout = QVBoxLayout(self.configListWidget)
502 self.leftVBoxLayout.setContentsMargins(0, 0, 0, 0) 502 self.leftVBoxLayout.setContentsMargins(0, 0, 0, 0)
510 self.configList.setObjectName("configList") 510 self.configList.setObjectName("configList")
511 self.leftVBoxLayout.addWidget(self.configList) 511 self.leftVBoxLayout.addWidget(self.configList)
512 self.configListSearch.textChanged.connect(self.__searchTextChanged) 512 self.configListSearch.textChanged.connect(self.__searchTextChanged)
513 513
514 self.scrollArea = QScrollArea(self.configSplitter) 514 self.scrollArea = QScrollArea(self.configSplitter)
515 self.scrollArea.setFrameShape(QFrame.NoFrame) 515 self.scrollArea.setFrameShape(QFrame.Shape.NoFrame)
516 self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) 516 self.scrollArea.setVerticalScrollBarPolicy(
517 self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) 517 Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
518 self.scrollArea.setHorizontalScrollBarPolicy(
519 Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
518 self.scrollArea.setWidgetResizable(False) 520 self.scrollArea.setWidgetResizable(False)
519 self.scrollArea.setSizeAdjustPolicy( 521 self.scrollArea.setSizeAdjustPolicy(
520 QAbstractScrollArea.AdjustToContents) 522 QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents)
521 self.scrollArea.setObjectName("scrollArea") 523 self.scrollArea.setObjectName("scrollArea")
522 524
523 self.configStack = QStackedWidget() 525 self.configStack = QStackedWidget()
524 self.configStack.setFrameShape(QFrame.Box) 526 self.configStack.setFrameShape(QFrame.Shape.Box)
525 self.configStack.setFrameShadow(QFrame.Sunken) 527 self.configStack.setFrameShadow(QFrame.Shadow.Sunken)
526 self.configStack.setObjectName("configStack") 528 self.configStack.setObjectName("configStack")
527 self.scrollArea.setWidget(self.configStack) 529 self.scrollArea.setWidget(self.configStack)
528 530
529 self.emptyPage = QWidget() 531 self.emptyPage = QWidget()
530 self.emptyPage.setGeometry(QRect(0, 0, 372, 591)) 532 self.emptyPage.setGeometry(QRect(0, 0, 372, 591))
532 self.vboxlayout = QVBoxLayout(self.emptyPage) 534 self.vboxlayout = QVBoxLayout(self.emptyPage)
533 self.vboxlayout.setSpacing(6) 535 self.vboxlayout.setSpacing(6)
534 self.vboxlayout.setContentsMargins(6, 6, 6, 6) 536 self.vboxlayout.setContentsMargins(6, 6, 6, 6)
535 self.vboxlayout.setObjectName("vboxlayout") 537 self.vboxlayout.setObjectName("vboxlayout")
536 spacerItem = QSpacerItem( 538 spacerItem = QSpacerItem(
537 20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding) 539 20, 20, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
538 self.vboxlayout.addItem(spacerItem) 540 self.vboxlayout.addItem(spacerItem)
539 self.emptyPagePixmap = QLabel(self.emptyPage) 541 self.emptyPagePixmap = QLabel(self.emptyPage)
540 self.emptyPagePixmap.setAlignment(Qt.AlignCenter) 542 self.emptyPagePixmap.setAlignment(Qt.AlignmentFlag.AlignCenter)
541 self.emptyPagePixmap.setObjectName("emptyPagePixmap") 543 self.emptyPagePixmap.setObjectName("emptyPagePixmap")
542 self.emptyPagePixmap.setPixmap( 544 self.emptyPagePixmap.setPixmap(
543 QPixmap(os.path.join(getConfig('ericPixDir'), 'eric.png'))) 545 QPixmap(os.path.join(getConfig('ericPixDir'), 'eric.png')))
544 self.vboxlayout.addWidget(self.emptyPagePixmap) 546 self.vboxlayout.addWidget(self.emptyPagePixmap)
545 self.textLabel1 = QLabel(self.emptyPage) 547 self.textLabel1 = QLabel(self.emptyPage)
546 self.textLabel1.setAlignment(Qt.AlignCenter) 548 self.textLabel1.setAlignment(Qt.AlignmentFlag.AlignCenter)
547 self.textLabel1.setObjectName("textLabel1") 549 self.textLabel1.setObjectName("textLabel1")
548 self.vboxlayout.addWidget(self.textLabel1) 550 self.vboxlayout.addWidget(self.textLabel1)
549 spacerItem1 = QSpacerItem( 551 spacerItem1 = QSpacerItem(
550 20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) 552 20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
551 self.vboxlayout.addItem(spacerItem1) 553 self.vboxlayout.addItem(spacerItem1)
552 self.configStack.addWidget(self.emptyPage) 554 self.configStack.addWidget(self.emptyPage)
553 555
554 self.verticalLayout_2.addWidget(self.configSplitter) 556 self.verticalLayout_2.addWidget(self.configSplitter)
555 557
556 self.buttonBox = QDialogButtonBox(self) 558 self.buttonBox = QDialogButtonBox(self)
557 self.buttonBox.setOrientation(Qt.Horizontal) 559 self.buttonBox.setOrientation(Qt.Orientation.Horizontal)
558 self.buttonBox.setStandardButtons( 560 self.buttonBox.setStandardButtons(
559 QDialogButtonBox.Apply | QDialogButtonBox.Cancel | 561 QDialogButtonBox.StandardButton.Apply |
560 QDialogButtonBox.Ok | QDialogButtonBox.Reset) 562 QDialogButtonBox.StandardButton.Cancel |
563 QDialogButtonBox.StandardButton.Ok |
564 QDialogButtonBox.StandardButton.Reset
565 )
561 self.buttonBox.setObjectName("buttonBox") 566 self.buttonBox.setObjectName("buttonBox")
562 if ( 567 if (
563 not self.fromEric and 568 not self.fromEric and
564 self.displayMode == ConfigurationWidget.DefaultMode 569 self.displayMode == ConfigurationWidget.DefaultMode
565 ): 570 ):
566 self.buttonBox.button(QDialogButtonBox.Apply).hide() 571 self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).hide()
567 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False) 572 self.buttonBox.button(
568 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False) 573 QDialogButtonBox.StandardButton.Apply).setEnabled(False)
574 self.buttonBox.button(
575 QDialogButtonBox.StandardButton.Reset).setEnabled(False)
569 self.verticalLayout_2.addWidget(self.buttonBox) 576 self.verticalLayout_2.addWidget(self.buttonBox)
570 577
571 self.setWindowTitle(self.tr("Preferences")) 578 self.setWindowTitle(self.tr("Preferences"))
572 579
573 self.configList.header().hide() 580 self.configList.header().hide()
574 self.configList.header().setSortIndicator(0, Qt.AscendingOrder) 581 self.configList.header().setSortIndicator(
582 0, Qt.SortOrder.AscendingOrder)
575 self.configList.setSortingEnabled(True) 583 self.configList.setSortingEnabled(True)
576 self.textLabel1.setText( 584 self.textLabel1.setText(
577 self.tr("Please select an entry of the list \n" 585 self.tr("Please select an entry of the list \n"
578 "to display the configuration page.")) 586 "to display the configuration page."))
579 587
709 if page is None: 717 if page is None:
710 page = self.emptyPage 718 page = self.emptyPage
711 elif setCurrent: 719 elif setCurrent:
712 items = self.configList.findItems( 720 items = self.configList.findItems(
713 pageData[0], 721 pageData[0],
714 Qt.MatchFixedString | Qt.MatchRecursive) 722 Qt.MatchFlag.MatchFixedString |
723 Qt.MatchFlag.MatchRecursive)
715 for item in items: 724 for item in items:
716 if item.data(0, Qt.UserRole) == pageName: 725 if item.data(0, Qt.ItemDataRole.UserRole) == pageName:
717 self.configList.setCurrentItem(item) 726 self.configList.setCurrentItem(item)
718 self.configStack.setCurrentWidget(page) 727 self.configStack.setCurrentWidget(page)
719 self.__resizeConfigStack() 728 self.__resizeConfigStack()
720 729
721 if page != self.emptyPage: 730 if page != self.emptyPage:
722 page.polishPage() 731 page.polishPage()
723 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(True) 732 self.buttonBox.button(
724 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(True) 733 QDialogButtonBox.StandardButton.Apply).setEnabled(True)
734 self.buttonBox.button(
735 QDialogButtonBox.StandardButton.Reset).setEnabled(True)
725 else: 736 else:
726 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False) 737 self.buttonBox.button(
727 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False) 738 QDialogButtonBox.StandardButton.Apply).setEnabled(False)
739 self.buttonBox.button(
740 QDialogButtonBox.StandardButton.Reset).setEnabled(False)
728 741
729 # reset scrollbars 742 # reset scrollbars
730 for sb in [self.scrollArea.horizontalScrollBar(), 743 for sb in [self.scrollArea.horizontalScrollBar(),
731 self.scrollArea.verticalScrollBar()]: 744 self.scrollArea.verticalScrollBar()]:
732 if sb: 745 if sb:
809 """ 822 """
810 Private slot called by a button of the button box clicked. 823 Private slot called by a button of the button box clicked.
811 824
812 @param button button that was clicked (QAbstractButton) 825 @param button button that was clicked (QAbstractButton)
813 """ 826 """
814 if button == self.buttonBox.button(QDialogButtonBox.Apply): 827 if button == self.buttonBox.button(
828 QDialogButtonBox.StandardButton.Apply
829 ):
815 self.on_applyButton_clicked() 830 self.on_applyButton_clicked()
816 elif button == self.buttonBox.button(QDialogButtonBox.Reset): 831 elif button == self.buttonBox.button(
832 QDialogButtonBox.StandardButton.Reset
833 ):
817 self.on_resetButton_clicked() 834 self.on_resetButton_clicked()
818 835
819 @pyqtSlot() 836 @pyqtSlot()
820 def on_applyButton_clicked(self): 837 def on_applyButton_clicked(self):
821 """ 838 """
861 """ 878 """
862 Private slot handling a list entry being collapsed. 879 Private slot handling a list entry being collapsed.
863 880
864 @param item reference to the collapsed item (QTreeWidgetItem) 881 @param item reference to the collapsed item (QTreeWidgetItem)
865 """ 882 """
866 pageName = item.data(0, Qt.UserRole) 883 pageName = item.data(0, Qt.ItemDataRole.UserRole)
867 if pageName in self.__expandedEntries: 884 if pageName in self.__expandedEntries:
868 self.__expandedEntries.remove(pageName) 885 self.__expandedEntries.remove(pageName)
869 886
870 @pyqtSlot(QTreeWidgetItem) 887 @pyqtSlot(QTreeWidgetItem)
871 def on_configList_itemExpanded(self, item): 888 def on_configList_itemExpanded(self, item):
872 """ 889 """
873 Private slot handling a list entry being expanded. 890 Private slot handling a list entry being expanded.
874 891
875 @param item reference to the expanded item (QTreeWidgetItem) 892 @param item reference to the expanded item (QTreeWidgetItem)
876 """ 893 """
877 pageName = item.data(0, Qt.UserRole) 894 pageName = item.data(0, Qt.ItemDataRole.UserRole)
878 if pageName not in self.__expandedEntries: 895 if pageName not in self.__expandedEntries:
879 self.__expandedEntries.append(pageName) 896 self.__expandedEntries.append(pageName)
880 897
881 def isUsingWebEngine(self): 898 def isUsingWebEngine(self):
882 """ 899 """
927 """ 944 """
928 super(ConfigurationDialog, self).__init__(parent) 945 super(ConfigurationDialog, self).__init__(parent)
929 if name: 946 if name:
930 self.setObjectName(name) 947 self.setObjectName(name)
931 self.setModal(modal) 948 self.setModal(modal)
932 self.setWindowFlags(Qt.Window) 949 self.setWindowFlags(Qt.WindowType.Window)
933 950
934 self.layout = QVBoxLayout(self) 951 self.layout = QVBoxLayout(self)
935 self.layout.setContentsMargins(0, 0, 0, 0) 952 self.layout.setContentsMargins(0, 0, 0, 0)
936 self.layout.setSpacing(0) 953 self.layout.setSpacing(0)
937 954

eric ide

mercurial