Remove main gui inheritance in manuscript tools
This commit is contained in:
@@ -28,16 +28,15 @@ import logging
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import time
|
from time import time
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
from PyQt5.QtCore import QTimer, QUrl, Qt, pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import Qt, QTimer, QUrl, pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtGui import QCloseEvent, QColor, QCursor, QFont, QPalette, QResizeEvent
|
from PyQt5.QtGui import QCloseEvent, QColor, QCursor, QFont, QPalette, QResizeEvent
|
||||||
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
|
from PyQt5.QtPrintSupport import QPrinter, QPrintPreviewDialog
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView, QApplication, QDialog, QFormLayout, QGridLayout,
|
QAbstractItemView, QApplication, QDialog, QFormLayout, QGridLayout,
|
||||||
QHBoxLayout, QLabel, QListWidget, QListWidgetItem, QPushButton,
|
QHBoxLayout, QLabel, QListWidget, QListWidgetItem, QPushButton, QSplitter,
|
||||||
QSplitter, QStackedWidget, QTabWidget, QTextBrowser, QTreeWidget,
|
QStackedWidget, QTabWidget, QTextBrowser, QTreeWidget, QTreeWidgetItem,
|
||||||
QTreeWidgetItem, QVBoxLayout, QWidget
|
QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG, SHARED
|
from novelwriter import CONFIG, SHARED
|
||||||
@@ -57,9 +56,6 @@ from novelwriter.types import (
|
|||||||
QtSizeExpanding, QtSizeIgnored, QtUserRole
|
QtSizeExpanding, QtSizeIgnored, QtUserRole
|
||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
|
||||||
from novelwriter.guimain import GuiMain
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@@ -73,16 +69,14 @@ class GuiManuscript(QDialog):
|
|||||||
|
|
||||||
D_KEY = QtUserRole
|
D_KEY = QtUserRole
|
||||||
|
|
||||||
def __init__(self, mainGui: GuiMain) -> None:
|
def __init__(self, parent: QWidget) -> None:
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
logger.debug("Create: GuiManuscript")
|
logger.debug("Create: GuiManuscript")
|
||||||
self.setObjectName("GuiManuscript")
|
self.setObjectName("GuiManuscript")
|
||||||
if CONFIG.osDarwin:
|
if CONFIG.osDarwin:
|
||||||
self.setWindowFlag(Qt.WindowType.Tool)
|
self.setWindowFlag(Qt.WindowType.Tool)
|
||||||
|
|
||||||
self.mainGui = mainGui
|
|
||||||
|
|
||||||
self._builds = BuildCollection(SHARED.project)
|
self._builds = BuildCollection(SHARED.project)
|
||||||
self._buildMap: dict[str, QListWidgetItem] = {}
|
self._buildMap: dict[str, QListWidgetItem] = {}
|
||||||
|
|
||||||
@@ -280,7 +274,7 @@ class GuiManuscript(QDialog):
|
|||||||
dialog open.
|
dialog open.
|
||||||
"""
|
"""
|
||||||
self._saveSettings()
|
self._saveSettings()
|
||||||
for obj in self.mainGui.children():
|
for obj in SHARED.mainGui.children():
|
||||||
# Make sure we don't have any settings windows open
|
# Make sure we don't have any settings windows open
|
||||||
if isinstance(obj, GuiBuildSettings) and obj.isVisible():
|
if isinstance(obj, GuiBuildSettings) and obj.isVisible():
|
||||||
obj.close()
|
obj.close()
|
||||||
@@ -467,7 +461,7 @@ class GuiManuscript(QDialog):
|
|||||||
|
|
||||||
def _openSettingsDialog(self, build: BuildSettings) -> None:
|
def _openSettingsDialog(self, build: BuildSettings) -> None:
|
||||||
"""Open the build settings dialog."""
|
"""Open the build settings dialog."""
|
||||||
for obj in self.mainGui.children():
|
for obj in SHARED.mainGui.children():
|
||||||
# Don't open a second dialog if one exists
|
# Don't open a second dialog if one exists
|
||||||
if isinstance(obj, GuiBuildSettings):
|
if isinstance(obj, GuiBuildSettings):
|
||||||
if obj.buildID == build.buildID:
|
if obj.buildID == build.buildID:
|
||||||
@@ -476,7 +470,7 @@ class GuiManuscript(QDialog):
|
|||||||
obj.raise_()
|
obj.raise_()
|
||||||
return
|
return
|
||||||
|
|
||||||
dlgSettings = GuiBuildSettings(self.mainGui, build)
|
dlgSettings = GuiBuildSettings(SHARED.mainGui, build)
|
||||||
dlgSettings.setModal(False)
|
dlgSettings.setModal(False)
|
||||||
dlgSettings.show()
|
dlgSettings.show()
|
||||||
dlgSettings.raise_()
|
dlgSettings.raise_()
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
from PyQt5.QtCore import QEvent, Qt, pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import QEvent, Qt, pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtGui import QFont, QIcon, QSyntaxHighlighter, QTextCharFormat, QTextDocument
|
from PyQt5.QtGui import QFont, QIcon, QSyntaxHighlighter, QTextCharFormat, QTextDocument
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
@@ -51,9 +49,6 @@ from novelwriter.types import (
|
|||||||
QtRoleApply, QtRoleReject, QtUserRole
|
QtRoleApply, QtRoleReject, QtUserRole
|
||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
|
||||||
from novelwriter.guimain import GuiMain
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@@ -72,8 +67,8 @@ class GuiBuildSettings(QDialog):
|
|||||||
|
|
||||||
newSettingsReady = pyqtSignal(BuildSettings)
|
newSettingsReady = pyqtSignal(BuildSettings)
|
||||||
|
|
||||||
def __init__(self, mainGui: GuiMain, build: BuildSettings) -> None:
|
def __init__(self, parent: QWidget, build: BuildSettings) -> None:
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
logger.debug("Create: GuiBuildSettings")
|
logger.debug("Create: GuiBuildSettings")
|
||||||
self.setObjectName("GuiBuildSettings")
|
self.setObjectName("GuiBuildSettings")
|
||||||
@@ -296,8 +291,8 @@ class _FilterTab(NFixedPage):
|
|||||||
F_INCLUDED = 2
|
F_INCLUDED = 2
|
||||||
F_EXCLUDED = 3
|
F_EXCLUDED = 3
|
||||||
|
|
||||||
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
def __init__(self, parent: QWidget, build: BuildSettings) -> None:
|
||||||
super().__init__(parent=buildMain)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
self._treeMap: dict[str, QTreeWidgetItem] = {}
|
self._treeMap: dict[str, QTreeWidgetItem] = {}
|
||||||
self._build = build
|
self._build = build
|
||||||
@@ -586,8 +581,8 @@ class _HeadingsTab(NScrollablePage):
|
|||||||
EDIT_HSCENE = 5
|
EDIT_HSCENE = 5
|
||||||
EDIT_SECTION = 6
|
EDIT_SECTION = 6
|
||||||
|
|
||||||
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
def __init__(self, parent: QWidget, build: BuildSettings) -> None:
|
||||||
super().__init__(parent=buildMain)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
self._build = build
|
self._build = build
|
||||||
self._editing = 0
|
self._editing = 0
|
||||||
@@ -972,8 +967,8 @@ class _HeadingSyntaxHighlighter(QSyntaxHighlighter):
|
|||||||
|
|
||||||
class _ContentTab(NScrollableForm):
|
class _ContentTab(NScrollableForm):
|
||||||
|
|
||||||
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
def __init__(self, parent: QWidget, build: BuildSettings) -> None:
|
||||||
super().__init__(parent=buildMain)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
self._build = build
|
self._build = build
|
||||||
|
|
||||||
@@ -1057,8 +1052,8 @@ class _ContentTab(NScrollableForm):
|
|||||||
|
|
||||||
class _FormatTab(NScrollableForm):
|
class _FormatTab(NScrollableForm):
|
||||||
|
|
||||||
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
def __init__(self, parent: QWidget, build: BuildSettings) -> None:
|
||||||
super().__init__(parent=buildMain)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
self._build = build
|
self._build = build
|
||||||
self._unitScale = 1.0
|
self._unitScale = 1.0
|
||||||
@@ -1324,8 +1319,8 @@ class _FormatTab(NScrollableForm):
|
|||||||
|
|
||||||
class _OutputTab(NScrollableForm):
|
class _OutputTab(NScrollableForm):
|
||||||
|
|
||||||
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
|
def __init__(self, parent: QWidget, build: BuildSettings) -> None:
|
||||||
super().__init__(parent=buildMain)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
self._build = build
|
self._build = build
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<novelWriterXML appVersion="2.5a2" hexVersion="0x020500a1" fileVersion="1.5" fileRevision="4" timeStamp="2024-04-18 17:57:37">
|
<novelWriterXML appVersion="2.5a3" hexVersion="0x020500a3" fileVersion="1.5" fileRevision="4" timeStamp="2024-05-01 19:43:08">
|
||||||
<project id="e2be99af-f9bf-4403-857a-c3d1ac25abea" saveCount="1916" autoCount="274" editTime="87487">
|
<project id="e2be99af-f9bf-4403-857a-c3d1ac25abea" saveCount="1917" autoCount="274" editTime="87503">
|
||||||
<name>Sample Project</name>
|
<name>Sample Project</name>
|
||||||
<author>Jane Smith</author>
|
<author>Jane Smith</author>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user