From 0c7f351623fbfb488b36daf5100b3ce63bd8fca0 Mon Sep 17 00:00:00 2001 From: Alexander Schlarb Date: Tue, 31 Jul 2018 07:04:04 -0600 Subject: [PATCH] Only include QtQuick support in Breeze KStyle if QtQuick is available Summary: Currently Breeze hard-depends on QtQuick in order to provide QtQuick-specific theme tweaks, but only for KDE5. This patch decouples KDE4 support from QtQuick support and allows Breeze to be built even when QtQuick is not available (at the loss of the QtQuick specific tweaks of course). Reviewers: mart Reviewed By: mart Subscribers: ngraham, davidedmundson, plasma-devel Tags: #plasma, #breeze Differential Revision: https://phabricator.kde.org/D12708 --- kstyle/CMakeLists.txt | 11 +++++++++-- kstyle/breezestyle.cpp | 2 +- kstyle/breezewindowmanager.cpp | 14 ++++++++------ kstyle/breezewindowmanager.h | 6 +++--- kstyle/config-breeze.h.cmake | 3 +++ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/kstyle/CMakeLists.txt b/kstyle/CMakeLists.txt index b16ff580..83538bec 100644 --- a/kstyle/CMakeLists.txt +++ b/kstyle/CMakeLists.txt @@ -25,6 +25,7 @@ if(BREEZE_USE_KDE4) set(BREEZE_HAVE_X11 FALSE) endif() + set(BREEZE_HAVE_QTQUICK FALSE) set(BREEZE_HAVE_KWAYLAND FALSE) ### KStyle @@ -32,7 +33,7 @@ if(BREEZE_USE_KDE4) else() - find_package(Qt5 REQUIRED CONFIG COMPONENTS Widgets DBus Quick) + find_package(Qt5 REQUIRED CONFIG COMPONENTS Widgets DBus) find_package(KF5 REQUIRED COMPONENTS I18n Config @@ -40,6 +41,9 @@ else() ConfigWidgets WindowSystem) + find_package(Qt5 COMPONENTS Quick) + set(BREEZE_HAVE_QTQUICK ${Qt5_Quick_FOUND}) + find_package( KF5FrameworkIntegration CONFIG ) set_package_properties(KF5FrameworkIntegration PROPERTIES DESCRIPTION "KF5 Framework Integration" @@ -155,7 +159,10 @@ else() kconfig_add_kcfg_files(breeze_PART_SRCS breezestyleconfigdata.kcfgc) add_library(breeze MODULE ${breeze_PART_SRCS}) - target_link_libraries(breeze Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus Qt5::Quick) + target_link_libraries(breeze Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus) + if( Qt5_Quick_FOUND ) + target_link_libraries(breeze Qt5::Quick) + endif() target_link_libraries(breeze KF5::ConfigCore KF5::ConfigWidgets KF5::GuiAddons KF5::WindowSystem) target_link_libraries(breeze breezecommon) diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp index a47d093c..29f45696 100644 --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -7158,7 +7158,7 @@ namespace Breeze //____________________________________________________________________ bool Style::isQtQuickControl( const QStyleOption* option, const QWidget* widget ) const { - #if QT_VERSION >= 0x050000 + #if QT_VERSION >= 0x050000 && BREEZE_HAVE_QTQUICK const bool is = (widget == nullptr) && option && option->styleObject && option->styleObject->inherits( "QQuickItem" ); if ( is ) _windowManager->registerQuickItem( static_cast( option->styleObject ) ); return is; diff --git a/kstyle/breezewindowmanager.cpp b/kstyle/breezewindowmanager.cpp index 7a8bc997..debbe916 100644 --- a/kstyle/breezewindowmanager.cpp +++ b/kstyle/breezewindowmanager.cpp @@ -79,7 +79,7 @@ #include #endif -#if QT_VERSION >= 0x050000 +#if BREEZE_HAVE_QTQUICK // needed to enable dragging from QQuickWindows #include #include @@ -319,7 +319,7 @@ namespace Breeze } - #if !BREEZE_USE_KDE4 + #if BREEZE_HAVE_QTQUICK //_____________________________________________________________ void WindowManager::registerQuickItem( QQuickItem* item ) { @@ -390,7 +390,7 @@ namespace Breeze case QEvent::MouseMove: if ( object == _target.data() - #if !BREEZE_USE_KDE4 + #if BREEZE_HAVE_QTQUICK || object == _quickTarget.data() #endif ) return mouseMoveEvent( object, event ); @@ -398,7 +398,7 @@ namespace Breeze case QEvent::MouseButtonRelease: if ( _target - #if !BREEZE_USE_KDE4 + #if BREEZE_HAVE_QTQUICK || _quickTarget #endif ) return mouseReleaseEvent( object, event ); @@ -426,8 +426,10 @@ namespace Breeze { startDrag( _target.data()->window(), _globalDragPoint ); } #else if( _target ) startDrag( _target.data()->window()->windowHandle(), _globalDragPoint ); + #if BREEZE_HAVE_QTQUICK else if( _quickTarget ) startDrag( _quickTarget.data()->window(), _globalDragPoint ); #endif + #endif } else { @@ -450,7 +452,7 @@ namespace Breeze if( isLocked() ) return false; else setLocked( true ); - #if !BREEZE_USE_KDE4 + #if BREEZE_HAVE_QTQUICK // check QQuickItem - we can immediately start drag, because QQuickWindow's contentItem // only receives mouse events that weren't handled by children if( auto item = qobject_cast( object ) ) @@ -837,7 +839,7 @@ namespace Breeze } _target.clear(); - #if !BREEZE_USE_KDE4 + #if BREEZE_HAVE_QTQUICK _quickTarget.clear(); #endif if( _dragTimer.isActive() ) _dragTimer.stop(); diff --git a/kstyle/breezewindowmanager.h b/kstyle/breezewindowmanager.h index 1373be4d..c52a0c24 100644 --- a/kstyle/breezewindowmanager.h +++ b/kstyle/breezewindowmanager.h @@ -33,7 +33,7 @@ #include #include -#if !BREEZE_USE_KDE4 +#if BREEZE_HAVE_QTQUICK #include #endif @@ -68,7 +68,7 @@ namespace Breeze //* register widget void registerWidget( QWidget* ); - #if !BREEZE_USE_KDE4 + #if BREEZE_HAVE_QTQUICK //* register quick item void registerQuickItem( QQuickItem* ); #endif @@ -286,7 +286,7 @@ namespace Breeze /** Weak pointer is used in case the target gets deleted while drag is in progress */ WeakPointer _target; - #if !BREEZE_USE_KDE4 + #if BREEZE_HAVE_QTQUICK WeakPointer _quickTarget; #endif diff --git a/kstyle/config-breeze.h.cmake b/kstyle/config-breeze.h.cmake index 130fc5bf..53dd6df2 100644 --- a/kstyle/config-breeze.h.cmake +++ b/kstyle/config-breeze.h.cmake @@ -25,6 +25,9 @@ /* Define to 1 if breeze is compiled against KDE4 */ #cmakedefine01 BREEZE_USE_KDE4 +/* Define to 1 if QtQuick is available */ +#cmakedefine01 BREEZE_HAVE_QTQUICK + /* Define to 1 if FrameworkIntegration/Kstyle libraries are found */ #cmakedefine01 BREEZE_HAVE_KSTYLE