Always use scrollable combo box and manually update the style sheet in build settings instead

This commit is contained in:
Veronica Berglyd Olsen
2025-10-27 20:01:25 +01:00
parent cd8cc81b5f
commit a8a6d199d1
4 changed files with 18 additions and 14 deletions
+5 -5
View File
@@ -158,7 +158,7 @@ class GuiPreferences(NDialog):
self.mainForm.addGroupLabel(title, section)
# Display Language
self.guiLocale = NComboBox(self, scrollable=True)
self.guiLocale = NComboBox(self)
self.guiLocale.setMinimumWidth(200)
for lang, name in CONFIG.listLanguages(CONFIG.LANG_NW):
self.guiLocale.addItem(name, lang)
@@ -170,9 +170,9 @@ class GuiPreferences(NDialog):
)
# Colour Theme
self.lightTheme = NComboBox(self, scrollable=True)
self.lightTheme = NComboBox(self)
self.lightTheme.setMinimumWidth(200)
self.darkTheme = NComboBox(self, scrollable=True)
self.darkTheme = NComboBox(self)
self.darkTheme.setMinimumWidth(200)
for key, theme in SHARED.theme.colourThemes.items():
if theme.dark:
@@ -193,7 +193,7 @@ class GuiPreferences(NDialog):
)
# Icon Theme
self.iconTheme = NComboBox(self, scrollable=True)
self.iconTheme = NComboBox(self)
self.iconTheme.setMinimumWidth(200)
for key, theme in SHARED.theme.iconCache.iconThemes.items():
self.iconTheme.addItem(theme.name, key)
@@ -513,7 +513,7 @@ class GuiPreferences(NDialog):
self.mainForm.addGroupLabel(title, section)
# Spell Checking
self.spellLanguage = NComboBox(self, scrollable=True)
self.spellLanguage = NComboBox(self)
self.spellLanguage.setMinimumWidth(200)
if CONFIG.hasEnchant:
+2 -2
View File
@@ -257,7 +257,7 @@ class _SettingsPage(NScrollableForm):
# Project Language
projLang = data.language or CONFIG.guiLocale
self.projLang = NComboBox(self, scrollable=True)
self.projLang = NComboBox(self)
self.projLang.setMinimumWidth(200)
for tag, language in CONFIG.listLanguages(CONFIG.LANG_PROJ):
self.projLang.addItem(language, tag)
@@ -269,7 +269,7 @@ class _SettingsPage(NScrollableForm):
)
# Spell Check Language
self.spellLang = NComboBox(self, scrollable=True)
self.spellLang = NComboBox(self)
self.spellLang.setMinimumWidth(200)
self.spellLang.addItem(self.tr("Default"), "None")
if CONFIG.hasEnchant:
+8 -7
View File
@@ -125,16 +125,11 @@ class NComboBox(QComboBox):
window of many widgets.
"""
def __init__(
self, parent: QWidget | None = None, maxItems: int = 15, scrollable: bool = False
) -> None:
def __init__(self, parent: QWidget | None = None, maxItems: int = 15) -> None:
super().__init__(parent=parent)
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
self.setMaxVisibleItems(maxItems)
if scrollable:
# The style sheet disables Fusion style pop-up mode on some
# platforms and allows for scrolling of long lists of items
self.setStyleSheet("QComboBox {combobox-popup: 0;}")
self.updateStyle()
def wheelEvent(self, event: QWheelEvent) -> None:
"""Only capture the mouse wheel if the widget has focus."""
@@ -148,6 +143,12 @@ class NComboBox(QComboBox):
idx = self.findData(data)
self.setCurrentIndex(self.findData(default) if idx < 0 else idx)
def updateStyle(self) -> None:
"""Update the style sheet."""
# The style sheet disables Fusion style pop-up mode on some
# platforms and allows for scrolling of long lists of items
self.setStyleSheet("QComboBox {combobox-popup: 0;}")
class NSpinBox(QSpinBox):
"""Custom: Modified QSpinBox.
+3
View File
@@ -1329,6 +1329,9 @@ class _FormattingTab(NScrollableForm):
self.pixH.setPixmap(SHARED.theme.getPixmap("fit_height", (iPx, iPx)))
self.pixW.setPixmap(SHARED.theme.getPixmap("fit_width", (iPx, iPx)))
self.pageSize.updateStyle()
self.pageUnit.updateStyle()
def loadContent(self) -> None:
"""Populate the widgets."""
# Text Content