Merge pull request #687 from vkbo/gui_tweaks
Make settings layouts more responsive
This commit is contained in:
+1
-2
@@ -167,7 +167,7 @@ def colRange(rgbStart, rgbEnd, nStep):
|
|||||||
cA = rgbStart[c]
|
cA = rgbStart[c]
|
||||||
cB = rgbEnd[c]
|
cB = rgbEnd[c]
|
||||||
dC[c] = (cB-cA)/(nStep-1)
|
dC[c] = (cB-cA)/(nStep-1)
|
||||||
print(dC)
|
|
||||||
retCol = [rgbStart]
|
retCol = [rgbStart]
|
||||||
for n in range(nStep):
|
for n in range(nStep):
|
||||||
if n > 0 and n < nStep:
|
if n > 0 and n < nStep:
|
||||||
@@ -177,7 +177,6 @@ def colRange(rgbStart, rgbEnd, nStep):
|
|||||||
int(retCol[n-1][2] + dC[2]),
|
int(retCol[n-1][2] + dC[2]),
|
||||||
])
|
])
|
||||||
retCol[-1] = rgbEnd
|
retCol[-1] = rgbEnd
|
||||||
print(retCol)
|
|
||||||
|
|
||||||
return retCol
|
return retCol
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ class Config:
|
|||||||
|
|
||||||
## Sizes
|
## Sizes
|
||||||
self.winGeometry = [1200, 650]
|
self.winGeometry = [1200, 650]
|
||||||
|
self.prefGeometry = [700, 615]
|
||||||
self.treeColWidth = [200, 50, 30]
|
self.treeColWidth = [200, 50, 30]
|
||||||
self.novelColWidth = [200, 50]
|
self.novelColWidth = [200, 50]
|
||||||
self.projColWidth = [200, 60, 140]
|
self.projColWidth = [200, 60, 140]
|
||||||
@@ -472,6 +473,9 @@ class Config:
|
|||||||
self.winGeometry = self._parseLine(
|
self.winGeometry = self._parseLine(
|
||||||
cnfParse, cnfSec, "geometry", self.CNF_I_LST, self.winGeometry
|
cnfParse, cnfSec, "geometry", self.CNF_I_LST, self.winGeometry
|
||||||
)
|
)
|
||||||
|
self.prefGeometry = self._parseLine(
|
||||||
|
cnfParse, cnfSec, "preferences", self.CNF_I_LST, self.prefGeometry
|
||||||
|
)
|
||||||
self.treeColWidth = self._parseLine(
|
self.treeColWidth = self._parseLine(
|
||||||
cnfParse, cnfSec, "treecols", self.CNF_I_LST, self.treeColWidth
|
cnfParse, cnfSec, "treecols", self.CNF_I_LST, self.treeColWidth
|
||||||
)
|
)
|
||||||
@@ -701,6 +705,7 @@ class Config:
|
|||||||
cnfSec = "Sizes"
|
cnfSec = "Sizes"
|
||||||
cnfParse.add_section(cnfSec)
|
cnfParse.add_section(cnfSec)
|
||||||
cnfParse.set(cnfSec, "geometry", self._packList(self.winGeometry))
|
cnfParse.set(cnfSec, "geometry", self._packList(self.winGeometry))
|
||||||
|
cnfParse.set(cnfSec, "preferences", self._packList(self.prefGeometry))
|
||||||
cnfParse.set(cnfSec, "treecols", self._packList(self.treeColWidth))
|
cnfParse.set(cnfSec, "treecols", self._packList(self.treeColWidth))
|
||||||
cnfParse.set(cnfSec, "novelcols", self._packList(self.novelColWidth))
|
cnfParse.set(cnfSec, "novelcols", self._packList(self.novelColWidth))
|
||||||
cnfParse.set(cnfSec, "projcols", self._packList(self.projColWidth))
|
cnfParse.set(cnfSec, "projcols", self._packList(self.projColWidth))
|
||||||
@@ -921,6 +926,12 @@ class Config:
|
|||||||
self.confChanged = True
|
self.confChanged = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def setPreferencesSize(self, newWidth, newHeight):
|
||||||
|
self.prefGeometry[0] = int(newWidth/self.guiScale)
|
||||||
|
self.prefGeometry[1] = int(newHeight/self.guiScale)
|
||||||
|
self.confChanged = True
|
||||||
|
return True
|
||||||
|
|
||||||
def setTreeColWidths(self, colWidths):
|
def setTreeColWidths(self, colWidths):
|
||||||
self.treeColWidth = [int(x/self.guiScale) for x in colWidths]
|
self.treeColWidth = [int(x/self.guiScale) for x in colWidths]
|
||||||
self.confChanged = True
|
self.confChanged = True
|
||||||
@@ -984,6 +995,9 @@ class Config:
|
|||||||
def getWinSize(self):
|
def getWinSize(self):
|
||||||
return [int(x*self.guiScale) for x in self.winGeometry]
|
return [int(x*self.guiScale) for x in self.winGeometry]
|
||||||
|
|
||||||
|
def getPreferencesSize(self):
|
||||||
|
return [int(x*self.guiScale) for x in self.prefGeometry]
|
||||||
|
|
||||||
def getTreeColWidths(self):
|
def getTreeColWidths(self):
|
||||||
return [int(x*self.guiScale) for x in self.treeColWidth]
|
return [int(x*self.guiScale) for x in self.treeColWidth]
|
||||||
|
|
||||||
|
|||||||
+19
-4
@@ -36,7 +36,8 @@ from PyQt5.QtCore import (
|
|||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QGridLayout, QLabel, QWidget, QVBoxLayout, QHBoxLayout, QSizePolicy,
|
QGridLayout, QLabel, QWidget, QVBoxLayout, QHBoxLayout, QSizePolicy,
|
||||||
QAbstractButton, QDialog, QTabWidget, QTabBar, QStyle, QDialogButtonBox,
|
QAbstractButton, QDialog, QTabWidget, QTabBar, QStyle, QDialogButtonBox,
|
||||||
QStylePainter, QStyleOptionTab, QListWidget, QListWidgetItem, QFrame
|
QStylePainter, QStyleOptionTab, QListWidget, QListWidgetItem, QFrame,
|
||||||
|
QLineEdit
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.constants import trConst, nwUnicode, nwQuotes
|
from nw.constants import trConst, nwUnicode, nwQuotes
|
||||||
@@ -61,6 +62,7 @@ class QConfigLayout(QGridLayout):
|
|||||||
wSp = nw.CONFIG.pxInt(8)
|
wSp = nw.CONFIG.pxInt(8)
|
||||||
self.setHorizontalSpacing(wSp)
|
self.setHorizontalSpacing(wSp)
|
||||||
self.setVerticalSpacing(wSp)
|
self.setVerticalSpacing(wSp)
|
||||||
|
self.setColumnStretch(0, 1)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -151,6 +153,7 @@ class QConfigLayout(QGridLayout):
|
|||||||
labelBox.addWidget(qLabel)
|
labelBox.addWidget(qLabel)
|
||||||
labelBox.addWidget(qHelp)
|
labelBox.addWidget(qHelp)
|
||||||
labelBox.setSpacing(0)
|
labelBox.setSpacing(0)
|
||||||
|
labelBox.addStretch(1)
|
||||||
|
|
||||||
thisEntry["help"] = qHelp
|
thisEntry["help"] = qHelp
|
||||||
self.addLayout(labelBox, self._nextRow, 0, 1, 1, Qt.AlignLeft | Qt.AlignTop)
|
self.addLayout(labelBox, self._nextRow, 0, 1, 1, Qt.AlignLeft | Qt.AlignTop)
|
||||||
@@ -163,15 +166,22 @@ class QConfigLayout(QGridLayout):
|
|||||||
controlBox.addWidget(qWidget, 0, Qt.AlignVCenter)
|
controlBox.addWidget(qWidget, 0, Qt.AlignVCenter)
|
||||||
controlBox.addWidget(QLabel(theUnit), 0, Qt.AlignVCenter)
|
controlBox.addWidget(QLabel(theUnit), 0, Qt.AlignVCenter)
|
||||||
controlBox.setSpacing(wSp)
|
controlBox.setSpacing(wSp)
|
||||||
self.addLayout(controlBox, self._nextRow, 1, 1, 1, Qt.AlignRight | Qt.AlignVCenter)
|
self.addLayout(controlBox, self._nextRow, 1, 1, 1, Qt.AlignRight | Qt.AlignTop)
|
||||||
|
|
||||||
elif theButton is not None:
|
elif theButton is not None:
|
||||||
controlBox = QHBoxLayout()
|
controlBox = QHBoxLayout()
|
||||||
controlBox.addWidget(qWidget, 0, Qt.AlignVCenter)
|
controlBox.addWidget(qWidget, 0, Qt.AlignVCenter)
|
||||||
controlBox.addWidget(theButton, 0, Qt.AlignVCenter)
|
controlBox.addWidget(theButton, 0, Qt.AlignVCenter)
|
||||||
controlBox.setSpacing(wSp)
|
controlBox.setSpacing(wSp)
|
||||||
self.addLayout(controlBox, self._nextRow, 1, 1, 1, Qt.AlignRight | Qt.AlignVCenter)
|
self.addLayout(controlBox, self._nextRow, 1, 1, 1, Qt.AlignRight | Qt.AlignTop)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.addWidget(qWidget, self._nextRow, 1, 1, 1, Qt.AlignRight | Qt.AlignVCenter)
|
if isinstance(theWidget, QLineEdit):
|
||||||
|
qLayout = QHBoxLayout()
|
||||||
|
qLayout.addWidget(theWidget)
|
||||||
|
self.addLayout(qLayout, self._nextRow, 1, 1, 1, Qt.AlignRight | Qt.AlignTop)
|
||||||
|
else:
|
||||||
|
self.addWidget(qWidget, self._nextRow, 1, 1, 1, Qt.AlignRight | Qt.AlignTop)
|
||||||
|
|
||||||
qLabel.setBuddy(qWidget)
|
qLabel.setBuddy(qWidget)
|
||||||
|
|
||||||
@@ -207,6 +217,9 @@ class QHelpLabel(QLabel):
|
|||||||
lblFont.setPointSizeF(fontSize*lblFont.pointSizeF())
|
lblFont.setPointSizeF(fontSize*lblFont.pointSizeF())
|
||||||
self.setFont(lblFont)
|
self.setFont(lblFont)
|
||||||
|
|
||||||
|
self.setWordWrap(True)
|
||||||
|
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class QHelpLabel
|
# END Class QHelpLabel
|
||||||
@@ -409,6 +422,7 @@ class VerticalTabBar(QTabBar):
|
|||||||
|
|
||||||
def __init__(self, theParent=None):
|
def __init__(self, theParent=None):
|
||||||
QTabBar.__init__(self, parent=theParent)
|
QTabBar.__init__(self, parent=theParent)
|
||||||
|
self._mW = nw.CONFIG.pxInt(150)
|
||||||
return
|
return
|
||||||
|
|
||||||
def tabSizeHint(self, theIndex):
|
def tabSizeHint(self, theIndex):
|
||||||
@@ -416,6 +430,7 @@ class VerticalTabBar(QTabBar):
|
|||||||
"""
|
"""
|
||||||
tSize = QTabBar.tabSizeHint(self, theIndex)
|
tSize = QTabBar.tabSizeHint(self, theIndex)
|
||||||
tSize.transpose()
|
tSize.transpose()
|
||||||
|
tSize.setWidth(min(tSize.width(), self._mW))
|
||||||
return tSize
|
return tSize
|
||||||
|
|
||||||
def paintEvent(self, theEvent):
|
def paintEvent(self, theEvent):
|
||||||
|
|||||||
+17
-1
@@ -74,12 +74,14 @@ class GuiPreferences(PagedDialog):
|
|||||||
self.buttonBox.rejected.connect(self._doClose)
|
self.buttonBox.rejected.connect(self._doClose)
|
||||||
self.addControls(self.buttonBox)
|
self.addControls(self.buttonBox)
|
||||||
|
|
||||||
|
self.resize(*self.mainConf.getPreferencesSize())
|
||||||
|
|
||||||
logger.debug("GuiPreferences initialisation complete")
|
logger.debug("GuiPreferences initialisation complete")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Buttons
|
# Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
def _doSave(self):
|
def _doSave(self):
|
||||||
@@ -102,6 +104,7 @@ class GuiPreferences(PagedDialog):
|
|||||||
nwAlert.INFO
|
nwAlert.INFO
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._saveWindowSize()
|
||||||
self.accept()
|
self.accept()
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -109,9 +112,22 @@ class GuiPreferences(PagedDialog):
|
|||||||
def _doClose(self):
|
def _doClose(self):
|
||||||
"""Close the preferences without saving the changes.
|
"""Close the preferences without saving the changes.
|
||||||
"""
|
"""
|
||||||
|
self._saveWindowSize()
|
||||||
self.reject()
|
self.reject()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Internal Functions
|
||||||
|
##
|
||||||
|
|
||||||
|
def _saveWindowSize(self):
|
||||||
|
"""Save the dialog window size.
|
||||||
|
"""
|
||||||
|
winWidth = self.mainConf.rpxInt(self.width())
|
||||||
|
winHeight = self.mainConf.rpxInt(self.height())
|
||||||
|
self.mainConf.setPreferencesSize(winWidth, winHeight)
|
||||||
|
return
|
||||||
|
|
||||||
# END Class GuiPreferences
|
# END Class GuiPreferences
|
||||||
|
|
||||||
class GuiPreferencesGeneral(QWidget):
|
class GuiPreferencesGeneral(QWidget):
|
||||||
|
|||||||
+7
-10
@@ -169,11 +169,11 @@ class GuiProjectEditMain(QWidget):
|
|||||||
self.mainForm.addGroupLabel(self.tr("Project Settings"))
|
self.mainForm.addGroupLabel(self.tr("Project Settings"))
|
||||||
|
|
||||||
xW = self.mainConf.pxInt(250)
|
xW = self.mainConf.pxInt(250)
|
||||||
xH = self.mainConf.pxInt(100)
|
xH = self.mainConf.pxInt(80)
|
||||||
|
|
||||||
self.editName = QLineEdit()
|
self.editName = QLineEdit()
|
||||||
self.editName.setMaxLength(200)
|
self.editName.setMaxLength(200)
|
||||||
self.editName.setFixedWidth(xW)
|
self.editName.setMaximumWidth(xW)
|
||||||
self.editName.setText(self.theProject.projName)
|
self.editName.setText(self.theProject.projName)
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
self.tr("Working title"),
|
self.tr("Working title"),
|
||||||
@@ -183,7 +183,7 @@ class GuiProjectEditMain(QWidget):
|
|||||||
|
|
||||||
self.editTitle = QLineEdit()
|
self.editTitle = QLineEdit()
|
||||||
self.editTitle.setMaxLength(200)
|
self.editTitle.setMaxLength(200)
|
||||||
self.editTitle.setFixedWidth(xW)
|
self.editTitle.setMaximumWidth(xW)
|
||||||
self.editTitle.setText(self.theProject.bookTitle)
|
self.editTitle.setText(self.theProject.bookTitle)
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
self.tr("Novel title"),
|
self.tr("Novel title"),
|
||||||
@@ -192,12 +192,9 @@ class GuiProjectEditMain(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.editAuthors = QPlainTextEdit()
|
self.editAuthors = QPlainTextEdit()
|
||||||
bookAuthors = ""
|
self.editAuthors.setMinimumHeight(xH)
|
||||||
for bookAuthor in self.theProject.bookAuthors:
|
self.editAuthors.setMaximumWidth(xW)
|
||||||
bookAuthors += bookAuthor+"\n"
|
self.editAuthors.setPlainText("\n".join(self.theProject.bookAuthors))
|
||||||
self.editAuthors.setPlainText(bookAuthors)
|
|
||||||
self.editAuthors.setFixedHeight(xH)
|
|
||||||
self.editAuthors.setFixedWidth(xW)
|
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
self.tr("Author(s)"),
|
self.tr("Author(s)"),
|
||||||
self.editAuthors,
|
self.editAuthors,
|
||||||
@@ -205,7 +202,7 @@ class GuiProjectEditMain(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.spellLang = QComboBox(self)
|
self.spellLang = QComboBox(self)
|
||||||
self.spellLang.setFixedWidth(xW)
|
self.spellLang.setMaximumWidth(xW)
|
||||||
theDict = self.theParent.docEditor.theDict
|
theDict = self.theParent.docEditor.theDict
|
||||||
self.spellLang.addItem(self.tr("Default"), "None")
|
self.spellLang.addItem(self.tr("Default"), "None")
|
||||||
if theDict is not None:
|
if theDict is not None:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ guilang = en-GB
|
|||||||
|
|
||||||
[Sizes]
|
[Sizes]
|
||||||
geometry = 1200, 650
|
geometry = 1200, 650
|
||||||
|
preferences = 700, 615
|
||||||
treecols = 200, 50, 30
|
treecols = 200, 50, 30
|
||||||
novelcols = 200, 50
|
novelcols = 200, 50
|
||||||
projcols = 200, 60, 140
|
projcols = 200, 60, 140
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ guilang = en-GB
|
|||||||
|
|
||||||
[Sizes]
|
[Sizes]
|
||||||
geometry = 1200, 650
|
geometry = 1200, 650
|
||||||
|
preferences = 700, 615
|
||||||
treecols = 200, 50, 30
|
treecols = 200, 50, 30
|
||||||
novelcols = 200, 50
|
novelcols = 200, 50
|
||||||
projcols = 200, 60, 140
|
projcols = 200, 60, 140
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ def testGuiProjSettings_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj, outDi
|
|||||||
|
|
||||||
assert projEdit.tabMain.editName.text() == "New Project"
|
assert projEdit.tabMain.editName.text() == "New Project"
|
||||||
assert projEdit.tabMain.editTitle.text() == ""
|
assert projEdit.tabMain.editTitle.text() == ""
|
||||||
assert projEdit.tabMain.editAuthors.toPlainText() == "Jane Smith\nJohn Smith\n"
|
assert projEdit.tabMain.editAuthors.toPlainText() == "Jane Smith\nJohn Smith"
|
||||||
assert projEdit.tabMain.spellLang.currentData() == "en"
|
assert projEdit.tabMain.spellLang.currentData() == "en"
|
||||||
assert projEdit.tabMain.doBackup.isChecked() is False
|
assert projEdit.tabMain.doBackup.isChecked() is False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user