From 2c337e593838ab43f7002f2d5d9f7efc1cdaca52 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Mon, 8 Jun 2020 00:24:23 +0200 Subject: [PATCH] Added the document tile buttons and icons --- nw/assets/icons/fallback/maximise-dark.svg | 56 +++++++++++++++++++ nw/assets/icons/fallback/maximise.svg | 56 +++++++++++++++++++ nw/assets/icons/fallback/minimise-dark.svg | 55 ++++++++++++++++++ nw/assets/icons/fallback/minimise.svg | 55 ++++++++++++++++++ nw/assets/icons/fallback/refresh-dark.svg | 56 +++++++++++++++++++ nw/assets/icons/fallback/refresh.svg | 56 +++++++++++++++++++ .../typicons_colour_dark/arrow-maximise.svg | 55 ++++++++++++++++++ .../typicons_colour_dark/arrow-minimise.svg | 55 ++++++++++++++++++ .../icons/typicons_colour_dark/icons.conf | 3 + .../icons/typicons_colour_dark/refresh.svg | 55 ++++++++++++++++++ .../typicons_colour_light/arrow-maximise.svg | 56 +++++++++++++++++++ .../typicons_colour_light/arrow-minimise.svg | 55 ++++++++++++++++++ .../icons/typicons_colour_light/icons.conf | 3 + .../icons/typicons_colour_light/refresh.svg | 56 +++++++++++++++++++ .../typicons_grey_dark/arrow-maximise.svg | 56 +++++++++++++++++++ .../typicons_grey_dark/arrow-minimise.svg | 55 ++++++++++++++++++ nw/assets/icons/typicons_grey_dark/icons.conf | 3 + .../icons/typicons_grey_dark/refresh.svg | 56 +++++++++++++++++++ .../typicons_grey_light/arrow-maximise.svg | 56 +++++++++++++++++++ .../typicons_grey_light/arrow-minimise.svg | 55 ++++++++++++++++++ .../icons/typicons_grey_light/icons.conf | 3 + .../icons/typicons_grey_light/refresh.svg | 56 +++++++++++++++++++ nw/gui/docbars.py | 55 +++++++++++++++++- nw/gui/doceditor.py | 2 +- nw/gui/docviewer.py | 2 +- nw/gui/theme.py | 3 + 26 files changed, 1069 insertions(+), 5 deletions(-) create mode 100644 nw/assets/icons/fallback/maximise-dark.svg create mode 100644 nw/assets/icons/fallback/maximise.svg create mode 100644 nw/assets/icons/fallback/minimise-dark.svg create mode 100644 nw/assets/icons/fallback/minimise.svg create mode 100644 nw/assets/icons/fallback/refresh-dark.svg create mode 100644 nw/assets/icons/fallback/refresh.svg create mode 100644 nw/assets/icons/typicons_colour_dark/arrow-maximise.svg create mode 100644 nw/assets/icons/typicons_colour_dark/arrow-minimise.svg create mode 100644 nw/assets/icons/typicons_colour_dark/refresh.svg create mode 100644 nw/assets/icons/typicons_colour_light/arrow-maximise.svg create mode 100644 nw/assets/icons/typicons_colour_light/arrow-minimise.svg create mode 100644 nw/assets/icons/typicons_colour_light/refresh.svg create mode 100644 nw/assets/icons/typicons_grey_dark/arrow-maximise.svg create mode 100644 nw/assets/icons/typicons_grey_dark/arrow-minimise.svg create mode 100644 nw/assets/icons/typicons_grey_dark/refresh.svg create mode 100644 nw/assets/icons/typicons_grey_light/arrow-maximise.svg create mode 100644 nw/assets/icons/typicons_grey_light/arrow-minimise.svg create mode 100644 nw/assets/icons/typicons_grey_light/refresh.svg diff --git a/nw/assets/icons/fallback/maximise-dark.svg b/nw/assets/icons/fallback/maximise-dark.svg new file mode 100644 index 00000000..1ce767a3 --- /dev/null +++ b/nw/assets/icons/fallback/maximise-dark.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/fallback/maximise.svg b/nw/assets/icons/fallback/maximise.svg new file mode 100644 index 00000000..0e1d4a86 --- /dev/null +++ b/nw/assets/icons/fallback/maximise.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/fallback/minimise-dark.svg b/nw/assets/icons/fallback/minimise-dark.svg new file mode 100644 index 00000000..4bc48ce2 --- /dev/null +++ b/nw/assets/icons/fallback/minimise-dark.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/fallback/minimise.svg b/nw/assets/icons/fallback/minimise.svg new file mode 100644 index 00000000..b0a1972f --- /dev/null +++ b/nw/assets/icons/fallback/minimise.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/fallback/refresh-dark.svg b/nw/assets/icons/fallback/refresh-dark.svg new file mode 100644 index 00000000..31367a18 --- /dev/null +++ b/nw/assets/icons/fallback/refresh-dark.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/fallback/refresh.svg b/nw/assets/icons/fallback/refresh.svg new file mode 100644 index 00000000..c87d3257 --- /dev/null +++ b/nw/assets/icons/fallback/refresh.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_colour_dark/arrow-maximise.svg b/nw/assets/icons/typicons_colour_dark/arrow-maximise.svg new file mode 100644 index 00000000..a5ee7fa0 --- /dev/null +++ b/nw/assets/icons/typicons_colour_dark/arrow-maximise.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_colour_dark/arrow-minimise.svg b/nw/assets/icons/typicons_colour_dark/arrow-minimise.svg new file mode 100644 index 00000000..83d5a066 --- /dev/null +++ b/nw/assets/icons/typicons_colour_dark/arrow-minimise.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_colour_dark/icons.conf b/nw/assets/icons/typicons_colour_dark/icons.conf index b0e75498..cffe7329 100644 --- a/nw/assets/icons/typicons_colour_dark/icons.conf +++ b/nw/assets/icons/typicons_colour_dark/icons.conf @@ -32,6 +32,9 @@ delete = delete.svg add = plus.svg remove = minus.svg close = times.svg +refresh = refresh.svg +maximise = arrow-maximise.svg +minimise = arrow-minimise.svg done = input-checked.svg search = search.svg search-replace = search-replace.svg diff --git a/nw/assets/icons/typicons_colour_dark/refresh.svg b/nw/assets/icons/typicons_colour_dark/refresh.svg new file mode 100644 index 00000000..f1853eb3 --- /dev/null +++ b/nw/assets/icons/typicons_colour_dark/refresh.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_colour_light/arrow-maximise.svg b/nw/assets/icons/typicons_colour_light/arrow-maximise.svg new file mode 100644 index 00000000..3ef012fe --- /dev/null +++ b/nw/assets/icons/typicons_colour_light/arrow-maximise.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_colour_light/arrow-minimise.svg b/nw/assets/icons/typicons_colour_light/arrow-minimise.svg new file mode 100644 index 00000000..0d9f7d13 --- /dev/null +++ b/nw/assets/icons/typicons_colour_light/arrow-minimise.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_colour_light/icons.conf b/nw/assets/icons/typicons_colour_light/icons.conf index 70477f64..ac281962 100644 --- a/nw/assets/icons/typicons_colour_light/icons.conf +++ b/nw/assets/icons/typicons_colour_light/icons.conf @@ -32,6 +32,9 @@ delete = delete.svg add = plus.svg remove = minus.svg close = times.svg +refresh = refresh.svg +maximise = arrow-maximise.svg +minimise = arrow-minimise.svg done = input-checked.svg search = search.svg search-replace = search-replace.svg diff --git a/nw/assets/icons/typicons_colour_light/refresh.svg b/nw/assets/icons/typicons_colour_light/refresh.svg new file mode 100644 index 00000000..d1d9513b --- /dev/null +++ b/nw/assets/icons/typicons_colour_light/refresh.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_grey_dark/arrow-maximise.svg b/nw/assets/icons/typicons_grey_dark/arrow-maximise.svg new file mode 100644 index 00000000..1ce767a3 --- /dev/null +++ b/nw/assets/icons/typicons_grey_dark/arrow-maximise.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_grey_dark/arrow-minimise.svg b/nw/assets/icons/typicons_grey_dark/arrow-minimise.svg new file mode 100644 index 00000000..4bc48ce2 --- /dev/null +++ b/nw/assets/icons/typicons_grey_dark/arrow-minimise.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_grey_dark/icons.conf b/nw/assets/icons/typicons_grey_dark/icons.conf index d06201b1..d03bec4d 100644 --- a/nw/assets/icons/typicons_grey_dark/icons.conf +++ b/nw/assets/icons/typicons_grey_dark/icons.conf @@ -32,6 +32,9 @@ delete = delete.svg add = plus.svg remove = minus.svg close = times.svg +refresh = refresh.svg +maximise = arrow-maximise.svg +minimise = arrow-minimise.svg done = input-checked.svg search = search.svg search-replace = search-replace.svg diff --git a/nw/assets/icons/typicons_grey_dark/refresh.svg b/nw/assets/icons/typicons_grey_dark/refresh.svg new file mode 100644 index 00000000..31367a18 --- /dev/null +++ b/nw/assets/icons/typicons_grey_dark/refresh.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_grey_light/arrow-maximise.svg b/nw/assets/icons/typicons_grey_light/arrow-maximise.svg new file mode 100644 index 00000000..0e1d4a86 --- /dev/null +++ b/nw/assets/icons/typicons_grey_light/arrow-maximise.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_grey_light/arrow-minimise.svg b/nw/assets/icons/typicons_grey_light/arrow-minimise.svg new file mode 100644 index 00000000..b0a1972f --- /dev/null +++ b/nw/assets/icons/typicons_grey_light/arrow-minimise.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_grey_light/icons.conf b/nw/assets/icons/typicons_grey_light/icons.conf index dd97c4c8..9f04ee61 100644 --- a/nw/assets/icons/typicons_grey_light/icons.conf +++ b/nw/assets/icons/typicons_grey_light/icons.conf @@ -32,6 +32,9 @@ delete = delete.svg add = plus.svg remove = minus.svg close = times.svg +refresh = refresh.svg +maximise = arrow-maximise.svg +minimise = arrow-minimise.svg done = input-checked.svg search = search.svg search-replace = search-replace.svg diff --git a/nw/assets/icons/typicons_grey_light/refresh.svg b/nw/assets/icons/typicons_grey_light/refresh.svg new file mode 100644 index 00000000..c87d3257 --- /dev/null +++ b/nw/assets/icons/typicons_grey_light/refresh.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/gui/docbars.py b/nw/gui/docbars.py index 546de674..1c8ad270 100644 --- a/nw/gui/docbars.py +++ b/nw/gui/docbars.py @@ -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 ## diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 97ef5c94..e523c6f7 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -85,7 +85,7 @@ class GuiDocEditor(QTextEdit): self.qDocument.contentsChange.connect(self._docChange) # Document Title - self.docTitle = GuiDocTitleBar(self, self.theProject) + self.docTitle = GuiDocTitleBar(self, self.theProject, isEditor=True) self.docTitle.setGeometry(0, 0, self.docTitle.width(), self.docTitle.height()) self.setViewportMargins(0, self.docTitle.height(), 0, 0) diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index a3d6eeda..3c4f86b9 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -58,7 +58,7 @@ class GuiDocViewer(QTextBrowser): self.initViewer() # Document Title - self.docTitle = GuiDocTitleBar(self, self.theProject) + self.docTitle = GuiDocTitleBar(self, self.theProject, isEditor=False) self.docTitle.setGeometry(0, 0, self.docTitle.width(), self.docTitle.height()) self.setViewportMargins(0, self.docTitle.height(), 0, 0) diff --git a/nw/gui/theme.py b/nw/gui/theme.py index 2f5a896f..8288e1fa 100644 --- a/nw/gui/theme.py +++ b/nw/gui/theme.py @@ -525,6 +525,9 @@ class GuiIcons: "check" : (None, None), "cross" : (None, None), "hash" : (None, None), + "maximise" : (None, None), + "minimise" : (None, None), + "refresh" : (None, None), ## Other Icons "warning" : (QStyle.SP_MessageBoxWarning, "dialog-warning"),