Migrate to Qt6 (#17167)

* (Qt) Migrate to Qt6

* basic support Qt6 with minimal changes required for compiling
* look `moc` in QT_HOST_LIBEXECS

* (Qt) Backward compatibility with Qt5
This commit is contained in:
Viačasłaŭ 2024-11-24 15:30:47 +03:00 committed by GitHub
parent b95c15cfdf
commit 3e2f0131ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 200 additions and 93 deletions

3
.gitignore vendored
View File

@ -249,3 +249,6 @@ param.sfo
# Visual Studio Code # Visual Studio Code
.vscode/ .vscode/
# Clazy
*.clazy.yaml

View File

@ -15,7 +15,9 @@ ifeq ($(HAVE_NOUNUSED_VARIABLE), 1)
DEF_FLAGS += $(NOUNUSED_VARIABLE_CFLAGS) DEF_FLAGS += $(NOUNUSED_VARIABLE_CFLAGS)
endif endif
ifeq ($(HAVE_CXX11), 1) ifeq ($(HAVE_QT6), 1)
CXXFLAGS += $(CXX17_CFLAGS)
else ifeq ($(HAVE_CXX11), 1)
CXXFLAGS += $(CXX11_CFLAGS) CXXFLAGS += $(CXX11_CFLAGS)
endif endif
@ -535,10 +537,18 @@ ifeq ($(HAVE_QT), 1)
endif endif
DEFINES += -DHAVE_MAIN 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 += $(QT5CORE_CFLAGS) $(QT5GUI_CFLAGS) $(QT5WIDGETS_CFLAGS) $(QT5CONCURRENT_CFLAGS) $(QT5NETWORK_CFLAGS)
#DEF_FLAGS += $(QT5WEBENGINE_CFLAGS) #DEF_FLAGS += $(QT5WEBENGINE_CFLAGS)
LIBS += $(QT5CORE_LIBS) $(QT5GUI_LIBS) $(QT5WIDGETS_LIBS) $(QT5CONCURRENT_LIBS) $(QT5NETWORK_LIBS) LIBS += $(QT5CORE_LIBS) $(QT5GUI_LIBS) $(QT5WIDGETS_LIBS) $(QT5CONCURRENT_LIBS) $(QT5NETWORK_LIBS)
#LIBS += $(QT5WEBENGINE_LIBS) #LIBS += $(QT5WEBENGINE_LIBS)
endif
NEED_CXX_LINKER = 1 NEED_CXX_LINKER = 1
ifneq ($(findstring Linux,$(OS)),) ifneq ($(findstring Linux,$(OS)),)

View File

@ -12,6 +12,7 @@ if [ "$HAVE_C99" = 'no' ]; then
fi fi
check_switch cxx CXX11 -std=c++11 '' check_switch cxx CXX11 -std=c++11 ''
check_switch cxx CXX17 -std=c++17 ''
check_switch '' NOUNUSED -Wno-unused-result '' check_switch '' NOUNUSED -Wno-unused-result ''
check_switch '' NOUNUSED_VARIABLE -Wno-unused-variable '' check_switch '' NOUNUSED_VARIABLE -Wno-unused-variable ''
@ -277,18 +278,45 @@ if [ "$HAVE_SDL2" = 'yes' ] && [ "$HAVE_SDL" = 'yes' ]; then
fi fi
check_enabled CXX11 CXX C++ 'C++11 support is' false check_enabled CXX11 CXX C++ 'C++11 support is' false
check_enabled CXX17 CXX C++ 'C++17 support is' false
check_platform Haiku DISCORD 'Discord is' false check_platform Haiku DISCORD 'Discord is' false
check_enabled CXX DISCORD discord 'The C++ compiler is' false check_enabled CXX DISCORD discord 'The C++ compiler is' false
check_enabled CXX QT 'Qt companion' 'The C++ compiler is' false check_enabled CXX QT 'Qt companion' 'The C++ compiler is' false
if [ "$HAVE_QT" != 'no' ]; then if [ "$HAVE_QT" != 'no' ]; then
if [ "$HAVE_CXX17" = 'yes' ]; then
check_pkgconf QT6CORE Qt6Core 6.2
check_pkgconf QT6GUI Qt6Gui 6.2
check_pkgconf QT6WIDGETS Qt6Widgets 6.2
check_pkgconf QT6CONCURRENT Qt6Concurrent 6.2
check_pkgconf QT6NETWORK Qt6Network 6.2
#check_pkgconf QT6WEBENGINE Qt6WebEngine 6.2
# pkg-config is needed to reliably find Qt6 libraries.
check_enabled QT6CORE QT Qt 'Qt6Core is' true
check_enabled QT6GUI QT Qt 'Qt6GUI is' true
check_enabled QT6WIDGETS QT Qt 'Qt6Widgets is' true
check_enabled QT6CONCURRENT QT Qt 'Qt6Concurrent is' true
check_enabled QT6NETWORK QT Qt 'Qt6Network is' true
#check_enabled QT6WEBENGINE QT Qt 'Qt6Webengine is' true
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 QT5CORE Qt5Core 5.2
check_pkgconf QT5GUI Qt5Gui 5.2 check_pkgconf QT5GUI Qt5Gui 5.2
check_pkgconf QT5WIDGETS Qt5Widgets 5.2 check_pkgconf QT5WIDGETS Qt5Widgets 5.2
check_pkgconf QT5CONCURRENT Qt5Concurrent 5.2 check_pkgconf QT5CONCURRENT Qt5Concurrent 5.2
check_pkgconf QT5NETWORK Qt5Network 5.2 check_pkgconf QT5NETWORK Qt5Network 5.2
#check_pkgconf QT5WEBENGINE Qt5WebEngine 5.4 #check_pkgconf QT5WEBENGINE Qt6WebEngine 5.2
# pkg-config is needed to reliably find Qt5 libraries. # pkg-config is needed to reliably find Qt5 libraries.
@ -302,6 +330,7 @@ if [ "$HAVE_QT" != 'no' ]; then
if [ "$HAVE_QT" != yes ]; then if [ "$HAVE_QT" != yes ]; then
die : 'Notice: Qt support disabled, required libraries were not found.' die : 'Notice: Qt support disabled, required libraries were not found.'
fi fi
fi
check_pkgconf OPENSSL openssl 1.0.0 check_pkgconf OPENSSL openssl 1.0.0
fi fi

View File

@ -1,4 +1,4 @@
QT_VERSION=qt5 [ "$HAVE_QT6" = "yes" ] && QT_VERSION=qt6 || QT_VERSION=qt5
QT_FLAGS="$CXX11_CFLAGS $QT5CORE_CFLAGS $QT5CORE_LIBS" [ "$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" add_define MAKEFILE QT_VERSION "$QT_VERSION"

View File

@ -29,7 +29,11 @@ if [ "$HAVE_QT" = "yes" ]; then
>/dev/null 2>&1 && >/dev/null 2>&1 &&
moc_works=1 moc_works=1
else else
for moc in "moc-$QT_VERSION" moc; do if [ "$QT_VERSION" = "qt6" ]; then
QMAKE="$(exists qmake6)" || QMAKE="qmake"
$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="" MOC="$(exists "$moc")" || MOC=""
if [ "$MOC" ]; then if [ "$MOC" ]; then
QT_SELECT="$QT_VERSION" \ QT_SELECT="$QT_VERSION" \

View File

@ -391,7 +391,12 @@ void GridView::paintEvent(QPaintEvent*)
{ {
QModelIndex index = model()->index(row, 0, rootIndex()); QModelIndex index = model()->index(row, 0, rootIndex());
QRectF rect = viewportRectForRow(row); QRectF rect = viewportRectForRow(row);
#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0))
QStyleOptionViewItem option;
initViewItemOption(&option);
#else
QStyleOptionViewItem option = viewOptions(); QStyleOptionViewItem option = viewOptions();
#endif
if (!rect.isValid() || rect.bottom() < 0 || rect.y() > viewport()->height()) if (!rect.isValid() || rect.bottom() < 0 || rect.y() > viewport()->height())
continue; continue;

View File

@ -455,7 +455,7 @@ QColor getLabelColor(const QString& objectName)
QLabel dummyColor; QLabel dummyColor;
dummyColor.setObjectName(objectName); dummyColor.setObjectName(objectName);
dummyColor.ensurePolished(); dummyColor.ensurePolished();
return dummyColor.palette().color(QPalette::Foreground); return dummyColor.palette().color(QPalette::WindowText);
} }
/* stolen from Qt Creator */ /* stolen from Qt Creator */
@ -543,7 +543,11 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
QHBoxLayout *headerHLayout = new QHBoxLayout; QHBoxLayout *headerHLayout = new QHBoxLayout;
const int leftMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin); 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); m_optionsStack->setMargin(0);
#endif
headerLabelFont.setBold(true); headerLabelFont.setBold(true);
@ -1193,7 +1197,12 @@ void CoreOptionsDialog::buildLayout()
} }
for (k = 0; k < option->vals->size; k++) 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); combo_box->addItem(option->vals->elems[k].data, option->key);
#endif
combo_box->setCurrentText(val); combo_box->setCurrentText(val);
combo_box->setProperty("default_index", combo_box->setProperty("default_index",
@ -1746,19 +1755,19 @@ void ShaderParamsDialog::onShaderLoadPresetClicked()
* of all shader types instead of hard-coding this? */ * of all shader types instead of hard-coding this? */
if (video_shader_is_supported(RARCH_SHADER_CG)) if (video_shader_is_supported(RARCH_SHADER_CG))
{ {
filter.append(QLatin1Literal(" *")); filter.append(QLatin1String(" *"));
filter.append(".cgp"); filter.append(".cgp");
} }
if (video_shader_is_supported(RARCH_SHADER_GLSL)) if (video_shader_is_supported(RARCH_SHADER_GLSL))
{ {
filter.append(QLatin1Literal(" *")); filter.append(QLatin1String(" *"));
filter.append(".glslp"); filter.append(".glslp");
} }
if (video_shader_is_supported(RARCH_SHADER_SLANG)) if (video_shader_is_supported(RARCH_SHADER_SLANG))
{ {
filter.append(QLatin1Literal(" *")); filter.append(QLatin1String(" *"));
filter.append(".slangp"); filter.append(".slangp");
} }
@ -1904,13 +1913,13 @@ void ShaderParamsDialog::onShaderAddPassClicked()
/* NOTE: Maybe we should have a way to get a list /* NOTE: Maybe we should have a way to get a list
* of all shader types instead of hard-coding this? */ * of all shader types instead of hard-coding this? */
if (video_shader_is_supported(RARCH_SHADER_CG)) if (video_shader_is_supported(RARCH_SHADER_CG))
filter.append(QLatin1Literal(" *.cg")); filter.append(QLatin1String(" *.cg"));
if (video_shader_is_supported(RARCH_SHADER_GLSL)) if (video_shader_is_supported(RARCH_SHADER_GLSL))
filter.append(QLatin1Literal(" *.glsl")); filter.append(QLatin1String(" *.glsl"));
if (video_shader_is_supported(RARCH_SHADER_SLANG)) if (video_shader_is_supported(RARCH_SHADER_SLANG))
filter.append(QLatin1Literal(" *.slang")); filter.append(QLatin1String(" *.slang"));
filter.append(")"); filter.append(")");

View File

@ -549,8 +549,12 @@ QGroupBox *NetplayPage::createMitmServerGroup()
groupBox->add(MENU_ENUM_LABEL_NETPLAY_CUSTOM_MITM_SERVER); 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, connect(buttonGroup, SIGNAL(buttonClicked(int)), this,
SLOT(onRadioButtonClicked(int))); SLOT(onRadioButtonClicked(int)));
#endif
return groupBox; return groupBox;
} }
@ -1439,7 +1443,13 @@ QWidget *VideoPage::widget()
layout->addStretch(); layout->addStretch();
connect(m_resolutionCombo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(onResolutionComboIndexChanged(const QString&))); #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); widget->setLayout(layout);
@ -1574,6 +1584,14 @@ void VideoPage::onResolutionComboIndexChanged(const QString &text)
NULL, 0, 0, 0); NULL, 0, 0, 0);
} }
void VideoPage::onResolutionComboIndexChanged(int index)
{
const QString& text = m_resolutionCombo->itemText(index);
const char *path = text.toUtf8().constData();
action_cb_push_dropdown_item_resolution(path,
NULL, 0, 0, 0);
}
void CrtSwitchresPage::onCrtSuperResolutionComboIndexChanged(int index) void CrtSwitchresPage::onCrtSuperResolutionComboIndexChanged(int index)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();

