#!/usr/bin/env python3 # Copyright (c) 2026 Storm Dragon # Authors: Storm Dragon, Angus Kola # SPDX-License-Identifier: GPL-3.0-or-later """Minimal Toby Doom Launcher combo-box fixture for native diagnostics.""" from PySide6.QtCore import Qt from PySide6.QtWidgets import QApplication, QComboBox, QLabel, QLineEdit, QPushButton, QVBoxLayout, QWidget class AccessibleComboBox(QComboBox): def __init__(self, parent=None): super().__init__(parent) self.setEditable(True) self.lineEdit().setReadOnly(True) self.pageStep = 5 def keyPressEvent(self, event): current_index = self.currentIndex() item_count = self.count() if event.key() == Qt.Key_PageUp: self.setCurrentIndex(max(0, current_index - self.pageStep)) elif event.key() == Qt.Key_PageDown: self.setCurrentIndex(min(item_count - 1, current_index + self.pageStep)) elif event.key() == Qt.Key_Home: self.setCurrentIndex(0) self.setFocus() self.currentIndexChanged.emit(0) self.activated.emit(0) elif event.key() == Qt.Key_End: last_index = item_count - 1 self.setCurrentIndex(last_index) self.setFocus() self.currentIndexChanged.emit(last_index) self.activated.emit(last_index) else: super().keyPressEvent(event) application = QApplication([]) window = QWidget() window.setWindowTitle("Toby combo probe") layout = QVBoxLayout(window) label = QLabel("Game") combo = AccessibleComboBox() combo.setAccessibleName("Game") combo.addItems(("Classic Doom", "Bring Back the 90s", "Funny Pack - Toby Doom")) label.setBuddy(combo) layout.addWidget(label) layout.addWidget(combo) button = QPushButton("Launch") layout.addWidget(button) editor = QLineEdit("alpha beta") editor.setAccessibleName("Plain editor") layout.addWidget(editor) read_only = QLineEdit("alpha beta") read_only.setReadOnly(True) read_only.setAccessibleName("Read-only text") layout.addWidget(read_only) writable_combo = QComboBox() writable_combo.setEditable(True) writable_combo.addItems(("alpha beta", "gamma delta")) layout.addWidget(writable_combo) window.resize(420, 300) window.show() combo.setFocus() application.exec()