Merge branch 'no-qml'

main
Adriaan de Groot 5 years ago
commit dd0491e5ca

@ -12,6 +12,10 @@ This release contains contributions from (alphabetically by first name):
- The slideshow in `branding.desc` can be configured with QML (recommended,
as it has been for the past umpteen releases) or with a list of
images (new).
- It is possible to turn off all the new QML code -- navigation, slideshow,
QML-based modules -- with a single `-DWITH_QML=OFF` at CMake time.
This removes QML from Calamares' dependency footprint (but only saves
200kB in Calamares itself).
## Modules ##
- No module changes yet

@ -56,7 +56,8 @@ option( WITH_KF5DBus "Use DBus service for unique-application." OFF )
# When adding WITH_* that affects the ABI offered by libcalamares,
# also update libcalamares/CalamaresConfig.h.in
option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON )
option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF )
option( WITH_PYTHONQT "Enable Python view modules API (deprecated, requires PythonQt)." OFF )
option( WITH_QML "Enable QML UI options." ON )
# Possible debugging flags are:
# - DEBUG_TIMEZONES draws latitude and longitude lines on the timezone
@ -253,7 +254,10 @@ include( CMakeColors )
### DEPENDENCIES
#
find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Concurrent Core Gui Widgets LinguistTools Svg Quick QuickWidgets )
find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Concurrent Core Gui LinguistTools Network Svg Widgets )
if( WITH_QML )
find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Quick QuickWidgets )
endif()
if( Qt5_VERSION VERSION_GREATER 5.12.1 )
# At least Qt 5.12.2 seems to support Esperanto in QLocale
if( "eo" IN_LIST _tx_incomplete )

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

@ -11,5 +11,6 @@
//cmakedefines for CMake variables (e.g. for optdepends) go here
#cmakedefine WITH_PYTHON
#cmakedefine WITH_PYTHONQT
#cmakedefine WITH_QML
#endif // CALAMARESCONFIG_H

