Merge pull request #300 from vkbo/various_fixes

Various fixes
This commit is contained in:
Veronica K. Berglyd Olsen
2020-06-08 19:03:25 +02:00
committed by GitHub
6 changed files with 58 additions and 35 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ Synopsis Feature
The "Synopsis" column of the Outline View takes its information from a specially formatted comment.
In order to flag a comment as a Synopsis, add the word "Synopsis:" as the first word of the comment.
The ";" is required, and "synopsis" is not case sensitive.
The ":" is required, and "synopsis" is not case sensitive.
If it is correctly formatted, the syntax highlighter will indicate this by altering the colour of the word.
.. note::
+12 -6
View File
@@ -309,11 +309,14 @@ class Config:
"""Load preferences from file and replace default settings.
"""
logger.debug("Loading config file")
if self.confPath is None:
return False
cnfParse = configparser.ConfigParser()
cnfPath = path.join(self.confPath, self.confFile)
try:
cnfParse.read_file(
open(path.join(self.confPath,self.confFile),mode="r",encoding="utf8")
)
with open(cnfPath, mode="r", encoding="utf8") as inFile:
cnfParse.read_file(inFile)
except Exception as e:
logger.error("Could not load config file")
logger.error(str(e))
@@ -484,6 +487,9 @@ class Config:
"""Save the current preferences to file.
"""
logger.debug("Saving config file")
if self.confPath is None:
return False
cnfParse = configparser.ConfigParser()
# Set options
@@ -562,10 +568,10 @@ class Config:
cnfParse.set(cnfSec,"lastpath", str(self.lastPath))
# Write config file
cnfPath = path.join(self.confPath, self.confFile)
try:
cnfParse.write(
open(path.join(self.confPath, self.confFile), mode="w", encoding="utf8")
)
with open(cnfPath, mode="w", encoding="utf8") as outFile:
cnfParse.write(outFile)
self.confChanged = False
except Exception as e:
logger.error("Could not save config file")
+18 -15
View File
@@ -187,8 +187,12 @@ class GuiDocTitleBar(QWidget):
self.thePalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack))
self.thePalette.setColor(QPalette.Text, QColor(*self.theTheme.colText))
fPx = int(0.9*self.theTheme.fontPixelSize)
hSp = self.mainConf.pxInt(6)
self.buttonSize = fPx + hSp
# Main Widget Settings
self.setContentsMargins(0, 0, 0, 0)
self.setContentsMargins(2*self.buttonSize, 0, 0, 0)
self.setAutoFillBackground(True)
self.setPalette(self.thePalette)
@@ -197,10 +201,10 @@ class GuiDocTitleBar(QWidget):
self.theTitle.setText("")
self.theTitle.setIndent(0)
self.theTitle.setMargin(0)
self.theTitle.setContentsMargins(10, 0, 0, 0)
self.theTitle.setContentsMargins(0, 0, 0, 0)
self.theTitle.setAutoFillBackground(True)
self.theTitle.setAlignment(Qt.AlignCenter)
self.theTitle.setWordWrap(True)
self.theTitle.setAlignment(Qt.AlignHCenter | Qt.AlignTop)
self.theTitle.setFixedHeight(fPx)
self.theTitle.setFrameShape(QFrame.NoFrame)
self.theTitle.setLineWidth(0)
self.theTitle.setPalette(self.thePalette)
@@ -210,13 +214,11 @@ class GuiDocTitleBar(QWidget):
self.theTitle.setFont(lblFont)
# Buttons
iPx = self.theTheme.textIconSize
self.closeButton = QPushButton("")
self.closeButton.setIcon(self.theTheme.getIcon("close"))
self.closeButton.setContentsMargins(0, 0, 0, 0)
self.closeButton.setIconSize(QSize(iPx, iPx))
self.closeButton.setFixedSize(iPx, iPx)
self.closeButton.setIconSize(QSize(fPx, fPx))
self.closeButton.setFixedSize(fPx, fPx)
self.closeButton.setFlat(True)
self.closeButton.setVisible(False)
self.closeButton.clicked.connect(self._closeDocument)
@@ -225,8 +227,8 @@ class GuiDocTitleBar(QWidget):
self.minmaxButton = QPushButton("")
self.minmaxButton.setIcon(self.theTheme.getIcon("maximise"))
self.minmaxButton.setContentsMargins(0, 0, 0, 0)
self.minmaxButton.setIconSize(QSize(iPx, iPx))
self.minmaxButton.setFixedSize(iPx, iPx)
self.minmaxButton.setIconSize(QSize(fPx, fPx))
self.minmaxButton.setFixedSize(fPx, fPx)
self.minmaxButton.setFlat(True)
self.minmaxButton.setVisible(False)
self.minmaxButton.clicked.connect(self._minmaxDocument)
@@ -234,17 +236,15 @@ class GuiDocTitleBar(QWidget):
self.refreshButton = QPushButton("")
self.refreshButton.setIcon(self.theTheme.getIcon("refresh"))
self.refreshButton.setContentsMargins(0, 0, 0, 0)
self.refreshButton.setIconSize(QSize(iPx, iPx))
self.refreshButton.setFixedSize(iPx, iPx)
self.refreshButton.setIconSize(QSize(fPx, fPx))
self.refreshButton.setFixedSize(fPx, fPx)
self.refreshButton.setFlat(True)
self.refreshButton.setVisible(False)
self.refreshButton.clicked.connect(self._refreshDocument)
# Assemble Layout
hSp = self.mainConf.pxInt(6)
self.outerBox = QHBoxLayout()
self.outerBox.setSpacing(hSp)
self.outerBox.addSpacing(2*(iPx + hSp))
self.outerBox.addWidget(self.theTitle, 1)
if self.isEditor:
self.outerBox.addWidget(self.minmaxButton, 0)
@@ -315,11 +315,14 @@ class GuiDocTitleBar(QWidget):
"""Switch on or off zen mode.
"""
self.theParent.theParent.toggleZenMode()
self.closeButton.setVisible(not self.theParent.theParent.isZenMode)
if self.theParent.theParent.isZenMode:
self.minmaxButton.setIcon(self.theTheme.getIcon("minimise"))
self.setContentsMargins(self.buttonSize, 0, 0, 0)
self.closeButton.setVisible(False)
else:
self.minmaxButton.setIcon(self.theTheme.getIcon("maximise"))
self.setContentsMargins(2*self.buttonSize, 0, 0, 0)
self.closeButton.setVisible(True)
return
def _refreshDocument(self):
+8 -6
View File
@@ -314,12 +314,14 @@ class GuiDocEditor(QTextEdit):
just ensure the margins are set correctly.
"""
cM = self.mainConf.getTextMargin()
vBar = self.verticalScrollBar()
if vBar.isVisible():
sW = vBar.width()
else:
sW = 0
if self.mainConf.textFixedW or self.theParent.isZenMode:
vBar = self.verticalScrollBar()
if vBar.isVisible():
sW = vBar.width()
else:
sW = 0
if self.theParent.isZenMode:
tW = self.mainConf.getZenWidth()
else:
@@ -332,7 +334,7 @@ class GuiDocEditor(QTextEdit):
tM = cM
tB = self.lineWidth()
tW = self.width() - 2*tB
tW = self.width() - 2*tB - sW
tH = self.docTitle.height()
tT = cM - tH
self.docTitle.setGeometry(tB, tB, tW, tH)
+7 -1
View File
@@ -224,8 +224,14 @@ class GuiDocViewer(QTextBrowser):
Config.textFixedW is enabled or we're in Zen mode. Otherwise,
just ensure the margins are set correctly.
"""
vBar = self.verticalScrollBar()
if vBar.isVisible():
sW = vBar.width()
else:
sW = 0
tB = self.lineWidth()
tW = self.width() - 2*tB
tW = self.width() - 2*tB - sW
tH = self.docTitle.height()
tT = self.mainConf.getTextMargin() - tH
self.docTitle.setGeometry(tB, tB, tW, tH)
+12 -6
View File
@@ -265,7 +265,8 @@ class GuiTheme:
# Config File
confParser = configparser.ConfigParser()
try:
confParser.read_file(open(self.confFile,mode="r",encoding="utf8"))
with open(self.confFile, mode="r", encoding="utf8") as inFile:
confParser.read_file(inFile)
except Exception as e:
logger.error("Could not load theme settings from: %s" % self.confFile)
return False
@@ -319,7 +320,8 @@ class GuiTheme:
confParser = configparser.ConfigParser()
try:
confParser.read_file(open(self.syntaxFile, mode="r", encoding="utf8"))
with open(self.syntaxFile, mode="r", encoding="utf8") as inFile:
confParser.read_file(inFile)
except Exception as e:
logger.error("Could not load syntax colours from: %s" % self.syntaxFile)
return False
@@ -370,7 +372,8 @@ class GuiTheme:
themeConf = path.join(self.mainConf.themeRoot, self.guiPath, themeDir, self.confName)
logger.verbose("Checking theme config for '%s'" % themeDir)
try:
confParser.read_file(open(themeConf, mode="r", encoding="utf8"))
with open(themeConf, mode="r", encoding="utf8") as inFile:
confParser.read_file(inFile)
except Exception as e:
self.theParent.makeAlert(
["Could not load theme config file.",str(e)], nwAlert.ERROR
@@ -402,7 +405,8 @@ class GuiTheme:
continue
logger.verbose("Checking theme syntax for '%s'" % syntaxFile)
try:
confParser.read_file(open(syntaxPath, mode="r", encoding="utf8"))
with open(syntaxPath, mode="r", encoding="utf8") as inFile:
confParser.read_file(inFile)
except Exception as e:
self.theParent.makeAlert(
["Could not load syntax file.",str(e)], nwAlert.ERROR
@@ -588,7 +592,8 @@ class GuiIcons:
# Config File
confParser = configparser.ConfigParser()
try:
confParser.read_file(open(self.confFile, mode="r", encoding="utf8"))
with open(self.confFile, mode="r", encoding="utf8") as inFile:
confParser.read_file(inFile)
except Exception as e:
logger.error("Could not load icon theme settings from: %s" % self.confFile)
return False
@@ -682,7 +687,8 @@ class GuiIcons:
themeConf = path.join(themePath, self.confName)
logger.verbose("Checking icon theme config for '%s'" % themeDir)
try:
confParser.read_file(open(themeConf, mode="r", encoding="utf8"))
with open(themeConf, mode="r", encoding="utf8") as inFile:
confParser.read_file(inFile)
except Exception as e:
self.theParent.makeAlert(
["Could not load theme config file.",str(e)], nwAlert.ERROR