[libcalamaresui] When QML is off, there is no Qml panel flavor

main
Adriaan de Groot 5 years ago
parent 736f99768a
commit c83e5c57a4

@ -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 <QFile>
#include <QFileInfo>
#include <QLabel>
#ifdef WITH_QML
#include <QQuickItem>
#include <QQuickWidget>
#endif
#include <QTreeView>
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;
}

@ -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 },

@ -22,8 +22,8 @@
#ifndef BRANDING_H
#define BRANDING_H
#include "CalamaresConfig.h"
#include "DllMacro.h"
#include "utils/NamedSuffix.h"
#include <QMap>
@ -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)

Loading…
Cancel
Save