@ -20,7 +20,7 @@
#ifndef DLLMACRO_H
#define DLLMACRO_H
#include <QtCore/qglobal.h>
#include <qglobal.h>
/*
* Mark symbols exported from Calamares non-GUI library with DLLEXPORT.

@ -180,6 +180,7 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
"component directory." );
initSimpleSettings( doc );
initSlideshowSettings( doc );
#ifdef WITH_KOSRelease
// Copy the os-release information into a QHash for use by KMacroExpander.
@ -202,17 +203,15 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
{ QStringLiteral( "VARIANT" ), relInfo.variant() },
{ QStringLiteral( "VARIANT_ID" ), relInfo.variantId() },
{ QStringLiteral( "LOGO" ), relInfo.logo() } } };
auto expand = [ & ]( const QString& s ) -> QString {
auto expand = [&]( const QString& s ) -> QString {
return KMacroExpander::expandMacros( s, relMap, QLatin1Char( '@' ) );
};
#else
auto expand = []( const QString& s ) -> QString { return s; };
#endif
// Massage the strings, images and style sections.
loadStrings( m_strings, doc, "strings", expand );
loadStrings( m_images, doc, "images", [ & ]( const QString& s ) -> QString {
loadStrings( m_images, doc, "images", [&]( const QString& s ) -> QString {
// See also image()
const QString imageName( expand( s ) );
QFileInfo imageFi( componentDir.absoluteFilePath( imageName ) );
@ -230,50 +229,6 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
return imageFi.absoluteFilePath();
} );
loadStrings( m_style, doc, "style", []( const QString& s ) -> QString { return s; } );
if ( doc[ "slideshow" ].IsSequence() )
{
QStringList slideShowPictures;
doc[ "slideshow" ] >> slideShowPictures;
for ( int i = 0; i < slideShowPictures.count(); ++i )
{
QString pathString = slideShowPictures[ i ];
QFileInfo imageFi( componentDir.absoluteFilePath( pathString ) );
if ( !imageFi.exists() )
{
bail( m_descriptorPath,
QString( "Slideshow file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
}
slideShowPictures[ i ] = imageFi.absoluteFilePath();
}
m_slideshowFilenames = slideShowPictures;
m_slideshowAPI = -1;
}
else if ( doc[ "slideshow" ].IsScalar() )
{
QString slideshowPath = QString::fromStdString( doc[ "slideshow" ].as< std::string >() );
QFileInfo slideshowFi( componentDir.absoluteFilePath( slideshowPath ) );
if ( !slideshowFi.exists() || !slideshowFi.fileName().toLower().endsWith( ".qml" ) )
bail( m_descriptorPath,
QString( "Slideshow file %1 does not exist or is not a valid QML file." )
.arg( slideshowFi.absoluteFilePath() ) );
m_slideshowPath = slideshowFi.absoluteFilePath();
// API choice is relevant for QML slideshow
int api = doc[ "slideshowAPI" ].IsScalar() ? doc[ "slideshowAPI" ].as< int >() : -1;
if ( ( api < 1 ) || ( api > 2 ) )
{
cWarning() << "Invalid or missing *slideshowAPI* in branding file.";
api = 1;
}
m_slideshowAPI = api;
}
else
{
bail( m_descriptorPath, "Syntax error in slideshow sequence." );
}
}
catch ( YAML::Exception& e )
{
@ -436,8 +391,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 },
@ -553,4 +511,62 @@ Branding::initSimpleSettings( const YAML::Node& doc )
}
}
void
Branding::initSlideshowSettings( const YAML::Node& doc )
{
QDir componentDir( componentDirectory() );
if ( doc[ "slideshow" ].IsSequence() )
{
QStringList slideShowPictures;
doc[ "slideshow" ] >> slideShowPictures;
for ( int i = 0; i < slideShowPictures.count(); ++i )
{
QString pathString = slideShowPictures[ i ];
QFileInfo imageFi( componentDir.absoluteFilePath( pathString ) );
if ( !imageFi.exists() )
{
bail( m_descriptorPath,
QString( "Slideshow file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
}
slideShowPictures[ i ] = imageFi.absoluteFilePath();
}
m_slideshowFilenames = slideShowPictures;
m_slideshowAPI = -1;
}
#ifdef WITH_QML
else if ( doc[ "slideshow" ].IsScalar() )
{
QString slideshowPath = QString::fromStdString( doc[ "slideshow" ].as< std::string >() );
QFileInfo slideshowFi( componentDir.absoluteFilePath( slideshowPath ) );
if ( !slideshowFi.exists() || !slideshowFi.fileName().toLower().endsWith( ".qml" ) )
bail( m_descriptorPath,
QString( "Slideshow file %1 does not exist or is not a valid QML file." )
.arg( slideshowFi.absoluteFilePath() ) );
m_slideshowPath = slideshowFi.absoluteFilePath();
// API choice is relevant for QML slideshow
int api = doc[ "slideshowAPI" ].IsScalar() ? doc[ "slideshowAPI" ].as< int >() : -1;
if ( ( api < 1 ) || ( api > 2 ) )
{
cWarning() << "Invalid or missing *slideshowAPI* in branding file.";
api = 1;
}
m_slideshowAPI = api;
}
#else
else if ( doc[ "slideshow" ].IsScalar() )
{
cWarning() << "Invalid *slideshow* setting, must be list of images.";
}
#endif
else
{
bail( m_descriptorPath, "Syntax error in slideshow sequence." );
}
}
} // namespace Calamares

@ -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)
@ -259,6 +262,8 @@ private:
/** @brief Initialize the simple settings below */
void initSimpleSettings( const YAML::Node& doc );
///@brief Initialize the slideshow settings, above
void initSlideshowSettings( const YAML::Node& doc );
bool m_welcomeStyleCalamares;
bool m_welcomeExpandingLogo;

