diff --git a/configure.ac b/configure.ac index c8993b1..44f8938 100644 --- a/configure.ac +++ b/configure.ac @@ -23,17 +23,29 @@ PKG_CHECK_MODULES([libavcodec], [libavcodec]) PKG_CHECK_MODULES([libavformat], [libavformat]) PKG_CHECK_MODULES([libavutil], [libavutil]) +PKG_CHECK_MODULES( + [QT6WIDGETS], [Qt6Widgets], [qt6_enabled="yes"], + [ + PKG_CHECK_MODULES([QT5WIDGETS], [Qt5Widgets], [qt6_enabled="no"]) + ] +) -qt_host_bins="$( eval $PKG_CONFIG --variable=host_bins Qt5Core )" - -PKG_CHECK_MODULES([QT5WIDGETS], [Qt5Widgets]) +if test "x$qt6_enabled" = "xyes"; then + qt_host_bins="$( eval $PKG_CONFIG --variable=host_bins Qt6Core )" +else + qt_host_bins="$( eval $PKG_CONFIG --variable=host_bins Qt5Core )" +fi AC_ARG_WITH( [moc], [AS_HELP_STRING([--with-moc], [Path of the Qt meta object compiler.])], [AC_SUBST([MOC], [$with_moc])], [ - AC_PATH_PROGS([MOC], [moc-qt5 moc], [not_found], [$qt_host_bins]) + if test "x$qt6_enabled" = "xyes"; then + AC_PATH_PROGS([MOC], [moc-qt6 moc], [not_found], [$qt_host_bins]) + else + AC_PATH_PROGS([MOC], [moc-qt5 moc], [not_found], [$qt_host_bins]) + fi AS_IF( [test "x$MOC" = "x$not_found"], [AC_MSG_ERROR(["moc (Qt's meta object compiler) was not found."])] @@ -41,18 +53,31 @@ AC_ARG_WITH( ] ) -AC_MSG_CHECKING([whether Qt is static]) -if [ `$PKG_CONFIG --variable=qt_config Qt5Core | $GREP 'static' > /dev/null` ]; then - static_qt="yes" +if test "x$qt6_enabled" = "xyes"; then + AC_MSG_CHECKING([whether Qt is static]) + if [ `$PKG_CONFIG --variable=qt_config Qt6Core | $GREP 'static' > /dev/null` ]; then + static_qt="yes" + else + static_qt="no" + fi else - static_qt="no" + AC_MSG_CHECKING([whether Qt is static]) + if [ `$PKG_CONFIG --variable=qt_config Qt5Core | $GREP 'static' > /dev/null` ]; then + static_qt="yes" + else + static_qt="no" + fi fi AC_MSG_RESULT([$static_qt]) AS_IF( [test "x$static_qt" = "xyes"], [ - PKG_CHECK_MODULES([QT5PLATFORMSUPPORT], [Qt5PlatformSupport]) + if test "x$qt6_enabled" = "xyes"; then + PKG_CHECK_MODULES([QT6PLATFORMSUPPORT], [Qt6PlatformSupport]) + else + PKG_CHECK_MODULES([QT5PLATFORMSUPPORT], [Qt5PlatformSupport]) + fi AC_DEFINE([D2VWITCH_STATIC_QT]) ] ) @@ -70,7 +95,11 @@ AS_CASE( AS_IF([test "x$static_qt" = "xyes"], [ - AC_SUBST([QT5PLATFORMPLUGIN], ["$qt_host_bins/../plugins/platforms/libqwindows.a"]) + if test "x$qt6_enabled" = "xyes"; then + AC_SUBST([QT6PLATFORMPLUGIN], ["$qt_host_bins/../plugins/platforms/libqwindows.a"]) + else + AC_SUBST([QT5PLATFORMPLUGIN], ["$qt_host_bins/../plugins/platforms/libqwindows.a"]) + fi ] ) ] diff --git a/meson.build b/meson.build index b1bf8c6..f10ee15 100644 --- a/meson.build +++ b/meson.build @@ -1,16 +1,30 @@ project('d2vwitch', 'cpp', version: '5', - default_options: ['cpp_std=c++11', 'buildtype=release'], + default_options: ['buildtype=release'], meson_version: '>=0.46') -qt5 = import('qt5') +dep_qt6 = dependency('qt6', modules: ['Core', 'Gui', 'Widgets'], required: false) +if dep_qt6.found() + if meson.version().version_compare('>= 0.57') + qt = import('qt6') + dep_qt = dep_qt6 + dep_qt_options = ['cpp_std=c++17'] + dep_qt_args = ['-std=c++17', '-DUSE_QT6'] + else + error('Qt 6 is only supported since Meson 0.57.') + endif +else + qt = import('qt5') + dep_qt = dependency('qt5', modules: ['Core', 'Gui', 'Widgets'], required : true) + dep_qt_options = ['cpp_std=c++11'] + dep_qt_args = ['-std=c++11'] +endif deps = [ dependency('vapoursynth').partial_dependency(includes: true, compile_args: true), dependency('libavcodec'), dependency('libavformat'), dependency('libavutil'), - dependency('qt5', modules: ['Core', 'Gui', 'Widgets']) ] moc_headers = [ @@ -19,7 +33,7 @@ moc_headers = [ 'src/ScrollArea.h' ] -processed_files = qt5.preprocess(moc_headers: moc_headers) +processed_files = qt.preprocess(moc_headers: moc_headers) sources = [ 'src/Audio.cpp', @@ -44,7 +58,6 @@ sources = [ processed_files ] - warnings = [ '-Wall', '-Wextra', @@ -58,7 +71,9 @@ cpp_args = [ executable('d2vwitch', sources: sources, - dependencies: deps, + dependencies: [deps, dep_qt], gui_app: true, - cpp_args: cpp_args, - install: true) + cpp_args: [cpp_args, dep_qt_args], + override_options: dep_qt_options, + install: true +) diff --git a/src/D2VWitch.cpp b/src/D2VWitch.cpp index e5273f6..62b1002 100644 --- a/src/D2VWitch.cpp +++ b/src/D2VWitch.cpp @@ -641,7 +641,11 @@ int main(int argc, char **_argv) { if (index > -1) { for (int i = index + 1; i < entries.size(); i++) { +#ifdef USE_QT6 + if (entries[i].mid(4, 2) == name.mid(4, 2)) +#else if (entries[i].midRef(4, 2) == name.midRef(4, 2)) +#endif fake_file.push_back(input_dir.absoluteFilePath(entries[i]).toStdString()); } } diff --git a/src/GUIWindow.cpp b/src/GUIWindow.cpp index 9b563ad..812267b 100644 --- a/src/GUIWindow.cpp +++ b/src/GUIWindow.cpp @@ -656,7 +656,11 @@ GUIWindow::GUIWindow(QSettings &_settings, QWidget *parent) d2v_edit->setText(file_name); }); +#ifdef USE_QT6 + connect(video_group, static_cast(&QButtonGroup::idToggled), [this] (int id, bool checked) { +#else connect(video_group, static_cast(&QButtonGroup::buttonToggled), [this] (int id, bool checked) { +#endif // "int id" is the QButtonGroup id, not AVStream::id if (checked) {