Clean up a lot more namespace flags
This commit is contained in:
@@ -39,6 +39,7 @@ from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import formatFileFilter, openExternalPath, formatInt, getFileSize
|
||||
from novelwriter.error import formatException
|
||||
from novelwriter.extensions.modified import NIconToolButton
|
||||
from novelwriter.types import QtDialogClose
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -107,7 +108,7 @@ class GuiDictionaries(QDialog):
|
||||
self.infoBox.setFrameStyle(QFrame.Shape.NoFrame)
|
||||
|
||||
# Buttons
|
||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Close)
|
||||
self.buttonBox = QDialogButtonBox(QtDialogClose)
|
||||
self.buttonBox.rejected.connect(self._doClose)
|
||||
|
||||
# Assemble
|
||||
|
||||
@@ -35,7 +35,7 @@ from PyQt5.QtWidgets import (
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import readTextFile
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.types import QtAlignLeft, QtAlignRight
|
||||
from novelwriter.types import QtAlignLeft, QtAlignRight, QtRoleAction, QtDialogClose
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -96,10 +96,10 @@ class GuiLipsum(QDialog):
|
||||
self.buttonBox = QDialogButtonBox()
|
||||
self.buttonBox.rejected.connect(self.close)
|
||||
|
||||
self.btnClose = self.buttonBox.addButton(QDialogButtonBox.Close)
|
||||
self.btnClose = self.buttonBox.addButton(QtDialogClose)
|
||||
self.btnClose.setAutoDefault(False)
|
||||
|
||||
self.btnInsert = self.buttonBox.addButton(self.tr("Insert"), QDialogButtonBox.ActionRole)
|
||||
self.btnInsert = self.buttonBox.addButton(self.tr("Insert"), QtRoleAction)
|
||||
self.btnInsert.clicked.connect(self._doInsert)
|
||||
self.btnInsert.setAutoDefault(False)
|
||||
|
||||
|
||||
@@ -44,7 +44,9 @@ from novelwriter.core.item import NWItem
|
||||
from novelwriter.enum import nwBuildFmt
|
||||
from novelwriter.extensions.modified import NIconToolButton
|
||||
from novelwriter.extensions.simpleprogress import NProgressSimple
|
||||
from novelwriter.types import QtAlignCenter, QtUserRole
|
||||
from novelwriter.types import (
|
||||
QtAlignCenter, QtDialogClose, QtRoleAction, QtRoleReject, QtUserRole
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -184,9 +186,9 @@ class GuiManuscriptBuild(QDialog):
|
||||
self.btnBuild = QPushButton(SHARED.theme.getIcon("export"), self.tr("&Build"))
|
||||
self.btnBuild.setIconSize(bSz)
|
||||
|
||||
self.dlgButtons = QDialogButtonBox(QDialogButtonBox.StandardButton.Close)
|
||||
self.dlgButtons.addButton(self.btnOpen, QDialogButtonBox.ButtonRole.ActionRole)
|
||||
self.dlgButtons.addButton(self.btnBuild, QDialogButtonBox.ButtonRole.ActionRole)
|
||||
self.dlgButtons = QDialogButtonBox(QtDialogClose)
|
||||
self.dlgButtons.addButton(self.btnOpen, QtRoleAction)
|
||||
self.dlgButtons.addButton(self.btnBuild, QtRoleAction)
|
||||
|
||||
# Assemble GUI
|
||||
# ============
|
||||
@@ -261,12 +263,12 @@ class GuiManuscriptBuild(QDialog):
|
||||
def _dialogButtonClicked(self, button: QAbstractButton):
|
||||
"""Handle button clicks from the dialog button box."""
|
||||
role = self.dlgButtons.buttonRole(button)
|
||||
if role == QDialogButtonBox.ActionRole:
|
||||
if role == QtRoleAction:
|
||||
if button == self.btnBuild:
|
||||
self._runBuild()
|
||||
elif button == self.btnOpen:
|
||||
self._openOutputFolder()
|
||||
elif role == QDialogButtonBox.RejectRole:
|
||||
elif role == QtRoleReject:
|
||||
self.close()
|
||||
return
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class GuiManuscript(QDialog):
|
||||
# ==============
|
||||
|
||||
qPalette = self.palette()
|
||||
qPalette.setBrush(QPalette.Window, qPalette.base())
|
||||
qPalette.setBrush(QPalette.ColorRole.Window, qPalette.base())
|
||||
self.setPalette(qPalette)
|
||||
|
||||
buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON)
|
||||
@@ -751,8 +751,8 @@ class _PreviewWidget(QTextBrowser):
|
||||
|
||||
# Document Setup
|
||||
dPalette = self.palette()
|
||||
dPalette.setColor(QPalette.Base, QColor(255, 255, 255))
|
||||
dPalette.setColor(QPalette.Text, QColor(0, 0, 0))
|
||||
dPalette.setColor(QPalette.ColorRole.Base, QColor(255, 255, 255))
|
||||
dPalette.setColor(QPalette.ColorRole.Text, QColor(0, 0, 0))
|
||||
self.setPalette(dPalette)
|
||||
|
||||
self.setMinimumWidth(40*SHARED.theme.textNWidth)
|
||||
@@ -769,8 +769,8 @@ class _PreviewWidget(QTextBrowser):
|
||||
|
||||
# Document Age
|
||||
aPalette = self.palette()
|
||||
aPalette.setColor(QPalette.Background, aPalette.toolTipBase().color())
|
||||
aPalette.setColor(QPalette.Foreground, aPalette.toolTipText().color())
|
||||
aPalette.setColor(QPalette.ColorRole.Window, aPalette.toolTipBase().color())
|
||||
aPalette.setColor(QPalette.ColorRole.WindowText, aPalette.toolTipText().color())
|
||||
|
||||
aFont = self.font()
|
||||
aFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
|
||||
|
||||
@@ -46,7 +46,10 @@ from novelwriter.extensions.modified import NComboBox, NDoubleSpinBox, NIconTool
|
||||
from novelwriter.extensions.pagedsidebar import NPagedSideBar
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.extensions.switchbox import NSwitchBox
|
||||
from novelwriter.types import QtAlignLeft, QtUserRole
|
||||
from novelwriter.types import (
|
||||
QtAlignLeft, QtDialogApply, QtDialogClose, QtDialogSave, QtRoleAccept,
|
||||
QtRoleApply, QtRoleReject, QtUserRole
|
||||
)
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from novelwriter.guimain import GuiMain
|
||||
@@ -131,11 +134,7 @@ class GuiBuildSettings(QDialog):
|
||||
self.toolStack.addWidget(self.optTabOutput)
|
||||
|
||||
# Buttons
|
||||
self.buttonBox = QDialogButtonBox(
|
||||
QDialogButtonBox.StandardButton.Apply
|
||||
| QDialogButtonBox.StandardButton.Save
|
||||
| QDialogButtonBox.StandardButton.Close
|
||||
)
|
||||
self.buttonBox = QDialogButtonBox(QtDialogApply | QtDialogSave | QtDialogClose)
|
||||
self.buttonBox.clicked.connect(self._dialogButtonClicked)
|
||||
|
||||
# Assemble
|
||||
@@ -226,12 +225,12 @@ class GuiBuildSettings(QDialog):
|
||||
def _dialogButtonClicked(self, button: QAbstractButton) -> None:
|
||||
"""Handle button clicks from the dialog button box."""
|
||||
role = self.buttonBox.buttonRole(button)
|
||||
if role == QDialogButtonBox.ApplyRole:
|
||||
if role == QtRoleApply:
|
||||
self._emitBuildData()
|
||||
elif role == QDialogButtonBox.AcceptRole:
|
||||
elif role == QtRoleAccept:
|
||||
self._emitBuildData()
|
||||
self.close()
|
||||
elif role == QDialogButtonBox.RejectRole:
|
||||
elif role == QtRoleReject:
|
||||
self.close()
|
||||
return
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ from novelwriter.extensions.configlayout import NColourLabel, NFixedPage, NScrol
|
||||
from novelwriter.extensions.novelselector import NovelSelector
|
||||
from novelwriter.extensions.pagedsidebar import NPagedSideBar
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.types import QtAlignRight, QtDecoration
|
||||
from novelwriter.types import QtAlignRight, QtDecoration, QtDialogClose
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -95,7 +95,7 @@ class GuiNovelDetails(QDialog):
|
||||
self.mainStack.addWidget(self.contentsPage)
|
||||
|
||||
# Buttons
|
||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.StandardButton.Close)
|
||||
self.buttonBox = QDialogButtonBox(QtDialogClose)
|
||||
self.buttonBox.rejected.connect(self.close)
|
||||
|
||||
# Assemble
|
||||
|
||||
@@ -36,8 +36,8 @@ from PyQt5.QtGui import QCloseEvent, QColor, QFont, QPaintEvent, QPainter, QPen
|
||||
from PyQt5.QtWidgets import (
|
||||
QAction, QApplication, QDialog, QFileDialog, QFormLayout, QHBoxLayout,
|
||||
QLabel, QLineEdit, QListView, QMenu, QPushButton, QScrollArea, QShortcut,
|
||||
QStackedWidget, QStyle, QStyleOptionViewItem, QStyledItemDelegate,
|
||||
QVBoxLayout, QWidget
|
||||
QStackedWidget, QStyleOptionViewItem, QStyledItemDelegate, QVBoxLayout,
|
||||
QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
@@ -49,7 +49,7 @@ from novelwriter.extensions.configlayout import NWrappedWidgetBox
|
||||
from novelwriter.extensions.modified import NIconToolButton, NSpinBox
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.extensions.versioninfo import VersionInfoWidget
|
||||
from novelwriter.types import QtAlignLeft, QtAlignRightTop
|
||||
from novelwriter.types import QtAlignLeft, QtAlignRightTop, QtSelected
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -431,7 +431,7 @@ class _ProjectListItem(QStyledItemDelegate):
|
||||
ix, iy, x, y1, y2 = self._pPx
|
||||
|
||||
painter.save()
|
||||
if opt.state & QStyle.StateFlag.State_Selected == QStyle.StateFlag.State_Selected:
|
||||
if opt.state & QtSelected == QtSelected:
|
||||
painter.setOpacity(0.25)
|
||||
painter.fillRect(rect, QApplication.palette().highlight())
|
||||
painter.setOpacity(1.0)
|
||||
@@ -813,7 +813,7 @@ class _PopLeftDirectionMenu(QMenu):
|
||||
|
||||
def event(self, event: QEvent) -> bool:
|
||||
"""Overload the show event and move the menu popup location."""
|
||||
if event.type() == QEvent.Show:
|
||||
if event.type() == QEvent.Type.Show:
|
||||
if isinstance(parent := self.parent(), QWidget):
|
||||
offset = QPoint(parent.width() - self.width(), parent.height())
|
||||
self.move(parent.mapToGlobal(offset))
|
||||
|
||||
@@ -42,7 +42,10 @@ from novelwriter.common import formatTime, checkInt, checkIntTuple, minmax
|
||||
from novelwriter.constants import nwConst
|
||||
from novelwriter.error import formatException
|
||||
from novelwriter.extensions.switch import NSwitch
|
||||
from novelwriter.types import QtAlignLeftMiddle, QtAlignRight, QtAlignRightMiddle, QtDecoration
|
||||
from novelwriter.types import (
|
||||
QtAlignLeftMiddle, QtAlignRight, QtAlignRightMiddle, QtDecoration,
|
||||
QtDialogClose, QtRoleAction
|
||||
)
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from novelwriter.guimain import GuiMain
|
||||
@@ -262,13 +265,13 @@ class GuiWritingStats(QDialog):
|
||||
self.optsBox.addWidget(self.histMax, 0)
|
||||
|
||||
# Buttons
|
||||
self.buttonBox = QDialogButtonBox()
|
||||
self.buttonBox = QDialogButtonBox(self)
|
||||
self.buttonBox.rejected.connect(self._doClose)
|
||||
|
||||
self.btnClose = self.buttonBox.addButton(QDialogButtonBox.Close)
|
||||
self.btnClose = self.buttonBox.addButton(QtDialogClose)
|
||||
self.btnClose.setAutoDefault(False)
|
||||
|
||||
self.btnSave = self.buttonBox.addButton(self.tr("Save As"), QDialogButtonBox.ActionRole)
|
||||
self.btnSave = self.buttonBox.addButton(self.tr("Save As"), QtRoleAction)
|
||||
self.btnSave.setAutoDefault(False)
|
||||
|
||||
self.saveMenu = QMenu(self)
|
||||
|
||||
Reference in New Issue
Block a user