Skip to content

Commit

Permalink
Migrate to Qt6
Browse files Browse the repository at this point in the history
* basic support Qt6 with minimal changes required for compiling
* look `moc` in QT_HOST_LIBEXECS
  • Loading branch information
viachaslavic committed Nov 7, 2024
1 parent b3f3856 commit 8814f72
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 116 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ param.sfo

# Visual Studio Code
.vscode/

# Clazy
*.clazy.yaml
12 changes: 7 additions & 5 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ ifeq ($(HAVE_NOUNUSED_VARIABLE), 1)
DEF_FLAGS += $(NOUNUSED_VARIABLE_CFLAGS)
endif

ifeq ($(HAVE_CXX11), 1)
ifeq ($(HAVE_CXX17), 1)
CXXFLAGS += $(CXX17_CFLAGS)
else ifeq ($(HAVE_CXX11), 1)
CXXFLAGS += $(CXX11_CFLAGS)
endif

Expand Down Expand Up @@ -531,10 +533,10 @@ ifeq ($(HAVE_QT), 1)
endif

DEFINES += -DHAVE_MAIN
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)
DEF_FLAGS += -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)
NEED_CXX_LINKER = 1

ifneq ($(findstring Linux,$(OS)),)
Expand Down
37 changes: 21 additions & 16 deletions qb/config.libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if [ "$HAVE_C99" = 'no' ]; then
fi

check_switch cxx CXX11 -std=c++11 ''
check_switch cxx CXX17 -std=c++17 ''
check_switch '' NOUNUSED -Wno-unused-result ''
check_switch '' NOUNUSED_VARIABLE -Wno-unused-variable ''

Expand Down Expand Up @@ -276,28 +277,32 @@ if [ "$HAVE_SDL2" = 'yes' ] && [ "$HAVE_SDL" = 'yes' ]; then
HAVE_SDL=no
fi

check_enabled CXX17 CXX C++ 'C++17 support is' false
check_enabled CXX11 CXX C++ 'C++11 support is' false

check_platform Haiku DISCORD 'Discord is' false
check_enabled CXX DISCORD discord 'The C++ compiler is' false
check_enabled CXX QT 'Qt companion' 'The C++ compiler is' false

if [ "$HAVE_QT" != 'no' ]; then
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 Qt5WebEngine 5.4

# 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
if [ "$HAVE_CXX17" != yes ]; then
HAVE_QT='no'
die : 'Notice: Qt support disabled, required compiler was not found.'
elif [ "$HAVE_QT" != 'no' ]; 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.'
Expand Down
4 changes: 2 additions & 2 deletions qb/config.moc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT_VERSION=qt5
QT_FLAGS="$CXX11_CFLAGS $QT5CORE_CFLAGS $QT5CORE_LIBS"
QT_VERSION=qt6
QT_FLAGS="$CXX17_CFLAGS $QT6CORE_CFLAGS $QT6CORE_LIBS"

add_define MAKEFILE QT_VERSION "$QT_VERSION"
4 changes: 3 additions & 1 deletion qb/qb.moc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ if [ "$HAVE_QT" = "yes" ]; then
moc_works=1
else
for moc in "moc-$QT_VERSION" moc; do
MOC="$(exists "$moc")" || MOC=""
QMAKE="$(exists qmake6)" || QMAKE="qmake"
QT_HOST_LIBEXECS="$($QMAKE -query QT_HOST_LIBEXECS)"
MOC="$(exists "$QT_HOST_LIBEXECS/$moc")" || MOC=""
if [ "$MOC" ]; then
QT_SELECT="$QT_VERSION" \
"$MOC" -o "$TEMP_CPP" "$TEMP_MOC" >/dev/null 2>&1 ||
Expand Down
3 changes: 2 additions & 1 deletion ui/drivers/qt/gridview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ void GridView::paintEvent(QPaintEvent*)
{
QModelIndex index = model()->index(row, 0, rootIndex());
QRectF rect = viewportRectForRow(row);
QStyleOptionViewItem option = viewOptions();
QStyleOptionViewItem option;
initViewItemOption(&option);

if (!rect.isValid() || rect.bottom() < 0 || rect.y() > viewport()->height())
continue;
Expand Down
77 changes: 39 additions & 38 deletions ui/drivers/qt/qt_dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ void PlaylistEntryDialog::loadPlaylistOptions()
m_coreComboBox->addItem(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE_SELECTION_ASK));
m_databaseComboBox->addItem(
QString("<")
+ msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE)
QString("<")
+ msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE)
+ ">",
QFileInfo(m_mainwindow->getCurrentPlaylistPath()).fileName().remove(".lpl"));

