eric6/Preferences/ConfigurationDialog.py

branch
maintenance
changeset 7824
096b3ebc1409
parent 7737
5371a22cf2aa
parent 7788
604a28a7767b
child 7924
8a96736d465e
--- a/eric6/Preferences/ConfigurationDialog.py	Sat Oct 03 11:14:23 2020 +0200
+++ b/eric6/Preferences/ConfigurationDialog.py	Sun Nov 01 11:15:18 2020 +0100
@@ -7,7 +7,6 @@
 Module implementing a dialog for the configuration of eric6.
 """
 
-
 import os
 import types
 
@@ -16,7 +15,7 @@
 from PyQt5.QtWidgets import (
     QSizePolicy, QSpacerItem, QWidget, QTreeWidget, QStackedWidget, QDialog,
     QSplitter, QScrollArea, QApplication, QDialogButtonBox, QFrame,
-    QVBoxLayout, QTreeWidgetItem, QLabel
+    QVBoxLayout, QTreeWidgetItem, QLabel, QAbstractScrollArea
 )
 
 from E5Gui.E5Application import e5App
@@ -463,6 +462,7 @@
         
         # set the initial size of the splitter
         self.configSplitter.setSizes([200, 600])
+        self.configSplitter.splitterMoved.connect(self.__resizeConfigStack)
         
         self.configList.itemActivated.connect(self.__showConfigurationPage)
         self.configList.itemClicked.connect(self.__showConfigurationPage)
@@ -496,7 +496,7 @@
         widget.
         """
         self.setObjectName("ConfigurationDialog")
-        self.resize(900, 650)
+        self.resize(900, 750)
         self.verticalLayout_2 = QVBoxLayout(self)
         self.verticalLayout_2.setSpacing(6)
         self.verticalLayout_2.setContentsMargins(6, 6, 6, 6)
@@ -524,7 +524,9 @@
         self.scrollArea.setFrameShape(QFrame.NoFrame)
         self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
         self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
-        self.scrollArea.setWidgetResizable(True)
+        self.scrollArea.setWidgetResizable(False)
+        self.scrollArea.setSizeAdjustPolicy(
+            QAbstractScrollArea.AdjustToContents)
         self.scrollArea.setObjectName("scrollArea")
         
         self.configStack = QStackedWidget()
@@ -723,18 +725,7 @@
                     if item.data(0, Qt.UserRole) == pageName:
                         self.configList.setCurrentItem(item)
         self.configStack.setCurrentWidget(page)
-        ssize = self.scrollArea.size()
-        if self.scrollArea.horizontalScrollBar():
-            ssize.setHeight(
-                ssize.height() -
-                self.scrollArea.horizontalScrollBar().height() - 2)
-        if self.scrollArea.verticalScrollBar():
-            ssize.setWidth(
-                ssize.width() -
-                self.scrollArea.verticalScrollBar().width() - 2)
-        psize = page.minimumSizeHint()
-        self.configStack.resize(max(ssize.width(), psize.width()),
-                                max(ssize.height(), psize.height()))
+        self.__resizeConfigStack()
         
         if page != self.emptyPage:
             page.polishPage()
@@ -751,7 +742,33 @@
                 sb.setValue(0)
         
         self.__currentConfigurationPageName = pageName
+    
+    def resizeEvent(self, evt):
+        """
+        Protected method to handle the resizing of the widget.
         
+        @param evt reference to the event object
+        @type QResizeEvent
+        """
+        self.__resizeConfigStack()
+    
+    def __resizeConfigStack(self):
+        """
+        Private method to resize the stack of configuration pages.
+        """
+        ssize = self.scrollArea.size()
+        if self.scrollArea.horizontalScrollBar():
+            ssize.setHeight(
+                ssize.height() -
+                self.scrollArea.horizontalScrollBar().height() - 2)
+        if self.scrollArea.verticalScrollBar():
+            ssize.setWidth(
+                ssize.width() -
+                self.scrollArea.verticalScrollBar().width() - 2)
+        psize = self.configStack.currentWidget().minimumSizeHint()
+        self.configStack.resize(max(ssize.width(), psize.width()),
+                                max(ssize.height(), psize.height()))
+    
     def getConfigurationPageName(self):
         """
         Public method to get the page name of the current page.

eric ide

mercurial