Set frameless popup with translucent background for combobox and context menu view to eliminate color underlay #161

Merged
Boria138 merged 2 commits from Dervart/PortProtonQt:combobox_fix into main 2026-05-14 11:48:24 +00:00
8 changed files with 102 additions and 0 deletions

No files matched your search

+6
View File
@@ -137,6 +137,8 @@ class ContextMenuManager:
return
menu = QMenu(file_explorer)
menu.setWindowFlags(menu.windowFlags() | Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint)
menu.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
menu.setStyleSheet(self.theme.CONTEXT_MENU_STYLE)
menu.setParent(file_explorer, Qt.WindowType.Popup) # Set transientParent for Wayland
@@ -362,6 +364,8 @@ class ContextMenuManager:
pos: The position (in widget coordinates) where the menu should appear.
"""
menu = QMenu(self.parent)
menu.setWindowFlags(menu.windowFlags() | Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint)
menu.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
menu.setStyleSheet(self.theme.CONTEXT_MENU_STYLE)
# For non-Steam games, check if exe exists
@@ -1261,6 +1265,8 @@ def show_themed_line_edit_context_menu(line_edit: QLineEdit, global_pos: QPoint,
action.setEnabled(enabled)
menu = QMenu(line_edit)
menu.setWindowFlags(menu.windowFlags() | Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint)
menu.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
current_theme = theme if theme is not None else getattr(line_edit, "theme", None)
if current_theme and hasattr(current_theme, "CONTEXT_MENU_STYLE"):
menu.setStyleSheet(current_theme.CONTEXT_MENU_STYLE)
+6
View File
@@ -583,6 +583,12 @@ class ExeSettingsDialog(DraggableDialog, MangoHudSettingsMixin, GamescopeSetting
if setting['type'] == 'combo':
combo = QComboBox()
combo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
combo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
combo.addItems(setting['options'])
if setting['key'] == 'PW_PREFIX_NAME':
combo.setEditable(True)
@@ -412,6 +412,12 @@ class GamescopeSettingsMixin:
def _create_gamescope_resolution_widget(self, target):
"""Create a resolution combo widget and bind it to width/height fields."""
widget = QComboBox()
widget.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
widget.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
widget.addItem(_("Default value"), '')
for resolution in self._get_gamescope_resolution_options():
widget.addItem(resolution, resolution)
@@ -523,6 +529,12 @@ class GamescopeSettingsMixin:
def _create_gamescope_value_widget(self, spec):
"""Create a Gamescope value widget."""
widget = QComboBox()
widget.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
widget.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
options = spec['options']
placeholder_text = _("Default value")
for option in options:
@@ -589,6 +601,12 @@ class GamescopeSettingsMixin:
self.gamescope_toggle_group = selector_group
self.gamescope_category_combo = QComboBox()
self.gamescope_category_combo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.gamescope_category_combo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.gamescope_category_combo.setStyleSheet(self.theme.COMBOBOX_STYLE + self.theme.SCROLL_STYLE)
selector_layout.addWidget(self.gamescope_category_combo)
+12
View File
@@ -443,6 +443,12 @@ class MangoHudSettingsMixin:
def _create_mangohud_value_widget(self, spec):
"""Create a MangoHud value widget."""
widget = QComboBox()
widget.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
widget.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
options = spec['options']
placeholder_text = _("Default value")
if spec['key'] == 'network':
@@ -549,6 +555,12 @@ class MangoHudSettingsMixin:
self.mangohud_toggle_group = selector_group
self.mangohud_category_combo = QComboBox()
self.mangohud_category_combo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.mangohud_category_combo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.mangohud_category_combo.addItems(list(MANGOHUD_TOGGLE_CATEGORIES.keys()))
self.mangohud_category_combo.setStyleSheet(self.theme.COMBOBOX_STYLE + self.theme.SCROLL_STYLE)
self.mangohud_category_combo.currentTextChanged.connect(self.on_mangohud_category_changed)
+54
View File
@@ -1696,6 +1696,12 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
self.wine_versions.append(version)
self.wine_versions.sort(key=version_sort_key)
self.wineCombo = QComboBox()
self.wineCombo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.wineCombo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.wineCombo.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.wineCombo.addItems(self.wine_versions)
self.wineCombo.setStyleSheet(self.theme.COMBOBOX_STYLE + self.theme.SCROLL_STYLE)
@@ -1709,6 +1715,12 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
self.prefixes = sorted([d for d in os.listdir(prefixes_path) if os.path.isdir(os.path.join(prefixes_path, d))], key=prefix_sort_key) if os.path.exists(prefixes_path) else []
self.prefixCombo = QComboBox()
self.prefixCombo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.prefixCombo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.prefixCombo.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.prefixCombo.addItems(self.prefixes)
self.prefixCombo.setEditable(True)
@@ -2164,6 +2176,12 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
scrollLayout.addWidget(genFrame)
self.timeDetailCombo = QComboBox()
self.timeDetailCombo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.timeDetailCombo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.timeDetailCombo.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.time_keys = ["detailed", "brief"]
self.time_labels = [_("Detailed"), _("Brief")]
@@ -2183,6 +2201,12 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
genForm.addRow(self.timeDetailTitle, self.timeDetailCombo)
self.gamesSortCombo = QComboBox()
self.gamesSortCombo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.gamesSortCombo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.gamesSortCombo.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.sort_keys = ["last_launch", "playtime", "alphabetical"]
self.sort_labels = [_("Last launch"), _("Playtime"), _("Alphabetical")]
@@ -2204,6 +2228,12 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
self.filter_keys = ["all", "steam", "portproton", "favorites"]
self.filter_labels = [_("All"), "Steam", "PortProton", _("Favorites")]
self.gamesDisplayCombo = QComboBox()
self.gamesDisplayCombo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.gamesDisplayCombo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.gamesDisplayCombo.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.gamesDisplayCombo.addItems(self.filter_labels)
self.gamesDisplayCombo.setStyleSheet(self.theme.COMBOBOX_STYLE + self.theme.SCROLL_STYLE)
@@ -2223,6 +2253,12 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
self.badge_view_keys = ["detailed", "compact", "hidden"]
self.badge_view_labels = [_("Detailed"), _("Compact"), _("Hidden")]
self.badgeViewCombo = QComboBox()
self.badgeViewCombo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.badgeViewCombo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.badgeViewCombo.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.badgeViewCombo.addItems(self.badge_view_labels)
self.badgeViewCombo.setStyleSheet(self.theme.COMBOBOX_STYLE + self.theme.SCROLL_STYLE)
@@ -2428,6 +2464,12 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
filtered_gpu_list = get_selectable_gpu_list()
if filtered_gpu_list:
self.gpuCombo = QComboBox()
self.gpuCombo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.gpuCombo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.gpuCombo.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.gpuCombo.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
self.gpuCombo.setStyleSheet(self.theme.COMBOBOX_STYLE + self.theme.SCROLL_STYLE)
@@ -2753,6 +2795,12 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
self.themeTabHeaderLayout.addWidget(self.themeTabTitleLabel)
self.themesCombo = QComboBox()
self.themesCombo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.themesCombo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.themesCombo.setStyleSheet(self.theme.COMBOBOX_STYLE + self.theme.SCROLL_STYLE)
self.themesCombo.setObjectName("themeTabCombo")
self.themesCombo.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
@@ -2770,6 +2818,12 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
self.themeTabHeaderLayout.addWidget(self.themesCombo)
self.themeVariantCombo = QComboBox()
self.themeVariantCombo.view().window().setWindowFlags(
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
)
self.themeVariantCombo.view().window().setAttribute(
Qt.WidgetAttribute.WA_TranslucentBackground
)
self.themeVariantCombo.setStyleSheet(self.theme.COMBOBOX_STYLE + self.theme.SCROLL_STYLE)
self.themeVariantCombo.setObjectName("themeVariantCombo")
self.themeVariantCombo.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
+2
View File
@@ -718,6 +718,8 @@ class MainWindowSystemTabMixin(_MainWindowTypingBase):
def _createSystemContextMenu(self) -> QMenu:
menu = QMenu(self)
menu.setWindowFlags(menu.windowFlags() | Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint)
menu.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
menu.setStyleSheet(self.theme.CONTEXT_MENU_STYLE)
menu.setParent(self, Qt.WindowType.Popup)
return menu
@@ -1401,6 +1401,8 @@ CONTEXT_MENU_STYLE = f"""
font-size: {font_size_a};
padding: 5px;
min-width: 150px;
border: {border_b} {color_a};
border-radius: {border_radius_a};
}}
QMenu::icon {{
margin-left: 15px;
@@ -8,6 +8,8 @@ CONTEXT_MENU_STYLE = f"""
font-size: {font_size_a};
padding: 5px;
min-width: 150px;
border: {border_b} {color_a};
border-radius: {border_radius_a};
}}
QMenu::icon {{
margin-left: 15px;