Update welcome dialog (#1689)

This commit is contained in:
Veronica Berglyd Olsen
2024-02-10 18:39:36 +01:00
committed by GitHub
12 changed files with 65 additions and 50 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 KiB

After

Width:  |  Height:  |  Size: 292 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 273 KiB

+1 -1
View File
@@ -110,7 +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._welcomeSize = [800, 550] # 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._mainPanePos = [300, 800] # Last position of the main window splitter self._mainPanePos = [300, 800] # Last position of the main window splitter
self._viewPanePos = [500, 150] # Last position of the document viewer splitter self._viewPanePos = [500, 150] # Last position of the document viewer splitter
+1 -1
View File
@@ -74,7 +74,7 @@ class GuiDocMerge(QDialog):
# Merge Options # Merge Options
self.trashLabel = QLabel(self.tr("Move merged items to Trash")) self.trashLabel = QLabel(self.tr("Move merged items to Trash"))
self.trashSwitch = NSwitch(width=2*iPx, height=iPx) self.trashSwitch = NSwitch(self, height=iPx)
self.optBox = QGridLayout() self.optBox = QGridLayout()
self.optBox.addWidget(self.trashLabel, 0, 0) self.optBox.addWidget(self.trashLabel, 0, 0)
+3 -3
View File
@@ -92,15 +92,15 @@ class GuiDocSplit(QDialog):
# Split Options # Split Options
self.folderLabel = QLabel(self.tr("Split into a new folder")) self.folderLabel = QLabel(self.tr("Split into a new folder"))
self.folderSwitch = NSwitch(width=2*iPx, height=iPx) self.folderSwitch = NSwitch(self, height=iPx)
self.folderSwitch.setChecked(intoFolder) self.folderSwitch.setChecked(intoFolder)
self.hierarchyLabel = QLabel(self.tr("Create document hierarchy")) self.hierarchyLabel = QLabel(self.tr("Create document hierarchy"))
self.hierarchySwitch = NSwitch(width=2*iPx, height=iPx) self.hierarchySwitch = NSwitch(self, height=iPx)
self.hierarchySwitch.setChecked(docHierarchy) self.hierarchySwitch.setChecked(docHierarchy)
self.trashLabel = QLabel(self.tr("Move split document to Trash")) self.trashLabel = QLabel(self.tr("Move split document to Trash"))
self.trashSwitch = NSwitch(width=2*iPx, height=iPx) self.trashSwitch = NSwitch(self, height=iPx)
self.optBox = QGridLayout() self.optBox = QGridLayout()
self.optBox.addWidget(self.folderLabel, 0, 0) self.optBox.addWidget(self.folderLabel, 0, 0)
+3 -3
View File
@@ -34,11 +34,11 @@ class NSwitch(QAbstractButton):
__slots__ = ("_xW", "_xH", "_xR", "_rB", "_rH", "_rR", "_offset") __slots__ = ("_xW", "_xH", "_xR", "_rB", "_rH", "_rR", "_offset")
def __init__(self, parent: QWidget | None = None, width: int = 0, height: int = 0) -> None: def __init__(self, parent: QWidget | None = None, height: int = 0) -> None:
super().__init__(parent=parent) super().__init__(parent=parent)
self._xW = width or CONFIG.pxInt(40)
self._xH = height or CONFIG.pxInt(20) self._xH = height or CONFIG.pxInt(20)
self._xW = 2*self._xH
self._xR = int(self._xH*0.5) self._xR = int(self._xH*0.5)
self._rB = int(CONFIG.guiScale*2) self._rB = int(CONFIG.guiScale*2)
self._rH = self._xH - 2*self._rB self._rH = self._xH - 2*self._rB
@@ -61,7 +61,7 @@ class NSwitch(QAbstractButton):
return self._offset return self._offset
@offset.setter # type: ignore @offset.setter # type: ignore
def offset(self, offset: int): def offset(self, offset: int) -> None:
self._offset = offset self._offset = offset
self.update() self.update()
return return
+1 -1
View File
@@ -87,7 +87,7 @@ class NSwitchBox(QScrollArea):
label = QLabel(text) label = QLabel(text)
self._content.addWidget(label, self._index, 1, Qt.AlignLeft) self._content.addWidget(label, self._index, 1, Qt.AlignLeft)
switch = NSwitch(width=self._wSwitch, height=self._hSwitch) switch = NSwitch(self, height=self._hSwitch)
switch.setChecked(default) switch.setChecked(default)
switch.toggled.connect(lambda state: self._emitSwitchSignal(identifier, state)) switch.toggled.connect(lambda state: self._emitSwitchSignal(identifier, state))
self._content.addWidget(switch, self._index, 2, Qt.AlignRight) self._content.addWidget(switch, self._index, 2, Qt.AlignRight)
+12 -12
View File
@@ -659,7 +659,7 @@ class _HeadingsTab(NScrollablePage):
self.btnScene.clicked.connect(lambda: self._editHeading(self.EDIT_SCENE)) self.btnScene.clicked.connect(lambda: self._editHeading(self.EDIT_SCENE))
self.hdeScene = QLabel(self.tr("Hide")) self.hdeScene = QLabel(self.tr("Hide"))
self.hdeScene.setToolTip(sceneHideTip) self.hdeScene.setToolTip(sceneHideTip)
self.swtScene = NSwitch(self, width=2*iPx, height=iPx) self.swtScene = NSwitch(self, height=iPx)
self.swtScene.setToolTip(sceneHideTip) self.swtScene.setToolTip(sceneHideTip)
wrapScene = QHBoxLayout() wrapScene = QHBoxLayout()
@@ -686,7 +686,7 @@ class _HeadingsTab(NScrollablePage):
self.btnSection.clicked.connect(lambda: self._editHeading(self.EDIT_SECTION)) self.btnSection.clicked.connect(lambda: self._editHeading(self.EDIT_SECTION))
self.hdeSection = QLabel(self.tr("Hide")) self.hdeSection = QLabel(self.tr("Hide"))
self.hdeSection.setToolTip(sectionHideTip) self.hdeSection.setToolTip(sectionHideTip)
self.swtSection = NSwitch(self, width=2*iPx, height=iPx) self.swtSection = NSwitch(self, height=iPx)
self.swtSection.setToolTip(sectionHideTip) self.swtSection.setToolTip(sectionHideTip)
wrapSection = QHBoxLayout() wrapSection = QHBoxLayout()
@@ -894,10 +894,10 @@ class _ContentTab(NScrollableForm):
iPx = SHARED.theme.baseIconSize iPx = SHARED.theme.baseIconSize
# Text Content # Text Content
self.incSynopsis = NSwitch(self, width=2*iPx, height=iPx) self.incSynopsis = NSwitch(self, height=iPx)
self.incComments = NSwitch(self, width=2*iPx, height=iPx) self.incComments = NSwitch(self, height=iPx)
self.incKeywords = NSwitch(self, width=2*iPx, height=iPx) self.incKeywords = NSwitch(self, height=iPx)
self.incBodyText = NSwitch(self, width=2*iPx, height=iPx) self.incBodyText = NSwitch(self, height=iPx)
self.addGroupLabel(self._build.getLabel("text.grpContent")) self.addGroupLabel(self._build.getLabel("text.grpContent"))
self.addRow(self._build.getLabel("text.includeSynopsis"), self.incSynopsis) self.addRow(self._build.getLabel("text.includeSynopsis"), self.incSynopsis)
@@ -906,7 +906,7 @@ class _ContentTab(NScrollableForm):
self.addRow(self._build.getLabel("text.includeBodyText"), self.incBodyText) self.addRow(self._build.getLabel("text.includeBodyText"), self.incBodyText)
# Insert Content # Insert Content
self.addNoteHead = NSwitch(self, width=2*iPx, height=iPx) self.addNoteHead = NSwitch(self, height=iPx)
self.addGroupLabel(self._build.getLabel("text.grpInsert")) self.addGroupLabel(self._build.getLabel("text.grpInsert"))
self.addRow(self._build.getLabel("text.addNoteHeadings"), self.addNoteHead) self.addRow(self._build.getLabel("text.addNoteHeadings"), self.addNoteHead)
@@ -989,9 +989,9 @@ class _FormatTab(NScrollableForm):
self.addGroupLabel(self._build.getLabel("format.grpOptions")) self.addGroupLabel(self._build.getLabel("format.grpOptions"))
self.justifyText = NSwitch(self, width=2*iPx, height=iPx) self.justifyText = NSwitch(self, height=iPx)
self.stripUnicode = NSwitch(self, width=2*iPx, height=iPx) self.stripUnicode = NSwitch(self, height=iPx)
self.replaceTabs = NSwitch(self, width=2*iPx, height=iPx) self.replaceTabs = NSwitch(self, height=iPx)
self.addRow(self._build.getLabel("format.justifyText"), self.justifyText) self.addRow(self._build.getLabel("format.justifyText"), self.justifyText)
self.addRow(self._build.getLabel("format.stripUnicode"), self.stripUnicode) self.addRow(self._build.getLabel("format.stripUnicode"), self.stripUnicode)
@@ -1219,7 +1219,7 @@ class _OutputTab(NScrollableForm):
# Open Document # Open Document
self.addGroupLabel(self._build.getLabel("odt")) self.addGroupLabel(self._build.getLabel("odt"))
self.odtAddColours = NSwitch(self, width=2*iPx, height=iPx) self.odtAddColours = NSwitch(self, height=iPx)
self.addRow(self._build.getLabel("odt.addColours"), self.odtAddColours) self.addRow(self._build.getLabel("odt.addColours"), self.odtAddColours)
self.odtPageHeader = QLineEdit(self) self.odtPageHeader = QLineEdit(self)
@@ -1242,7 +1242,7 @@ class _OutputTab(NScrollableForm):
# HTML Document # HTML Document
self.addGroupLabel(self._build.getLabel("html")) self.addGroupLabel(self._build.getLabel("html"))
self.htmlAddStyles = NSwitch(self, width=2*iPx, height=iPx) self.htmlAddStyles = NSwitch(self, height=iPx)
self.addRow(self._build.getLabel("html.addStyles"), self.htmlAddStyles) self.addRow(self._build.getLabel("html.addStyles"), self.htmlAddStyles)
# Finalise # Finalise
+1 -1
View File
@@ -384,7 +384,7 @@ class _ContentsPage(NFixedPage):
self.dblLabel = QLabel(self.tr("Chapters on odd pages")) self.dblLabel = QLabel(self.tr("Chapters on odd pages"))
self.dblValue = NSwitch(self, 2*iPx, iPx) self.dblValue = NSwitch(self, height=iPx)
self.dblValue.setChecked(clearDouble) self.dblValue.setChecked(clearDouble)
self.dblValue.clicked.connect(self._populateTree) self.dblValue.clicked.connect(self._populateTree)
+35 -20
View File
@@ -34,8 +34,8 @@ from PyQt5.QtCore import (
pyqtSignal, pyqtSlot pyqtSignal, pyqtSlot
) )
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QDialog, QDialogButtonBox, QFileDialog, QFormLayout, QHBoxLayout, QLabel, QAction, QDialog, QDialogButtonBox, QFileDialog, QFormLayout, QHBoxLayout,
QLineEdit, QListView, QMenu, QPushButton, QScrollArea, QShortcut, QLabel, QLineEdit, QListView, QMenu, QPushButton, QScrollArea, QShortcut,
QStackedWidget, QStyle, QStyleOptionViewItem, QStyledItemDelegate, QStackedWidget, QStyle, QStyleOptionViewItem, QStyledItemDelegate,
QToolButton, QVBoxLayout, QWidget, qApp QToolButton, QVBoxLayout, QWidget, qApp
) )
@@ -43,13 +43,15 @@ from PyQt5.QtWidgets import (
from novelwriter import CONFIG, SHARED, __version__, __date__ from novelwriter import CONFIG, SHARED, __version__, __date__
from novelwriter.enum import nwItemClass from novelwriter.enum import nwItemClass
from novelwriter.common import formatInt, formatVersion, makeFileNameSafe from novelwriter.common import formatInt, formatVersion, makeFileNameSafe
from novelwriter.constants import nwUnicode from novelwriter.constants import nwFiles, nwUnicode
from novelwriter.core.coretools import ProjectBuilder from novelwriter.core.coretools import ProjectBuilder
from novelwriter.extensions.switch import NSwitch from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.modified import NComboBox, NSpinBox from novelwriter.extensions.modified import NComboBox, NSpinBox
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
PANEL_ALPHA = 0.7
class GuiWelcome(QDialog): class GuiWelcome(QDialog):
@@ -62,15 +64,16 @@ class GuiWelcome(QDialog):
self.setObjectName("GuiWelcome") self.setObjectName("GuiWelcome")
self.setWindowTitle(self.tr("Welcome")) self.setWindowTitle(self.tr("Welcome"))
self.setMinimumWidth(CONFIG.pxInt(700)) self.setMinimumWidth(CONFIG.pxInt(650))
self.setMinimumHeight(CONFIG.pxInt(400)) self.setMinimumHeight(CONFIG.pxInt(450))
hA = CONFIG.pxInt(8) hA = CONFIG.pxInt(8)
hB = CONFIG.pxInt(16) hB = CONFIG.pxInt(16)
hC = CONFIG.pxInt(24) hC = CONFIG.pxInt(24)
hD = CONFIG.pxInt(36) hD = CONFIG.pxInt(36)
hE = CONFIG.pxInt(48) hE = CONFIG.pxInt(48)
hF = CONFIG.pxInt(96) hF = CONFIG.pxInt(128)
self._hPx = CONFIG.pxInt(600)
self.resize(*CONFIG.welcomeWinSize) self.resize(*CONFIG.welcomeWinSize)
@@ -127,14 +130,14 @@ class GuiWelcome(QDialog):
self.innerBox.addWidget(self.nwInfo) self.innerBox.addWidget(self.nwInfo)
self.innerBox.addSpacing(hA) self.innerBox.addSpacing(hA)
self.innerBox.addWidget(self.mainStack) self.innerBox.addWidget(self.mainStack)
self.innerBox.addSpacing(hA) self.innerBox.addSpacing(hB)
self.innerBox.addWidget(self.btnBox) self.innerBox.addWidget(self.btnBox)
topRight = Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignRight topRight = Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignRight
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, 9)
self.outerBox.setContentsMargins(hF, hE, hC, hE) self.outerBox.setContentsMargins(hF, hE, hC, hE)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
@@ -155,7 +158,7 @@ class GuiWelcome(QDialog):
def paintEvent(self, event: QPaintEvent) -> None: def paintEvent(self, event: QPaintEvent) -> None:
"""Overload the paint event to draw the background image.""" """Overload the paint event to draw the background image."""
hWin = self.height() hWin = self.height()
hPix = min(hWin, 700) hPix = min(hWin, self._hPx)
tMode = Qt.TransformationMode.SmoothTransformation tMode = Qt.TransformationMode.SmoothTransformation
painter = QPainter(self) painter = QPainter(self)
painter.fillRect(self.rect(), self.bgColor) painter.fillRect(self.rect(), self.bgColor)
@@ -238,8 +241,13 @@ class _OpenProjectPage(QWidget):
self.listWidget.customContextMenuRequested.connect(self._openContextMenu) self.listWidget.customContextMenuRequested.connect(self._openContextMenu)
# Info / Tool # Info / Tool
self.aMissing = QAction(self)
self.aMissing.setIcon(SHARED.theme.getIcon("alert_warn"))
self.aMissing.setToolTip(self.tr("The project path is not reachable."))
self.selectedPath = QLineEdit(self) self.selectedPath = QLineEdit(self)
self.selectedPath.setReadOnly(True) self.selectedPath.setReadOnly(True)
self.selectedPath.addAction(self.aMissing, QLineEdit.ActionPosition.TrailingPosition)
self.keyDelete = QShortcut(self) self.keyDelete = QShortcut(self)
self.keyDelete.setKey(Qt.Key.Key_Delete) self.keyDelete.setKey(Qt.Key.Key_Delete)
@@ -257,9 +265,10 @@ class _OpenProjectPage(QWidget):
baseCol = self.palette().base().color() baseCol = self.palette().base().color()
self.setStyleSheet(( self.setStyleSheet((
"QListView {{border: none; background: rgba({r},{g},{b},0.65);}} " "QListView {{border: none; background: rgba({r},{g},{b},{a});}} "
"QLineEdit {{border: none; background: rgba({r},{g},{b},0.65); padding: {m}px;}} " "QLineEdit {{border: none; background: rgba({r},{g},{b},{a}); padding: {m}px;}} "
).format(r=baseCol.red(), g=baseCol.green(), b=baseCol.blue(), m=CONFIG.pxInt(4))) ).format(r=baseCol.red(), g=baseCol.green(), b=baseCol.blue(),
a=PANEL_ALPHA, m=CONFIG.pxInt(4)))
return return
@@ -283,7 +292,11 @@ class _OpenProjectPage(QWidget):
"""Process single click on project item.""" """Process single click on project item."""
path = self.tr("Path") path = self.tr("Path")
value = index.data()[1] if index.isValid() else "" value = index.data()[1] if index.isValid() else ""
self.selectedPath.setText(f"{path}: {value}") text = f"{path}: {value}"
self.selectedPath.setText(text)
self.selectedPath.setToolTip(text)
self.selectedPath.setCursorPosition(0)
self.aMissing.setVisible(not (Path(value) / nwFiles.PROJ_FILE).is_file())
return return
@pyqtSlot(QModelIndex) @pyqtSlot(QModelIndex)
@@ -482,9 +495,9 @@ class _NewProjectPage(QWidget):
baseCol = self.palette().base().color() baseCol = self.palette().base().color()
self.setStyleSheet(( self.setStyleSheet((
"QScrollArea {{border: none; background: rgba({r},{g},{b},0.65);}} " "QScrollArea {{border: none; background: rgba({r},{g},{b},{a});}} "
"_NewProjectForm {{border: none; background: rgba({r},{g},{b},0.65);}} " "_NewProjectForm {{border: none; background: rgba({r},{g},{b},{a});}} "
).format(r=baseCol.red(), g=baseCol.green(), b=baseCol.blue())) ).format(r=baseCol.red(), g=baseCol.green(), b=baseCol.blue(), a=PANEL_ALPHA))
return return
@@ -520,6 +533,8 @@ class _NewProjectForm(QWidget):
self._fillMode = self.FILL_BLANK self._fillMode = self.FILL_BLANK
self._copyPath = None self._copyPath = None
iPx = SHARED.theme.baseIconSize
# Project Settings # Project Settings
# ================ # ================
@@ -623,19 +638,19 @@ class _NewProjectForm(QWidget):
# Project Notes # Project Notes
# ============= # =============
self.addPlot = NSwitch(self) self.addPlot = NSwitch(self, height=iPx)
self.addPlot.setChecked(True) self.addPlot.setChecked(True)
self.addPlot.clicked.connect(self._syncSwitches) self.addPlot.clicked.connect(self._syncSwitches)
self.addChar = NSwitch(self) self.addChar = NSwitch(self, height=iPx)
self.addChar.setChecked(True) self.addChar.setChecked(True)
self.addChar.clicked.connect(self._syncSwitches) self.addChar.clicked.connect(self._syncSwitches)
self.addWorld = NSwitch(self) self.addWorld = NSwitch(self, height=iPx)
self.addWorld.setChecked(False) self.addWorld.setChecked(False)
self.addWorld.clicked.connect(self._syncSwitches) self.addWorld.clicked.connect(self._syncSwitches)
self.addNotes = NSwitch() self.addNotes = NSwitch(self, height=iPx)
self.addNotes.setChecked(False) self.addNotes.setChecked(False)
self.notesForm = QFormLayout() self.notesForm = QFormLayout()
+6 -6
View File
@@ -193,37 +193,37 @@ class GuiWritingStats(QDialog):
self.filterForm = QGridLayout(self) self.filterForm = QGridLayout(self)
self.filterBox.setLayout(self.filterForm) self.filterBox.setLayout(self.filterForm)
self.incNovel = NSwitch(width=2*sPx, height=sPx) self.incNovel = NSwitch(self, height=sPx)
self.incNovel.setChecked( self.incNovel.setChecked(
pOptions.getBool("GuiWritingStats", "incNovel", True) pOptions.getBool("GuiWritingStats", "incNovel", True)
) )
self.incNovel.clicked.connect(self._updateListBox) self.incNovel.clicked.connect(self._updateListBox)
self.incNotes = NSwitch(width=2*sPx, height=sPx) self.incNotes = NSwitch(self, height=sPx)
self.incNotes.setChecked( self.incNotes.setChecked(
pOptions.getBool("GuiWritingStats", "incNotes", True) pOptions.getBool("GuiWritingStats", "incNotes", True)
) )
self.incNotes.clicked.connect(self._updateListBox) self.incNotes.clicked.connect(self._updateListBox)
self.hideZeros = NSwitch(width=2*sPx, height=sPx) self.hideZeros = NSwitch(self, height=sPx)
self.hideZeros.setChecked( self.hideZeros.setChecked(
pOptions.getBool("GuiWritingStats", "hideZeros", True) pOptions.getBool("GuiWritingStats", "hideZeros", True)
) )
self.hideZeros.clicked.connect(self._updateListBox) self.hideZeros.clicked.connect(self._updateListBox)
self.hideNegative = NSwitch(width=2*sPx, height=sPx) self.hideNegative = NSwitch(self, height=sPx)
self.hideNegative.setChecked( self.hideNegative.setChecked(
pOptions.getBool("GuiWritingStats", "hideNegative", False) pOptions.getBool("GuiWritingStats", "hideNegative", False)
) )
self.hideNegative.clicked.connect(self._updateListBox) self.hideNegative.clicked.connect(self._updateListBox)
self.groupByDay = NSwitch(width=2*sPx, height=sPx) self.groupByDay = NSwitch(self, height=sPx)
self.groupByDay.setChecked( self.groupByDay.setChecked(
pOptions.getBool("GuiWritingStats", "groupByDay", False) pOptions.getBool("GuiWritingStats", "groupByDay", False)
) )
self.groupByDay.clicked.connect(self._updateListBox) self.groupByDay.clicked.connect(self._updateListBox)
self.showIdleTime = NSwitch(width=2*sPx, height=sPx) self.showIdleTime = NSwitch(self, height=sPx)
self.showIdleTime.setChecked( self.showIdleTime.setChecked(
pOptions.getBool("GuiWritingStats", "showIdleTime", False) pOptions.getBool("GuiWritingStats", "showIdleTime", False)
) )
+2 -2
View File
@@ -1,5 +1,5 @@
[Meta] [Meta]
timestamp = 2023-12-29 14:11:20 timestamp = 2024-02-09 12:05:00
[Main] [Main]
theme = default theme = default
@@ -14,7 +14,7 @@ lastpath =
[Sizes] [Sizes]
mainwindow = 1200, 650 mainwindow = 1200, 650
welcome = 800, 500 welcome = 800, 550
preferences = 700, 615 preferences = 700, 615
mainpane = 300, 800 mainpane = 300, 800
viewpane = 500, 150 viewpane = 500, 150