diff --git a/novelwriter/dialogs/docmerge.py b/novelwriter/dialogs/docmerge.py index a0c43611..0466b09c 100644 --- a/novelwriter/dialogs/docmerge.py +++ b/novelwriter/dialogs/docmerge.py @@ -74,7 +74,7 @@ class GuiDocMerge(QDialog): # Merge Options self.trashLabel = QLabel(self.tr("Move merged items to Trash")) - self.trashSwitch = NSwitch(width=2*iPx, height=iPx) + self.trashSwitch = NSwitch(self, height=iPx) self.optBox = QGridLayout() self.optBox.addWidget(self.trashLabel, 0, 0) diff --git a/novelwriter/dialogs/docsplit.py b/novelwriter/dialogs/docsplit.py index b8add4c0..6c96fc16 100644 --- a/novelwriter/dialogs/docsplit.py +++ b/novelwriter/dialogs/docsplit.py @@ -92,15 +92,15 @@ class GuiDocSplit(QDialog): # Split Options self.folderLabel = QLabel(self.tr("Split into a new folder")) - self.folderSwitch = NSwitch(width=2*iPx, height=iPx) + self.folderSwitch = NSwitch(self, height=iPx) self.folderSwitch.setChecked(intoFolder) self.hierarchyLabel = QLabel(self.tr("Create document hierarchy")) - self.hierarchySwitch = NSwitch(width=2*iPx, height=iPx) + self.hierarchySwitch = NSwitch(self, height=iPx) self.hierarchySwitch.setChecked(docHierarchy) self.trashLabel = QLabel(self.tr("Move split document to Trash")) - self.trashSwitch = NSwitch(width=2*iPx, height=iPx) + self.trashSwitch = NSwitch(self, height=iPx) self.optBox = QGridLayout() self.optBox.addWidget(self.folderLabel, 0, 0) diff --git a/novelwriter/extensions/switch.py b/novelwriter/extensions/switch.py index 54db8914..ab32ddbb 100644 --- a/novelwriter/extensions/switch.py +++ b/novelwriter/extensions/switch.py @@ -34,11 +34,11 @@ class NSwitch(QAbstractButton): __slots__ = ("_xW", "_xH", "_xR", "_rB", "_rH", "_rR", "_offset") - def __init__(self, parent: QWidget | None = None, width: int = 0, height: int = 0) -> None: + def __init__(self, parent: QWidget | None = None, height: int = 0) -> None: super().__init__(parent=parent) - self._xW = width or CONFIG.pxInt(40) self._xH = height or CONFIG.pxInt(20) + self._xW = 2*self._xH self._xR = int(self._xH*0.5) self._rB = int(CONFIG.guiScale*2) self._rH = self._xH - 2*self._rB @@ -61,7 +61,7 @@ class NSwitch(QAbstractButton): return self._offset @offset.setter # type: ignore - def offset(self, offset: int): + def offset(self, offset: int) -> None: self._offset = offset self.update() return diff --git a/novelwriter/extensions/switchbox.py b/novelwriter/extensions/switchbox.py index 5a21ddf7..28f9d81a 100644 --- a/novelwriter/extensions/switchbox.py +++ b/novelwriter/extensions/switchbox.py @@ -87,7 +87,7 @@ class NSwitchBox(QScrollArea): label = QLabel(text) self._content.addWidget(label, self._index, 1, Qt.AlignLeft) - switch = NSwitch(width=self._wSwitch, height=self._hSwitch) + switch = NSwitch(self, height=self._hSwitch) switch.setChecked(default) switch.toggled.connect(lambda state: self._emitSwitchSignal(identifier, state)) self._content.addWidget(switch, self._index, 2, Qt.AlignRight) diff --git a/novelwriter/tools/manussettings.py b/novelwriter/tools/manussettings.py index 28404c50..fe78f3b4 100644 --- a/novelwriter/tools/manussettings.py +++ b/novelwriter/tools/manussettings.py @@ -659,7 +659,7 @@ class _HeadingsTab(NScrollablePage): self.btnScene.clicked.connect(lambda: self._editHeading(self.EDIT_SCENE)) self.hdeScene = QLabel(self.tr("Hide")) self.hdeScene.setToolTip(sceneHideTip) - self.swtScene = NSwitch(self, width=2*iPx, height=iPx) + self.swtScene = NSwitch(self, height=iPx) self.swtScene.setToolTip(sceneHideTip) wrapScene = QHBoxLayout() @@ -686,7 +686,7 @@ class _HeadingsTab(NScrollablePage): self.btnSection.clicked.connect(lambda: self._editHeading(self.EDIT_SECTION)) self.hdeSection = QLabel(self.tr("Hide")) self.hdeSection.setToolTip(sectionHideTip) - self.swtSection = NSwitch(self, width=2*iPx, height=iPx) + self.swtSection = NSwitch(self, height=iPx) self.swtSection.setToolTip(sectionHideTip) wrapSection = QHBoxLayout() @@ -894,10 +894,10 @@ class _ContentTab(NScrollableForm): iPx = SHARED.theme.baseIconSize # Text Content - self.incSynopsis = NSwitch(self, width=2*iPx, height=iPx) - self.incComments = NSwitch(self, width=2*iPx, height=iPx) - self.incKeywords = NSwitch(self, width=2*iPx, height=iPx) - self.incBodyText = NSwitch(self, width=2*iPx, height=iPx) + self.incSynopsis = NSwitch(self, height=iPx) + self.incComments = NSwitch(self, height=iPx) + self.incKeywords = NSwitch(self, height=iPx) + self.incBodyText = NSwitch(self, height=iPx) self.addGroupLabel(self._build.getLabel("text.grpContent")) self.addRow(self._build.getLabel("text.includeSynopsis"), self.incSynopsis) @@ -906,7 +906,7 @@ class _ContentTab(NScrollableForm): self.addRow(self._build.getLabel("text.includeBodyText"), self.incBodyText) # Insert Content - self.addNoteHead = NSwitch(self, width=2*iPx, height=iPx) + self.addNoteHead = NSwitch(self, height=iPx) self.addGroupLabel(self._build.getLabel("text.grpInsert")) self.addRow(self._build.getLabel("text.addNoteHeadings"), self.addNoteHead) @@ -989,9 +989,9 @@ class _FormatTab(NScrollableForm): self.addGroupLabel(self._build.getLabel("format.grpOptions")) - self.justifyText = NSwitch(self, width=2*iPx, height=iPx) - self.stripUnicode = NSwitch(self, width=2*iPx, height=iPx) - self.replaceTabs = NSwitch(self, width=2*iPx, height=iPx) + self.justifyText = NSwitch(self, height=iPx) + self.stripUnicode = NSwitch(self, height=iPx) + self.replaceTabs = NSwitch(self, height=iPx) self.addRow(self._build.getLabel("format.justifyText"), self.justifyText) self.addRow(self._build.getLabel("format.stripUnicode"), self.stripUnicode) @@ -1219,7 +1219,7 @@ class _OutputTab(NScrollableForm): # Open Document self.addGroupLabel(self._build.getLabel("odt")) - self.odtAddColours = NSwitch(self, width=2*iPx, height=iPx) + self.odtAddColours = NSwitch(self, height=iPx) self.addRow(self._build.getLabel("odt.addColours"), self.odtAddColours) self.odtPageHeader = QLineEdit(self) @@ -1242,7 +1242,7 @@ class _OutputTab(NScrollableForm): # HTML Document self.addGroupLabel(self._build.getLabel("html")) - self.htmlAddStyles = NSwitch(self, width=2*iPx, height=iPx) + self.htmlAddStyles = NSwitch(self, height=iPx) self.addRow(self._build.getLabel("html.addStyles"), self.htmlAddStyles) # Finalise diff --git a/novelwriter/tools/noveldetails.py b/novelwriter/tools/noveldetails.py index 1dcbbeb6..05cf0436 100644 --- a/novelwriter/tools/noveldetails.py +++ b/novelwriter/tools/noveldetails.py @@ -384,7 +384,7 @@ class _ContentsPage(NFixedPage): self.dblLabel = QLabel(self.tr("Chapters on odd pages")) - self.dblValue = NSwitch(self, 2*iPx, iPx) + self.dblValue = NSwitch(self, height=iPx) self.dblValue.setChecked(clearDouble) self.dblValue.clicked.connect(self._populateTree) diff --git a/novelwriter/tools/writingstats.py b/novelwriter/tools/writingstats.py index 1309c61f..a215df20 100644 --- a/novelwriter/tools/writingstats.py +++ b/novelwriter/tools/writingstats.py @@ -193,37 +193,37 @@ class GuiWritingStats(QDialog): self.filterForm = QGridLayout(self) self.filterBox.setLayout(self.filterForm) - self.incNovel = NSwitch(width=2*sPx, height=sPx) + self.incNovel = NSwitch(self, height=sPx) self.incNovel.setChecked( pOptions.getBool("GuiWritingStats", "incNovel", True) ) self.incNovel.clicked.connect(self._updateListBox) - self.incNotes = NSwitch(width=2*sPx, height=sPx) + self.incNotes = NSwitch(self, height=sPx) self.incNotes.setChecked( pOptions.getBool("GuiWritingStats", "incNotes", True) ) self.incNotes.clicked.connect(self._updateListBox) - self.hideZeros = NSwitch(width=2*sPx, height=sPx) + self.hideZeros = NSwitch(self, height=sPx) self.hideZeros.setChecked( pOptions.getBool("GuiWritingStats", "hideZeros", True) ) self.hideZeros.clicked.connect(self._updateListBox) - self.hideNegative = NSwitch(width=2*sPx, height=sPx) + self.hideNegative = NSwitch(self, height=sPx) self.hideNegative.setChecked( pOptions.getBool("GuiWritingStats", "hideNegative", False) ) self.hideNegative.clicked.connect(self._updateListBox) - self.groupByDay = NSwitch(width=2*sPx, height=sPx) + self.groupByDay = NSwitch(self, height=sPx) self.groupByDay.setChecked( pOptions.getBool("GuiWritingStats", "groupByDay", False) ) self.groupByDay.clicked.connect(self._updateListBox) - self.showIdleTime = NSwitch(width=2*sPx, height=sPx) + self.showIdleTime = NSwitch(self, height=sPx) self.showIdleTime.setChecked( pOptions.getBool("GuiWritingStats", "showIdleTime", False) )