Expand Down Expand Up @@ -381,7 +381,7 @@ void CoreInfoDialog::showCoreInfo()
int row = 0;
int row_count = m_formLayout->rowCount();
int i = 0;
QVector<QHash<QString, QString> > info_list
QVector<QHash<QString, QString> > info_list
= m_mainwindow->getCoreInfo();

if (row_count > 0)
Expand All @@ -392,7 +392,7 @@ void CoreInfoDialog::showCoreInfo()
/* removeRow() and takeRow() was only added in 5.8! */
m_formLayout->removeRow(0);
#else
/* something is buggy here...
/* something is buggy here...
* sometimes items appear duplicated, and other times not */
QLayoutItem *item = m_formLayout->itemAt(0);
QWidget *w = NULL;
Expand Down Expand Up @@ -455,7 +455,7 @@ QColor getLabelColor(const QString& objectName)
QLabel dummyColor;
dummyColor.setObjectName(objectName);
dummyColor.ensurePolished();
return dummyColor.palette().color(QPalette::Foreground);
return dummyColor.palette().color(QPalette::WindowText);
}

/* stolen from Qt Creator */
Expand All @@ -482,7 +482,7 @@ class SmartScrollArea : public QScrollArea

/* Widget wants to be bigger than available space */
if (innerSizeHint.height() > innerSize.height())
{
{
innerSize.setWidth(innerSize.width() - scrollBarWidth());
innerSize.setHeight(innerSizeHint.height());
}
Expand Down Expand Up @@ -536,14 +536,14 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
int width;
QGridLayout *layout = new QGridLayout(this);
QLabel *m_headerLabel = new QLabel(this);
/* Header label with large font and a bit of spacing
/* Header label with large font and a bit of spacing
* (align with group boxes) */
QFont headerLabelFont = m_headerLabel->font();
const int pointSize = headerLabelFont.pointSize();
QHBoxLayout *headerHLayout = new QHBoxLayout;
const int leftMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin);

m_optionsStack->setMargin(0);
m_optionsStack->setContentsMargins(0, 0, 0, 0);

headerLabelFont.setBold(true);

Expand Down Expand Up @@ -576,9 +576,9 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
addCategory(new UserCategory(this));
addCategory(new DirectoryCategory(this));

width =
m_optionsList->sizeHintForColumn(0)
+ m_optionsList->frameWidth() * 2
width =
m_optionsList->sizeHintForColumn(0)
+ m_optionsList->frameWidth() * 2
+ 5;
width += m_optionsList->verticalScrollBar()->sizeHint().width();

