From 6de5ebadf9462ea48978850c811fea592e592aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Via=C4=8Das=C5=82a=C5=AD?= Date: Mon, 25 Nov 2024 01:50:56 +0300 Subject: [PATCH] Revert Qt5 implementation (#17202) --- ui/drivers/qt/gridview.cpp | 2 +- ui/drivers/qt/qt_dialogs.cpp | 2 +- ui/drivers/qt/qt_options.cpp | 2 +- ui/drivers/qt/qt_playlist.cpp | 8 +++++-- ui/drivers/ui_qt.cpp | 39 +++++++++++++++++++++++++++++------ 5 files changed, 42 insertions(+), 11 deletions(-) diff --git a/ui/drivers/qt/gridview.cpp b/ui/drivers/qt/gridview.cpp index 1565ca9426..d2e5e451a5 100644 --- a/ui/drivers/qt/gridview.cpp +++ b/ui/drivers/qt/gridview.cpp @@ -391,7 +391,7 @@ void GridView::paintEvent(QPaintEvent*) { QModelIndex index = model()->index(row, 0, rootIndex()); QRectF rect = viewportRectForRow(row); -#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) QStyleOptionViewItem option; initViewItemOption(&option); #else diff --git a/ui/drivers/qt/qt_dialogs.cpp b/ui/drivers/qt/qt_dialogs.cpp index db2f96b1a9..69c0de4d75 100644 --- a/ui/drivers/qt/qt_dialogs.cpp +++ b/ui/drivers/qt/qt_dialogs.cpp @@ -543,7 +543,7 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) : QHBoxLayout *headerHLayout = new QHBoxLayout; const int leftMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin); -#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) m_optionsStack->setContentsMargins(0, 0, 0, 0); #else m_optionsStack->setMargin(0); diff --git a/ui/drivers/qt/qt_options.cpp b/ui/drivers/qt/qt_options.cpp index 0308d51be6..8efa77c450 100644 --- a/ui/drivers/qt/qt_options.cpp +++ b/ui/drivers/qt/qt_options.cpp @@ -1443,7 +1443,7 @@ QWidget *VideoPage::widget() layout->addStretch(); -#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) void (VideoPage::*cb)(int) = &VideoPage::onResolutionComboIndexChanged; connect(m_resolutionCombo, &QComboBox::currentIndexChanged, this, cb); #else diff --git a/ui/drivers/qt/qt_playlist.cpp b/ui/drivers/qt/qt_playlist.cpp index 9250630637..7ee0d49188 100644 --- a/ui/drivers/qt/qt_playlist.cpp +++ b/ui/drivers/qt/qt_playlist.cpp @@ -246,7 +246,7 @@ void PlaylistModel::loadThumbnail(const QModelIndex &index) if (!m_pendingImages.contains(path) && !m_cache.contains(path)) { m_pendingImages.insert(path); -#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) QtConcurrent::run(&PlaylistModel::loadImage, this, index, path); #else QtConcurrent::run(this, &PlaylistModel::loadImage, index, path); @@ -878,7 +878,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&) for (j = 0; j < m_listWidget->count(); j++) { QListWidgetItem *item = m_listWidget->item(j); -#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) bool hidden = item->isHidden(); #else bool hidden = m_listWidget->isItemHidden(item); @@ -1499,7 +1499,11 @@ void PlaylistModel::getPlaylistItems(QString path) playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match; playlist_config_set_base_content_directory(&playlist_config, settings->bools.playlist_portable_paths ? settings->paths.directory_menu_content : NULL); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) pathArray.append(path.toUtf8()); +#else + pathArray.append(path); +#endif pathData = pathArray.constData(); if (!string_is_empty(pathData)) playlistName = path_basename(pathData); diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index f2fb1f9c92..a8a40a0b0d 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -20,6 +20,11 @@ #include #include #include + +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +#include +#endif + #include #include #include @@ -1908,7 +1913,7 @@ void MainWindow::onFileBrowserTreeContextMenuRequested(const QPoint&) if (currentDirString.isEmpty()) return; -#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) dir.setPath(currentDirString); #else dir = currentDirString; @@ -2629,13 +2634,13 @@ void MainWindow::selectBrowserDir(QString path) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) m_proxyFileModel->setFilterRegularExpression(QRegularExpression()); #else - m_proxyFileModel->setFilterRegExp(QRegExp()); + m_proxyFileModel->setFilterRegExp(QRegExp()); #endif m_fileTableView->setRootIndex(m_proxyFileModel->mapFromSource(sourceIndex)); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) m_proxyFileModel->setFilterRegularExpression(m_searchRegularExpression); #else - m_proxyFileModel->setFilterRegExp(m_searchRegExp); + m_proxyFileModel->setFilterRegExp(m_searchRegExp); #endif } } @@ -3194,8 +3199,13 @@ QComboBox* MainWindow::launchWithComboBox() void MainWindow::onSearchLineEditEdited(const QString &text) { int i; +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) QVector textHiraToKata; QVector textKataToHira; +#else + QVector textHiraToKata; + QVector textKataToHira; +#endif QVector textUnicode = text.toUcs4(); bool found_hiragana = false; bool found_katakana = false; @@ -4312,7 +4322,7 @@ static void ui_application_qt_process_events(void) QAbstractEventDispatcher *dispatcher = QApplication::eventDispatcher(); if (dispatcher && dispatcher->hasPendingEvents()) #endif - QApplication::processEvents(); + QApplication::processEvents(); } static void ui_application_qt_quit(void) @@ -4550,7 +4560,11 @@ static void* ui_companion_qt_init(void) QVBoxLayout *launchWithWidgetLayout = NULL; QHBoxLayout *coreComboBoxLayout = NULL; QMenuBar *menu = NULL; +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) QScreen *screen = NULL; +#else + QDesktopWidget *desktop = NULL; +#endif QMenu *fileMenu = NULL; QMenu *editMenu = NULL; QMenu *viewMenu = NULL; @@ -4593,8 +4607,13 @@ static void* ui_companion_qt_init(void) (ui_application_qt.initialize()); handle->window = static_cast(ui_window_qt.init()); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) screen = qApp->primaryScreen(); desktopRect = screen->availableGeometry(); +#else + desktop = qApp->desktop(); + desktopRect = desktop->availableGeometry(); +#endif mainwindow = handle->window->qtWindow; @@ -5204,7 +5223,7 @@ void LoadCoreWindow::onCoreEnterPressed() Qt::UserRole).toHash(); QString path = hash["path"].toString(); -#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) pathArray.append(path.toStdString()); #else pathArray.append(path); @@ -5238,7 +5257,11 @@ void LoadCoreWindow::onLoadCustomCoreClicked() if (path.isEmpty()) return; +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) pathArray.append(path.toUtf8()); +#else + pathArray.append(path); +#endif pathData = pathArray.constData(); loadCore(pathData); @@ -5250,7 +5273,11 @@ void LoadCoreWindow::initCoreList(const QStringList &extensionFilters) unsigned i; QStringList horizontal_header_labels; core_info_list_t *cores = NULL; - QScreen *desktop = qApp->primaryScreen(); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + QScreen *desktop = qApp->primaryScreen(); +#else + QDesktopWidget *desktop = qApp->desktop(); +#endif QRect desktopRect = desktop->availableGeometry(); horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME);