diff --git a/nw/gui/docbars.py b/nw/gui/docbars.py index e1240e2d..66f6a2b5 100644 --- a/nw/gui/docbars.py +++ b/nw/gui/docbars.py @@ -33,7 +33,7 @@ from PyQt5.QtCore import Qt, QSize from PyQt5.QtGui import QPalette, QColor from PyQt5.QtWidgets import ( qApp, QWidget, QFrame, QGridLayout, QLabel, QLineEdit, QPushButton, - QHBoxLayout + QHBoxLayout, QSizePolicy ) from nw.constants import nwDocAction, nwUnicode @@ -187,8 +187,12 @@ class GuiDocTitleBar(QWidget): self.thePalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack)) self.thePalette.setColor(QPalette.Text, QColor(*self.theTheme.colText)) + iPx = self.theTheme.textIconSize + hSp = self.mainConf.pxInt(6) + self.buttonSize = iPx + hSp + # Main Widget Settings - self.setContentsMargins(0, 0, 0, 0) + self.setContentsMargins(2*self.buttonSize, 0, 0, 0) self.setAutoFillBackground(True) self.setPalette(self.thePalette) @@ -197,10 +201,11 @@ class GuiDocTitleBar(QWidget): self.theTitle.setText("") self.theTitle.setIndent(0) self.theTitle.setMargin(0) - self.theTitle.setContentsMargins(10, 0, 0, 0) + self.theTitle.setContentsMargins(0, 0, 0, 0) self.theTitle.setAutoFillBackground(True) - self.theTitle.setAlignment(Qt.AlignCenter) - self.theTitle.setWordWrap(True) + self.theTitle.setAlignment(Qt.AlignTop | Qt.AlignHCenter) + self.theTitle.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) + self.theTitle.setMinimumHeight(self.theTheme.fontPixelSize) self.theTitle.setFrameShape(QFrame.NoFrame) self.theTitle.setLineWidth(0) self.theTitle.setPalette(self.thePalette) @@ -210,8 +215,6 @@ class GuiDocTitleBar(QWidget): self.theTitle.setFont(lblFont) # Buttons - iPx = self.theTheme.textIconSize - self.closeButton = QPushButton("") self.closeButton.setIcon(self.theTheme.getIcon("close")) self.closeButton.setContentsMargins(0, 0, 0, 0) @@ -241,10 +244,8 @@ class GuiDocTitleBar(QWidget): self.refreshButton.clicked.connect(self._refreshDocument) # Assemble Layout - hSp = self.mainConf.pxInt(6) self.outerBox = QHBoxLayout() self.outerBox.setSpacing(hSp) - self.outerBox.addSpacing(2*(iPx + hSp)) self.outerBox.addWidget(self.theTitle, 1) if self.isEditor: self.outerBox.addWidget(self.minmaxButton, 0) @@ -315,11 +316,14 @@ class GuiDocTitleBar(QWidget): """Switch on or off zen mode. """ self.theParent.theParent.toggleZenMode() - self.closeButton.setVisible(not self.theParent.theParent.isZenMode) if self.theParent.theParent.isZenMode: self.minmaxButton.setIcon(self.theTheme.getIcon("minimise")) + self.setContentsMargins(self.buttonSize, 0, 0, 0) + self.closeButton.setVisible(False) else: self.minmaxButton.setIcon(self.theTheme.getIcon("maximise")) + self.setContentsMargins(2*self.buttonSize, 0, 0, 0) + self.closeButton.setVisible(True) return def _refreshDocument(self):