Add modified combo and spinboxes that don't scroll on mouse wheel

This commit is contained in:
Veronica Berglyd Olsen
2024-02-01 23:35:14 +01:00
parent c866491910
commit a8f61f2b98
5 changed files with 126 additions and 42 deletions
+16 -16
View File
@@ -30,17 +30,17 @@ from typing import TYPE_CHECKING
from PyQt5.QtGui import QFont, QIcon, QSyntaxHighlighter, QTextCharFormat, QTextDocument
from PyQt5.QtCore import QEvent, QSize, Qt, pyqtSignal, pyqtSlot
from PyQt5.QtWidgets import (
QAbstractButton, QAbstractItemView, QComboBox, QDialog, QDialogButtonBox,
QDoubleSpinBox, QFontDialog, QFrame, QGridLayout, QHBoxLayout, QHeaderView,
QLabel, QLineEdit, QMenu, QPlainTextEdit, QPushButton, QSpinBox, QSplitter,
QStackedWidget, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout,
QWidget
QAbstractButton, QAbstractItemView, QDialog, QDialogButtonBox,
QFontDialog, QFrame, QGridLayout, QHBoxLayout, QHeaderView, QLabel,
QLineEdit, QMenu, QPlainTextEdit, QPushButton, QSplitter, QStackedWidget,
QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
)
from novelwriter import CONFIG, SHARED
from novelwriter.constants import nwHeadFmt, nwLabels, trConst
from novelwriter.core.buildsettings import BuildSettings, FilterMode
from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.modified import NComboBox, NDoubleSpinBox, NSpinBox
from novelwriter.extensions.switchbox import NSwitchBox
from novelwriter.extensions.configlayout import (
NColourLabel, NFixedPage, NScrollableForm, NScrollablePage
@@ -968,7 +968,7 @@ class _FormatTab(NScrollableForm):
)
# Font Size
self.textSize = QSpinBox(self)
self.textSize = NSpinBox(self)
self.textSize.setMinimum(8)
self.textSize.setMaximum(60)
self.textSize.setSingleStep(1)
@@ -976,7 +976,7 @@ class _FormatTab(NScrollableForm):
self.addRow(self._build.getLabel("format.textSize"), self.textSize, unit="pt")
# Line Height
self.lineHeight = QDoubleSpinBox(self)
self.lineHeight = NDoubleSpinBox(self)
self.lineHeight.setFixedWidth(spW)
self.lineHeight.setMinimum(0.75)
self.lineHeight.setMaximum(3.0)
@@ -1002,34 +1002,34 @@ class _FormatTab(NScrollableForm):
self.addGroupLabel(self._build.getLabel("format.grpPage"))
self.pageUnit = QComboBox(self)
self.pageUnit = NComboBox(self)
for key, name in nwLabels.UNIT_NAME.items():
self.pageUnit.addItem(trConst(name), key)
self.pageSize = QComboBox(self)
self.pageSize = NComboBox(self)
for key, name in nwLabels.PAPER_NAME.items():
self.pageSize.addItem(trConst(name), key)
self.pageWidth = QDoubleSpinBox(self)
self.pageWidth = NDoubleSpinBox(self)
self.pageWidth.setFixedWidth(dbW)
self.pageWidth.setMaximum(500.0)
self.pageWidth.valueChanged.connect(self._pageSizeValueChanged)
self.pageHeight = QDoubleSpinBox(self)
self.pageHeight = NDoubleSpinBox(self)
self.pageHeight.setFixedWidth(dbW)
self.pageHeight.setMaximum(500.0)
self.pageHeight.valueChanged.connect(self._pageSizeValueChanged)
self.topMargin = QDoubleSpinBox(self)
self.topMargin = NDoubleSpinBox(self)
self.topMargin.setFixedWidth(dbW)
self.bottomMargin = QDoubleSpinBox(self)
self.bottomMargin = NDoubleSpinBox(self)
self.bottomMargin.setFixedWidth(dbW)
self.leftMargin = QDoubleSpinBox(self)
self.leftMargin = NDoubleSpinBox(self)
self.leftMargin.setFixedWidth(dbW)
self.rightMargin = QDoubleSpinBox(self)
self.rightMargin = NDoubleSpinBox(self)
self.rightMargin.setFixedWidth(dbW)
self.addRow(self._build.getLabel("format.pageUnit"), self.pageUnit)
@@ -1232,7 +1232,7 @@ class _OutputTab(NScrollableForm):
button=self.btnPageHeader, stretch=(1, 1)
)
self.odtPageCountOffset = QSpinBox(self)
self.odtPageCountOffset = NSpinBox(self)
self.odtPageCountOffset.setMinimum(0)
self.odtPageCountOffset.setMaximum(999)
self.odtPageCountOffset.setSingleStep(1)
+7 -6
View File
@@ -34,9 +34,9 @@ from PyQt5.QtCore import (
pyqtSignal, pyqtSlot
)
from PyQt5.QtWidgets import (
QComboBox, QDialog, QDialogButtonBox, QFileDialog, QFormLayout,
QHBoxLayout, QLabel, QLineEdit, QListView, QMenu, QPushButton, QScrollArea, QShortcut,
QSpinBox, QStackedWidget, QStyle, QStyleOptionViewItem, QStyledItemDelegate,
QDialog, QDialogButtonBox, QFileDialog, QFormLayout, QHBoxLayout, QLabel,
QLineEdit, QListView, QMenu, QPushButton, QScrollArea, QShortcut,
QStackedWidget, QStyle, QStyleOptionViewItem, QStyledItemDelegate,
QToolButton, QVBoxLayout, QWidget, qApp
)
@@ -46,6 +46,7 @@ from novelwriter.common import formatInt, formatVersion, makeFileNameSafe
from novelwriter.constants import nwUnicode
from novelwriter.core.coretools import ProjectBuilder
from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.modified import NComboBox, NSpinBox
logger = logging.getLogger(__name__)
@@ -534,7 +535,7 @@ class _NewProjectForm(QWidget):
self.projAuthor.setPlaceholderText(self.tr("Optional"))
# Project Language
self.projLang = QComboBox(self)
self.projLang = NComboBox(self)
for tag, language in CONFIG.listLanguages(CONFIG.LANG_PROJ):
self.projLang.addItem(language, tag)
@@ -594,7 +595,7 @@ class _NewProjectForm(QWidget):
# Chapters and Scenes
# ===================
self.numChapters = QSpinBox()
self.numChapters = NSpinBox(self)
self.numChapters.setRange(0, 200)
self.numChapters.setValue(5)
self.numChapters.setToolTip(self.tr("Set to 0 to only add scenes"))
@@ -605,7 +606,7 @@ class _NewProjectForm(QWidget):
self.chapterBox.addWidget(QLabel(self.tr("chapter documents")))
self.chapterBox.addStretch(1)
self.numScenes = QSpinBox()
self.numScenes = NSpinBox(self)
self.numScenes.setRange(0, 200)
self.numScenes.setValue(5)