Update title on welcome dialog
This commit is contained in:
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.8 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.8 KiB |
@@ -110,6 +110,7 @@ class Config:
|
|||||||
|
|
||||||
# Size Settings
|
# Size Settings
|
||||||
self._mainWinSize = [1200, 650] # Last size of the main GUI window
|
self._mainWinSize = [1200, 650] # Last size of the main GUI window
|
||||||
|
self._welcomeSize = [800, 500] # Last size of the welcome window
|
||||||
self._prefsWinSize = [700, 615] # Last size of the Preferences dialog
|
self._prefsWinSize = [700, 615] # Last size of the Preferences dialog
|
||||||
self._projLoadCols = [280, 60, 160] # Last columns widths of the Project Load dialog
|
self._projLoadCols = [280, 60, 160] # Last columns widths of the Project Load dialog
|
||||||
self._mainPanePos = [300, 800] # Last position of the main window splitter
|
self._mainPanePos = [300, 800] # Last position of the main window splitter
|
||||||
@@ -249,6 +250,10 @@ class Config:
|
|||||||
def mainWinSize(self) -> list[int]:
|
def mainWinSize(self) -> list[int]:
|
||||||
return [int(x*self.guiScale) for x in self._mainWinSize]
|
return [int(x*self.guiScale) for x in self._mainWinSize]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def welcomeWinSize(self) -> list[int]:
|
||||||
|
return [int(x*self.guiScale) for x in self._welcomeSize]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preferencesWinSize(self) -> list[int]:
|
def preferencesWinSize(self) -> list[int]:
|
||||||
return [int(x*self.guiScale) for x in self._prefsWinSize]
|
return [int(x*self.guiScale) for x in self._prefsWinSize]
|
||||||
@@ -306,6 +311,12 @@ class Config:
|
|||||||
self._mainWinSize[1] = height
|
self._mainWinSize[1] = height
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def setWelcomeWinSize(self, width: int, height: int) -> None:
|
||||||
|
"""Set the size of the Preferences dialog window."""
|
||||||
|
self._welcomeSize[0] = int(width/self.guiScale)
|
||||||
|
self._welcomeSize[1] = int(height/self.guiScale)
|
||||||
|
return
|
||||||
|
|
||||||
def setPreferencesWinSize(self, width: int, height: int) -> None:
|
def setPreferencesWinSize(self, width: int, height: int) -> None:
|
||||||
"""Set the size of the Preferences dialog window."""
|
"""Set the size of the Preferences dialog window."""
|
||||||
self._prefsWinSize[0] = int(width/self.guiScale)
|
self._prefsWinSize[0] = int(width/self.guiScale)
|
||||||
@@ -545,6 +556,7 @@ class Config:
|
|||||||
# Sizes
|
# Sizes
|
||||||
sec = "Sizes"
|
sec = "Sizes"
|
||||||
self._mainWinSize = conf.rdIntList(sec, "mainwindow", self._mainWinSize)
|
self._mainWinSize = conf.rdIntList(sec, "mainwindow", self._mainWinSize)
|
||||||
|
self._welcomeSize = conf.rdIntList(sec, "welcome", self._welcomeSize)
|
||||||
self._prefsWinSize = conf.rdIntList(sec, "preferences", self._prefsWinSize)
|
self._prefsWinSize = conf.rdIntList(sec, "preferences", self._prefsWinSize)
|
||||||
self._projLoadCols = conf.rdIntList(sec, "projloadcols", self._projLoadCols)
|
self._projLoadCols = conf.rdIntList(sec, "projloadcols", self._projLoadCols)
|
||||||
self._mainPanePos = conf.rdIntList(sec, "mainpane", self._mainPanePos)
|
self._mainPanePos = conf.rdIntList(sec, "mainpane", self._mainPanePos)
|
||||||
@@ -652,6 +664,7 @@ class Config:
|
|||||||
|
|
||||||
conf["Sizes"] = {
|
conf["Sizes"] = {
|
||||||
"mainwindow": self._packList(self._mainWinSize),
|
"mainwindow": self._packList(self._mainWinSize),
|
||||||
|
"welcome": self._packList(self._welcomeSize),
|
||||||
"preferences": self._packList(self._prefsWinSize),
|
"preferences": self._packList(self._prefsWinSize),
|
||||||
"projloadcols": self._packList(self._projLoadCols),
|
"projloadcols": self._packList(self._projLoadCols),
|
||||||
"mainpane": self._packList(self._mainPanePos),
|
"mainpane": self._packList(self._mainPanePos),
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
NWEnum = TypeVar("NWEnum", bound=Enum)
|
NWEnum = TypeVar("NWEnum", bound=Enum)
|
||||||
|
|
||||||
VALID_MAP = {
|
VALID_MAP: dict[str, set[str]] = {
|
||||||
"GuiWritingStats": {
|
"GuiWritingStats": {
|
||||||
"winWidth", "winHeight", "widthCol0", "widthCol1", "widthCol2",
|
"winWidth", "winHeight", "widthCol0", "widthCol1", "widthCol2",
|
||||||
"widthCol3", "sortCol", "sortOrder", "incNovel", "incNotes",
|
"widthCol3", "sortCol", "sortOrder", "incNovel", "incNotes",
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class GuiTheme:
|
|||||||
self.themeLicense = ""
|
self.themeLicense = ""
|
||||||
self.themeLicenseUrl = ""
|
self.themeLicenseUrl = ""
|
||||||
self.themeIcons = ""
|
self.themeIcons = ""
|
||||||
|
self.isLightTheme = True
|
||||||
|
|
||||||
# GUI
|
# GUI
|
||||||
self.statNone = [120, 120, 120]
|
self.statNone = [120, 120, 120]
|
||||||
@@ -112,7 +113,7 @@ class GuiTheme:
|
|||||||
self._setGuiFont()
|
self._setGuiFont()
|
||||||
|
|
||||||
# Load Themes
|
# Load Themes
|
||||||
self._guiPalette = QPalette()
|
self._guiPalette = QPalette()
|
||||||
self._themeList: list[tuple[str, str]] = []
|
self._themeList: list[tuple[str, str]] = []
|
||||||
self._syntaxList: list[tuple[str, str]] = []
|
self._syntaxList: list[tuple[str, str]] = []
|
||||||
self._availThemes: dict[str, Path] = {}
|
self._availThemes: dict[str, Path] = {}
|
||||||
@@ -256,7 +257,8 @@ class GuiTheme:
|
|||||||
textLNess = textCol.lightnessF()
|
textLNess = textCol.lightnessF()
|
||||||
|
|
||||||
if self.helpText == [0, 0, 0]:
|
if self.helpText == [0, 0, 0]:
|
||||||
if backLNess > textLNess:
|
self.isLightTheme = backLNess > textLNess
|
||||||
|
if self.isLightTheme:
|
||||||
helpLCol = textLNess + 0.35*(backLNess - textLNess)
|
helpLCol = textLNess + 0.35*(backLNess - textLNess)
|
||||||
else:
|
else:
|
||||||
helpLCol = backLNess + 0.65*(textLNess - backLNess)
|
helpLCol = backLNess + 0.65*(textLNess - backLNess)
|
||||||
@@ -443,7 +445,7 @@ class GuiIcons:
|
|||||||
missing, a blank icon is returned and a warning issued.
|
missing, a blank icon is returned and a warning issued.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ICON_KEYS = {
|
ICON_KEYS: set[str] = {
|
||||||
# Project and GUI Icons
|
# Project and GUI Icons
|
||||||
"novelwriter", "alert_error", "alert_info", "alert_question", "alert_warn",
|
"novelwriter", "alert_error", "alert_info", "alert_question", "alert_warn",
|
||||||
"build_excluded", "build_filtered", "build_included", "proj_chapter", "proj_details",
|
"build_excluded", "build_filtered", "build_included", "proj_chapter", "proj_details",
|
||||||
@@ -478,13 +480,15 @@ class GuiIcons:
|
|||||||
"deco_doc_nt_n",
|
"deco_doc_nt_n",
|
||||||
}
|
}
|
||||||
|
|
||||||
TOGGLE_ICON_KEYS = {
|
TOGGLE_ICON_KEYS: dict[str, tuple[str, str]] = {
|
||||||
"sticky": ("sticky-on", "sticky-off"),
|
"sticky": ("sticky-on", "sticky-off"),
|
||||||
"bullet": ("bullet-on", "bullet-off"),
|
"bullet": ("bullet-on", "bullet-off"),
|
||||||
}
|
}
|
||||||
|
|
||||||
IMAGE_MAP = {
|
IMAGE_MAP: dict[str, tuple[str, str]] = {
|
||||||
"wiz-back": "wizard-back.jpg",
|
"wiz-back": ("wizard-back.jpg", "wizard-back.jpg"),
|
||||||
|
"welcome": ("welcome.jpg", "welcome.jpg"),
|
||||||
|
"nw-text": ("novelwriter-text-light.svg", "novelwriter-text-dark.svg"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, mainTheme: GuiTheme) -> None:
|
def __init__(self, mainTheme: GuiTheme) -> None:
|
||||||
@@ -598,7 +602,8 @@ class GuiIcons:
|
|||||||
if name in self._themeMap:
|
if name in self._themeMap:
|
||||||
imgPath = self._themeMap[name]
|
imgPath = self._themeMap[name]
|
||||||
elif name in self.IMAGE_MAP:
|
elif name in self.IMAGE_MAP:
|
||||||
imgPath = CONFIG.assetPath("images") / self.IMAGE_MAP[name]
|
idx = 0 if self.mainTheme.isLightTheme else 1
|
||||||
|
imgPath = CONFIG.assetPath("images") / self.IMAGE_MAP[name][idx]
|
||||||
else:
|
else:
|
||||||
logger.error("Decoration with name '%s' does not exist", name)
|
logger.error("Decoration with name '%s' does not exist", name)
|
||||||
return QPixmap()
|
return QPixmap()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import logging
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from PyQt5.QtGui import QPaintEvent, QPainter, QPixmap
|
from PyQt5.QtGui import QCloseEvent, QPaintEvent, QPainter
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QDialogButtonBox, QHBoxLayout, QLabel, QStackedWidget,
|
QDialog, QDialogButtonBox, QHBoxLayout, QLabel, QStackedWidget,
|
||||||
@@ -36,6 +36,7 @@ from PyQt5.QtWidgets import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG, SHARED, __version__, __date__
|
from novelwriter import CONFIG, SHARED, __version__, __date__
|
||||||
|
from novelwriter.constants import nwUnicode
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
if TYPE_CHECKING: # pragma: no cover
|
||||||
from novelwriter.guimain import GuiMain
|
from novelwriter.guimain import GuiMain
|
||||||
@@ -50,19 +51,30 @@ class GuiWelcome(QDialog):
|
|||||||
|
|
||||||
logger.debug("Create: GuiWelcome")
|
logger.debug("Create: GuiWelcome")
|
||||||
|
|
||||||
self.bgImage = QPixmap(str(CONFIG.assetPath("images") / "welcome.jpg"))
|
self.setWindowTitle(self.tr("Welcome"))
|
||||||
|
self.setMinimumWidth(CONFIG.pxInt(700))
|
||||||
|
self.setMinimumHeight(CONFIG.pxInt(400))
|
||||||
|
|
||||||
|
hA = CONFIG.pxInt(8)
|
||||||
|
hB = CONFIG.pxInt(16)
|
||||||
|
hC = CONFIG.pxInt(24)
|
||||||
|
hD = CONFIG.pxInt(36)
|
||||||
|
hE = CONFIG.pxInt(48)
|
||||||
|
hF = CONFIG.pxInt(96)
|
||||||
|
|
||||||
|
self.resize(*CONFIG.welcomeWinSize)
|
||||||
|
|
||||||
|
self.bgImage = SHARED.theme.loadDecoration("welcome")
|
||||||
|
self.nwImage = SHARED.theme.loadDecoration("nw-text", h=hD)
|
||||||
|
|
||||||
self.nwLogo = QLabel()
|
self.nwLogo = QLabel()
|
||||||
self.nwLogo.setPixmap(SHARED.theme.getPixmap("novelwriter", (96, 96)))
|
self.nwLogo.setPixmap(SHARED.theme.getPixmap("novelwriter", (hF, hF)))
|
||||||
|
|
||||||
font = self.font()
|
|
||||||
font.setPointSize(48)
|
|
||||||
|
|
||||||
self.nwLabel = QLabel("novelWriter")
|
self.nwLabel = QLabel("novelWriter")
|
||||||
self.nwLabel.setFont(font)
|
self.nwLabel.setPixmap(self.nwImage)
|
||||||
|
|
||||||
self.nwInfo = QLabel(self.tr("Version {0}, Released on {1}").format(
|
self.nwInfo = QLabel(self.tr("Version {0} {1} Released on {2}").format(
|
||||||
__version__, datetime.strptime(__date__, "%Y-%m-%d").strftime("%x")
|
__version__, nwUnicode.U_ENDASH, datetime.strptime(__date__, "%Y-%m-%d").strftime("%x")
|
||||||
))
|
))
|
||||||
|
|
||||||
self.mainStack = QStackedWidget()
|
self.mainStack = QStackedWidget()
|
||||||
@@ -71,6 +83,8 @@ class GuiWelcome(QDialog):
|
|||||||
# Buttons
|
# Buttons
|
||||||
# =======
|
# =======
|
||||||
self.btnBox = QDialogButtonBox(QDialogButtonBox.Open | QDialogButtonBox.Cancel, self)
|
self.btnBox = QDialogButtonBox(QDialogButtonBox.Open | QDialogButtonBox.Cancel, self)
|
||||||
|
self.btnBox.accepted.connect(self.accept)
|
||||||
|
self.btnBox.rejected.connect(self.close)
|
||||||
|
|
||||||
self.newButton = self.btnBox.addButton(self.tr("New Project"), QDialogButtonBox.ActionRole)
|
self.newButton = self.btnBox.addButton(self.tr("New Project"), QDialogButtonBox.ActionRole)
|
||||||
self.newButton.setIcon(SHARED.theme.getIcon("add"))
|
self.newButton.setIcon(SHARED.theme.getIcon("add"))
|
||||||
@@ -81,9 +95,12 @@ class GuiWelcome(QDialog):
|
|||||||
# Assemble
|
# Assemble
|
||||||
# ========
|
# ========
|
||||||
self.innerBox = QVBoxLayout()
|
self.innerBox = QVBoxLayout()
|
||||||
|
self.innerBox.addSpacing(hB)
|
||||||
self.innerBox.addWidget(self.nwLabel)
|
self.innerBox.addWidget(self.nwLabel)
|
||||||
self.innerBox.addWidget(self.nwInfo)
|
self.innerBox.addWidget(self.nwInfo)
|
||||||
|
self.innerBox.addSpacing(hA)
|
||||||
self.innerBox.addWidget(self.mainStack)
|
self.innerBox.addWidget(self.mainStack)
|
||||||
|
self.innerBox.addSpacing(hA)
|
||||||
self.innerBox.addWidget(self.btnBox)
|
self.innerBox.addWidget(self.btnBox)
|
||||||
|
|
||||||
topRight = Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignRight
|
topRight = Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignRight
|
||||||
@@ -91,12 +108,10 @@ class GuiWelcome(QDialog):
|
|||||||
self.outerBox = QHBoxLayout()
|
self.outerBox = QHBoxLayout()
|
||||||
self.outerBox.addWidget(self.nwLogo, 3, topRight)
|
self.outerBox.addWidget(self.nwLogo, 3, topRight)
|
||||||
self.outerBox.addLayout(self.innerBox, 7)
|
self.outerBox.addLayout(self.innerBox, 7)
|
||||||
self.outerBox.setContentsMargins(24, 24, 24, 96)
|
self.outerBox.setContentsMargins(hF, hE, hC, hE)
|
||||||
|
|
||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
self.setMinimumSize(900, 500)
|
|
||||||
|
|
||||||
logger.debug("Ready: GuiWelcome")
|
logger.debug("Ready: GuiWelcome")
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -119,6 +134,23 @@ class GuiWelcome(QDialog):
|
|||||||
super().paintEvent(event)
|
super().paintEvent(event)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
|
"""Capture the user closing the window and save settings."""
|
||||||
|
self._saveSettings()
|
||||||
|
event.accept()
|
||||||
|
self.deleteLater()
|
||||||
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Internal Functions
|
||||||
|
##
|
||||||
|
|
||||||
|
def _saveSettings(self) -> None:
|
||||||
|
"""Save the user GUI settings."""
|
||||||
|
logger.debug("Saving State: GuiWelcome")
|
||||||
|
CONFIG.setWelcomeWinSize(self.width(), self.height())
|
||||||
|
return
|
||||||
|
|
||||||
# END Class GuiWelcome
|
# END Class GuiWelcome
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user