@ -14,11 +14,9 @@ set( calamaresui_SOURCES
utils/CalamaresUtilsGui.cpp
utils/ImageRegistry.cpp
utils/Paste.cpp
utils/Qml.cpp
viewpages/BlankViewStep.cpp
viewpages/ExecutionViewStep.cpp
viewpages/QmlViewStep.cpp
viewpages/Slideshow.cpp
viewpages/ViewStep.cpp
@ -45,10 +43,6 @@ if( WITH_PYTHON )
endif()
if( WITH_PYTHONQT )
include_directories(${PYTHON_INCLUDE_DIRS})
# *_DIRS because we also use extensions
include_directories(${PYTHONQT_INCLUDE_DIRS})
list( APPEND calamaresui_SOURCES
modulesystem/PythonQtViewModule.cpp
utils/PythonQtUtils.cpp
@ -57,25 +51,33 @@ if( WITH_PYTHONQT )
viewpages/PythonQtGlobalStorageWrapper.cpp
viewpages/PythonQtUtilsWrapper.cpp
)
set( OPTIONAL_PYTHON_LIBRARIES
${PYTHON_LIBRARIES}
${PYTHONQT_LIBRARIES}
endif()
if( WITH_QML )
list( APPEND calamaresui_SOURCES
utils/Qml.cpp
viewpages/QmlViewStep.cpp
)
endif()
calamares_add_library( calamaresui
SOURCES ${calamaresui_SOURCES}
EXPORT_MACRO UIDLLEXPORT_PRO
LINK_PRIVATE_LIBRARIES
${OPTIONAL_PYTHON_LIBRARIES}
LINK_LIBRARIES
Qt5::Svg
Qt5::QuickWidgets
RESOURCES libcalamaresui.qrc
EXPORT CalamaresLibraryDepends
VERSION ${CALAMARES_VERSION_SHORT}
)
if ( KF5CoreAddons_FOUND AND KF5CoreAddons_VERSION VERSION_GREATER_EQUAL 5.58 )
if( KF5CoreAddons_FOUND AND KF5CoreAddons_VERSION VERSION_GREATER_EQUAL 5.58 )
target_compile_definitions( calamaresui PRIVATE WITH_KOSRelease )
endif()
if( WITH_PYTHONQT )
# *_DIRS because we also use extensions
target_include_directories( calamaresui PRIVATE ${PYTHON_INCLUDE_DIRS} ${PYTHONQT_INCLUDE_DIRS} )
target_link_libraries( calamaresui PRIVATE ${PYTHON_LIBRARIES} ${PYTHONQT_LIBRARIES} )
endif()
if( WITH_QML )
target_link_libraries( calamaresui PUBLIC Qt5::QuickWidgets )
endif()

@ -23,11 +23,11 @@
#include "Slideshow.h"
#include "Branding.h"
#include "CalamaresConfig.h"
#include "Job.h"
#include "JobQueue.h"
#include "Settings.h"
#include "ViewManager.h"
#include "modulesystem/Module.h"
#include "modulesystem/ModuleManager.h"
#include "utils/CalamaresUtilsGui.h"
@ -49,10 +49,12 @@ makeSlideshow( QWidget* parent )
{
case -1:
return new Calamares::SlideshowPictures( parent );
#ifdef WITH_QML
case 1:
FALLTHRU;
case 2:
return new Calamares::SlideshowQML( parent );
#endif
default:
cWarning() << "Unknown Branding slideshow API" << api;
return new Calamares::SlideshowPictures( parent );

@ -28,10 +28,12 @@
#include <QLabel>
#include <QMutexLocker>
#ifdef WITH_QML
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQuickItem>
#include <QQuickWidget>
#endif
#include <QTimer>
#include <chrono>
@ -41,6 +43,7 @@ namespace Calamares
Slideshow::~Slideshow() {}
#ifdef WITH_QML
SlideshowQML::SlideshowQML( QWidget* parent )
: Slideshow( parent )
, m_qmlShow( new QQuickWidget )
@ -173,6 +176,7 @@ SlideshowQML::changeSlideShowState( Action state )
m_state = state;
}
#endif
SlideshowPictures::SlideshowPictures( QWidget* parent )
: Slideshow( parent )

@ -21,15 +21,19 @@
#ifndef LIBCALAMARESUI_SLIDESHOW_H
#define LIBCALAMARESUI_SLIDESHOW_H
#include "CalamaresConfig.h"
#include <QMutex>
#include <QStringList>
#include <QWidget>
class QLabel;
class QTimer;
#ifdef WITH_QML
class QQmlComponent;
class QQuickItem;
class QQuickWidget;
#endif
namespace Calamares
{
@ -81,6 +85,7 @@ protected:
Action m_state = Stop;
};
#ifdef WITH_QML
/** @brief Slideshow using a QML file
*
* This is the "classic" slideshow in Calamares, which runs some QML
@ -109,6 +114,7 @@ private:
QQmlComponent* m_qmlComponent;
QQuickItem* m_qmlObject; ///< The actual show
};
#endif
/** @brief Slideshow using images
*

@ -1,3 +1,8 @@
if( NOT WITH_QML )
calamares_skip_module( "keyboardq (QML is not supported in this build)" )
return()
endif()
set( _keyboard ${CMAKE_CURRENT_SOURCE_DIR}/../keyboard )
include_directories( ${_keyboard} )

@ -1,3 +1,8 @@
if( NOT WITH_QML )
calamares_skip_module( "localeq (QML is not supported in this build)" )
return()
endif()
# When debugging the timezone widget, add this debugging definition
# to have a debugging-friendly timezone widget, debug logging,
# and no intrusive timezone-setting while clicking around.

@ -1,3 +1,8 @@
if( NOT WITH_QML )
calamares_skip_module( "notesqml (QML is not supported in this build)" )
return()
endif()
calamares_add_plugin( notesqml
TYPE viewmodule
EXPORT_MACRO PLUGINDLLEXPORT_PRO

@ -1,6 +1,11 @@
# This is a re-write of the welcome module using QML view steps
# instead of widgets.
if( NOT WITH_QML )
calamares_skip_module( "welcomeq (QML is not supported in this build)" )
return()
endif()
set( _welcome ${CMAKE_CURRENT_SOURCE_DIR}/../welcome )
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ${CMAKE_CURRENT_SOURCE_DIR}/../../libcalamares ${_welcome} )

Loading…
Cancel
Save