Expand All @@ -601,9 +601,9 @@ QIcon getIcon(OptionsCategory *category)
{
settings_t *settings = config_get_ptr();
const char *path_dir_assets = settings->paths.directory_assets;
QPixmap pixmap = QPixmap(QString(path_dir_assets)
+ "/xmb/monochrome/png/"
+ category->categoryIconName()
QPixmap pixmap = QPixmap(QString(path_dir_assets)
+ "/xmb/monochrome/png/"
+ category->categoryIconName()
+ ".png");
return QIcon(getColorizedPixmap(pixmap, getLabelColor("iconColor")));
}
Expand Down Expand Up @@ -728,7 +728,7 @@ ViewOptionsWidget::ViewOptionsWidget(MainWindow *mainwindow, QWidget *parent) :

m_thumbnailCacheSpinBox->setSuffix(" MB");
m_thumbnailCacheSpinBox->setRange(0, 99999);

m_thumbnailDropSizeSpinBox->setSuffix(" px");
m_thumbnailDropSizeSpinBox->setRange(0, 99999);

Expand Down Expand Up @@ -825,7 +825,7 @@ void ViewOptionsWidget::loadViewOptions()
int i;
int themeIndex = 0;
int playlistIndex = 0;
QColor highlightColor =
QColor highlightColor =
m_settings->value("highlight_color",
QApplication::palette().highlight().color()).value<QColor>();
QPixmap highlightPixmap(m_highlightColorPushButton->iconSize());
Expand Down Expand Up @@ -1144,9 +1144,9 @@ void CoreOptionsDialog::buildLayout()

for (j = 0; j < opts; j++)
{
QString desc =
QString desc =
core_option_manager_get_desc(coreopts, j, false);
QString val =
QString val =
core_option_manager_get_val(coreopts, j);
QComboBox *combo_box = NULL;
QLabel *descLabel = NULL;
Expand Down Expand Up @@ -1193,7 +1193,8 @@ void CoreOptionsDialog::buildLayout()
}

for (k = 0; k < option->vals->size; k++)
combo_box->addItem(option->vals->elems[k].data, option->key);
combo_box->addItem(option->vals->elems[k].data, QVariant::fromValue(option->key));


combo_box->setCurrentText(val);
combo_box->setProperty("default_index",
Expand Down Expand Up @@ -1481,7 +1482,7 @@ void ShaderParamsDialog::onFilterComboBoxIndexChanged(int)
if (!ok)
return;

if ( menu_shader
if ( menu_shader
&& (pass >= 0)
&& (pass < static_cast<int>(menu_shader->passes)))
{
Expand Down Expand Up @@ -1742,23 +1743,23 @@ void ShaderParamsDialog::onShaderLoadPresetClicked()

filter.append("Shader Preset (");

/* 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? */
if (video_shader_is_supported(RARCH_SHADER_CG))
{
filter.append(QLatin1Literal(" *"));
filter.append(QLatin1String(" *"));
filter.append(".cgp");
}

if (video_shader_is_supported(RARCH_SHADER_GLSL))
{
filter.append(QLatin1Literal(" *"));
filter.append(QLatin1String(" *"));
filter.append(".glslp");
}

if (video_shader_is_supported(RARCH_SHADER_SLANG))
{
filter.append(QLatin1Literal(" *"));
filter.append(QLatin1String(" *"));
filter.append(".slangp");
}

Expand Down Expand Up @@ -1901,16 +1902,16 @@ void ShaderParamsDialog::onShaderAddPassClicked()

filter.append("Shader (");

/* 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? */
if (video_shader_is_supported(RARCH_SHADER_CG))
filter.append(QLatin1Literal(" *.cg"));
filter.append(QLatin1String(" *.cg"));

if (video_shader_is_supported(RARCH_SHADER_GLSL))
filter.append(QLatin1Literal(" *.glsl"));
filter.append(QLatin1String(" *.glsl"));

if (video_shader_is_supported(RARCH_SHADER_SLANG))
filter.append(QLatin1Literal(" *.slang"));
filter.append(QLatin1String(" *.slang"));

filter.append(")");

Expand Down Expand Up @@ -2181,28 +2182,28 @@ void ShaderParamsDialog::updateRemovePresetButtonsState()
menu_shader_manager_auto_preset_exists(
SHADER_PRESET_GLOBAL,
path_dir_video_shader,
path_dir_menu_config
path_dir_menu_config
));
if (removeCorePresetAction)
removeCorePresetAction->setEnabled(
menu_shader_manager_auto_preset_exists(
SHADER_PRESET_CORE,
path_dir_video_shader,
path_dir_menu_config
path_dir_menu_config
));
if (removeParentPresetAction)
removeParentPresetAction->setEnabled(
menu_shader_manager_auto_preset_exists(
SHADER_PRESET_PARENT,
path_dir_video_shader,
path_dir_menu_config
path_dir_menu_config
));
if (removeGamePresetAction)
removeGamePresetAction->setEnabled(
menu_shader_manager_auto_preset_exists(
SHADER_PRESET_GAME,
path_dir_video_shader,
path_dir_menu_config
path_dir_menu_config
));
}

Expand Down Expand Up @@ -2235,14 +2236,14 @@ void ShaderParamsDialog::buildLayout()

getShaders(&menu_shader, &video_shader);

/* NOTE: For some reason, menu_shader_get() returns a COPY
/* NOTE: For some reason, menu_shader_get() returns a COPY
* of what get_current_shader() gives us.
* And if you want to be able to change shader settings/parameters
* And if you want to be able to change shader settings/parameters
* from both the raster menu and
* Qt at the same time... you must change BOTH or one will
* Qt at the same time... you must change BOTH or one will
* overwrite the other.
*
* AND, during a context reset, video_shader will be NULL
* AND, during a context reset, video_shader will be NULL
* but not menu_shader, so don't totally bail
* just because video_shader is NULL.
*
Expand All @@ -2256,7 +2257,7 @@ void ShaderParamsDialog::buildLayout()
if (video_shader->passes == 0)
setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS));
}
/* Normally we'd only use video_shader,
/* Normally we'd only use video_shader,
* but the Vulkan driver returns a NULL shader when there
* are zero passes, so just fall back to menu_shader.
*/
Expand All @@ -2278,7 +2279,7 @@ void ShaderParamsDialog::buildLayout()

clearLayout();

/* Only check video_shader for the path, menu_shader seems stale...
/* Only check video_shader for the path, menu_shader seems stale...
* e.g. if you remove all the shader passes,
* it still has the old path in it, but video_shader does not
*/
Expand Down
Loading

0 comments on commit 8814f72

Please sign in to comment.