Added the document tile buttons and icons

This commit is contained in:
Veronica K. B. Olsen
2020-06-08 00:24:23 +02:00
parent 36933de973
commit 2c337e5938
26 changed files with 1069 additions and 5 deletions
+52 -3
View File
@@ -29,7 +29,7 @@
import logging
import nw
from PyQt5.QtCore import Qt
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QPalette, QColor
from PyQt5.QtWidgets import (
qApp, QWidget, QFrame, QGridLayout, QLabel, QLineEdit, QPushButton,
@@ -170,7 +170,7 @@ class GuiSearchBar(QWidget):
class GuiDocTitleBar(QWidget):
def __init__(self, theParent, theProject):
def __init__(self, theParent, theProject, isEditor):
QWidget.__init__(self, theParent)
logger.debug("Initialising GuiDocTitleBar ...")
@@ -180,6 +180,7 @@ class GuiDocTitleBar(QWidget):
self.theProject = theProject
self.theTheme = theParent.theTheme
self.theHandle = None
self.isEditor = isEditor
# Make a QPalette that matches the Syntax Theme
self.thePalette = QPalette()
@@ -191,6 +192,7 @@ class GuiDocTitleBar(QWidget):
self.setAutoFillBackground(True)
self.setPalette(self.thePalette)
# Title Label
self.theTitle = QLabel()
self.theTitle.setText("")
self.theTitle.setIndent(0)
@@ -207,9 +209,45 @@ class GuiDocTitleBar(QWidget):
lblFont.setPointSizeF(0.9*self.theTheme.fontPointSize)
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)
self.closeButton.setIconSize(QSize(iPx, iPx))
self.closeButton.setFixedSize(iPx, iPx)
self.closeButton.setFlat(True)
self.closeButton.setVisible(False)
if self.isEditor:
self.minmaxButton = QPushButton("")
self.minmaxButton.setIcon(self.theTheme.getIcon("maximise"))
self.minmaxButton.setContentsMargins(0, 0, 0, 0)
self.minmaxButton.setIconSize(QSize(iPx, iPx))
self.minmaxButton.setFixedSize(iPx, iPx)
self.minmaxButton.setFlat(True)
self.minmaxButton.setVisible(False)
else:
self.refreshButton = QPushButton("")
self.refreshButton.setIcon(self.theTheme.getIcon("refresh"))
self.refreshButton.setContentsMargins(0, 0, 0, 0)
self.refreshButton.setIconSize(QSize(iPx, iPx))
self.refreshButton.setFixedSize(iPx, iPx)
self.refreshButton.setFlat(True)
self.refreshButton.setVisible(False)
# Assemble Layout
hSp = self.mainConf.pxInt(6)
self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.theTitle)
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)
else:
self.outerBox.addWidget(self.refreshButton, 0)
self.outerBox.addWidget(self.closeButton, 0)
self.setLayout(self.outerBox)
logger.debug("GuiDocTitleBar initialisation complete")
@@ -227,6 +265,11 @@ class GuiDocTitleBar(QWidget):
self.theTitle.setText("")
self.theHandle = tHandle
if tHandle is None:
self.closeButton.setVisible(False)
if self.isEditor:
self.minmaxButton.setVisible(False)
else:
self.refreshButton.setVisible(False)
return False
if self.mainConf.showFullPath:
@@ -244,6 +287,12 @@ class GuiDocTitleBar(QWidget):
return False
self.theTitle.setText(nwItem.itemName)
self.closeButton.setVisible(True)
if self.isEditor:
self.minmaxButton.setVisible(True)
else:
self.refreshButton.setVisible(True)
return True
##