Always use scrollable combo box and manually update the style sheet in build settings instead
This commit is contained in:
@@ -158,7 +158,7 @@ class GuiPreferences(NDialog):
|
|||||||
self.mainForm.addGroupLabel(title, section)
|
self.mainForm.addGroupLabel(title, section)
|
||||||
|
|
||||||
# Display Language
|
# Display Language
|
||||||
self.guiLocale = NComboBox(self, scrollable=True)
|
self.guiLocale = NComboBox(self)
|
||||||
self.guiLocale.setMinimumWidth(200)
|
self.guiLocale.setMinimumWidth(200)
|
||||||
for lang, name in CONFIG.listLanguages(CONFIG.LANG_NW):
|
for lang, name in CONFIG.listLanguages(CONFIG.LANG_NW):
|
||||||
self.guiLocale.addItem(name, lang)
|
self.guiLocale.addItem(name, lang)
|
||||||
@@ -170,9 +170,9 @@ class GuiPreferences(NDialog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Colour Theme
|
# Colour Theme
|
||||||
self.lightTheme = NComboBox(self, scrollable=True)
|
self.lightTheme = NComboBox(self)
|
||||||
self.lightTheme.setMinimumWidth(200)
|
self.lightTheme.setMinimumWidth(200)
|
||||||
self.darkTheme = NComboBox(self, scrollable=True)
|
self.darkTheme = NComboBox(self)
|
||||||
self.darkTheme.setMinimumWidth(200)
|
self.darkTheme.setMinimumWidth(200)
|
||||||
for key, theme in SHARED.theme.colourThemes.items():
|
for key, theme in SHARED.theme.colourThemes.items():
|
||||||
if theme.dark:
|
if theme.dark:
|
||||||
@@ -193,7 +193,7 @@ class GuiPreferences(NDialog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Icon Theme
|
# Icon Theme
|
||||||
self.iconTheme = NComboBox(self, scrollable=True)
|
self.iconTheme = NComboBox(self)
|
||||||
self.iconTheme.setMinimumWidth(200)
|
self.iconTheme.setMinimumWidth(200)
|
||||||
for key, theme in SHARED.theme.iconCache.iconThemes.items():
|
for key, theme in SHARED.theme.iconCache.iconThemes.items():
|
||||||
self.iconTheme.addItem(theme.name, key)
|
self.iconTheme.addItem(theme.name, key)
|
||||||
@@ -513,7 +513,7 @@ class GuiPreferences(NDialog):
|
|||||||
self.mainForm.addGroupLabel(title, section)
|
self.mainForm.addGroupLabel(title, section)
|
||||||
|
|
||||||
# Spell Checking
|
# Spell Checking
|
||||||
self.spellLanguage = NComboBox(self, scrollable=True)
|
self.spellLanguage = NComboBox(self)
|
||||||
self.spellLanguage.setMinimumWidth(200)
|
self.spellLanguage.setMinimumWidth(200)
|
||||||
|
|
||||||
if CONFIG.hasEnchant:
|
if CONFIG.hasEnchant:
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ class _SettingsPage(NScrollableForm):
|
|||||||
|
|
||||||
# Project Language
|
# Project Language
|
||||||
projLang = data.language or CONFIG.guiLocale
|
projLang = data.language or CONFIG.guiLocale
|
||||||
self.projLang = NComboBox(self, scrollable=True)
|
self.projLang = NComboBox(self)
|
||||||
self.projLang.setMinimumWidth(200)
|
self.projLang.setMinimumWidth(200)
|
||||||
for tag, language in CONFIG.listLanguages(CONFIG.LANG_PROJ):
|
for tag, language in CONFIG.listLanguages(CONFIG.LANG_PROJ):
|
||||||
self.projLang.addItem(language, tag)
|
self.projLang.addItem(language, tag)
|
||||||
@@ -269,7 +269,7 @@ class _SettingsPage(NScrollableForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Spell Check Language
|
# Spell Check Language
|
||||||
self.spellLang = NComboBox(self, scrollable=True)
|
self.spellLang = NComboBox(self)
|
||||||
self.spellLang.setMinimumWidth(200)
|
self.spellLang.setMinimumWidth(200)
|
||||||
self.spellLang.addItem(self.tr("Default"), "None")
|
self.spellLang.addItem(self.tr("Default"), "None")
|
||||||
if CONFIG.hasEnchant:
|
if CONFIG.hasEnchant:
|
||||||
|
|||||||
@@ -125,16 +125,11 @@ class NComboBox(QComboBox):
|
|||||||
window of many widgets.
|
window of many widgets.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(self, parent: QWidget | None = None, maxItems: int = 15) -> None:
|
||||||
self, parent: QWidget | None = None, maxItems: int = 15, scrollable: bool = False
|
|
||||||
) -> None:
|
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||||
self.setMaxVisibleItems(maxItems)
|
self.setMaxVisibleItems(maxItems)
|
||||||
if scrollable:
|
self.updateStyle()
|
||||||
# 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;}")
|
|
||||||
|
|
||||||
def wheelEvent(self, event: QWheelEvent) -> None:
|
def wheelEvent(self, event: QWheelEvent) -> None:
|
||||||
"""Only capture the mouse wheel if the widget has focus."""
|
"""Only capture the mouse wheel if the widget has focus."""
|
||||||
@@ -148,6 +143,12 @@ class NComboBox(QComboBox):
|
|||||||
idx = self.findData(data)
|
idx = self.findData(data)
|
||||||
self.setCurrentIndex(self.findData(default) if idx < 0 else idx)
|
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):
|
class NSpinBox(QSpinBox):
|
||||||
"""Custom: Modified QSpinBox.
|
"""Custom: Modified QSpinBox.
|
||||||
|
|||||||
@@ -1329,6 +1329,9 @@ class _FormattingTab(NScrollableForm):
|
|||||||
self.pixH.setPixmap(SHARED.theme.getPixmap("fit_height", (iPx, iPx)))
|
self.pixH.setPixmap(SHARED.theme.getPixmap("fit_height", (iPx, iPx)))
|
||||||
self.pixW.setPixmap(SHARED.theme.getPixmap("fit_width", (iPx, iPx)))
|
self.pixW.setPixmap(SHARED.theme.getPixmap("fit_width", (iPx, iPx)))
|
||||||
|
|
||||||
|
self.pageSize.updateStyle()
|
||||||
|
self.pageUnit.updateStyle()
|
||||||
|
|
||||||
def loadContent(self) -> None:
|
def loadContent(self) -> None:
|
||||||
"""Populate the widgets."""
|
"""Populate the widgets."""
|
||||||
# Text Content
|
# Text Content
|
||||||
|
|||||||
Reference in New Issue
Block a user