Added PagedDialog base class, and applied it to project settings

This commit is contained in:
Veronica K. B. Olsen
2020-05-17 12:56:58 +02:00
parent cfeadc9b59
commit bd9b40a1ca
4 changed files with 77 additions and 27 deletions
-6
View File
@@ -7,10 +7,6 @@ from nw.gui.mainmenu import GuiMainMenu
from nw.gui.statusbar import GuiMainStatus
from nw.gui.theme import GuiTheme
# Qt Additions
from nw.gui.additions.qconfiglayout import QConfigLayout
from nw.gui.additions.qswitch import QSwitch
# Dialogs
from nw.gui.dialogs.configeditor import GuiConfigEditor
from nw.gui.dialogs.docmerge import GuiDocMerge
@@ -42,8 +38,6 @@ __all__ = [
"GuiMainMenu",
"GuiMainStatus",
"GuiTheme",
"QConfigLayout",
"QSwitch",
"GuiConfigEditor",
"GuiDocMerge",
"GuiDocSplit",
+2
View File
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
from nw.gui.additions.pageddialog import PagedDialog
from nw.gui.additions.qconfiglayout import QConfigLayout
from nw.gui.additions.qswitch import QSwitch
__all__ = [
"PagedDialog",
"QConfigLayout",
"QSwitch",
]
+65
View File
@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
"""novelWriter Paged Dialog
novelWriter Paged Dialog
============================
A custom QDialog with a built-in QTabWidget and vertical tabs.
File History:
Created: 2020-05-17 [0.5.1]
This file is a part of novelWriter
Copyright 2020, Veronica Berglyd Olsen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
import nw
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QVBoxLayout, QTabWidget
)
from nw.constants import nwUnicode
logger = logging.getLogger(__name__)
class PagedDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent=parent)
self._outerBox = QVBoxLayout()
self._innerBox = QHBoxLayout()
self._navBox = QVBoxLayout()
self._tabBox = QTabWidget()
self._outerBox.addLayout(self._innerBox)
self._innerBox.addLayout(self._navBox)
self._innerBox.addWidget(self._tabBox)
self.setLayout(self._outerBox)
return
def addPage(self, tabWidget, tabLabel):
self._tabBox.addTab(tabWidget, tabLabel)
return
def addControls(self, buttonBar):
self._outerBox.addWidget(buttonBar)
return
# END Class PagedDialog
+10 -21
View File
@@ -38,13 +38,14 @@ from PyQt5.QtWidgets import (
)
from nw.constants import nwAlert
from nw.gui.additions import PagedDialog
logger = logging.getLogger(__name__)
class GuiProjectEditor(QDialog):
class GuiProjectEditor(PagedDialog):
def __init__(self, theParent, theProject):
QDialog.__init__(self, theParent)
PagedDialog.__init__(self, theParent)
logger.debug("Initialising ProjectEditor ...")
@@ -52,35 +53,23 @@ class GuiProjectEditor(QDialog):
self.theParent = theParent
self.theProject = theProject
self.outerBox = QHBoxLayout()
self.innerBox = QVBoxLayout()
self.setWindowTitle("Project Settings")
self.guiDeco = self.theParent.theTheme.loadDecoration("settings", (64,64))
self.outerBox.setSpacing(16)
self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.outerBox.addLayout(self.innerBox)
self.setLayout(self.outerBox)
self.theProject.countStatus()
self.setWindowTitle("Project Settings")
self.tabMain = GuiProjectEditMain(self.theParent, self.theProject)
self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject.statusItems)
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject.importItems)
self.tabReplace = GuiProjectEditReplace(self.theParent, self.theProject)
self.tabWidget = QTabWidget()
self.tabWidget.addTab(self.tabMain, "Settings")
self.tabWidget.addTab(self.tabStatus, "Status")
self.tabWidget.addTab(self.tabImport, "Importance")
self.tabWidget.addTab(self.tabReplace,"Auto-Replace")
self.addPage(self.tabMain, "Settings")
self.addPage(self.tabStatus, "Status")
self.addPage(self.tabImport, "Importance")
self.addPage(self.tabReplace,"Auto-Replace")
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.addControls(self.buttonBox)
self.show()