diff --git a/Makefile.common b/Makefile.common index e423ade1a56..ef68568148e 100644 --- a/Makefile.common +++ b/Makefile.common @@ -15,7 +15,7 @@ ifeq ($(HAVE_NOUNUSED_VARIABLE), 1) DEF_FLAGS += $(NOUNUSED_VARIABLE_CFLAGS) endif -ifeq ($(HAVE_CXX17), 1) +ifeq ($(HAVE_QT6), 1) CXXFLAGS += $(CXX17_CFLAGS) else ifeq ($(HAVE_CXX11), 1) CXXFLAGS += $(CXX11_CFLAGS) @@ -533,10 +533,18 @@ ifeq ($(HAVE_QT), 1) endif DEFINES += -DHAVE_MAIN +ifeq ($(HAVE_QT6), 1) CXXFLAGS += -DQT_DISABLE_DEPRECATED_BEFORE=0x060000 $(QT6CORE_CFLAGS) $(QT6GUI_CFLAGS) $(QT6WIDGETS_CFLAGS) $(QT6CONCURRENT_CFLAGS) $(QT6NETWORK_CFLAGS) #DEF_FLAGS += $(QT6WEBENGINE_CFLAGS) LIBS += $(QT6CORE_LIBS) $(QT6GUI_LIBS) $(QT6WIDGETS_LIBS) $(QT6CONCURRENT_LIBS) $(QT6NETWORK_LIBS) #LIBS += $(QT6WEBENGINE_LIBS) +else + DEF_FLAGS += $(QT5CORE_CFLAGS) $(QT5GUI_CFLAGS) $(QT5WIDGETS_CFLAGS) $(QT5CONCURRENT_CFLAGS) $(QT5NETWORK_CFLAGS) + #DEF_FLAGS += $(QT5WEBENGINE_CFLAGS) + LIBS += $(QT5CORE_LIBS) $(QT5GUI_LIBS) $(QT5WIDGETS_LIBS) $(QT5CONCURRENT_LIBS) $(QT5NETWORK_LIBS) + #LIBS += $(QT5WEBENGINE_LIBS) +endif + NEED_CXX_LINKER = 1 ifneq ($(findstring Linux,$(OS)),) diff --git a/qb/config.libs.sh b/qb/config.libs.sh index b83e24dfa10..79584792e78 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -304,13 +304,35 @@ if [ "$HAVE_QT" != 'no' ]; then if [ "$HAVE_QT" != yes ]; then die : 'Notice: Qt support disabled, required libraries were not found.' + else + HAVE_QT6='yes' + add_define MAKEFILE HAVE_QT6 1 fi + fi + if [ "$HAVE_QT6" != 'yes' ]; then + HAVE_QT='auto' + check_pkgconf QT5CORE Qt5Core 5.2 + check_pkgconf QT5GUI Qt5Gui 5.2 + check_pkgconf QT5WIDGETS Qt5Widgets 5.2 + check_pkgconf QT5CONCURRENT Qt5Concurrent 5.2 + check_pkgconf QT5NETWORK Qt5Network 5.2 + #check_pkgconf QT5WEBENGINE Qt6WebEngine 5.2 + + # pkg-config is needed to reliably find Qt5 libraries. + + check_enabled QT5CORE QT Qt 'Qt5Core is' true + check_enabled QT5GUI QT Qt 'Qt5GUI is' true + check_enabled QT5WIDGETS QT Qt 'Qt5Widgets is' true + check_enabled QT5CONCURRENT QT Qt 'Qt5Concurrent is' true + check_enabled QT5NETWORK QT Qt 'Qt5Network is' true + #check_enabled QT5WEBENGINE QT Qt 'Qt5Webengine is' true - check_pkgconf OPENSSL openssl 1.0.0 - else - HAVE_QT='no' - die : 'Notice: Qt support disabled, required compiler was not found.' + if [ "$HAVE_QT" != yes ]; then + die : 'Notice: Qt support disabled, required libraries were not found.' + fi fi + + check_pkgconf OPENSSL openssl 1.0.0 fi check_enabled FLAC BUILTINFLAC 'builtin flac' 'flac is' true diff --git a/qb/config.moc.sh b/qb/config.moc.sh index 24c88fb1af2..3102c77888f 100644 --- a/qb/config.moc.sh +++ b/qb/config.moc.sh @@ -1,4 +1,4 @@ -QT_VERSION=qt6 -QT_FLAGS="$CXX17_CFLAGS $QT6CORE_CFLAGS $QT6CORE_LIBS" +[ "$HAVE_QT6" = "yes" ] && QT_VERSION=qt6 || QT_VERSION=qt5 +[ "$HAVE_QT6" = "yes" ] && QT_FLAGS="$CXX17_CFLAGS $QT6CORE_CFLAGS $QT6CORE_LIBS" || QT_FLAGS="$CXX11_CFLAGS $QT5CORE_CFLAGS $QT5CORE_LIBS" add_define MAKEFILE QT_VERSION "$QT_VERSION" diff --git a/qb/qb.moc.sh b/qb/qb.moc.sh index c421830353b..f360c8296a5 100644 --- a/qb/qb.moc.sh +++ b/qb/qb.moc.sh @@ -29,10 +29,12 @@ if [ "$HAVE_QT" = "yes" ]; then >/dev/null 2>&1 && moc_works=1 else - for moc in "moc-$QT_VERSION" moc; do + if [ "$QT_VERSION" = "qt6" ]; then QMAKE="$(exists qmake6)" || QMAKE="qmake" - QT_HOST_LIBEXECS="$($QMAKE -query QT_HOST_LIBEXECS)" - MOC="$(exists "$QT_HOST_LIBEXECS/$moc")" || MOC="" + $QMAKE -query QT_HOST_LIBEXECS && QT_HOST_LIBEXECS="$($QMAKE -query QT_HOST_LIBEXECS)/" + fi + for moc in "${QT_HOST_LIBEXECS}moc-$QT_VERSION" "${QT_HOST_LIBEXECS}moc"; do + MOC="$(exists "$moc")" || MOC="" if [ "$MOC" ]; then QT_SELECT="$QT_VERSION" \ "$MOC" -o "$TEMP_CPP" "$TEMP_MOC" >/dev/null 2>&1 || diff --git a/ui/drivers/qt/gridview.cpp b/ui/drivers/qt/gridview.cpp index cf617263768..1565ca9426b 100644 --- a/ui/drivers/qt/gridview.cpp +++ b/ui/drivers/qt/gridview.cpp @@ -391,8 +391,12 @@ void GridView::paintEvent(QPaintEvent*) { QModelIndex index = model()->index(row, 0, rootIndex()); QRectF rect = viewportRectForRow(row); +#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) QStyleOptionViewItem option; initViewItemOption(&option); +#else + QStyleOptionViewItem option = viewOptions(); +#endif if (!rect.isValid() || rect.bottom() < 0 || rect.y() > viewport()->height()) continue; diff --git a/ui/drivers/qt/qt_dialogs.cpp b/ui/drivers/qt/qt_dialogs.cpp index a81c1a63736..8231d2bdb93 100644 --- a/ui/drivers/qt/qt_dialogs.cpp +++ b/ui/drivers/qt/qt_dialogs.cpp @@ -543,7 +543,11 @@ 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)) m_optionsStack->setContentsMargins(0, 0, 0, 0); +#else + m_optionsStack->setMargin(0); +#endif headerLabelFont.setBold(true); @@ -1193,7 +1197,11 @@ void CoreOptionsDialog::buildLayout() } for (k = 0; k < option->vals->size; k++) +#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) combo_box->addItem(option->vals->elems[k].data, QVariant::fromValue(option->key)); +#else + combo_box->addItem(option->vals->elems[k].data, option->key); +#endif combo_box->setCurrentText(val); diff --git a/ui/drivers/qt/qt_options.cpp b/ui/drivers/qt/qt_options.cpp index 35fea220e94..dde1345b475 100644 --- a/ui/drivers/qt/qt_options.cpp +++ b/ui/drivers/qt/qt_options.cpp @@ -549,7 +549,12 @@ QGroupBox *NetplayPage::createMitmServerGroup() groupBox->add(MENU_ENUM_LABEL_NETPLAY_CUSTOM_MITM_SERVER); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) connect(buttonGroup, &QButtonGroup::idClicked, this, &NetplayPage::onRadioButtonClicked); +#else + connect(buttonGroup, SIGNAL(buttonClicked(int)), this, + SLOT(onRadioButtonClicked(int))); +#endif return groupBox; } @@ -1438,7 +1443,12 @@ QWidget *VideoPage::widget() layout->addStretch(); - connect(m_resolutionCombo, &QComboBox::currentIndexChanged, this, &VideoPage::onResolutionComboIndexChanged); +#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) + void (VideoPage::*cb)(int) = &VideoPage::onResolutionComboIndexChanged; + connect(m_resolutionCombo, &QComboBox::currentIndexChanged, this, cb); +#else + connect(m_resolutionCombo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(onResolutionComboIndexChanged(const QString&))); +#endif widget->setLayout(layout); @@ -1566,6 +1576,13 @@ QWidget *CrtSwitchresPage::widget() return widget; } +void VideoPage::onResolutionComboIndexChanged(const QString &text) +{ + const char *path = text.toUtf8().constData(); + action_cb_push_dropdown_item_resolution(path, + NULL, 0, 0, 0); +} + void VideoPage::onResolutionComboIndexChanged(int index) { const QString& text = m_resolutionCombo->itemText(index); diff --git a/ui/drivers/qt/qt_options.h b/ui/drivers/qt/qt_options.h index a67181f96c1..6eb8d322866 100644 --- a/ui/drivers/qt/qt_options.h +++ b/ui/drivers/qt/qt_options.h @@ -154,6 +154,7 @@ class VideoPage : public OptionsPage VideoPage(QObject *parent = nullptr); QWidget *widget(); private slots: + Q_DECL_DEPRECATED void onResolutionComboIndexChanged(const QString& value); void onResolutionComboIndexChanged(int index); private: QComboBox *m_resolutionCombo; diff --git a/ui/drivers/qt/qt_playlist.cpp b/ui/drivers/qt/qt_playlist.cpp index 225e61c5144..92506306376 100644 --- a/ui/drivers/qt/qt_playlist.cpp +++ b/ui/drivers/qt/qt_playlist.cpp @@ -246,7 +246,11 @@ 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)) QtConcurrent::run(&PlaylistModel::loadImage, this, index, path); +#else + QtConcurrent::run(this, &PlaylistModel::loadImage, index, path); +#endif } } @@ -874,7 +878,11 @@ 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)) bool hidden = item->isHidden(); +#else + bool hidden = m_listWidget->isItemHidden(item); +#endif if (hidden) { diff --git a/ui/drivers/qt/qt_widgets.cpp b/ui/drivers/qt/qt_widgets.cpp index 18fd31354f7..d6ec17c688f 100644 --- a/ui/drivers/qt/qt_widgets.cpp +++ b/ui/drivers/qt/qt_widgets.cpp @@ -724,7 +724,11 @@ UIntRadioButtons::UIntRadioButtons(rarch_setting_t *setting, QWidget *parent) : *setting->value.target.unsigned_integer = orig_value; } add_sublabel_and_whats_this(this, m_setting); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) connect(m_buttonGroup, &QButtonGroup::idClicked, this, &UIntRadioButtons::onButtonClicked); +#else + connect(m_buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(onButtonClicked(int))); +#endif } UIntRadioButtons::UIntRadioButtons(msg_hash_enums enum_idx, QWidget *parent) : diff --git a/ui/drivers/ui_qt.cpp b/ui/drivers/ui_qt.cpp index 25c743d02e3..aedf8b45125 100644 --- a/ui/drivers/ui_qt.cpp +++ b/ui/drivers/ui_qt.cpp @@ -3107,8 +3107,13 @@ void MainWindow::setCoreActions() if (!found_existing) { QVariantMap comboBoxMap; +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) comboBoxMap["core_name"] = QVariant::fromValue(coreInfo->core_name); comboBoxMap["core_path"] = QVariant::fromValue(coreInfo->path); +#else + comboBoxMap["core_name"] = coreInfo->core_name; + comboBoxMap["core_path"] = coreInfo->path; +#endif comboBoxMap["core_selection"] = CORE_SELECTION_PLAYLIST_DEFAULT; m_launchWithComboBox->addItem(coreInfo->core_name, QVariant::fromValue(comboBoxMap)); } @@ -4216,6 +4221,11 @@ static void* ui_application_qt_initialize(void) app_handler = new AppHandler(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + /* HiDpi supported since Qt 5.6 */ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif + /* Create QApplication() before calling QApplication::setStyle() * to ensure that plugin path is determined correctly */ ui_application.app = new QApplication(app_argc, app_argv); @@ -4255,6 +4265,10 @@ static void* ui_application_qt_initialize(void) static void ui_application_qt_process_events(void) { +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + QAbstractEventDispatcher *dispatcher = QApplication::eventDispatcher(); + if (dispatcher && dispatcher->hasPendingEvents()) +#endif QApplication::processEvents(); } @@ -5147,7 +5161,11 @@ void LoadCoreWindow::onCoreEnterPressed() Qt::UserRole).toHash(); QString path = hash["path"].toString(); +#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) pathArray.append(path.toStdString()); +#else + pathArray.append(path); +#endif pathData = pathArray.constData(); loadCore(pathData);