Using two splitters instead of one to make positioning easier.
This commit is contained in:
+13
-2
@@ -48,7 +48,8 @@ class Config:
|
||||
self.guiTheme = "default"
|
||||
self.winGeometry = [1100, 650]
|
||||
self.treeColWidth = [120, 30, 50]
|
||||
self.mainPanePos = [300, 400, 400]
|
||||
self.mainPanePos = [300, 800]
|
||||
self.docPanePos = [400, 400]
|
||||
|
||||
## Project
|
||||
self.autoSaveProj = 60
|
||||
@@ -138,7 +139,11 @@ class Config:
|
||||
)
|
||||
if confParser.has_option(cnfSec,"mainpane"):
|
||||
self.mainPanePos = self.unpackList(
|
||||
confParser.get(cnfSec,"mainpane"), 3, self.mainPanePos
|
||||
confParser.get(cnfSec,"mainpane"), 2, self.mainPanePos
|
||||
)
|
||||
if confParser.has_option(cnfSec,"docpane"):
|
||||
self.docPanePos = self.unpackList(
|
||||
confParser.get(cnfSec,"docpane"), 2, self.docPanePos
|
||||
)
|
||||
|
||||
## Project
|
||||
@@ -206,6 +211,7 @@ class Config:
|
||||
confParser.set(cnfSec,"geometry", self.packList(self.winGeometry))
|
||||
confParser.set(cnfSec,"treecols", self.packList(self.treeColWidth))
|
||||
confParser.set(cnfSec,"mainpane", self.packList(self.mainPanePos))
|
||||
confParser.set(cnfSec,"docpane", self.packList(self.docPanePos))
|
||||
|
||||
## Project
|
||||
cnfSec = "Project"
|
||||
@@ -298,4 +304,9 @@ class Config:
|
||||
self.confChanged = True
|
||||
return True
|
||||
|
||||
def setDocPanePos(self, panePos):
|
||||
self.docPanePos = panePos
|
||||
self.confChanged = True
|
||||
return True
|
||||
|
||||
# End Class Config
|
||||
|
||||
+16
-14
@@ -70,27 +70,29 @@ class GuiMain(QMainWindow):
|
||||
self.treeBox.addWidget(self.docDetails)
|
||||
self.treePane.setLayout(self.treeBox)
|
||||
|
||||
self.splitView = QSplitter(Qt.Horizontal)
|
||||
self.splitView.addWidget(self.docEditor)
|
||||
self.splitView.addWidget(self.docViewer)
|
||||
|
||||
self.splitMain = QSplitter(Qt.Horizontal)
|
||||
self.splitMain.addWidget(self.treePane)
|
||||
self.splitMain.addWidget(self.docEditor)
|
||||
self.splitMain.addWidget(self.docViewer)
|
||||
self.splitMain.addWidget(self.splitView)
|
||||
self.splitMain.setSizes(self.mainConf.mainPanePos)
|
||||
self.splitMain.splitterMoved.connect(self._splitMainMove)
|
||||
|
||||
self.setCentralWidget(self.splitMain)
|
||||
|
||||
self.idxTree = self.splitMain.indexOf(self.treePane)
|
||||
self.idxEditor = self.splitMain.indexOf(self.docEditor)
|
||||
self.idxViewer = self.splitMain.indexOf(self.docViewer)
|
||||
self.idxMain = self.splitMain.indexOf(self.splitView)
|
||||
self.idxEditor = self.splitView.indexOf(self.docEditor)
|
||||
self.idxViewer = self.splitView.indexOf(self.docViewer)
|
||||
|
||||
self.splitMain.setCollapsible(self.idxTree, False)
|
||||
self.splitMain.setCollapsible(self.idxEditor, False)
|
||||
self.splitMain.setCollapsible(self.idxViewer, True)
|
||||
self.splitMain.setCollapsible(self.idxMain, False)
|
||||
self.splitView.setCollapsible(self.idxEditor, False)
|
||||
self.splitView.setCollapsible(self.idxViewer, True)
|
||||
|
||||
self.docViewer.setVisible(False)
|
||||
pPos = self.mainConf.mainPanePos
|
||||
tPos = [pPos[0], pPos[1]+pPos[2]]
|
||||
self.splitMain.setSizes(tPos)
|
||||
|
||||
# Build GUI Elements
|
||||
self.treeView.itemSelectionChanged.connect(self._treeSingleClick)
|
||||
@@ -260,11 +262,10 @@ class GuiMain(QMainWindow):
|
||||
|
||||
bPos = self.splitMain.sizes()
|
||||
self.docViewer.setVisible(True)
|
||||
if bPos[2] == 0:
|
||||
bWidth = bPos[1]+bPos[2]
|
||||
bPos[1] = int(bWidth/2)
|
||||
bPos[2] = bWidth-bPos[1]
|
||||
self.splitMain.setSizes(bPos)
|
||||
vPos = [0,0]
|
||||
vPos[0] = int(bPos[1]/2)
|
||||
vPos[1] = bPos[1]-vPos[0]
|
||||
self.splitView.setSizes(vPos)
|
||||
self.docEditor.changeWidth()
|
||||
|
||||
return True
|
||||
@@ -346,6 +347,7 @@ class GuiMain(QMainWindow):
|
||||
self.mainConf.setWinSize(self.width(), self.height())
|
||||
self.mainConf.setTreeColWidths(self.treeView.getColumnSizes())
|
||||
self.mainConf.setMainPanePos(self.splitMain.sizes())
|
||||
self.mainConf.setDocPanePos(self.splitView.sizes())
|
||||
self.mainConf.saveConfig()
|
||||
return
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<novelWriterXML appVersion="0.1.3" fileVersion="1.0" timeStamp="2019-05-18 18:12:49">
|
||||
<novelWriterXML appVersion="0.1.3" fileVersion="1.0" timeStamp="2019-05-18 19:29:51">
|
||||
<project>
|
||||
<name>Sample Project</name>
|
||||
<title>Sample Project</title>
|
||||
|
||||
@@ -4,7 +4,8 @@ timestamp = 2019-05-18 15:06:44
|
||||
[Sizes]
|
||||
geometry = 1100, 650
|
||||
treecols = 120, 30, 50
|
||||
mainpane = 300, 400, 400
|
||||
mainpane = 300, 800
|
||||
docpane = 400, 400
|
||||
|
||||
[Project]
|
||||
autosaveproject = 60
|
||||
|
||||
@@ -70,7 +70,8 @@ def testConfigSetMainPanePos(nwTemp,nwRef):
|
||||
refConf = path.join(nwRef, "novelwriter.conf")
|
||||
assert theConf.setMainPanePos([0, 0])
|
||||
assert theConf.confChanged
|
||||
assert theConf.setMainPanePos([300, 400, 400])
|
||||
assert theConf.setMainPanePos([300, 800])
|
||||
assert theConf.setDocPanePos([400, 400])
|
||||
assert theConf.saveConfig()
|
||||
assert cmpFiles(tmpConf, refConf, [2])
|
||||
assert not theConf.confChanged
|
||||
|
||||
Reference in New Issue
Block a user