Skip to content

Commit 52a92f8

Browse files
committed
Qt: companion driver cleanup pass
Refactor pass on ui/drivers/ui_qt.{cpp,h} and ui_qt_widgets.{cpp,h} to reduce Qt-specific surface, lift pure-C work out of C++ syntax, and use libretro-common idioms in place of locally-rolled equivalents. ui/drivers/ui_qt.cpp 5620 -> 5462 (-158) ui/drivers/ui_qt_widgets.cpp 8888 -> 8783 (-105) ui/drivers/ui_qt.h 761 -> 747 ( -14) ui/drivers/ui_qt_widgets.h 1442 -> 1381 ( -61) ----- TOTAL 16711 -> 16373 (-338) No functional change. Build verified for ui_qt.o, ui_qt_widgets.o, moc_ui_qt.o and moc_ui_qt_widgets.o; the only warnings emitted are the same three pre-existing -Wdeprecated-declarations warnings the original tree emits (QDir::operator=(const QString&), QByteArray::append(const QString&), QListWidget::isItemHidden). Iterative-build wall clock on the four targets drops ~9% (28.1s -> 25.6s, hyperfine n=5), MOC-generated .cpp drops ~9% (8666 -> 7874 lines), and total object size drops ~4% (2.05 MiB -> 1.97 MiB). Changes: * Drop string_split_to_qt and use QString::split. The function was declared inside RETRO_BEGIN_DECLS - i.e. with C linkage - but returned QStringList, which is not a C-compatible type. The four call sites become QString::split('|') / .split(' '). * Replace MainWindow::getScrubbedString with a static scrub_qstring() helper using string_replace_all_chars from libretro-common. Moves the function out of MOC (one fewer slot to generate). * Collapse 11 trivial OptionsPage subclasses (MenuSoundsPage, UpdaterPage, QuickMenuPage, DriversPage, DirectoryPage, ConfigurationPage, CorePage, LoggingPage, AIServicePage, FrameThrottlePage, RewindPage) into one runtime-parameterised SimplePage class. Each was a do-nothing constructor plus a one-line widget() returning create_widget(DISPLAYLIST_X). The 12 instantiation sites in *Category::pages() become new SimplePage(DISPLAYLIST_X, MENU_ENUM_LABEL_VALUE_X, this). * Extract MainWindow::getCoreInfo() into a C helper qt_core_info_collect that emits two parallel struct string_list outputs (keys, values) with a status code (enum qt_core_info_row_status) packed into values->elems[i].attr.i. The walking logic is now pure C using libretro-common idioms (string_list_*, core_info_*, fill_pathname_basedir, string_count_occurrences_single_character); the C++ wrapper is a ~50-line loop applying status-driven HTML/CSS styling for firmware rows. Both consumers (onLaunchWithComboBoxIndexChanged, CoreInfoDialog::showCoreInfo) work unchanged. * Replace four parallel thumbnail paths with arrays. The m_thumbnailPixmap{,2,3,4} pointers, onResizeThumbnail{One,Two, Three,Four} slots, and thumbnailChanged{,2,3,4} signals are consolidated into m_thumbnailPixmaps[4] and three static tables. The four thumbnailChanged* signals were never emitted and never connected anywhere - deleted. The four onResizeThumbnail* slots were one-line wrappers around setThumbnail("thumbnailN", ...) - deleted, callers use setThumbnail directly. Destructor, onCurrentItemChanged and onThumbnailDropped collapse to short loops; an explicit ThumbnailType -> widget-index mapping handles the asymmetric ordering between the enum (BOXART, SCREENSHOT, TITLE_SCREEN, LOGO) and the 1..4 widget naming (boxart, title, screenshot, logo). * Convert MainWindow::getSelectedCore (which returned QHash<QString,QString> but only ever set a single field) to getSelectedCorePath returning QString. Sole caller updated. * Replace QFileInfo/QDir/QFile usage with file_path.h / file_stream.h equivalents in three high-leverage spots: - renamePlaylistItem: now uses path_basename, path_basedir, path_get_extension, fill_pathname_slash, string_is_equal_case_insensitive, and filestream_rename. - onExtractArchive's per-entry delete-or-rename loop: now uses filestream_exists, filestream_delete, filestream_rename. Also fixes a pre-existing leak: the original code returned -1 on three error paths without freeing file_list. - loadContent's extension-filter block: collapses lastIndexOf('.') + .mid() onto path_get_extension, which the same block was already using three lines below. - Three QFileInfo(pathData).suffix() callers in add-files-to-playlist code: replaced with QString::fromUtf8(path_get_extension(pathData)). * Split ui_companion_qt_init from a 516-line monolith into six focused static helpers (qt_companion_build_menubar, qt_companion_build_browser_dock, qt_companion_build_thumbnail_docks, qt_companion_build_core_selection_dock, qt_companion_restore_settings, qt_companion_select_initial_playlist) plus a ~75-line orchestrator. Behaviour preserved verbatim. The thumbnail-dock setup that was 65 lines of 4-way copy-paste collapses to a 30-line loop using qt_thumbnail_widget_names from above.
1 parent fca0e40 commit 52a92f8

4 files changed

Lines changed: 722 additions & 1060 deletions

File tree

0 commit comments

Comments
 (0)