Changed a bit how novelWriter icon and dialog decoration is loaded
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
+4
-3
@@ -58,15 +58,16 @@ class GuiAbout(QDialog):
|
|||||||
self.setMinimumWidth(self.mainConf.pxInt(650))
|
self.setMinimumWidth(self.mainConf.pxInt(650))
|
||||||
self.setMinimumHeight(self.mainConf.pxInt(600))
|
self.setMinimumHeight(self.mainConf.pxInt(600))
|
||||||
|
|
||||||
iPx = self.mainConf.pxInt(96)
|
nPx = self.mainConf.pxInt(96)
|
||||||
self.guiDeco = self.theParent.theTheme.loadDecoration("nwicon", (iPx, iPx))
|
self.nwIcon = QLabel()
|
||||||
|
self.nwIcon.setPixmap(self.theParent.theTheme.getPixmap("novelwriter", (nPx, nPx)))
|
||||||
self.lblName = QLabel("<b>%s</b>" % nw.__package__)
|
self.lblName = QLabel("<b>%s</b>" % nw.__package__)
|
||||||
self.lblVers = QLabel("v%s" % nw.__version__)
|
self.lblVers = QLabel("v%s" % nw.__version__)
|
||||||
self.lblDate = QLabel(datetime.strptime(nw.__date__, "%Y-%m-%d").strftime("%x"))
|
self.lblDate = QLabel(datetime.strptime(nw.__date__, "%Y-%m-%d").strftime("%x"))
|
||||||
|
|
||||||
self.leftBox = QVBoxLayout()
|
self.leftBox = QVBoxLayout()
|
||||||
self.leftBox.setSpacing(self.mainConf.pxInt(4))
|
self.leftBox.setSpacing(self.mainConf.pxInt(4))
|
||||||
self.leftBox.addWidget(self.guiDeco, 0, Qt.AlignCenter)
|
self.leftBox.addWidget(self.nwIcon, 0, Qt.AlignCenter)
|
||||||
self.leftBox.addWidget(self.lblName, 0, Qt.AlignCenter)
|
self.leftBox.addWidget(self.lblName, 0, Qt.AlignCenter)
|
||||||
self.leftBox.addWidget(self.lblVers, 0, Qt.AlignCenter)
|
self.leftBox.addWidget(self.lblVers, 0, Qt.AlignCenter)
|
||||||
self.leftBox.addWidget(self.lblDate, 0, Qt.AlignCenter)
|
self.leftBox.addWidget(self.lblDate, 0, Qt.AlignCenter)
|
||||||
|
|||||||
+3
-2
@@ -79,8 +79,9 @@ class GuiProjectLoad(QDialog):
|
|||||||
self.setMinimumHeight(self.mainConf.pxInt(400))
|
self.setMinimumHeight(self.mainConf.pxInt(400))
|
||||||
self.setModal(True)
|
self.setModal(True)
|
||||||
|
|
||||||
self.guiDeco = self.theTheme.loadDecoration("nwicon", (nPx, nPx))
|
self.nwIcon = QLabel()
|
||||||
self.innerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
|
self.nwIcon.setPixmap(self.theParent.theTheme.getPixmap("novelwriter", (nPx, nPx)))
|
||||||
|
self.innerBox.addWidget(self.nwIcon, 0, Qt.AlignTop)
|
||||||
|
|
||||||
self.projectForm = QGridLayout()
|
self.projectForm = QGridLayout()
|
||||||
self.projectForm.setContentsMargins(0, 0, 0, 0)
|
self.projectForm.setContentsMargins(0, 0, 0, 0)
|
||||||
|
|||||||
+11
-10
@@ -33,7 +33,7 @@ from os import path
|
|||||||
from PyQt5.QtGui import QPixmap, QColor
|
from PyQt5.QtGui import QPixmap, QColor
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QWizard, QWizardPage, QLabel, QVBoxLayout, QLineEdit, QPlainTextEdit,
|
QWizard, QWizardPage, QLabel, QVBoxLayout, QLineEdit, QPlainTextEdit,
|
||||||
QPushButton, QFileDialog, QHBoxLayout
|
QPushButton, QFileDialog, QHBoxLayout, QLayout
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.common import makeFileNameSafe
|
from nw.common import makeFileNameSafe
|
||||||
@@ -52,14 +52,10 @@ class GuiProjectWizard(QWizard):
|
|||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
self.theTheme = theParent.theTheme
|
self.theTheme = theParent.theTheme
|
||||||
|
|
||||||
nPx = self.mainConf.pxInt(96)
|
self.sideImage = self.theTheme.loadDecoration(
|
||||||
wmW = self.mainConf.pxInt(100)
|
"wiz-back", None, self.mainConf.pxInt(370)
|
||||||
wmH = self.mainConf.pxInt(340)
|
)
|
||||||
|
self.setWizardStyle(QWizard.ModernStyle)
|
||||||
self.sideImage = QPixmap(wmW, wmH)
|
|
||||||
self.sideImage.fill(self.palette().dark().color())
|
|
||||||
|
|
||||||
# self.setWizardStyle(QWizard.ModernStyle)
|
|
||||||
self.setPixmap(QWizard.WatermarkPixmap, self.sideImage)
|
self.setPixmap(QWizard.WatermarkPixmap, self.sideImage)
|
||||||
|
|
||||||
self.introPage = ProjWizardIntroPage(self.theParent)
|
self.introPage = ProjWizardIntroPage(self.theParent)
|
||||||
@@ -69,7 +65,6 @@ class GuiProjectWizard(QWizard):
|
|||||||
self.addPage(self.storagePage)
|
self.addPage(self.storagePage)
|
||||||
|
|
||||||
self.setOption(QWizard.NoBackButtonOnStartPage, True)
|
self.setOption(QWizard.NoBackButtonOnStartPage, True)
|
||||||
# self.setOption(QWizard.ExtendedWatermarkPixmap, True)
|
|
||||||
|
|
||||||
logger.debug("GuiProjectWizard initialisation complete")
|
logger.debug("GuiProjectWizard initialisation complete")
|
||||||
|
|
||||||
@@ -95,6 +90,11 @@ class ProjWizardIntroPage(QWizardPage):
|
|||||||
)
|
)
|
||||||
self.theText.setWordWrap(True)
|
self.theText.setWordWrap(True)
|
||||||
|
|
||||||
|
self.imgCredit = QLabel("Side image by Peter Mitterhofer, CC BY-SA 4.0")
|
||||||
|
lblFont = self.imgCredit.font()
|
||||||
|
lblFont.setPointSizeF(0.6*self.theTheme.fontPointSize)
|
||||||
|
self.imgCredit.setFont(lblFont)
|
||||||
|
|
||||||
xW = self.mainConf.pxInt(300)
|
xW = self.mainConf.pxInt(300)
|
||||||
xH = self.mainConf.pxInt(100)
|
xH = self.mainConf.pxInt(100)
|
||||||
vS = self.mainConf.pxInt(12)
|
vS = self.mainConf.pxInt(12)
|
||||||
@@ -132,6 +132,7 @@ class ProjWizardIntroPage(QWizardPage):
|
|||||||
self.outerBox.addWidget(self.theText)
|
self.outerBox.addWidget(self.theText)
|
||||||
self.outerBox.addLayout(self.mainForm)
|
self.outerBox.addLayout(self.mainForm)
|
||||||
self.outerBox.addStretch(1)
|
self.outerBox.addStretch(1)
|
||||||
|
self.outerBox.addWidget(self.imgCredit)
|
||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
+22
-14
@@ -33,7 +33,7 @@ import nw
|
|||||||
from os import path, listdir
|
from os import path, listdir
|
||||||
from math import ceil
|
from math import ceil
|
||||||
|
|
||||||
from PyQt5.QtCore import QSize
|
from PyQt5.QtCore import Qt, QSize
|
||||||
from PyQt5.QtSvg import QSvgWidget
|
from PyQt5.QtSvg import QSvgWidget
|
||||||
from PyQt5.QtWidgets import QStyle, qApp
|
from PyQt5.QtWidgets import QStyle, qApp
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import (
|
||||||
@@ -497,6 +497,7 @@ class GuiIcons:
|
|||||||
|
|
||||||
ICON_MAP = {
|
ICON_MAP = {
|
||||||
# Project and GUI icons
|
# Project and GUI icons
|
||||||
|
"novelwriter" : (None, None),
|
||||||
"cls_none" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
|
"cls_none" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
|
||||||
"cls_novel" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
|
"cls_novel" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
|
||||||
"cls_plot" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
|
"cls_plot" : (QStyle.SP_DriveHDIcon, "drive-harddisk"),
|
||||||
@@ -552,7 +553,7 @@ class GuiIcons:
|
|||||||
}
|
}
|
||||||
|
|
||||||
DECO_MAP = {
|
DECO_MAP = {
|
||||||
"nwicon" : ["icons", "novelwriter.svg"],
|
"wiz-back" : "wizard-back.jpg",
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, theParent):
|
def __init__(self, theParent):
|
||||||
@@ -645,7 +646,7 @@ class GuiIcons:
|
|||||||
# Access Functions
|
# Access Functions
|
||||||
##
|
##
|
||||||
|
|
||||||
def loadDecoration(self, decoKey, decoSize=None):
|
def loadDecoration(self, decoKey, pxW, pxH):
|
||||||
"""Load graphical decoration element based on the decoration
|
"""Load graphical decoration element based on the decoration
|
||||||
map. This function always returns a QSwgWidget.
|
map. This function always returns a QSwgWidget.
|
||||||
"""
|
"""
|
||||||
@@ -653,20 +654,22 @@ class GuiIcons:
|
|||||||
logger.error("Decoration with name '%s' does not exist" % decoKey)
|
logger.error("Decoration with name '%s' does not exist" % decoKey)
|
||||||
return QSvgWidget()
|
return QSvgWidget()
|
||||||
|
|
||||||
svgPath = path.join(
|
imgPath = path.join(
|
||||||
self.mainConf.assetPath,
|
self.mainConf.assetPath, "images", self.DECO_MAP[decoKey]
|
||||||
self.DECO_MAP[decoKey][0],
|
|
||||||
self.DECO_MAP[decoKey][1]
|
|
||||||
)
|
)
|
||||||
if not path.isfile(svgPath):
|
if not path.isfile(imgPath):
|
||||||
logger.error("Decoration file '%s' not in assets folder" % self.DECO_MAP[decoKey])
|
logger.error("Decoration file '%s' not in assets folder" % self.DECO_MAP[decoKey])
|
||||||
return QSvgWidget()
|
return QPixmap()
|
||||||
|
|
||||||
svgDeco = QSvgWidget(svgPath)
|
theDeco = QPixmap(imgPath)
|
||||||
if decoSize is not None:
|
if pxW is not None and pxH is not None:
|
||||||
svgDeco.setFixedSize(QSize(decoSize[0],decoSize[1]))
|
return theDeco.scaled(pxW, pxH, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
|
||||||
|
elif pxW is None and pxH is not None:
|
||||||
|
return theDeco.scaledToHeight(pxH, Qt.SmoothTransformation)
|
||||||
|
elif pxW is not None and pxH is None:
|
||||||
|
return theDeco.scaledToWidth(pxW, Qt.SmoothTransformation)
|
||||||
|
|
||||||
return svgDeco
|
return theDeco
|
||||||
|
|
||||||
def getIcon(self, iconKey, iconSize=None):
|
def getIcon(self, iconKey, iconSize=None):
|
||||||
"""Return an icon from the icon buffer. If it doesn't exist,
|
"""Return an icon from the icon buffer. If it doesn't exist,
|
||||||
@@ -730,11 +733,16 @@ class GuiIcons:
|
|||||||
an icon exists. Prefer svg files over png files. Always returns
|
an icon exists. Prefer svg files over png files. Always returns
|
||||||
a QIcon.
|
a QIcon.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if iconKey not in self.ICON_MAP:
|
if iconKey not in self.ICON_MAP:
|
||||||
logger.error("Requested unknown icon name '%s'" % iconKey)
|
logger.error("Requested unknown icon name '%s'" % iconKey)
|
||||||
return QIcon()
|
return QIcon()
|
||||||
|
|
||||||
|
# If we just want the app icon, return it right away
|
||||||
|
if iconKey == "novelwriter":
|
||||||
|
return QIcon(path.join(self.mainConf.iconPath, "novelwriter.svg"))
|
||||||
|
|
||||||
|
# Otherwise, we start looking for it
|
||||||
|
# First in the theme folder
|
||||||
if iconKey in self.themeMap:
|
if iconKey in self.themeMap:
|
||||||
logger.verbose("Loading: %s" % path.relpath(self.themeMap[iconKey]))
|
logger.verbose("Loading: %s" % path.relpath(self.themeMap[iconKey]))
|
||||||
return QIcon(self.themeMap[iconKey])
|
return QIcon(self.themeMap[iconKey])
|
||||||
|
|||||||
Reference in New Issue
Block a user