View File

@ -154,7 +154,8 @@ public:
VideoPage(QObject *parent = nullptr); VideoPage(QObject *parent = nullptr);
QWidget *widget(); QWidget *widget();
private slots: private slots:
void onResolutionComboIndexChanged(const QString& value); Q_DECL_DEPRECATED void onResolutionComboIndexChanged(const QString& value);
void onResolutionComboIndexChanged(int index);
private: private:
QComboBox *m_resolutionCombo; QComboBox *m_resolutionCombo;
}; };

View File

@ -246,7 +246,11 @@ void PlaylistModel::loadThumbnail(const QModelIndex &index)
if (!m_pendingImages.contains(path) && !m_cache.contains(path)) if (!m_pendingImages.contains(path) && !m_cache.contains(path))
{ {
m_pendingImages.insert(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); QtConcurrent::run(this, &PlaylistModel::loadImage, index, path);
#endif
} }
} }
@ -566,7 +570,7 @@ void MainWindow::addFilesToPlaylist(QStringList files)
* automatically in setValue() */ * automatically in setValue() */
dialog->setValue(i + 1); dialog->setValue(i + 1);
fileInfo = fileName; fileInfo = QFileInfo(fileName);
/* Make sure we're looking at a user-specified field /* Make sure we're looking at a user-specified field
* and not just "<multiple>" * and not just "<multiple>"
@ -874,7 +878,11 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
for (j = 0; j < m_listWidget->count(); j++) for (j = 0; j < m_listWidget->count(); j++)
{ {
QListWidgetItem *item = m_listWidget->item(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); bool hidden = m_listWidget->isItemHidden(item);
#endif
if (hidden) if (hidden)
{ {
@ -1168,19 +1176,19 @@ void MainWindow::reloadPlaylists()
allPlaylistsItem->setData(Qt::UserRole, ALL_PLAYLISTS_TOKEN); allPlaylistsItem->setData(Qt::UserRole, ALL_PLAYLISTS_TOKEN);
favoritesPlaylistsItem = new QListWidgetItem(m_folderIcon, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES_TAB)); favoritesPlaylistsItem = new QListWidgetItem(m_folderIcon, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES_TAB));
favoritesPlaylistsItem->setData(Qt::UserRole, settings->paths.path_content_favorites); favoritesPlaylistsItem->setData(Qt::UserRole, QString(settings->paths.path_content_favorites));
m_historyPlaylistsItem = new QListWidgetItem(m_folderIcon, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_HISTORY_TAB)); m_historyPlaylistsItem = new QListWidgetItem(m_folderIcon, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_HISTORY_TAB));
m_historyPlaylistsItem->setData(Qt::UserRole, settings->paths.path_content_history); m_historyPlaylistsItem->setData(Qt::UserRole, QString(settings->paths.path_content_history));
imagePlaylistsItem = new QListWidgetItem(m_folderIcon, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_IMAGES_TAB)); imagePlaylistsItem = new QListWidgetItem(m_folderIcon, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_IMAGES_TAB));
imagePlaylistsItem->setData(Qt::UserRole, settings->paths.path_content_image_history); imagePlaylistsItem->setData(Qt::UserRole, QString(settings->paths.path_content_image_history));
musicPlaylistsItem = new QListWidgetItem(m_folderIcon, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MUSIC_TAB)); musicPlaylistsItem = new QListWidgetItem(m_folderIcon, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MUSIC_TAB));
musicPlaylistsItem->setData(Qt::UserRole, settings->paths.path_content_music_history); musicPlaylistsItem->setData(Qt::UserRole, QString(settings->paths.path_content_music_history));
videoPlaylistsItem = new QListWidgetItem(m_folderIcon, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_TAB)); videoPlaylistsItem = new QListWidgetItem(m_folderIcon, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_TAB));
videoPlaylistsItem->setData(Qt::UserRole, settings->paths.path_content_video_history); videoPlaylistsItem->setData(Qt::UserRole, QString(settings->paths.path_content_video_history));
m_listWidget->addItem(allPlaylistsItem); m_listWidget->addItem(allPlaylistsItem);
m_listWidget->addItem(favoritesPlaylistsItem); m_listWidget->addItem(favoritesPlaylistsItem);
@ -1491,7 +1499,7 @@ void PlaylistModel::getPlaylistItems(QString path)
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match; 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); playlist_config_set_base_content_directory(&playlist_config, settings->bools.playlist_portable_paths ? settings->paths.directory_menu_content : NULL);
pathArray.append(path); pathArray.append(path.toUtf8());
pathData = pathArray.constData(); pathData = pathArray.constData();
if (!string_is_empty(pathData)) if (!string_is_empty(pathData))
playlistName = path_basename(pathData); playlistName = path_basename(pathData);

View File

@ -724,7 +724,11 @@ UIntRadioButtons::UIntRadioButtons(rarch_setting_t *setting, QWidget *parent) :
*setting->value.target.unsigned_integer = orig_value; *setting->value.target.unsigned_integer = orig_value;
} }
add_sublabel_and_whats_this(this, m_setting); 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))); connect(m_buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(onButtonClicked(int)));
#endif
} }
UIntRadioButtons::UIntRadioButtons(msg_hash_enums enum_idx, QWidget *parent) : UIntRadioButtons::UIntRadioButtons(msg_hash_enums enum_idx, QWidget *parent) :

View File

@ -20,7 +20,6 @@
#include <QtWidgets/QFileDialog> #include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox> #include <QtWidgets/QMessageBox>
#include <QtCore/QString> #include <QtCore/QString>
#include <QDesktopWidget>
#include <QtGlobal> #include <QtGlobal>
#include <QCloseEvent> #include <QCloseEvent>
#include <QResizeEvent> #include <QResizeEvent>
@ -1217,7 +1216,7 @@ MainWindow::MainWindow(QWidget *parent) :
,m_thumbnailTimer(new QTimer(this)) ,m_thumbnailTimer(new QTimer(this))
,m_gridItem(this) ,m_gridItem(this)
,m_currentBrowser(BROWSER_TYPE_PLAYLISTS) ,m_currentBrowser(BROWSER_TYPE_PLAYLISTS)
,m_searchRegExp() ,m_searchRegularExpression()
,m_zoomWidget(new QWidget(this)) ,m_zoomWidget(new QWidget(this))
,m_itemsCountLiteral(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ITEMS_COUNT)) ,m_itemsCountLiteral(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ITEMS_COUNT))
,m_itemsCountLabel(new QLabel(this)) ,m_itemsCountLabel(new QLabel(this))
@ -1905,7 +1904,11 @@ void MainWindow::onFileBrowserTreeContextMenuRequested(const QPoint&)
if (currentDirString.isEmpty()) if (currentDirString.isEmpty())
return; return;
#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0))
dir.setPath(currentDirString);
#else
dir = currentDirString; dir = currentDirString;
#endif
if (!dir.exists()) if (!dir.exists())
return; return;
@ -2619,9 +2622,9 @@ void MainWindow::selectBrowserDir(QString path)
/* the directory is filtered out. Remove the filter for a moment. /* the directory is filtered out. Remove the filter for a moment.
* FIXME: Find a way to not have to do this * FIXME: Find a way to not have to do this
* (not filtering dirs is one). */ * (not filtering dirs is one). */
m_proxyFileModel->setFilterRegExp(QRegExp()); m_proxyFileModel->setFilterRegularExpression(QRegularExpression());
m_fileTableView->setRootIndex(m_proxyFileModel->mapFromSource(sourceIndex)); m_fileTableView->setRootIndex(m_proxyFileModel->mapFromSource(sourceIndex));
m_proxyFileModel->setFilterRegExp(m_searchRegExp); m_proxyFileModel->setFilterRegularExpression(m_searchRegularExpression);
} }
} }
setCoreActions(); setCoreActions();
@ -3108,8 +3111,13 @@ void MainWindow::setCoreActions()
if (!found_existing) if (!found_existing)
{ {
QVariantMap comboBoxMap; 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_name"] = coreInfo->core_name;
comboBoxMap["core_path"] = coreInfo->path; comboBoxMap["core_path"] = coreInfo->path;
#endif
comboBoxMap["core_selection"] = CORE_SELECTION_PLAYLIST_DEFAULT; comboBoxMap["core_selection"] = CORE_SELECTION_PLAYLIST_DEFAULT;
m_launchWithComboBox->addItem(coreInfo->core_name, QVariant::fromValue(comboBoxMap)); m_launchWithComboBox->addItem(coreInfo->core_name, QVariant::fromValue(comboBoxMap));
} }
@ -3179,8 +3187,8 @@ QComboBox* MainWindow::launchWithComboBox()
void MainWindow::onSearchLineEditEdited(const QString &text) void MainWindow::onSearchLineEditEdited(const QString &text)
{ {
int i; int i;
QVector<unsigned> textHiraToKata; QVector<char32_t> textHiraToKata;
QVector<unsigned> textKataToHira; QVector<char32_t> textKataToHira;
QVector<unsigned> textUnicode = text.toUcs4(); QVector<unsigned> textUnicode = text.toUcs4();
bool found_hiragana = false; bool found_hiragana = false;
bool found_katakana = false; bool found_katakana = false;
@ -3207,21 +3215,21 @@ void MainWindow::onSearchLineEditEdited(const QString &text)
} }
if (!found_hiragana && !found_katakana) if (!found_hiragana && !found_katakana)
m_searchRegExp = QRegExp(text, Qt::CaseInsensitive); m_searchRegularExpression = QRegularExpression(text, QRegularExpression::CaseInsensitiveOption);
else if (found_hiragana && !found_katakana) else if (found_hiragana && !found_katakana)
m_searchRegExp = QRegExp(text + "|" m_searchRegularExpression = QRegularExpression(text + "|"
+ QString::fromUcs4(textHiraToKata.constData(), + QString::fromUcs4(textHiraToKata.constData(),
textHiraToKata.size()), Qt::CaseInsensitive); textHiraToKata.size()), QRegularExpression::CaseInsensitiveOption);
else if (!found_hiragana && found_katakana) else if (!found_hiragana && found_katakana)
m_searchRegExp = QRegExp(text + "|" m_searchRegularExpression = QRegularExpression(text + "|"
+ QString::fromUcs4(textKataToHira.constData(), + QString::fromUcs4(textKataToHira.constData(),
textKataToHira.size()), Qt::CaseInsensitive); textKataToHira.size()), QRegularExpression::CaseInsensitiveOption);
else else
m_searchRegExp = QRegExp(text + "|" m_searchRegularExpression = QRegularExpression(text + "|"
+ QString::fromUcs4(textHiraToKata.constData(), + QString::fromUcs4(textHiraToKata.constData(),
textHiraToKata.size()) + "|" + textHiraToKata.size()) + "|" +
QString::fromUcs4(textKataToHira.constData(), QString::fromUcs4(textKataToHira.constData(),
textKataToHira.size()), Qt::CaseInsensitive); textKataToHira.size()), QRegularExpression::CaseInsensitiveOption);
applySearch(); applySearch();
} }
@ -3231,15 +3239,15 @@ void MainWindow::applySearch()
switch (m_currentBrowser) switch (m_currentBrowser)
{ {
case BROWSER_TYPE_PLAYLISTS: case BROWSER_TYPE_PLAYLISTS:
if (m_proxyModel->filterRegExp() != m_searchRegExp) if (m_proxyModel->filterRegularExpression() != m_searchRegularExpression)
{ {
m_proxyModel->setFilterRegExp(m_searchRegExp); m_proxyModel->setFilterRegularExpression(m_searchRegularExpression);
updateItemsCount(); updateItemsCount();
} }
break; break;
case BROWSER_TYPE_FILES: case BROWSER_TYPE_FILES:
if (m_proxyFileModel->filterRegExp() != m_searchRegExp) if (m_proxyFileModel->filterRegularExpression() != m_searchRegularExpression)
m_proxyFileModel->setFilterRegExp(m_searchRegExp); m_proxyFileModel->setFilterRegularExpression(m_searchRegularExpression);
break; break;
} }
} }
@ -3357,7 +3365,7 @@ void MainWindow::renamePlaylistItem(QListWidgetItem *item, QString newName)
return; return;
playlistPath = item->data(Qt::UserRole).toString(); playlistPath = item->data(Qt::UserRole).toString();
playlistInfo = playlistPath; playlistInfo = QFileInfo(playlistPath);
oldName = playlistInfo.completeBaseName(); oldName = playlistInfo.completeBaseName();
/* Don't just compare strings in case there are /* Don't just compare strings in case there are
@ -3379,7 +3387,7 @@ void MainWindow::renamePlaylistItem(QListWidgetItem *item, QString newName)
oldPath = item->data(Qt::UserRole).toString(); oldPath = item->data(Qt::UserRole).toString();
file.setFileName(oldPath); file.setFileName(oldPath);
info = file; info = QFileInfo(file);
extension = info.suffix(); extension = info.suffix();
@ -4217,7 +4225,7 @@ static void* ui_application_qt_initialize(void)
app_handler = new AppHandler(); app_handler = new AppHandler();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
/* HiDpi supported since Qt 5.6 */ /* HiDpi supported since Qt 5.6 */
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif #endif
@ -4261,8 +4269,10 @@ static void* ui_application_qt_initialize(void)
static void ui_application_qt_process_events(void) static void ui_application_qt_process_events(void)
{ {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QAbstractEventDispatcher *dispatcher = QApplication::eventDispatcher(); QAbstractEventDispatcher *dispatcher = QApplication::eventDispatcher();
if (dispatcher && dispatcher->hasPendingEvents()) if (dispatcher && dispatcher->hasPendingEvents())
#endif
QApplication::processEvents(); QApplication::processEvents();
} }
@ -4316,6 +4326,8 @@ typedef struct ui_companion_qt
ui_window_qt_t *window; ui_window_qt_t *window;
} ui_companion_qt_t; } ui_companion_qt_t;
ThumbnailWidget::ThumbnailWidget(QWidget *parent) { }
ThumbnailWidget::ThumbnailWidget(ThumbnailType type, QWidget *parent) : ThumbnailWidget::ThumbnailWidget(ThumbnailType type, QWidget *parent) :
QStackedWidget(parent) QStackedWidget(parent)
,m_thumbnailType(type) ,m_thumbnailType(type)
@ -4499,7 +4511,7 @@ static void* ui_companion_qt_init(void)
QVBoxLayout *launchWithWidgetLayout = NULL; QVBoxLayout *launchWithWidgetLayout = NULL;
QHBoxLayout *coreComboBoxLayout = NULL; QHBoxLayout *coreComboBoxLayout = NULL;
QMenuBar *menu = NULL; QMenuBar *menu = NULL;
QDesktopWidget *desktop = NULL; QScreen *screen = NULL;
QMenu *fileMenu = NULL; QMenu *fileMenu = NULL;
QMenu *editMenu = NULL; QMenu *editMenu = NULL;
QMenu *viewMenu = NULL; QMenu *viewMenu = NULL;
@ -4542,8 +4554,8 @@ static void* ui_companion_qt_init(void)
(ui_application_qt.initialize()); (ui_application_qt.initialize());
handle->window = static_cast<ui_window_qt_t*>(ui_window_qt.init()); handle->window = static_cast<ui_window_qt_t*>(ui_window_qt.init());
desktop = qApp->desktop(); screen = qApp->primaryScreen();
desktopRect = desktop->availableGeometry(); desktopRect = screen->availableGeometry();
mainwindow = handle->window->qtWindow; mainwindow = handle->window->qtWindow;
@ -5153,7 +5165,11 @@ void LoadCoreWindow::onCoreEnterPressed()
Qt::UserRole).toHash(); Qt::UserRole).toHash();
QString path = hash["path"].toString(); QString path = hash["path"].toString();
#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0))
pathArray.append(path.toStdString());
#else
pathArray.append(path); pathArray.append(path);
#endif
pathData = pathArray.constData(); pathData = pathArray.constData();
loadCore(pathData); loadCore(pathData);
@ -5183,7 +5199,7 @@ void LoadCoreWindow::onLoadCustomCoreClicked()
if (path.isEmpty()) if (path.isEmpty())
return; return;
pathArray.append(path); pathArray.append(path.toUtf8());
pathData = pathArray.constData(); pathData = pathArray.constData();
loadCore(pathData); loadCore(pathData);
@ -5195,7 +5211,7 @@ void LoadCoreWindow::initCoreList(const QStringList &extensionFilters)
unsigned i; unsigned i;
QStringList horizontal_header_labels; QStringList horizontal_header_labels;
core_info_list_t *cores = NULL; core_info_list_t *cores = NULL;
QDesktopWidget *desktop = qApp->desktop(); QScreen *desktop = qApp->primaryScreen();
QRect desktopRect = desktop->availableGeometry(); QRect desktopRect = desktop->availableGeometry();
horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME); horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME);
@ -5229,7 +5245,7 @@ void LoadCoreWindow::initCoreList(const QStringList &extensionFilters)
name_item = new QTableWidgetItem(name); name_item = new QTableWidgetItem(name);
hash["path"] = core->path; hash["path"] = QByteArray(core->path);
hash["extensions"] = string_split_to_qt(QString(core->supported_extensions), '|'); hash["extensions"] = string_split_to_qt(QString(core->supported_extensions), '|');
name_item->setData(Qt::UserRole, hash); name_item->setData(Qt::UserRole, hash);

View File

@ -634,7 +634,7 @@ private:
QTimer *m_thumbnailTimer; QTimer *m_thumbnailTimer;
GridItem m_gridItem; GridItem m_gridItem;
BrowserType m_currentBrowser; BrowserType m_currentBrowser;
QRegExp m_searchRegExp; QRegularExpression m_searchRegularExpression;
QByteArray m_fileTableHeaderState; QByteArray m_fileTableHeaderState;
QWidget *m_zoomWidget; QWidget *m_zoomWidget;
QString m_itemsCountLiteral; QString m_itemsCountLiteral;