From c83e5c57a455e2c91c60fbadc5b6f006c8ef4ecf Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 14 May 2020 16:56:50 +0200 Subject: [PATCH] [libcalamaresui] When QML is off, there is no Qml panel flavor --- src/calamares/CalamaresWindow.cpp | 48 ++++++++++++++++++++++--------- src/libcalamaresui/Branding.cpp | 5 +++- src/libcalamaresui/Branding.h | 7 +++-- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 06a31a0e9..2ab7cd5fa 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -22,6 +22,7 @@ #include "CalamaresWindow.h" #include "Branding.h" +#include "CalamaresConfig.h" #include "DebugWindow.h" #include "Settings.h" #include "ViewManager.h" @@ -38,8 +39,10 @@ #include #include #include +#ifdef WITH_QML #include #include +#endif #include static inline int @@ -132,18 +135,6 @@ CalamaresWindow::getWidgetSidebar( QWidget* parent, int desiredWidth ) return sideBox; } -QWidget* -CalamaresWindow::getQmlSidebar( QWidget* parent, int ) -{ - CalamaresUtils::registerCalamaresModels(); - QQuickWidget* w = new QQuickWidget( parent ); - w->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - w->setResizeMode( QQuickWidget::SizeRootObjectToView ); - w->setSource( QUrl( - CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) ); - return w; -} - /** @brief Get a button-sized icon. */ static inline QPixmap getButtonIcon( const QString& name ) @@ -213,6 +204,19 @@ CalamaresWindow::getWidgetNavigation( QWidget* parent ) return navigation; } +#ifdef WITH_QML +QWidget* +CalamaresWindow::getQmlSidebar( QWidget* parent, int ) +{ + CalamaresUtils::registerCalamaresModels(); + QQuickWidget* w = new QQuickWidget( parent ); + w->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + w->setResizeMode( QQuickWidget::SizeRootObjectToView ); + w->setSource( QUrl( + CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) ); + return w; +} + QWidget* CalamaresWindow::getQmlNavigation( QWidget* parent ) { @@ -231,6 +235,19 @@ CalamaresWindow::getQmlNavigation( QWidget* parent ) return w; } +#else +// Bogus to keep the linker happy +QWidget * CalamaresWindow::getQmlSidebar(QWidget* , int ) +{ + return nullptr; +} +QWidget * CalamaresWindow::getQmlNavigation(QWidget* ) +{ + return nullptr; +} + + +#endif /**@brief Picks one of two methods to call * @@ -243,16 +260,21 @@ flavoredWidget( Calamares::Branding::PanelFlavor flavor, CalamaresWindow* w, QWidget* parent, widgetMaker widget, - widgetMaker qml, + widgetMaker qml, // Only if WITH_QML is on args... a ) { +#ifndef WITH_QML + Q_UNUSED( qml ) +#endif // Member-function calling syntax is (object.*member)(args) switch ( flavor ) { case Calamares::Branding::PanelFlavor::Widget: return ( w->*widget )( parent, a... ); +#ifdef WITH_QML case Calamares::Branding::PanelFlavor::Qml: return ( w->*qml )( parent, a... ); +#endif case Calamares::Branding::PanelFlavor::None: return nullptr; } diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 0ec691904..2eb64e875 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -436,8 +436,11 @@ flavorAndSide( const YAML::Node& doc, const char* key, Branding::PanelFlavor& fl static const NamedEnumTable< PanelFlavor > sidebarFlavorNames { { QStringLiteral( "widget" ), PanelFlavor::Widget }, { QStringLiteral( "none" ), PanelFlavor::None }, - { QStringLiteral( "hidden" ), PanelFlavor::None }, + { QStringLiteral( "hidden" ), PanelFlavor::None } +#ifdef WITH_QML + , { QStringLiteral( "qml" ), PanelFlavor::Qml } +#endif }; static const NamedEnumTable< PanelSide > panelSideNames { { QStringLiteral( "left" ), PanelSide::Left }, diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 1244ede7d..0723d9287 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -22,8 +22,8 @@ #ifndef BRANDING_H #define BRANDING_H +#include "CalamaresConfig.h" #include "DllMacro.h" - #include "utils/NamedSuffix.h" #include @@ -131,8 +131,11 @@ public: enum class PanelFlavor { None, - Widget, + Widget +#ifdef WITH_QML + , Qml +#endif }; Q_ENUM( PanelFlavor ) ///@brief Where to place a panel (sidebar, navigation)