14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QMetaObject, QRect |
14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QMetaObject, QRect |
15 from PyQt5.QtGui import QPixmap |
15 from PyQt5.QtGui import QPixmap |
16 from PyQt5.QtWidgets import ( |
16 from PyQt5.QtWidgets import ( |
17 QSizePolicy, QSpacerItem, QWidget, QTreeWidget, QStackedWidget, QDialog, |
17 QSizePolicy, QSpacerItem, QWidget, QTreeWidget, QStackedWidget, QDialog, |
18 QSplitter, QScrollArea, QApplication, QDialogButtonBox, QFrame, |
18 QSplitter, QScrollArea, QApplication, QDialogButtonBox, QFrame, |
19 QVBoxLayout, QTreeWidgetItem, QLabel |
19 QVBoxLayout, QTreeWidgetItem, QLabel, QAbstractScrollArea |
20 ) |
20 ) |
21 |
21 |
22 from E5Gui.E5Application import e5App |
22 from E5Gui.E5Application import e5App |
23 from E5Gui.E5LineEdit import E5ClearableLineEdit |
23 from E5Gui.E5LineEdit import E5ClearableLineEdit |
24 from E5Gui import E5MessageBox |
24 from E5Gui import E5MessageBox |
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(QAbstractScrollArea.AdjustToContents) |
528 self.scrollArea.setObjectName("scrollArea") |
529 self.scrollArea.setObjectName("scrollArea") |
529 |
530 |
530 self.configStack = QStackedWidget() |
531 self.configStack = QStackedWidget() |
531 self.configStack.setFrameShape(QFrame.Box) |
532 self.configStack.setFrameShape(QFrame.Box) |
532 self.configStack.setFrameShadow(QFrame.Sunken) |
533 self.configStack.setFrameShadow(QFrame.Sunken) |
721 Qt.MatchFixedString | Qt.MatchRecursive) |
722 Qt.MatchFixedString | Qt.MatchRecursive) |
722 for item in items: |
723 for item in items: |
723 if item.data(0, Qt.UserRole) == pageName: |
724 if item.data(0, Qt.UserRole) == pageName: |
724 self.configList.setCurrentItem(item) |
725 self.configList.setCurrentItem(item) |
725 self.configStack.setCurrentWidget(page) |
726 self.configStack.setCurrentWidget(page) |
|
727 self.__resizeConfigStack() |
|
728 |
|
729 if page != self.emptyPage: |
|
730 page.polishPage() |
|
731 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(True) |
|
732 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(True) |
|
733 else: |
|
734 self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False) |
|
735 self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False) |
|
736 |
|
737 # reset scrollbars |
|
738 for sb in [self.scrollArea.horizontalScrollBar(), |
|
739 self.scrollArea.verticalScrollBar()]: |
|
740 if sb: |
|
741 sb.setValue(0) |
|
742 |
|
743 self.__currentConfigurationPageName = pageName |
|
744 |
|
745 def resizeEvent(self, evt): |
|
746 """ |
|
747 Protected method to handle the resizing of the widget. |
|
748 |
|
749 @param evt reference to the event object |
|
750 @type QResizeEvent |
|
751 """ |
|
752 self.__resizeConfigStack() |
|
753 |
|
754 def __resizeConfigStack(self): |
|
755 """ |
|
756 Private method to resize the stack of configuration pages. |
|
757 """ |
726 ssize = self.scrollArea.size() |
758 ssize = self.scrollArea.size() |
727 if self.scrollArea.horizontalScrollBar(): |
759 if self.scrollArea.horizontalScrollBar(): |
728 ssize.setHeight( |
760 ssize.setHeight( |
729 ssize.height() - |
761 ssize.height() - |
730 self.scrollArea.horizontalScrollBar().height() - 2) |
762 self.scrollArea.horizontalScrollBar().height() - 2) |
731 if self.scrollArea.verticalScrollBar(): |
763 if self.scrollArea.verticalScrollBar(): |
732 ssize.setWidth( |
764 ssize.setWidth( |
733 ssize.width() - |
765 ssize.width() - |
734 self.scrollArea.verticalScrollBar().width() - 2) |
766 self.scrollArea.verticalScrollBar().width() - 2) |
735 psize = page.minimumSizeHint() |
767 psize = self.configStack.currentWidget().sizeHint() |
736 self.configStack.resize(max(ssize.width(), psize.width()), |
768 self.configStack.resize(max(ssize.width(), psize.width()), |
737 max(ssize.height(), psize.height())) |
769 max(ssize.height(), psize.height())) |
738 |
770 |
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): |
771 def getConfigurationPageName(self): |
756 """ |
772 """ |
757 Public method to get the page name of the current page. |
773 Public method to get the page name of the current page. |
758 |
774 |
759 @return page name of the current page (string) |
775 @return page name of the current page (string) |