diff --git a/nw/gui/about.py b/nw/gui/about.py index 653f87ae..5d869c9a 100644 --- a/nw/gui/about.py +++ b/nw/gui/about.py @@ -48,22 +48,24 @@ class GuiAbout(QDialog): self.mainConf = nw.CONFIG self.theParent = theParent + self.theTheme = theParent.theTheme self.outerBox = QVBoxLayout() self.innerBox = QHBoxLayout() - self.innerBox.setSpacing(16) + self.innerBox.setSpacing(self.mainConf.pxInt(16)) self.setWindowTitle("About %s" % nw.__package__) - self.setMinimumWidth(700) - self.setMinimumHeight(600) + self.setMinimumWidth(self.mainConf.pxInt(650)) + self.setMinimumHeight(self.mainConf.pxInt(600)) - self.guiDeco = self.theParent.theTheme.loadDecoration("nwicon", (96, 96)) + iPx = self.mainConf.pxInt(96) + self.guiDeco = self.theParent.theTheme.loadDecoration("nwicon", (iPx, iPx)) self.lblName = QLabel("%s" % nw.__package__) self.lblVers = QLabel("v%s" % nw.__version__) self.lblDate = QLabel(datetime.strptime(nw.__date__, "%Y-%m-%d").strftime("%x")) self.leftBox = QVBoxLayout() - self.leftBox.setSpacing(4) + self.leftBox.setSpacing(self.mainConf.pxInt(4)) self.leftBox.addWidget(self.guiDeco, 0, Qt.AlignCenter) self.leftBox.addWidget(self.lblName, 0, Qt.AlignCenter) self.leftBox.addWidget(self.lblVers, 0, Qt.AlignCenter) @@ -74,7 +76,7 @@ class GuiAbout(QDialog): # Pages self.pageAbout = QTextBrowser() self.pageAbout.setOpenExternalLinks(True) - self.pageAbout.document().setDocumentMargin(16) + self.pageAbout.document().setDocumentMargin(self.mainConf.pxInt(16)) # self.pageCredit = QTextBrowser() # self.pageCredit.setOpenExternalLinks(True) @@ -82,7 +84,7 @@ class GuiAbout(QDialog): self.pageLicense = QTextBrowser() self.pageLicense.setOpenExternalLinks(True) - self.pageLicense.document().setDocumentMargin(16) + self.pageLicense.document().setDocumentMargin(self.mainConf.pxInt(16)) # Main Tab Area self.tabBox = QTabWidget() diff --git a/nw/gui/build.py b/nw/gui/build.py index f072b6ea..30bd4cf5 100644 --- a/nw/gui/build.py +++ b/nw/gui/build.py @@ -77,13 +77,17 @@ class GuiBuildNovel(QDialog): self.htmlStyle = [] # List of html styles self.nwdText = [] # List of markdown documents + x800 = self.mainConf.pxInt(800) + x900 = self.mainConf.pxInt(900) + xFmt = self.mainConf.pxInt(220) + self.setWindowTitle("Build Novel Project") - self.setMinimumWidth(900) - self.setMinimumHeight(800) + self.setMinimumWidth(x900) + self.setMinimumHeight(x800) self.resize( - self.optState.getInt("GuiBuildNovel", "winWidth", 900), - self.optState.getInt("GuiBuildNovel", "winHeight", 800) + self.optState.getInt("GuiBuildNovel", "winWidth", x900), + self.optState.getInt("GuiBuildNovel", "winHeight", x800) ) self.outerBox = QHBoxLayout() @@ -115,7 +119,7 @@ class GuiBuildNovel(QDialog): self.fmtTitle = QLineEdit() self.fmtTitle.setMaxLength(200) - self.fmtTitle.setFixedWidth(220) + self.fmtTitle.setFixedWidth(xFmt) self.fmtTitle.setToolTip(fmtHelp) self.fmtTitle.setText( self._reFmtCodes(self.theProject.titleFormat["title"]) @@ -123,7 +127,7 @@ class GuiBuildNovel(QDialog): self.fmtChapter = QLineEdit() self.fmtChapter.setMaxLength(200) - self.fmtChapter.setFixedWidth(220) + self.fmtChapter.setFixedWidth(xFmt) self.fmtChapter.setToolTip(fmtHelp) self.fmtChapter.setText( self._reFmtCodes(self.theProject.titleFormat["chapter"]) @@ -131,7 +135,7 @@ class GuiBuildNovel(QDialog): self.fmtUnnumbered = QLineEdit() self.fmtUnnumbered.setMaxLength(200) - self.fmtUnnumbered.setFixedWidth(220) + self.fmtUnnumbered.setFixedWidth(xFmt) self.fmtUnnumbered.setToolTip(fmtHelp) self.fmtUnnumbered.setText( self._reFmtCodes(self.theProject.titleFormat["unnumbered"]) @@ -139,7 +143,7 @@ class GuiBuildNovel(QDialog): self.fmtScene = QLineEdit() self.fmtScene.setMaxLength(200) - self.fmtScene.setFixedWidth(220) + self.fmtScene.setFixedWidth(xFmt) self.fmtScene.setToolTip(fmtHelp + fmtScHelp) self.fmtScene.setText( self._reFmtCodes(self.theProject.titleFormat["scene"]) @@ -147,7 +151,7 @@ class GuiBuildNovel(QDialog): self.fmtSection = QLineEdit() self.fmtSection.setMaxLength(200) - self.fmtSection.setFixedWidth(220) + self.fmtSection.setFixedWidth(xFmt) self.fmtSection.setToolTip(fmtHelp + fmtScHelp) self.fmtSection.setText( self._reFmtCodes(self.theProject.titleFormat["section"]) @@ -176,7 +180,7 @@ class GuiBuildNovel(QDialog): ## Font Family self.textFont = QLineEdit() self.textFont.setReadOnly(True) - self.textFont.setFixedWidth(182) + self.textFont.setFixedWidth(self.mainConf.pxInt(182)) self.textFont.setText( self.optState.getString("GuiBuildNovel", "textFont", self.mainConf.textFont) ) @@ -185,7 +189,7 @@ class GuiBuildNovel(QDialog): self.fontButton.clicked.connect(self._selectFont) self.textSize = QSpinBox(self) - self.textSize.setFixedWidth(60) + self.textSize.setFixedWidth(5*self.theTheme.textNWidth) self.textSize.setMinimum(6) self.textSize.setMaximum(72) self.textSize.setSingleStep(1) @@ -894,7 +898,7 @@ class GuiBuildNovelDocView(QTextBrowser): self.theProject = theProject self.theParent = theParent - self.setMinimumWidth(400) + self.setMinimumWidth(40*self.theParent.theTheme.textNWidth) self.setOpenExternalLinks(False) self.qDocument = self.document() diff --git a/nw/gui/docbars.py b/nw/gui/docbars.py index 0923cb91..3e65855d 100644 --- a/nw/gui/docbars.py +++ b/nw/gui/docbars.py @@ -53,7 +53,7 @@ class GuiSearchBar(QFrame): self.theTheme = theParent.theTheme self.repVisible = False - self.setContentsMargins(0,0,0,0) + self.setContentsMargins(0, 0, 0, 0) self.mainBox = QGridLayout(self) self.setLayout(self.mainBox) @@ -72,24 +72,25 @@ class GuiSearchBar(QFrame): self.searchBox.returnPressed.connect(self._doSearch) self.replaceBox.returnPressed.connect(self._doSearch) - self.mainBox.addWidget(QLabel(""), 0,0) - self.mainBox.addWidget(self.searchLabel, 0,1) - self.mainBox.addWidget(self.searchBox, 0,2) - self.mainBox.addWidget(self.searchButton, 0,3) - self.mainBox.addWidget(self.closeButton, 0,4) - self.mainBox.addWidget(self.replaceLabel, 1,1) - self.mainBox.addWidget(self.replaceBox, 1,2) - self.mainBox.addWidget(self.replaceButton, 1,3) + self.mainBox.addWidget(QLabel(""), 0, 0) + self.mainBox.addWidget(self.searchLabel, 0, 1) + self.mainBox.addWidget(self.searchBox, 0, 2) + self.mainBox.addWidget(self.searchButton, 0, 3) + self.mainBox.addWidget(self.closeButton, 0, 4) + self.mainBox.addWidget(self.replaceLabel, 1, 1) + self.mainBox.addWidget(self.replaceBox, 1, 2) + self.mainBox.addWidget(self.replaceButton, 1, 3) - self.mainBox.setColumnStretch(0,1) - self.mainBox.setColumnStretch(1,0) - self.mainBox.setColumnStretch(2,0) - self.mainBox.setColumnStretch(3,0) - self.mainBox.setColumnStretch(4,0) - self.mainBox.setContentsMargins(0,0,0,0) + self.mainBox.setColumnStretch(0, 1) + self.mainBox.setColumnStretch(1, 0) + self.mainBox.setColumnStretch(2, 0) + self.mainBox.setColumnStretch(3, 0) + self.mainBox.setColumnStretch(4, 0) + self.mainBox.setContentsMargins(0, 0, 0, 0) - self.searchBox.setMinimumWidth(180) - self.replaceBox.setMinimumWidth(180) + boxWidth = 16*self.theTheme.textNWidth + self.searchBox.setMinimumWidth(boxWidth) + self.replaceBox.setMinimumWidth(boxWidth) self._replaceVisible(False) @@ -175,15 +176,18 @@ class GuiNoticeBar(QFrame): logger.debug("Initialising GuiNoticeBar ...") - self.mainConf = nw.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = nw.CONFIG + self.theParent = theParent + self.theTheme = theParent.theTheme - self.setContentsMargins(0,0,0,0) + self.setContentsMargins(0, 0, 0, 0) self.setFrameShape(QFrame.Box) + m8 = self.mainConf.pxInt(8) + m2 = self.mainConf.pxInt(2) + self.mainBox = QHBoxLayout(self) - self.mainBox.setContentsMargins(8,2,2,2) + self.mainBox.setContentsMargins(m8, m2, m2, m2) self.noteLabel = QLabel("") diff --git a/nw/gui/docdetails.py b/nw/gui/docdetails.py index 09b43426..7c4ec8f7 100644 --- a/nw/gui/docdetails.py +++ b/nw/gui/docdetails.py @@ -44,12 +44,17 @@ class GuiDocViewDetails(QWidget): self.mainConf = nw.CONFIG self.theParent = theParent self.theProject = theParent.theProject + self.theTheme = theParent.theTheme self.currHandle = None + x4 = self.mainConf.pxInt(4) + x80 = self.mainConf.pxInt(80) + iPx = self.theTheme.textIconSize + self.outerBox = QGridLayout(self) - self.outerBox.setContentsMargins(0,0,0,0) + self.outerBox.setContentsMargins(0, 0, 0, 0) self.outerBox.setHorizontalSpacing(0) - self.outerBox.setVerticalSpacing(4) + self.outerBox.setVerticalSpacing(x4) self.refLabel = QLabel("Referenced By", self) @@ -58,7 +63,7 @@ class GuiDocViewDetails(QWidget): self.showHide.setToolButtonStyle(Qt.ToolButtonIconOnly) self.showHide.setArrowType(Qt.DownArrow) self.showHide.setCheckable(True) - self.showHide.setIconSize(QSize(16,16)) + self.showHide.setIconSize(QSize(iPx, iPx)) self.showHide.toggled.connect(self._doShowHide) self.isSticky = QCheckBox("Sticky") @@ -75,7 +80,7 @@ class GuiDocViewDetails(QWidget): self.scrollBox.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scrollBox.setFrameStyle(QFrame.NoFrame) self.scrollBox.setWidgetResizable(True) - self.scrollBox.setFixedHeight(80) + self.scrollBox.setFixedHeight(x80) self.scrollBox.setWidget(self.refList) self.outerBox.addWidget(self.showHide, 0, 0) @@ -85,7 +90,7 @@ class GuiDocViewDetails(QWidget): self.outerBox.setColumnStretch(1, 1) self.setLayout(self.outerBox) - self.setContentsMargins(0,0,0,0) + self.setContentsMargins(0, 0, 0, 0) self._doShowHide(self.mainConf.showRefPanel) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 1b3f81bb..884c4ae3 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -98,7 +98,7 @@ class GuiDocEditor(QTextEdit): # Editor State self.hasSelection = False - self.setMinimumWidth(300) + self.setMinimumWidth(self.mainConf.pxInt(300)) self.setAcceptRichText(False) # Custom Shortcuts diff --git a/nw/gui/docmerge.py b/nw/gui/docmerge.py index 73b15a6a..1294501f 100644 --- a/nw/gui/docmerge.py +++ b/nw/gui/docmerge.py @@ -62,8 +62,8 @@ class GuiDocMerge(QDialog): self.listBox = QListWidget() self.listBox.setDragDropMode(QAbstractItemView.InternalMove) - self.listBox.setMinimumWidth(400) - self.listBox.setMinimumHeight(180) + self.listBox.setMinimumWidth(self.mainConf.pxInt(400)) + self.listBox.setMinimumHeight(self.mainConf.pxInt(180)) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonBox.accepted.connect(self._doMerge) @@ -72,9 +72,9 @@ class GuiDocMerge(QDialog): self.outerBox.setSpacing(0) self.outerBox.addWidget(self.headLabel) self.outerBox.addWidget(self.helpLabel) - self.outerBox.addSpacing(8) + self.outerBox.addSpacing(self.mainConf.pxInt(8)) self.outerBox.addWidget(self.listBox) - self.outerBox.addSpacing(12) + self.outerBox.addSpacing(self.mainConf.pxInt(12)) self.outerBox.addWidget(self.buttonBox) self.setLayout(self.outerBox) diff --git a/nw/gui/docsplit.py b/nw/gui/docsplit.py index 702e8f17..98ef95d7 100644 --- a/nw/gui/docsplit.py +++ b/nw/gui/docsplit.py @@ -62,8 +62,8 @@ class GuiDocSplit(QDialog): self.listBox = QListWidget() self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop) - self.listBox.setMinimumWidth(400) - self.listBox.setMinimumHeight(180) + self.listBox.setMinimumWidth(self.mainConf.pxInt(400)) + self.listBox.setMinimumHeight(self.mainConf.pxInt(180)) self.splitLevel = QComboBox(self) self.splitLevel.addItem("Split on Header Level 1 (Title)", 1) @@ -84,10 +84,10 @@ class GuiDocSplit(QDialog): self.outerBox.setSpacing(0) self.outerBox.addWidget(self.headLabel) self.outerBox.addWidget(self.helpLabel) - self.outerBox.addSpacing(8) + self.outerBox.addSpacing(self.mainConf.pxInt(8)) self.outerBox.addWidget(self.listBox) self.outerBox.addWidget(self.splitLevel) - self.outerBox.addSpacing(12) + self.outerBox.addSpacing(self.mainConf.pxInt(12)) self.outerBox.addWidget(self.buttonBox) self.setLayout(self.outerBox) diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index fb1a9c99..70163b7b 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -53,7 +53,7 @@ class GuiDocViewer(QTextBrowser): self.theHandle = None self.qDocument = self.document() - self.setMinimumWidth(300) + self.setMinimumWidth(self.mainConf.pxInt(300)) self.setOpenExternalLinks(False) self.initViewer() diff --git a/nw/gui/itemdetails.py b/nw/gui/itemdetails.py index 7335a596..182fb3fd 100644 --- a/nw/gui/itemdetails.py +++ b/nw/gui/itemdetails.py @@ -170,11 +170,11 @@ class GuiItemDetails(QWidget): self.mainBox.addWidget(self.pCountName, 3, 3, 1, 1) self.mainBox.addWidget(self.pCountData, 3, 4, 1, 1) - self.mainBox.setColumnStretch(0,0) - self.mainBox.setColumnStretch(1,0) - self.mainBox.setColumnStretch(2,1) - self.mainBox.setColumnStretch(3,0) - self.mainBox.setColumnStretch(4,0) + self.mainBox.setColumnStretch(0, 0) + self.mainBox.setColumnStretch(1, 0) + self.mainBox.setColumnStretch(2, 1) + self.mainBox.setColumnStretch(3, 0) + self.mainBox.setColumnStretch(4, 0) # Make sure the columns for flags and counts don't resize too often flagWidth = self.theTheme.getTextWidth("Mm", self.fntValue) diff --git a/nw/gui/itemeditor.py b/nw/gui/itemeditor.py index 7eb54b14..65c4cde9 100644 --- a/nw/gui/itemeditor.py +++ b/nw/gui/itemeditor.py @@ -61,8 +61,8 @@ class GuiItemEditor(QDialog): # Item Label self.editName = QLineEdit() - self.editName.setMinimumWidth(220) - self.editName.setMaxLength(200) + self.editName.setMinimumWidth(self.mainConf.pxInt(220)) + self.editName.setMaxLength(self.mainConf.pxInt(200)) # Item Status self.editStatus = QComboBox() @@ -135,7 +135,7 @@ class GuiItemEditor(QDialog): self.mainForm.addWidget(self.textExport, 3, 0, 1, 2) self.mainForm.addWidget(self.editExport, 3, 2, 1, 1) - self.outerBox.setSpacing(16) + self.outerBox.setSpacing(self.mainConf.pxInt(16)) self.outerBox.addLayout(self.mainForm) self.outerBox.addStretch(1) self.outerBox.addWidget(self.buttonBox) diff --git a/nw/gui/outlinedetails.py b/nw/gui/outlinedetails.py index 33048837..739b1c37 100644 --- a/nw/gui/outlinedetails.py +++ b/nw/gui/outlinedetails.py @@ -63,8 +63,8 @@ class GuiOutlineDetails(QScrollArea): minTitle = 30*self.theTheme.textNWidth maxTitle = 40*self.theTheme.textNWidth wCount = self.theTheme.getTextWidth("999,999") - hSpace = int(0.8*self.theTheme.textNWidth) - vSpace = int(0.2*self.theTheme.textNHeight) + hSpace = int(self.mainConf.pxInt(10)) + vSpace = int(self.mainConf.pxInt(4)) # Details Area self.titleLabel = QLabel("Title") diff --git a/nw/gui/preferences.py b/nw/gui/preferences.py index a05e5eb0..55d62fe9 100644 --- a/nw/gui/preferences.py +++ b/nw/gui/preferences.py @@ -143,7 +143,7 @@ class GuiConfigEditGeneralTab(QWidget): ## Select Theme self.selectTheme = QComboBox() - self.selectTheme.setMinimumWidth(200) + self.selectTheme.setMinimumWidth(self.mainConf.pxInt(200)) self.theThemes = self.theTheme.listThemes() for themeDir, themeName in self.theThemes: self.selectTheme.addItem(themeName, themeDir) @@ -159,7 +159,7 @@ class GuiConfigEditGeneralTab(QWidget): ## Select Icon Theme self.selectIcons = QComboBox() - self.selectIcons.setMinimumWidth(200) + self.selectIcons.setMinimumWidth(self.mainConf.pxInt(200)) self.theIcons = self.theTheme.theIcons.listThemes() for iconDir, iconName in self.theIcons: self.selectIcons.addItem(iconName, iconDir) @@ -185,7 +185,7 @@ class GuiConfigEditGeneralTab(QWidget): ## Font Family self.guiFont = QLineEdit() self.guiFont.setReadOnly(True) - self.guiFont.setFixedWidth(162) + self.guiFont.setFixedWidth(self.mainConf.pxInt(162)) self.guiFont.setText(self.mainConf.guiFont) self.fontButton = QPushButton("...") self.fontButton.setMaximumWidth(int(2.5*self.theTheme.getTextWidth("..."))) @@ -389,7 +389,7 @@ class GuiConfigEditLayoutTab(QWidget): ## Font Family self.textStyleFont = QLineEdit() self.textStyleFont.setReadOnly(True) - self.textStyleFont.setFixedWidth(162) + self.textStyleFont.setFixedWidth(self.mainConf.pxInt(162)) self.textStyleFont.setText(self.mainConf.textFont) self.fontButton = QPushButton("...") self.fontButton.setMaximumWidth(int(2.5*self.theTheme.getTextWidth("..."))) @@ -575,7 +575,7 @@ class GuiConfigEditEditingTab(QWidget): ## Syntax Highlighting self.selectSyntax = QComboBox() - self.selectSyntax.setMinimumWidth(200) + self.selectSyntax.setMinimumWidth(self.mainConf.pxInt(200)) self.theSyntaxes = self.theTheme.listSyntax() for syntaxFile, syntaxName in self.theSyntaxes: self.selectSyntax.addItem(syntaxName, syntaxFile) @@ -789,10 +789,12 @@ class GuiConfigEditAutoReplaceTab(QWidget): # =============== self.mainForm.addGroupLabel("Quotation Style") + qWidth = self.mainConf.pxInt(40) + ## Single Quote Style self.quoteSingleStyleO = QLineEdit() self.quoteSingleStyleO.setMaxLength(1) - self.quoteSingleStyleO.setFixedWidth(40) + self.quoteSingleStyleO.setFixedWidth(qWidth) self.quoteSingleStyleO.setAlignment(Qt.AlignCenter) self.quoteSingleStyleO.setText(self.mainConf.fmtSingleQuotes[0]) self.mainForm.addRow( @@ -803,7 +805,7 @@ class GuiConfigEditAutoReplaceTab(QWidget): self.quoteSingleStyleC = QLineEdit() self.quoteSingleStyleC.setMaxLength(1) - self.quoteSingleStyleC.setFixedWidth(40) + self.quoteSingleStyleC.setFixedWidth(qWidth) self.quoteSingleStyleC.setAlignment(Qt.AlignCenter) self.quoteSingleStyleC.setText(self.mainConf.fmtSingleQuotes[1]) self.mainForm.addRow( @@ -815,7 +817,7 @@ class GuiConfigEditAutoReplaceTab(QWidget): ## Double Quote Style self.quoteDoubleStyleO = QLineEdit() self.quoteDoubleStyleO.setMaxLength(1) - self.quoteDoubleStyleO.setFixedWidth(40) + self.quoteDoubleStyleO.setFixedWidth(qWidth) self.quoteDoubleStyleO.setAlignment(Qt.AlignCenter) self.quoteDoubleStyleO.setText(self.mainConf.fmtDoubleQuotes[0]) self.mainForm.addRow( @@ -826,7 +828,7 @@ class GuiConfigEditAutoReplaceTab(QWidget): self.quoteDoubleStyleC = QLineEdit() self.quoteDoubleStyleC.setMaxLength(1) - self.quoteDoubleStyleC.setFixedWidth(40) + self.quoteDoubleStyleC.setFixedWidth(qWidth) self.quoteDoubleStyleC.setAlignment(Qt.AlignCenter) self.quoteDoubleStyleC.setText(self.mainConf.fmtDoubleQuotes[1]) self.mainForm.addRow( diff --git a/nw/gui/projload.py b/nw/gui/projload.py index 63f0be9f..361b5ba8 100644 --- a/nw/gui/projload.py +++ b/nw/gui/projload.py @@ -61,17 +61,20 @@ class GuiProjectLoad(QDialog): self.openState = self.NONE_STATE self.openPath = None + xSp = self.mainConf.pxInt(16) + xIc = self.mainConf.pxInt(96) + self.outerBox = QVBoxLayout() self.innerBox = QHBoxLayout() - self.outerBox.setSpacing(16) - self.innerBox.setSpacing(16) + self.outerBox.setSpacing(xSp) + self.innerBox.setSpacing(xSp) self.setWindowTitle("Open Project") - self.setMinimumWidth(650) - self.setMinimumHeight(400) + self.setMinimumWidth(self.mainConf.pxInt(650)) + self.setMinimumHeight(self.mainConf.pxInt(400)) self.setModal(True) - self.guiDeco = self.theTheme.loadDecoration("nwicon", (96, 96)) + self.guiDeco = self.theTheme.loadDecoration("nwicon", (xIc, xIc)) self.innerBox.addWidget(self.guiDeco, 0, Qt.AlignTop) self.projectForm = QGridLayout() @@ -113,8 +116,8 @@ class GuiProjectLoad(QDialog): self.projectForm.setColumnStretch(0, 0) self.projectForm.setColumnStretch(1, 1) self.projectForm.setColumnStretch(2, 0) - self.projectForm.setVerticalSpacing(4) - self.projectForm.setHorizontalSpacing(8) + self.projectForm.setVerticalSpacing(self.mainConf.pxInt(4)) + self.projectForm.setHorizontalSpacing(self.mainConf.pxInt(8)) self.innerBox.addLayout(self.projectForm) diff --git a/nw/gui/projsettings.py b/nw/gui/projsettings.py index a1c28ca4..2a4dc680 100644 --- a/nw/gui/projsettings.py +++ b/nw/gui/projsettings.py @@ -119,6 +119,7 @@ class GuiProjectEditMain(QWidget): def __init__(self, theParent, theProject): QWidget.__init__(self, theParent) + self.mainConf = nw.CONFIG self.theParent = theParent self.theProject = theProject @@ -129,9 +130,12 @@ class GuiProjectEditMain(QWidget): self.mainForm.addGroupLabel("Project Settings") + xW = self.mainConf.pxInt(250) + xH = self.mainConf.pxInt(100) + self.editName = QLineEdit() self.editName.setMaxLength(200) - self.editName.setFixedWidth(250) + self.editName.setFixedWidth(xW) self.editName.setText(self.theProject.projName) self.mainForm.addRow( "Working title", @@ -141,7 +145,7 @@ class GuiProjectEditMain(QWidget): self.editTitle = QLineEdit() self.editTitle.setMaxLength(200) - self.editTitle.setFixedWidth(250) + self.editTitle.setFixedWidth(xW) self.editTitle.setText(self.theProject.bookTitle) self.mainForm.addRow( "Novel title", @@ -154,8 +158,8 @@ class GuiProjectEditMain(QWidget): for bookAuthor in self.theProject.bookAuthors: bookAuthors += bookAuthor+"\n" self.editAuthors.setPlainText(bookAuthors) - self.editAuthors.setFixedHeight(100) - self.editAuthors.setFixedWidth(250) + self.editAuthors.setFixedHeight(xH) + self.editAuthors.setFixedWidth(xW) self.mainForm.addRow( "Author(s)", self.editAuthors, @@ -179,9 +183,12 @@ class GuiProjectEditMeta(QWidget): def __init__(self, theParent, theProject): QWidget.__init__(self, theParent) + self.mainConf = nw.CONFIG self.theParent = theParent self.theProject = theProject + xInd = self.mainConf.pxInt(8) + # The Form self.mainForm = QGridLayout() self.setLayout(self.mainForm) @@ -189,17 +196,17 @@ class GuiProjectEditMeta(QWidget): self.headLabel = QLabel("Project Details") self.nameLabel = QLabel("Working title:") - self.nameLabel.setIndent(8) + self.nameLabel.setIndent(xInd) self.nameValue = QLabel(self.theProject.projName) self.nameValue.setWordWrap(True) self.pathLabel = QLabel("Project path:") - self.pathLabel.setIndent(8) + self.pathLabel.setIndent(xInd) self.pathValue = QLabel(self.theProject.projPath) self.pathValue.setWordWrap(True) self.revLabel = QLabel("Revision count:") - self.revLabel.setIndent(8) + self.revLabel.setIndent(xInd) self.revValue = QLabel("{:n}".format(self.theProject.saveCount)) self.statsLabel = QLabel("Project Stats") @@ -207,19 +214,19 @@ class GuiProjectEditMeta(QWidget): nR, nD, nF = self.theProject.projTree.countTypes() self.nRootLabel = QLabel("Root folders:") - self.nRootLabel.setIndent(8) + self.nRootLabel.setIndent(xInd) self.nRootValue = QLabel("{:n}".format(nR)) self.nDirLabel = QLabel("Folders:") - self.nDirLabel.setIndent(8) + self.nDirLabel.setIndent(xInd) self.nDirValue = QLabel("{:n}".format(nD)) self.nFileLabel = QLabel("Documents:") - self.nFileLabel.setIndent(8) + self.nFileLabel.setIndent(xInd) self.nFileValue = QLabel("{:n}".format(nF)) self.wordsLabel = QLabel("Word count:") - self.wordsLabel.setIndent(8) + self.wordsLabel.setIndent(xInd) self.wordsValue = QLabel("{:n}".format(self.theProject.currWCount)) self.mainForm.addWidget(self.headLabel, 0, 0, 1, 2, Qt.AlignTop) @@ -240,8 +247,8 @@ class GuiProjectEditMeta(QWidget): self.mainForm.addWidget(self.wordsLabel, 8, 0, 1, 1, Qt.AlignTop) self.mainForm.addWidget(self.wordsValue, 8, 1, 1, 1, Qt.AlignTop) - self.mainForm.setVerticalSpacing(6) - self.mainForm.setHorizontalSpacing(12) + self.mainForm.setVerticalSpacing(self.mainConf.pxInt(6)) + self.mainForm.setHorizontalSpacing(self.mainConf.pxInt(12)) self.mainForm.setColumnStretch(0, 0) self.mainForm.setColumnStretch(1, 1) self.mainForm.setRowStretch(10, 1) @@ -255,8 +262,10 @@ class GuiProjectEditStatus(QWidget): def __init__(self, theParent, theProject, isStatus): QWidget.__init__(self, theParent) + self.mainConf = nw.CONFIG self.theParent = theParent self.theProject = theProject + self.theTheme = theParent.theTheme if isStatus: self.theStatus = self.theProject.statusItems else: @@ -267,6 +276,8 @@ class GuiProjectEditStatus(QWidget): self.colChanged = False self.selColour = None + self.iPx = self.theTheme.textIconSize + self.outerBox = QVBoxLayout() self.mainBox = QHBoxLayout() self.mainForm = QVBoxLayout() @@ -285,8 +296,8 @@ class GuiProjectEditStatus(QWidget): self.newButton = QPushButton("New") self.delButton = QPushButton("Delete") self.saveButton = QPushButton("Save") - self.colPixmap = QPixmap(16,16) - self.colPixmap.fill(QColor(120,120,120)) + self.colPixmap = QPixmap(self.iPx, self.iPx) + self.colPixmap.fill(QColor(120, 120, 120)) self.colButton = QPushButton(QIcon(self.colPixmap),"Colour") self.colButton.setIconSize(self.colPixmap.rect().size()) @@ -339,7 +350,7 @@ class GuiProjectEditStatus(QWidget): ) if newCol: self.selColour = newCol - colPixmap = QPixmap(16,16) + colPixmap = QPixmap(self.iPx, self.iPx) colPixmap.fill(newCol) self.colButton.setIcon(QIcon(colPixmap)) self.colButton.setIconSize(colPixmap.rect().size()) @@ -348,7 +359,7 @@ class GuiProjectEditStatus(QWidget): def _newItem(self): logger.verbose("New item button clicked") newItem = self._addItem("New Item", (0, 0, 0), None, 0) - newItem.setBackground(QBrush(QColor(0,255,0,80))) + newItem.setBackground(QBrush(QColor(0, 255, 0, 80))) self.colChanged = True return @@ -387,14 +398,14 @@ class GuiProjectEditStatus(QWidget): return def _addItem(self, iName, iCol, oName, nUse): - newIcon = QPixmap(16,16) + newIcon = QPixmap(self.iPx, self.iPx) newIcon.fill(QColor(*iCol)) newItem = QListWidgetItem() newItem.setText("%s [%d]" % (iName, nUse)) newItem.setIcon(QIcon(newIcon)) newItem.setData(Qt.UserRole, len(self.colData)) self.listBox.addItem(newItem) - self.colData.append((iName,iCol[0],iCol[1],iCol[2],oName)) + self.colData.append((iName, iCol[0], iCol[1], iCol[2], oName)) self.colCounts.append(nUse) return newItem @@ -404,8 +415,8 @@ class GuiProjectEditStatus(QWidget): if selItem is not None: selIdx = selItem.data(Qt.UserRole) selVal = self.colData[selIdx] - self.selColour = QColor(selVal[1],selVal[2],selVal[3]) - newIcon = QPixmap(16,16) + self.selColour = QColor(selVal[1], selVal[2], selVal[3]) + newIcon = QPixmap(self.iPx, self.iPx) newIcon.fill(self.selColour) self.editName.setText(selVal[0]) self.colButton.setIcon(QIcon(newIcon)) diff --git a/nw/gui/sessionlog.py b/nw/gui/sessionlog.py index fdda4166..2e31d02f 100644 --- a/nw/gui/sessionlog.py +++ b/nw/gui/sessionlog.py @@ -61,32 +61,26 @@ class GuiSessionLogView(QDialog): self.bottomBox = QHBoxLayout() self.setWindowTitle("Session Log") - self.setMinimumWidth(420) - self.setMinimumHeight(400) + self.setMinimumWidth(self.mainConf.pxInt(420)) + self.setMinimumHeight(self.mainConf.pxInt(400)) - widthCol0 = self.optState.validIntRange( - self.optState.getInt("GuiSession", "widthCol0", 180), 30, 999, 180 - ) - widthCol1 = self.optState.validIntRange( - self.optState.getInt("GuiSession", "widthCol1", 80), 30, 999, 80 - ) - widthCol2 = self.optState.validIntRange( - self.optState.getInt("GuiSession", "widthCol2", 80), 30, 999, 80 - ) + widthCol0 = self.optState.getInt("GuiSession", "widthCol0", self.mainConf.pxInt(180)) + widthCol1 = self.optState.getInt("GuiSession", "widthCol1", self.mainConf.pxInt(80)) + widthCol2 = self.optState.getInt("GuiSession", "widthCol2", self.mainConf.pxInt(80)) self.listBox = QTreeWidget() self.listBox.setHeaderLabels(["Session Start","Length","Words",""]) self.listBox.setIndentation(0) - self.listBox.setColumnWidth(0,widthCol0) - self.listBox.setColumnWidth(1,widthCol1) - self.listBox.setColumnWidth(2,widthCol2) - self.listBox.setColumnWidth(3,0) + self.listBox.setColumnWidth(0, widthCol0) + self.listBox.setColumnWidth(1, widthCol1) + self.listBox.setColumnWidth(2, widthCol2) + self.listBox.setColumnWidth(3, 0) hHeader = self.listBox.headerItem() hHeader.setTextAlignment(1,Qt.AlignRight) hHeader.setTextAlignment(2,Qt.AlignRight) - self.monoFont = QFont("Monospace",10) + self.monoFont = QFont("Monospace", 10) sortValid = (Qt.AscendingOrder, Qt.DescendingOrder) sortCol = self.optState.validIntRange( diff --git a/nw/gui/statusbar.py b/nw/gui/statusbar.py index 129ab9a8..a7fbc342 100644 --- a/nw/gui/statusbar.py +++ b/nw/gui/statusbar.py @@ -66,12 +66,14 @@ class GuiMainStatus(QStatusBar): # Permanent Widgets # ================= + xM = self.mainConf.pxInt(8) + ## The Spell Checker Language self.langIcon = QLabel("") self.langText = QLabel("None") self.langIcon.setPixmap(self.theTheme.getPixmap("status_lang", (iPx, iPx))) self.langIcon.setContentsMargins(0, 0, 0, 0) - self.langText.setContentsMargins(0, 0, 8, 0) + self.langText.setContentsMargins(0, 0, xM, 0) self.addPermanentWidget(self.langIcon) self.addPermanentWidget(self.langText) @@ -79,7 +81,7 @@ class GuiMainStatus(QStatusBar): self.docIcon = StatusLED(colNone, colTrue, colFalse, iPx, iPx, self) self.docText = QLabel("Editor") self.docIcon.setContentsMargins(0, 0, 0, 0) - self.docText.setContentsMargins(0, 0, 8, 0) + self.docText.setContentsMargins(0, 0, xM, 0) self.addPermanentWidget(self.docIcon) self.addPermanentWidget(self.docText) @@ -87,7 +89,7 @@ class GuiMainStatus(QStatusBar): self.projIcon = StatusLED(colNone, colTrue, colFalse, iPx, iPx, self) self.projText = QLabel("Project") self.projIcon.setContentsMargins(0, 0, 0, 0) - self.projText.setContentsMargins(0, 0, 8, 0) + self.projText.setContentsMargins(0, 0, xM, 0) self.addPermanentWidget(self.projIcon) self.addPermanentWidget(self.projText) @@ -96,7 +98,7 @@ class GuiMainStatus(QStatusBar): self.statsText = QLabel("") self.statsIcon.setPixmap(self.theTheme.getPixmap("status_stats", (iPx, iPx))) self.statsIcon.setContentsMargins(0, 0, 0, 0) - self.statsText.setContentsMargins(0, 0, 8, 0) + self.statsText.setContentsMargins(0, 0, xM, 0) self.addPermanentWidget(self.statsIcon) self.addPermanentWidget(self.statsText) diff --git a/nw/guimain.py b/nw/guimain.py index e9d9b81d..c74d4e1c 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -108,15 +108,15 @@ class GuiMain(QMainWindow): # Assemble Main Window self.treePane = QWidget() self.treeBox = QVBoxLayout() - self.treeBox.setContentsMargins(0,0,0,0) + self.treeBox.setContentsMargins(0, 0, 0, 0) self.treeBox.addWidget(self.treeView) self.treeBox.addWidget(self.treeMeta) self.treePane.setLayout(self.treeBox) self.editPane = QWidget() self.docEdit = QVBoxLayout() - self.docEdit.setContentsMargins(0,0,0,0) - self.docEdit.setSpacing(2) + self.docEdit.setContentsMargins(0, 0, 0, 0) + self.docEdit.setSpacing(self.mainConf.pxInt(2)) self.docEdit.addWidget(self.searchBar) self.docEdit.addWidget(self.noticeBar) self.docEdit.addWidget(self.docEditor) @@ -124,8 +124,8 @@ class GuiMain(QMainWindow): self.viewPane = QWidget() self.docView = QVBoxLayout() - self.docView.setContentsMargins(0,0,0,0) - self.docView.setSpacing(2) + self.docView.setContentsMargins(0, 0, 0, 0) + self.docView.setSpacing(self.mainConf.pxInt(2)) self.docView.addWidget(self.docViewer) self.docView.addWidget(self.viewMeta) self.docView.setStretch(0, 1) @@ -148,8 +148,9 @@ class GuiMain(QMainWindow): self.tabWidget.addTab(self.splitOutline, "Outline") self.tabWidget.currentChanged.connect(self._mainTabChanged) + xCM = self.mainConf.pxInt(4) self.splitMain = QSplitter(Qt.Horizontal) - self.splitMain.setContentsMargins(4,4,4,4) + self.splitMain.setContentsMargins(xCM, xCM, xCM, xCM) self.splitMain.setOpaqueResize(False) self.splitMain.addWidget(self.treePane) self.splitMain.addWidget(self.tabWidget) @@ -513,9 +514,9 @@ class GuiMain(QMainWindow): if not self.viewPane.isVisible(): bPos = self.splitMain.sizes() self.viewPane.setVisible(True) - vPos = [0,0] + vPos = [0, 0] vPos[0] = int(bPos[1]/2) - vPos[1] = bPos[1]-vPos[0] + vPos[1] = bPos[1] - vPos[0] self.splitView.setSizes(vPos) self.docViewer.navigateTo(navLink) @@ -877,7 +878,7 @@ class GuiMain(QMainWindow): self.theProject.setLastViewed(None) bPos = self.splitMain.sizes() self.viewPane.setVisible(False) - vPos = [bPos[1],0] + vPos = [bPos[1], 0] self.splitView.setSizes(vPos) return not self.viewPane.isVisible() @@ -988,16 +989,18 @@ class GuiMain(QMainWindow): def _makeStatusIcons(self): self.statusIcons = {} + iPx = self.mainConf.pxInt(32) for sLabel, sCol, _ in self.theProject.statusItems: - theIcon = QPixmap(32,32) + theIcon = QPixmap(iPx, iPx) theIcon.fill(QColor(*sCol)) self.statusIcons[sLabel] = QIcon(theIcon) return def _makeImportIcons(self): self.importIcons = {} + iPx = self.mainConf.pxInt(32) for sLabel, sCol, _ in self.theProject.importItems: - theIcon = QPixmap(32,32) + theIcon = QPixmap(iPx, iPx) theIcon.fill(QColor(*sCol)) self.importIcons[sLabel] = QIcon(theIcon) return