From e0ce894c4f8f9d30b9d0e32e2bc81a77a51263c2 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Mon, 10 Jun 2019 12:48:36 +0200 Subject: [PATCH] Added a config dialog --- nw/gui/configeditor.py | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 nw/gui/configeditor.py diff --git a/nw/gui/configeditor.py b/nw/gui/configeditor.py new file mode 100644 index 00000000..bd440272 --- /dev/null +++ b/nw/gui/configeditor.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +"""novelWriter GUI Config Editor + + novelWriter – GUI Config Editor +================================= + Class holding the config dialog + + File History: + Created: 2019-06-10 [0.1.5] + +""" + +import logging +import nw + +from os import path + +from PyQt5.QtCore import Qt +from PyQt5.QtGui import QIcon, QPixmap, QColor, QBrush, QStandardItemModel +from PyQt5.QtSvg import QSvgWidget +from PyQt5.QtWidgets import ( + QDialog, QHBoxLayout, QVBoxLayout, QFormLayout, QLineEdit, QPlainTextEdit, QLabel, + QWidget, QTabWidget, QDialogButtonBox, QListWidget, QListWidgetItem, QPushButton, + QColorDialog, QAbstractItemView, QTreeWidget, QTreeWidgetItem +) +from nw.enum import nwAlert + +logger = logging.getLogger(__name__) + +class GuiConfigEditor(QDialog): + + def __init__(self, theParent, theProject): + QDialog.__init__(self, theParent) + + logger.debug("Initialising ConfigEditor ...") + + self.mainConf = nw.CONFIG + self.theParent = theParent + self.theProject = theProject + self.outerBox = QHBoxLayout() + self.innerBox = QVBoxLayout() + + self.setWindowTitle("%s Configuration" % nw.__package__) + + self.gradPath = path.abspath(path.join(self.mainConf.appPath,"graphics","block.svg")) + self.svgGradient = QSvgWidget(self.gradPath) + self.svgGradient.setFixedWidth(80) + + self.theProject.countStatus() + self.tabMain = GuiConfigEditGeneral(self.theParent, self.theProject) + + self.tabWidget = QTabWidget() + self.tabWidget.addTab(self.tabMain, "General") + + self.setLayout(self.outerBox) + self.outerBox.addWidget(self.svgGradient) + self.outerBox.addLayout(self.innerBox) + + self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) + self.buttonBox.accepted.connect(self._doSave) + self.buttonBox.rejected.connect(self._doClose) + + self.innerBox.addWidget(self.tabWidget) + self.innerBox.addWidget(self.buttonBox) + + self.show() + + logger.debug("ProjectEditor ConfigEditor complete") + + return + + def _doSave(self): + logger.verbose("ConfigEditor save button clicked") + self.close() + return + + def _doClose(self): + logger.verbose("ConfigEditor close button clicked") + self.close() + return + +# END Class GuiConfigEditor + +class GuiConfigEditGeneral(QWidget): + + def __init__(self, theParent, theProject): + QWidget.__init__(self, theParent) + + self.theParent = theParent + self.theProject = theProject + self.mainForm = QFormLayout() + + self.setLayout(self.mainForm) + + return + +# END Class GuiConfigEditGeneral