eric6/Preferences/ConfigurationDialog.py

branch
maintenance
changeset 7824
096b3ebc1409
parent 7737
5371a22cf2aa
parent 7788
604a28a7767b
child 7924
8a96736d465e
equal deleted inserted replaced
7738:10554f5fac78 7824:096b3ebc1409
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a dialog for the configuration of eric6. 7 Module implementing a dialog for the configuration of eric6.
8 """ 8 """
9
10 9
11 import os 10 import os
12 import types 11 import types
13 12
14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QMetaObject, QRect 13 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QMetaObject, QRect
15 from PyQt5.QtGui import QPixmap 14 from PyQt5.QtGui import QPixmap
16 from PyQt5.QtWidgets import ( 15 from PyQt5.QtWidgets import (
17 QSizePolicy, QSpacerItem, QWidget, QTreeWidget, QStackedWidget, QDialog, 16 QSizePolicy, QSpacerItem, QWidget, QTreeWidget, QStackedWidget, QDialog,
18 QSplitter, QScrollArea, QApplication, QDialogButtonBox, QFrame, 17 QSplitter, QScrollArea, QApplication, QDialogButtonBox, QFrame,
19 QVBoxLayout, QTreeWidgetItem, QLabel 18 QVBoxLayout, QTreeWidgetItem, QLabel, QAbstractScrollArea
20 ) 19 )
21 20
22 from E5Gui.E5Application import e5App 21 from E5Gui.E5Application import e5App
23 from E5Gui.E5LineEdit import E5ClearableLineEdit 22 from E5Gui.E5LineEdit import E5ClearableLineEdit
24 from E5Gui import E5MessageBox 23 from E5Gui import E5MessageBox
461 self.itmDict[key].setExpanded(True) 460 self.itmDict[key].setExpanded(True)
462 self.configList.sortByColumn(0, Qt.AscendingOrder) 461 self.configList.sortByColumn(0, Qt.AscendingOrder)
463 462
464 # set the initial size of the splitter 463 # set the initial size of the splitter
465 self.configSplitter.setSizes([200, 600]) 464 self.configSplitter.setSizes([200, 600])
465 self.configSplitter.splitterMoved.connect(self.__resizeConfigStack)
466 466
467 self.configList.itemActivated.connect(self.__showConfigurationPage) 467 self.configList.itemActivated.connect(self.__showConfigurationPage)
468 self.configList.itemClicked.connect(self.__showConfigurationPage) 468 self.configList.itemClicked.connect(self.__showConfigurationPage)
469 self.buttonBox.accepted.connect(self.accept) 469 self.buttonBox.accepted.connect(self.accept)
470 self.buttonBox.rejected.connect(self.rejected) 470 self.buttonBox.rejected.connect(self.rejected)
494 """ 494 """
495 Private method to perform the general setup of the configuration 495 Private method to perform the general setup of the configuration
496 widget. 496 widget.
497 """ 497 """
498 self.setObjectName("ConfigurationDialog") 498 self.setObjectName("ConfigurationDialog")
499 self.resize(900, 650) 499 self.resize(900, 750)
500 self.verticalLayout_2 = QVBoxLayout(self) 500 self.verticalLayout_2 = QVBoxLayout(self)
501 self.verticalLayout_2.setSpacing(6) 501 self.verticalLayout_2.setSpacing(6)
502 self.verticalLayout_2.setContentsMargins(6, 6, 6, 6) 502 self.verticalLayout_2.setContentsMargins(6, 6, 6, 6)
503 self.verticalLayout_2.setObjectName("verticalLayout_2") 503 self.verticalLayout_2.setObjectName("verticalLayout_2")
504 504
522 522
523 self.scrollArea = QScrollArea(self.configSplitter) 523 self.scrollArea = QScrollArea(self.configSplitter)
524 self.scrollArea.setFrameShape(QFrame.NoFrame) 524 self.scrollArea.setFrameShape(QFrame.NoFrame)
525 self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) 525 self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
526 self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) 526 self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
527 self.scrollArea.setWidgetResizable(True) 527 self.scrollArea.setWidgetResizable(False)
528 self.scrollArea.setSizeAdjustPolicy(
529 QAbstractScrollArea.AdjustToContents)
528 self.scrollArea.setObjectName("scrollArea") 530 self.scrollArea.setObjectName("scrollArea")
529 531
530 self.configStack = QStackedWidget() 532 self.configStack = QStackedWidget()
531 self.configStack.setFrameShape(QFrame.Box) 533 self.configStack.setFrameShape(QFrame.Box)
532 self.configStack.setFrameShadow(QFrame.Sunken) 534 self.configStack.setFrameShadow(QFrame.Sunken)
721 Qt.MatchFixedString | Qt.MatchRecursive) 723 Qt.MatchFixedString | Qt.MatchRecursive)
722 for item in items: 724 for item in items:
723 if item.data(0, Qt.UserRole) == pageName: 725 if item.data(0, Qt.UserRole) == pageName:
724 self.configList.setCurrentItem(item) 726 self.configList.setCurrentItem(item)
725 self.configStack.setCurrentWidget(page) 727 self.configStack.setCurrentWidget(page)
728 self.__resizeConfigStack()
729
730 if page != self.emptyPage:
731 page.polishPage()
732 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(True)
733 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(True)
734 else:
735 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False)
736 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False)
737
738 # reset scrollbars
739 for sb in [self.scrollArea.horizontalScrollBar(),
740 self.scrollArea.verticalScrollBar()]:
741 if sb:
742 sb.setValue(0)
743
744 self.__currentConfigurationPageName = pageName
745
746 def resizeEvent(self, evt):
747 """
748 Protected method to handle the resizing of the widget.
749
750 @param evt reference to the event object
751 @type QResizeEvent
752 """
753 self.__resizeConfigStack()
754
755 def __resizeConfigStack(self):
756 """
757 Private method to resize the stack of configuration pages.
758 """
726 ssize = self.scrollArea.size() 759 ssize = self.scrollArea.size()
727 if self.scrollArea.horizontalScrollBar(): 760 if self.scrollArea.horizontalScrollBar():
728 ssize.setHeight( 761 ssize.setHeight(
729 ssize.height() - 762 ssize.height() -
730 self.scrollArea.horizontalScrollBar().height() - 2) 763 self.scrollArea.horizontalScrollBar().height() - 2)
731 if self.scrollArea.verticalScrollBar(): 764 if self.scrollArea.verticalScrollBar():
732 ssize.setWidth( 765 ssize.setWidth(
733 ssize.width() - 766 ssize.width() -
734 self.scrollArea.verticalScrollBar().width() - 2) 767 self.scrollArea.verticalScrollBar().width() - 2)
735 psize = page.minimumSizeHint() 768 psize = self.configStack.currentWidget().minimumSizeHint()
736 self.configStack.resize(max(ssize.width(), psize.width()), 769 self.configStack.resize(max(ssize.width(), psize.width()),
737 max(ssize.height(), psize.height())) 770 max(ssize.height(), psize.height()))
738 771
739 if page != self.emptyPage:
740 page.polishPage()
741 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(True)
742 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(True)
743 else:
744 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False)
745 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False)
746
747 # reset scrollbars
748 for sb in [self.scrollArea.horizontalScrollBar(),
749 self.scrollArea.verticalScrollBar()]:
750 if sb:
751 sb.setValue(0)
752
753 self.__currentConfigurationPageName = pageName
754
755 def getConfigurationPageName(self): 772 def getConfigurationPageName(self):
756 """ 773 """
757 Public method to get the page name of the current page. 774 Public method to get the page name of the current page.
758 775
759 @return page name of the current page (string) 776 @return page name of the current page (string)

eric ide

mercurial