diff --git a/pyqtribbon/panel.py b/pyqtribbon/panel.py index 8ea3dde..9169400 100644 --- a/pyqtribbon/panel.py +++ b/pyqtribbon/panel.py @@ -116,7 +116,7 @@ class RibbonPanel(QtWidgets.QFrame): _widgets: List[QtWidgets.QWidget] = [] # height of the title widget - _titleHeight: int = 20 + _titleHeight: int = 15 # Panel options signal panelOptionClicked = QtCore.Signal(bool) @@ -183,7 +183,7 @@ def __init__(self, *args, **kwargs): self._panelOption = RibbonPanelOptionButton() # type: ignore self._panelOption.setAutoRaise(True) self._panelOption.setIcon(QtGui.QIcon(DataFile("icons/linking.png"))) - self._panelOption.setIconSize(QtCore.QSize(16, 16)) + self._panelOption.setIconSize(QtCore.QSize(self._titleHeight, self._titleHeight)) self._panelOption.setToolTip("Panel options") self._panelOption.clicked.connect(self.panelOptionClicked) # type: ignore self._titleLayout.addWidget(self._panelOption, 0) @@ -593,3 +593,19 @@ def title(self): :return: The title. """ return self._titleLabel.text() + + def setTitleHeight(self, height: int): + """Set the height of the title widget. + + :param height: The height to set. + """ + self._titleHeight = height + self._titleWidget.setFixedHeight(height) + self._panelOption.setIconSize(QtCore.QSize(height, height)) + + def titleHeight(self) -> int: + """Get the height of the title widget. + + :return: The height of the title widget. + """ + return self._titleHeight diff --git a/pyqtribbon/ribbonbar.py b/pyqtribbon/ribbonbar.py index 5e8078d..63d3823 100644 --- a/pyqtribbon/ribbonbar.py +++ b/pyqtribbon/ribbonbar.py @@ -49,7 +49,7 @@ class RibbonBar(QtWidgets.QMenuBar): _ribbonVisible = True #: heights of the ribbon elements - _ribbonHeight = 180 + _ribbonHeight = 150 #: current tab index _currentTabIndex = 0 @@ -250,7 +250,7 @@ def addQuickAccessButton(self, button: QtWidgets.QToolButton): button.setAutoRaise(True) self._titleWidget.quickAccessToolBar().addWidget(button) - def setQuickAccessButtonHeight(self, height: int = 30): + def setQuickAccessButtonHeight(self, height: int): """Set the height of the quick access buttons. :param height: The height to set. @@ -271,6 +271,13 @@ def setTitle(self, title: str): """ self._titleWidget.setTitle(title) + def setTitleWidgetHeight(self, height: int): + """Set the height of the title widget. + + :param height: The height to set. + """ + self._titleWidget.setTitleWidgetHeight(height) + def rightToolBar(self) -> QtWidgets.QToolBar: """Return the right toolbar of the ribbon. @@ -286,7 +293,7 @@ def addRightToolButton(self, button: QtWidgets.QToolButton): button.setAutoRaise(True) self._titleWidget.addRightToolButton(button) - def setRightToolBarHeight(self, height: int = 24): + def setRightToolBarHeight(self, height: int): """Set the height of the right buttons. :param height: The height to set. diff --git a/pyqtribbon/titlewidget.py b/pyqtribbon/titlewidget.py index 2d6720d..466f860 100644 --- a/pyqtribbon/titlewidget.py +++ b/pyqtribbon/titlewidget.py @@ -39,8 +39,8 @@ class RibbonTitleWidget(QtWidgets.QFrame): _quickAccessButtons = [] _rightToolButtons = [] - _quickAccessButtonHeight = 30 - _rightButtonHeight = 24 + _quickAccessButtonHeight = 20 + _rightButtonHeight = 20 # Mouse move events _start_point = None @@ -197,15 +197,14 @@ def addQuickAccessButton(self, button: QtWidgets.QToolButton): self._quickAccessButtons.append(button) self._quickAccessToolBar.addWidget(button) - def setQuickAccessButtonHeight(self, height: int = 30): + def setQuickAccessButtonHeight(self, height: int): """Set the height of the quick access buttons. :param height: The height to set. """ self._quickAccessButtonHeight = height - self._applicationButton.setIconSize(QtCore.QSize(height, height)) - for button in self._quickAccessButtons: - button.setIconSize(QtCore.QSize(height, height)) + self._applicationButton.setIcon(self._applicationButton.icon().pixmap(height, height)) + self._quickAccessToolBar.setIconSize(QtCore.QSize(height, height)) def title(self) -> str: """Return the title of the ribbon. @@ -237,14 +236,13 @@ def addRightToolButton(self, button: QtWidgets.QToolButton): self._rightToolButtons.append(button) self._rightToolBar.addWidget(button) - def setRightToolBarHeight(self, height: int = 24): + def setRightToolBarHeight(self, height: int): """Set the height of the right buttons. :param height: The height to set. """ self._rightButtonHeight = height - for button in self._rightToolButtons: - button.setIconSize(QtCore.QSize(height, height)) + self._rightToolBar.setIconSize(QtCore.QSize(height, height)) def helpRibbonButton(self) -> QtWidgets.QToolButton: """Return the help ribbon button. @@ -282,6 +280,14 @@ def collapseRibbonButton(self) -> QtWidgets.QToolButton: """ return self._collapseRibbonButton + def setTitleWidgetHeight(self, height: int): + """Set the height of the title widget. + + :param height: The height to set. + """ + self.setQuickAccessButtonHeight(height) + self.setRightToolBarHeight(height) + def topLevelWidget(self) -> QtWidgets.QWidget: widget = self while widget.parentWidget():