From 159eccbda08bd06765494839d878273360aaacc6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Sep 2023 21:36:13 +0200 Subject: [PATCH] libcalamaresui: enable build for Qt6 Compatibility code for mutex and variant is already in place. --- src/CMakeLists.txt | 3 +-- src/libcalamaresui/CMakeLists.txt | 6 ++++-- src/libcalamaresui/viewpages/QmlViewStep.cpp | 4 +++- src/libcalamaresui/viewpages/Slideshow.cpp | 14 ++++++++------ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 97e678083..a92119d06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,10 +12,9 @@ include(CalamaresAddTranslations) # library add_subdirectory(libcalamares) - -if(NOT WITH_QT6) # TODO: Qt6 add_subdirectory(libcalamaresui) +if(NOT WITH_QT6) # TODO: Qt6 # all things qml add_subdirectory(qml/calamares) diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index 20af93a56..42b11b58d 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -47,7 +47,7 @@ calamares_add_library(calamaresui SOURCES ${calamaresui_SOURCES} EXPORT_MACRO UIDLLEXPORT_PRO LINK_LIBRARIES - Qt5::Svg + ${qtname}::Svg RESOURCES libcalamaresui.qrc EXPORT Calamares UI @@ -56,12 +56,14 @@ calamares_add_library(calamaresui SOVERSION ${CALAMARES_SOVERSION} ) target_link_libraries(calamaresui PRIVATE yamlcpp::yamlcpp) +if(NOT WITH_QT6) # TODO: Qt6 if(KF5CoreAddons_FOUND AND KF5CoreAddons_VERSION VERSION_GREATER_EQUAL 5.58) target_compile_definitions(calamaresui PRIVATE WITH_KOSRelease) target_link_libraries(calamaresui PRIVATE KF5::CoreAddons) endif() +endif() if(WITH_QML) - target_link_libraries(calamaresui PUBLIC Qt5::QuickWidgets) + target_link_libraries(calamaresui PUBLIC ${qtname}::QuickWidgets) endif() add_library(Calamares::calamaresui ALIAS calamaresui) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index b0392e404..aa034ca7e 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -12,6 +12,7 @@ #include "Branding.h" #include "ViewManager.h" +#include "compat/Variant.h" #include "utils/Dirs.h" #include "utils/Logger.h" #include "utils/NamedEnum.h" @@ -52,7 +53,8 @@ changeQMLState( QMLAction action, QQuickItem* item ) CalamaresUtils::callQmlFunction( item, activate ? "onActivate" : "onLeave" ); auto property = item->property( propertyName ); - if ( property.isValid() && ( property.type() == QVariant::Bool ) && ( property.toBool() != activate ) ) + if ( property.isValid() && ( Calamares::typeOf( property ) == Calamares::BoolVariantType ) + && ( property.toBool() != activate ) ) { item->setProperty( propertyName, activate ); } diff --git a/src/libcalamaresui/viewpages/Slideshow.cpp b/src/libcalamaresui/viewpages/Slideshow.cpp index 6ae5618db..2aa5060b1 100644 --- a/src/libcalamaresui/viewpages/Slideshow.cpp +++ b/src/libcalamaresui/viewpages/Slideshow.cpp @@ -12,6 +12,8 @@ #include "Slideshow.h" #include "Branding.h" +#include "compat/Mutex.h" +#include "compat/Variant.h" #include "utils/Dirs.h" #include "utils/Logger.h" #ifdef WITH_QML @@ -79,7 +81,7 @@ SlideshowQML::widget() void SlideshowQML::loadQmlV2() { - QMutexLocker l( &m_mutex ); + Calamares::MutexLocker l( &m_mutex ); if ( !m_qmlComponent && !Calamares::Branding::instance()->slideshowPath().isEmpty() ) { m_qmlComponent = new QQmlComponent( m_qmlShow->engine(), @@ -92,7 +94,7 @@ SlideshowQML::loadQmlV2() void SlideshowQML::loadQmlV2Complete() { - QMutexLocker l( &m_mutex ); + Calamares::MutexLocker l( &m_mutex ); if ( m_qmlComponent && m_qmlComponent->isReady() && !m_qmlObject ) { cDebug() << "QML component complete, API 2"; @@ -158,7 +160,7 @@ SlideshowQML::startSlideShow() void SlideshowQML::changeSlideShowState( Action state ) { - QMutexLocker l( &m_mutex ); + Calamares::MutexLocker l( &m_mutex ); bool activate = state == Slideshow::Start; if ( Branding::instance()->slideshowAPI() == 2 ) @@ -182,7 +184,7 @@ SlideshowQML::changeSlideShowState( Action state ) { static const char propertyName[] = "activatedInCalamares"; auto property = m_qmlObject->property( propertyName ); - if ( property.isValid() && ( property.type() == QVariant::Bool ) && ( property.toBool() != activate ) ) + if ( property.isValid() && ( Calamares::typeOf( property ) == Calamares::BoolVariantType ) && ( property.toBool() != activate ) ) { m_qmlObject->setProperty( propertyName, activate ); } @@ -228,7 +230,7 @@ SlideshowPictures::widget() void SlideshowPictures::changeSlideShowState( Calamares::Slideshow::Action a ) { - QMutexLocker l( &m_mutex ); + Calamares::MutexLocker l( &m_mutex ); m_state = a; if ( a == Slideshow::Start ) { @@ -253,7 +255,7 @@ SlideshowPictures::changeSlideShowState( Calamares::Slideshow::Action a ) void SlideshowPictures::next() { - QMutexLocker l( &m_mutex ); + Calamares::MutexLocker l( &m_mutex ); if ( m_imageIndex < 0 ) {