From 156d78feb3d65ed158956dd9be8ba3eb9d57334d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 13 Dec 2019 11:50:12 +0100 Subject: [PATCH 02/32] [welcome] Add QML support - test application to display the QML (this will be extended with adding the locale model to it) - sample QML that does nothing useful yet (will display the locale model once it's there) --- src/modules/welcome/CMakeLists.txt | 3 ++ src/modules/welcome/qmlmain.cpp | 52 ++++++++++++++++++++++++++++++ src/modules/welcome/welcome.qml | 12 +++++++ 3 files changed, 67 insertions(+) create mode 100644 src/modules/welcome/qmlmain.cpp create mode 100644 src/modules/welcome/welcome.qml diff --git a/src/modules/welcome/CMakeLists.txt b/src/modules/welcome/CMakeLists.txt index e25b7f5d0..e0fbcfca1 100644 --- a/src/modules/welcome/CMakeLists.txt +++ b/src/modules/welcome/CMakeLists.txt @@ -40,3 +40,6 @@ calamares_add_plugin( welcome Qt5::Network SHARED_LIB ) + +add_executable( welcomeqmltest qmlmain.cpp ) +target_link_libraries( welcomeqmltest calamaresui ) diff --git a/src/modules/welcome/qmlmain.cpp b/src/modules/welcome/qmlmain.cpp new file mode 100644 index 000000000..81bf08df5 --- /dev/null +++ b/src/modules/welcome/qmlmain.cpp @@ -0,0 +1,52 @@ +/* Example executable showing a QML page and using the + * models from libcalamares for displaying a welcome. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "utils/Logger.h" + +int main(int argc, char **argv) +{ + QApplication a( argc, argv ); + + KAboutData aboutData( "calamares", + "Calamares", + "0.1", + "Calamares QML Test Application", + KAboutLicense::GPL_V3, + QString(), + QString(), + "https://calamares.io", + "https://github.com/calamares/calamares/issues" ); + KAboutData::setApplicationData( aboutData ); + a.setApplicationDisplayName( QString() ); // To avoid putting an extra "Calamares/" into the log-file + + Logger::setupLogLevel( Logger::LOGVERBOSE ); + + QMainWindow mw; + QWidget background; + QVBoxLayout vl; + QLabel l( "Hello, world", &mw ); + QQuickWidget qqw( &mw ); + vl.addWidget( &qqw ); + vl.addWidget( &l ); + background.setLayout( &vl ); + mw.setCentralWidget( &background ); + mw.resize( QSize( 400, 400 ) ); + mw.show(); + + qqw.setSource( QUrl::fromLocalFile("../src/modules/welcome/welcome.qml") ); + + return a.exec(); +} diff --git a/src/modules/welcome/welcome.qml b/src/modules/welcome/welcome.qml new file mode 100644 index 000000000..f73b66571 --- /dev/null +++ b/src/modules/welcome/welcome.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0; + +Rectangle { + width: 200; + height: 200; + color: "pink"; + + Text { + anchors.centerIn: parent; + text: "Welcome to Calamares"; + } +} From c59678594bbd81c6ddb7d39b32f48b8ae9471f6a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 13 Dec 2019 12:35:42 +0100 Subject: [PATCH 03/32] [welcome] More QML support - start of a class to hold configuration information; this can later be substituted into the WelcomeViewStep and filled from setConfigurationMap() In the example application: - register the Config type --- src/modules/welcome/CMakeLists.txt | 11 ++++++-- src/modules/welcome/Config.cpp | 27 ++++++++++++++++++++ src/modules/welcome/Config.h | 40 ++++++++++++++++++++++++++++++ src/modules/welcome/qmlmain.cpp | 10 ++++++++ src/modules/welcome/welcome.qml | 1 + 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 src/modules/welcome/Config.cpp create mode 100644 src/modules/welcome/Config.h diff --git a/src/modules/welcome/CMakeLists.txt b/src/modules/welcome/CMakeLists.txt index e0fbcfca1..b25bb6720 100644 --- a/src/modules/welcome/CMakeLists.txt +++ b/src/modules/welcome/CMakeLists.txt @@ -41,5 +41,12 @@ calamares_add_plugin( welcome SHARED_LIB ) -add_executable( welcomeqmltest qmlmain.cpp ) -target_link_libraries( welcomeqmltest calamaresui ) +add_executable( welcomeqmltest qmlmain.cpp Config.cpp ) +target_link_libraries( welcomeqmltest PRIVATE calamaresui Qt5::Core ) +set_target_properties( welcomeqmltest + PROPERTIES + ENABLE_EXPORTS TRUE + RUNTIME_OUTPUT_NAME welcomeqmltest +) +calamares_automoc( welcomeqmltest ) +calamares_autouic( welcomeqmltest ) diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp new file mode 100644 index 000000000..35ce99184 --- /dev/null +++ b/src/modules/welcome/Config.cpp @@ -0,0 +1,27 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "Config.h" + +Config::Config() +{ +} + +Config::~Config() +{ +} diff --git a/src/modules/welcome/Config.h b/src/modules/welcome/Config.h new file mode 100644 index 000000000..91f5bec5c --- /dev/null +++ b/src/modules/welcome/Config.h @@ -0,0 +1,40 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef WELCOME_CONFIG_H +#define WELCOME_CONFIG_H + +#include +#include + +class Config : public QObject +{ + Q_OBJECT + Q_PROPERTY( QUrl helpUrl READ helpUrl WRITE setHelpUrl ) +public: + Config(); + virtual ~Config(); + + QUrl helpUrl() const { return m_helpUrl; } + void setHelpUrl( const QUrl& url ) { m_helpUrl = url; } + +private: + QUrl m_helpUrl; +}; + +#endif diff --git a/src/modules/welcome/qmlmain.cpp b/src/modules/welcome/qmlmain.cpp index 81bf08df5..cc538747a 100644 --- a/src/modules/welcome/qmlmain.cpp +++ b/src/modules/welcome/qmlmain.cpp @@ -16,6 +16,8 @@ #include "utils/Logger.h" +#include "Config.h" + int main(int argc, char **argv) { QApplication a( argc, argv ); @@ -46,6 +48,14 @@ int main(int argc, char **argv) mw.resize( QSize( 400, 400 ) ); mw.show(); + Config cnf; + if ( argc > 1 ) + { + cnf.setHelpUrl( QUrl( argv[1] ) ); + } + + qmlRegisterType< Config >( "io.calamares.modules.welcome", 1, 0, "Config" ); + qqw.setSource( QUrl::fromLocalFile("../src/modules/welcome/welcome.qml") ); return a.exec(); diff --git a/src/modules/welcome/welcome.qml b/src/modules/welcome/welcome.qml index f73b66571..d442bfa11 100644 --- a/src/modules/welcome/welcome.qml +++ b/src/modules/welcome/welcome.qml @@ -1,4 +1,5 @@ import QtQuick 2.0; +import io.calamares.modules.welcome 1.0; Rectangle { width: 200; From d41d8df2a55c794cbb74204dcb3978c54c88de28 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 13 Dec 2019 13:19:38 +0100 Subject: [PATCH 04/32] [welcome] Put Config object into context --- src/modules/welcome/Config.cpp | 1 + src/modules/welcome/Config.h | 2 +- src/modules/welcome/qmlmain.cpp | 9 ++++++++- src/modules/welcome/welcome.qml | 10 +++++++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 35ce99184..b46b85bf3 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -19,6 +19,7 @@ #include "Config.h" Config::Config() + : m_helpUrl( "https://www.kde.org/" ) { } diff --git a/src/modules/welcome/Config.h b/src/modules/welcome/Config.h index 91f5bec5c..7b0cfd734 100644 --- a/src/modules/welcome/Config.h +++ b/src/modules/welcome/Config.h @@ -25,7 +25,7 @@ class Config : public QObject { Q_OBJECT - Q_PROPERTY( QUrl helpUrl READ helpUrl WRITE setHelpUrl ) + Q_PROPERTY( QUrl helpUrl READ helpUrl WRITE setHelpUrl CONSTANT ) public: Config(); virtual ~Config(); diff --git a/src/modules/welcome/qmlmain.cpp b/src/modules/welcome/qmlmain.cpp index cc538747a..0aca1ddcd 100644 --- a/src/modules/welcome/qmlmain.cpp +++ b/src/modules/welcome/qmlmain.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,12 @@ #include "Config.h" +static Config* theConfig() +{ + static Config* cnf = new Config(); + return cnf; +} + int main(int argc, char **argv) { QApplication a( argc, argv ); @@ -54,7 +61,7 @@ int main(int argc, char **argv) cnf.setHelpUrl( QUrl( argv[1] ) ); } - qmlRegisterType< Config >( "io.calamares.modules.welcome", 1, 0, "Config" ); + qmlRegisterSingletonType< Config >( "io.calamares.modules.welcome", 1, 0, "PotatoConfig", [](QQmlEngine*, QJSEngine*) -> QObject* { return theConfig(); }); qqw.setSource( QUrl::fromLocalFile("../src/modules/welcome/welcome.qml") ); diff --git a/src/modules/welcome/welcome.qml b/src/modules/welcome/welcome.qml index d442bfa11..ba28d660b 100644 --- a/src/modules/welcome/welcome.qml +++ b/src/modules/welcome/welcome.qml @@ -1,4 +1,5 @@ import QtQuick 2.0; +import QtQuick.Controls 2.3; import io.calamares.modules.welcome 1.0; Rectangle { @@ -6,8 +7,15 @@ Rectangle { height: 200; color: "pink"; - Text { + Label { + id: label; anchors.centerIn: parent; text: "Welcome to Calamares"; } + + Button { + anchors.top: label.bottom; + text: PotatoConfig.helpUrl; + + } } From 03ed308bd93633466e7bde7852d7c21b9c3d5ed3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 13 Dec 2019 14:31:42 +0100 Subject: [PATCH 05/32] [welcome] Add QML model for translations --- src/modules/welcome/qmlmain.cpp | 4 ++++ src/modules/welcome/welcome.qml | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/modules/welcome/qmlmain.cpp b/src/modules/welcome/qmlmain.cpp index 0aca1ddcd..9c160fc1d 100644 --- a/src/modules/welcome/qmlmain.cpp +++ b/src/modules/welcome/qmlmain.cpp @@ -15,6 +15,7 @@ #include +#include "locale/LabelModel.h" #include "utils/Logger.h" #include "Config.h" @@ -61,8 +62,11 @@ int main(int argc, char **argv) cnf.setHelpUrl( QUrl( argv[1] ) ); } + // TODO: this should put the one config object in the context, rather than adding a factory function to share it everywhere qmlRegisterSingletonType< Config >( "io.calamares.modules.welcome", 1, 0, "PotatoConfig", [](QQmlEngine*, QJSEngine*) -> QObject* { return theConfig(); }); + qmlRegisterSingletonType< CalamaresUtils::Locale::LabelModel >( "io.calamares.locale", 1, 0, "LocaleModel", [](QQmlEngine*, QJSEngine*) -> QObject* { return CalamaresUtils::Locale::availableTranslations(); } ); + qqw.setSource( QUrl::fromLocalFile("../src/modules/welcome/welcome.qml") ); return a.exec(); diff --git a/src/modules/welcome/welcome.qml b/src/modules/welcome/welcome.qml index ba28d660b..bdb7c4416 100644 --- a/src/modules/welcome/welcome.qml +++ b/src/modules/welcome/welcome.qml @@ -1,6 +1,7 @@ import QtQuick 2.0; import QtQuick.Controls 2.3; import io.calamares.modules.welcome 1.0; +import io.calamares.locale 1.0; Rectangle { width: 200; @@ -14,8 +15,15 @@ Rectangle { } Button { + id: thebutton; anchors.top: label.bottom; text: PotatoConfig.helpUrl; } + + ListView { + anchors.fill: parent; + model: LocaleModel; + delegate: Label { text: display } + } } From 55f61fda3527c4072060b08d1833cd44788b4bc0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 13 Dec 2019 18:18:02 +0100 Subject: [PATCH 06/32] [welcome] Create branding and settings objects --- src/modules/welcome/qmlmain.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/welcome/qmlmain.cpp b/src/modules/welcome/qmlmain.cpp index 9c160fc1d..93017a9c7 100644 --- a/src/modules/welcome/qmlmain.cpp +++ b/src/modules/welcome/qmlmain.cpp @@ -2,6 +2,8 @@ * models from libcalamares for displaying a welcome. */ +#include + #include #include #include @@ -15,6 +17,8 @@ #include +#include "JobQueue.h" +#include "Settings.h" #include "locale/LabelModel.h" #include "utils/Logger.h" @@ -44,6 +48,9 @@ int main(int argc, char **argv) Logger::setupLogLevel( Logger::LOGVERBOSE ); + std::unique_ptr< Calamares::Settings > settings_p( new Calamares::Settings( QString(), true ) ); + std::unique_ptr< Calamares::JobQueue > jobqueue_p( new Calamares::JobQueue( nullptr ) ); + QMainWindow mw; QWidget background; QVBoxLayout vl; From 6c4efc1f9ce512f710cecb78a0ef1eea94ed1b17 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 13 Dec 2019 18:23:01 +0100 Subject: [PATCH 07/32] [welcome] Add Branding object to QML demo --- src/modules/welcome/qmlmain.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/welcome/qmlmain.cpp b/src/modules/welcome/qmlmain.cpp index 93017a9c7..96d9d245f 100644 --- a/src/modules/welcome/qmlmain.cpp +++ b/src/modules/welcome/qmlmain.cpp @@ -17,6 +17,7 @@ #include +#include "Branding.h" #include "JobQueue.h" #include "Settings.h" #include "locale/LabelModel.h" @@ -51,6 +52,9 @@ int main(int argc, char **argv) std::unique_ptr< Calamares::Settings > settings_p( new Calamares::Settings( QString(), true ) ); std::unique_ptr< Calamares::JobQueue > jobqueue_p( new Calamares::JobQueue( nullptr ) ); + Calamares::Branding defaultBrand( "src/branding/default/branding.desc" ); + cDebug() << "Branding @" << (void *)Calamares::Branding::instance(); + QMainWindow mw; QWidget background; QVBoxLayout vl; From 53b208e891d1f8e7ecc77437ad6c3a0cd54228bd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 14 Dec 2019 12:48:09 +0100 Subject: [PATCH 08/32] [welcomeq] Start new ViewStep for QML-based welcome --- src/modules/welcomeq/CMakeLists.txt | 41 ++++ src/modules/welcomeq/Config.cpp | 28 +++ src/modules/welcomeq/Config.h | 40 ++++ src/modules/welcomeq/WelcomeQmlViewStep.cpp | 243 ++++++++++++++++++++ src/modules/welcomeq/WelcomeQmlViewStep.h | 85 +++++++ 5 files changed, 437 insertions(+) create mode 100644 src/modules/welcomeq/CMakeLists.txt create mode 100644 src/modules/welcomeq/Config.cpp create mode 100644 src/modules/welcomeq/Config.h create mode 100644 src/modules/welcomeq/WelcomeQmlViewStep.cpp create mode 100644 src/modules/welcomeq/WelcomeQmlViewStep.h diff --git a/src/modules/welcomeq/CMakeLists.txt b/src/modules/welcomeq/CMakeLists.txt new file mode 100644 index 000000000..2105c77e6 --- /dev/null +++ b/src/modules/welcomeq/CMakeLists.txt @@ -0,0 +1,41 @@ +set( _welcome ${CMAKE_CURRENT_SOURCE_DIR}/../welcome ) + +include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ${_welcome} ) + +# DUPLICATED WITH WELCOME MODULE +find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED DBus Network ) + +find_package( LIBPARTED ) +if ( LIBPARTED_FOUND ) + set( PARTMAN_SRC ${_welcome}/checker/partman_devices.c ) + set( CHECKER_LINK_LIBRARIES ${LIBPARTED_LIBRARY} ) +else() + set( PARTMAN_SRC ) + set( CHECKER_LINK_LIBRARIES ) + add_definitions( -DWITHOUT_LIBPARTED ) +endif() + +set( CHECKER_SOURCES + ${_welcome}/checker/CheckerContainer.cpp + ${_welcome}/checker/GeneralRequirements.cpp + ${_welcome}/checker/ResultWidget.cpp + ${_welcome}/checker/ResultsListWidget.cpp + ${PARTMAN_SRC} +) + +calamares_add_plugin( welcomeq + TYPE viewmodule + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + ${CHECKER_SOURCES} + WelcomeQmlViewStep.cpp + Config.cpp + RESOURCES + welcomeq.qrc + LINK_PRIVATE_LIBRARIES + calamaresui + ${CHECKER_LINK_LIBRARIES} + Qt5::DBus + Qt5::Network + SHARED_LIB +) diff --git a/src/modules/welcomeq/Config.cpp b/src/modules/welcomeq/Config.cpp new file mode 100644 index 000000000..b46b85bf3 --- /dev/null +++ b/src/modules/welcomeq/Config.cpp @@ -0,0 +1,28 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "Config.h" + +Config::Config() + : m_helpUrl( "https://www.kde.org/" ) +{ +} + +Config::~Config() +{ +} diff --git a/src/modules/welcomeq/Config.h b/src/modules/welcomeq/Config.h new file mode 100644 index 000000000..7b0cfd734 --- /dev/null +++ b/src/modules/welcomeq/Config.h @@ -0,0 +1,40 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef WELCOME_CONFIG_H +#define WELCOME_CONFIG_H + +#include +#include + +class Config : public QObject +{ + Q_OBJECT + Q_PROPERTY( QUrl helpUrl READ helpUrl WRITE setHelpUrl CONSTANT ) +public: + Config(); + virtual ~Config(); + + QUrl helpUrl() const { return m_helpUrl; } + void setHelpUrl( const QUrl& url ) { m_helpUrl = url; } + +private: + QUrl m_helpUrl; +}; + +#endif diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.cpp b/src/modules/welcomeq/WelcomeQmlViewStep.cpp new file mode 100644 index 000000000..6a01f1ada --- /dev/null +++ b/src/modules/welcomeq/WelcomeQmlViewStep.cpp @@ -0,0 +1,243 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2018, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "WelcomeQmlViewStep.h" + +#include "checker/GeneralRequirements.h" + +#include "geoip/Handler.h" +#include "locale/LabelModel.h" +#include "locale/Lookup.h" +#include "utils/Logger.h" +#include "utils/Variant.h" + +#include "Branding.h" +#include "modulesystem/ModuleManager.h" + +#include +#include +#include + +CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeQmlViewStepFactory, registerPlugin< WelcomeQmlViewStep >(); ) + +WelcomeQmlViewStep::WelcomeQmlViewStep( QObject* parent ) + : Calamares::ViewStep( parent ) + , m_requirementsChecker( new GeneralRequirements( this ) ) +{ + connect( Calamares::ModuleManager::instance(), + &Calamares::ModuleManager::requirementsComplete, + this, + &WelcomeQmlViewStep::nextStatusChanged ); +} + + +WelcomeQmlViewStep::~WelcomeQmlViewStep() +{ +} + + +QString +WelcomeQmlViewStep::prettyName() const +{ + return tr( "Welcome" ); +} + + +QWidget* +WelcomeQmlViewStep::widget() +{ + return nullptr; +} + + +bool +WelcomeQmlViewStep::isNextEnabled() const +{ + // TODO: should return true + return false; +} + + +bool +WelcomeQmlViewStep::isBackEnabled() const +{ + // TODO: should return true (it's weird that you are not allowed to have welcome *after* anything + return false; +} + + +bool +WelcomeQmlViewStep::isAtBeginning() const +{ + // TODO: adjust to "pages" in the QML + return true; +} + + +bool +WelcomeQmlViewStep::isAtEnd() const +{ + // TODO: adjust to "pages" in the QML + return true; +} + + +Calamares::JobList +WelcomeQmlViewStep::jobs() const +{ + return Calamares::JobList(); +} + + +/** @brief Look up a URL for a button + * + * Looks up @p key in @p map; if it is a *boolean* value, then + * assume an old-style configuration, and fetch the string from + * the branding settings @p e. If it is a string, not a boolean, + * use it as-is. If not found, or a weird type, returns empty. + * + * This allows switching the showKnownIssuesUrl and similar settings + * in welcome.conf from a boolean (deferring to branding) to an + * actual string for immediate use. Empty strings, as well as + * "false" as a setting, will hide the buttons as before. + */ +static QString +jobOrBrandingSetting( Calamares::Branding::StringEntry e, const QVariantMap& map, const QString& key ) +{ + if ( !map.contains( key ) ) + { + return QString(); + } + auto v = map.value( key ); + if ( v.type() == QVariant::Bool ) + { + return v.toBool() ? ( *e ) : QString(); + } + if ( v.type() == QVariant::String ) + { + return v.toString(); + } + + return QString(); +} + +void +WelcomeQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +{ + using Calamares::Branding; + + m_config.setHelpUrl( jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) ); + // TODO: expand Config class and set the remaining fields + + // TODO: figure out how the requirements (held by ModuleManager) should be accessible + // to QML as a odel. + if ( configurationMap.contains( "requirements" ) + && configurationMap.value( "requirements" ).type() == QVariant::Map ) + { + m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() ); + } + else + cWarning() << "no valid requirements map found in welcome " + "module configuration."; + + bool ok = false; + QVariantMap geoip = CalamaresUtils::getSubMap( configurationMap, "geoip", ok ); + if ( ok ) + { + using FWString = QFutureWatcher< QString >; + + auto* handler = new CalamaresUtils::GeoIP::Handler( CalamaresUtils::getString( geoip, "style" ), + CalamaresUtils::getString( geoip, "url" ), + CalamaresUtils::getString( geoip, "selector" ) ); + if ( handler->type() != CalamaresUtils::GeoIP::Handler::Type::None ) + { + auto* future = new FWString(); + connect( future, &FWString::finished, [view = this, f = future, h = handler]() { + QString countryResult = f->future().result(); + cDebug() << "GeoIP result for welcome=" << countryResult; + view->setCountry( countryResult, h ); + f->deleteLater(); + delete h; + } ); + future->setFuture( handler->queryRaw() ); + } + else + { + // Would not produce useful country code anyway. + delete handler; + } + } + + QString language = CalamaresUtils::getString( configurationMap, "languageIcon" ); + if ( !language.isEmpty() ) + { + auto icon = Calamares::Branding::instance()->image( language, QSize( 48, 48 ) ); + if ( !icon.isNull() ) + { + // TODO: figure out where to set this: Config? + } + } +} + +Calamares::RequirementsList +WelcomeQmlViewStep::checkRequirements() +{ + return m_requirementsChecker->checkRequirements(); +} + +static inline void +logGeoIPHandler( CalamaresUtils::GeoIP::Handler* handler ) +{ + if ( handler ) + { + cDebug() << Logger::SubEntry << "Obtained from" << handler->url() << " (" + << static_cast< int >( handler->type() ) << handler->selector() << ')'; + } +} + +void +WelcomeQmlViewStep::setCountry( const QString& countryCode, CalamaresUtils::GeoIP::Handler* handler ) +{ + if ( countryCode.length() != 2 ) + { + cDebug() << "Unusable country code" << countryCode; + logGeoIPHandler( handler ); + return; + } + + auto c_l = CalamaresUtils::Locale::countryData( countryCode ); + if ( c_l.first == QLocale::Country::AnyCountry ) + { + cDebug() << "Unusable country code" << countryCode; + logGeoIPHandler( handler ); + return; + } + else + { + int r = CalamaresUtils::Locale::availableTranslations()->find( countryCode ); + if ( r < 0 ) + { + cDebug() << "Unusable country code" << countryCode << "(no suitable translation)"; + } + if ( ( r >= 0 ) ) + { + // TODO: update Config to point to selected language + } + } +} diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.h b/src/modules/welcomeq/WelcomeQmlViewStep.h new file mode 100644 index 000000000..162df0a7f --- /dev/null +++ b/src/modules/welcomeq/WelcomeQmlViewStep.h @@ -0,0 +1,85 @@ +/* === This file is part of Calamares - === + * + * Copyright 20195, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef WELCOME_QMLVIEWSTEP_H +#define WELCOME_QMLVIEWSTEP_H + +#include "Config.h" + +#include "modulesystem/Requirement.h" +#include "utils/PluginFactory.h" +#include "viewpages/ViewStep.h" + +#include + +#include +#include + +namespace CalamaresUtils +{ +namespace GeoIP +{ +class Handler; +} +} // namespace CalamaresUtils + +class GeneralRequirements; + +// TODO: Needs a generic Calamares::QmlViewStep as base class +// TODO: refactor and move what makes sense to base class +class PLUGINDLLEXPORT WelcomeQmlViewStep : public Calamares::ViewStep +{ + Q_OBJECT + +public: + explicit WelcomeQmlViewStep( QObject* parent = nullptr ); + virtual ~WelcomeQmlViewStep() override; + + QString prettyName() const override; + + QWidget* widget() override; + + bool isNextEnabled() const override; + bool isBackEnabled() const override; + + bool isAtBeginning() const override; + bool isAtEnd() const override; + + Calamares::JobList jobs() const override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; + + /** @brief Sets the country that Calamares is running in. + * + * This (ideally) sets up language and locale settings that are right for + * the given 2-letter country code. Uses the handler's information (if + * given) for error reporting. + */ + void setCountry( const QString&, CalamaresUtils::GeoIP::Handler* handler ); + + Calamares::RequirementsList checkRequirements() override; + +private: + // TODO: a generic QML viewstep should return a config object from a method + Config m_config; + GeneralRequirements* m_requirementsChecker; +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( WelcomeQmlViewStepFactory ) + +#endif // WELCOME_QMLVIEWSTEP_H From 8e2d257040a1da0d1d75f50f0e5004001f76dfe1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 14 Dec 2019 13:11:14 +0100 Subject: [PATCH 09/32] [welcomeq] Add QML machinery (uninitialized) --- src/modules/welcomeq/WelcomeQmlViewStep.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.h b/src/modules/welcomeq/WelcomeQmlViewStep.h index 162df0a7f..7d10e35ef 100644 --- a/src/modules/welcomeq/WelcomeQmlViewStep.h +++ b/src/modules/welcomeq/WelcomeQmlViewStep.h @@ -40,6 +40,10 @@ class Handler; class GeneralRequirements; +class QQmlComponent; +class QQuickItem; +class QQuickWidget; + // TODO: Needs a generic Calamares::QmlViewStep as base class // TODO: refactor and move what makes sense to base class class PLUGINDLLEXPORT WelcomeQmlViewStep : public Calamares::ViewStep @@ -78,6 +82,12 @@ private: // TODO: a generic QML viewstep should return a config object from a method Config m_config; GeneralRequirements* m_requirementsChecker; + + // TODO: these need to be in the base class (also a base class of ExecutionViewStep) + QQuickWidget* m_qmlWidget; + QQmlComponent* m_qmlComponent; + QQuickItem* m_qmlItem; + }; CALAMARES_PLUGIN_FACTORY_DECLARATION( WelcomeQmlViewStepFactory ) From 56f926094e6dd0f7b2a4f5a6c62fc70090c37a1c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 9 Jan 2020 15:11:36 +0100 Subject: [PATCH 10/32] [welcomeq] Update comments - Copyright years - Purpose of this module --- src/modules/welcomeq/CMakeLists.txt | 3 +++ src/modules/welcomeq/Config.cpp | 2 +- src/modules/welcomeq/Config.h | 2 +- src/modules/welcomeq/WelcomeQmlViewStep.cpp | 2 +- src/modules/welcomeq/WelcomeQmlViewStep.h | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/welcomeq/CMakeLists.txt b/src/modules/welcomeq/CMakeLists.txt index 2105c77e6..7ee0350af 100644 --- a/src/modules/welcomeq/CMakeLists.txt +++ b/src/modules/welcomeq/CMakeLists.txt @@ -1,3 +1,6 @@ +# This is a re-write of the welcome module using QML view steps +# instead of widgets. + set( _welcome ${CMAKE_CURRENT_SOURCE_DIR}/../welcome ) include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ${_welcome} ) diff --git a/src/modules/welcomeq/Config.cpp b/src/modules/welcomeq/Config.cpp index b46b85bf3..6d085143c 100644 --- a/src/modules/welcomeq/Config.cpp +++ b/src/modules/welcomeq/Config.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2019, Adriaan de Groot + * Copyright 2019-2020, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/welcomeq/Config.h b/src/modules/welcomeq/Config.h index 7b0cfd734..2295d4ee2 100644 --- a/src/modules/welcomeq/Config.h +++ b/src/modules/welcomeq/Config.h @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2019, Adriaan de Groot + * Copyright 2019-2020, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.cpp b/src/modules/welcomeq/WelcomeQmlViewStep.cpp index 6a01f1ada..2a5b0f661 100644 --- a/src/modules/welcomeq/WelcomeQmlViewStep.cpp +++ b/src/modules/welcomeq/WelcomeQmlViewStep.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2018, Adriaan de Groot + * Copyright 2018,2020 Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.h b/src/modules/welcomeq/WelcomeQmlViewStep.h index 7d10e35ef..5486d8d31 100644 --- a/src/modules/welcomeq/WelcomeQmlViewStep.h +++ b/src/modules/welcomeq/WelcomeQmlViewStep.h @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 20195, Adriaan de Groot + * Copyright 2019-2020 Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 63b8de00ef55f3a16d6512347d362f46e5f48c44 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 9 Jan 2020 15:25:30 +0100 Subject: [PATCH 11/32] CI: allow plain clang-format (Tumbleweed) --- ci/calamaresstyle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/calamaresstyle b/ci/calamaresstyle index 8b13b6f31..65dc83de7 100755 --- a/ci/calamaresstyle +++ b/ci/calamaresstyle @@ -8,7 +8,7 @@ # AS=$( which astyle ) -for _cf in clang-format-7 clang-format-8 clang-format70 clang-format80 +for _cf in clang-format-7 clang-format-8 clang-format70 clang-format80 clang-format do # Not an error if this particular clang-format isn't found CF=$( which $_cf || true ) From 970702daa080446b23b9c6af4df53fb95e3d6aa8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 9 Jan 2020 21:36:43 +0100 Subject: [PATCH 12/32] [libcalamaresui] Tidy up includes --- src/libcalamaresui/viewpages/BlankViewStep.h | 7 +------ src/libcalamaresui/viewpages/ViewStep.h | 8 ++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/libcalamaresui/viewpages/BlankViewStep.h b/src/libcalamaresui/viewpages/BlankViewStep.h index 17d323c85..ab44205ac 100644 --- a/src/libcalamaresui/viewpages/BlankViewStep.h +++ b/src/libcalamaresui/viewpages/BlankViewStep.h @@ -19,12 +19,7 @@ #ifndef BLANKVIEWSTEP_H #define BLANKVIEWSTEP_H -#include - -#include -#include - -class QWidget; +#include "viewpages/ViewStep.h" namespace Calamares { diff --git a/src/libcalamaresui/viewpages/ViewStep.h b/src/libcalamaresui/viewpages/ViewStep.h index 8c5020f83..3ae05c49f 100644 --- a/src/libcalamaresui/viewpages/ViewStep.h +++ b/src/libcalamaresui/viewpages/ViewStep.h @@ -20,15 +20,15 @@ #ifndef VIEWSTEP_H #define VIEWSTEP_H -#include -#include -#include - #include "Job.h" #include "UiDllMacro.h" #include "modulesystem/Requirement.h" +#include +#include +#include + namespace Calamares { From 16a460adff38e7043e5cdd7347c7be97616beda5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 11:56:30 +0100 Subject: [PATCH 13/32] [libcalamaresui] Move ExecutionViewStep where it belongs - viewpages/ collects the ViewStep implementations - chase header moving and tidy some #includes --- src/libcalamaresui/CMakeLists.txt | 2 +- src/libcalamaresui/ViewManager.cpp | 7 +++---- src/libcalamaresui/modulesystem/ModuleManager.cpp | 6 +++--- src/libcalamaresui/{ => viewpages}/ExecutionViewStep.cpp | 4 ++-- src/libcalamaresui/{ => viewpages}/ExecutionViewStep.h | 0 src/modules/summary/SummaryPage.cpp | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) rename src/libcalamaresui/{ => viewpages}/ExecutionViewStep.cpp (99%) rename src/libcalamaresui/{ => viewpages}/ExecutionViewStep.h (100%) diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index a9d31c2c3..c315a6b3e 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -18,6 +18,7 @@ set( calamaresui_SOURCES utils/Paste.cpp viewpages/BlankViewStep.cpp + viewpages/ExecutionViewStep.cpp viewpages/ViewStep.cpp widgets/ClickableLabel.cpp @@ -25,7 +26,6 @@ set( calamaresui_SOURCES widgets/WaitingWidget.cpp ${CMAKE_SOURCE_DIR}/3rdparty/waitingspinnerwidget.cpp - ExecutionViewStep.cpp Branding.cpp ViewManager.cpp ) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 68d918971..4721370b9 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -21,17 +21,16 @@ #include "ViewManager.h" -#include "viewpages/BlankViewStep.h" -#include "viewpages/ViewStep.h" - #include "Branding.h" -#include "ExecutionViewStep.h" #include "JobQueue.h" #include "Settings.h" #include "utils/Logger.h" #include "utils/Paste.h" #include "utils/Retranslator.h" +#include "viewpages/BlankViewStep.h" +#include "viewpages/ViewStep.h" +#include "viewpages/ExecutionViewStep.h" #include #include diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index 33b638e64..8591a558f 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -19,7 +19,6 @@ #include "ModuleManager.h" -#include "ExecutionViewStep.h" #include "Module.h" #include "RequirementsChecker.h" #include "Settings.h" @@ -27,6 +26,7 @@ #include "utils/Logger.h" #include "utils/Yaml.h" +#include "viewpages/ExecutionViewStep.h" #include #include @@ -131,9 +131,9 @@ ModuleManager::doInit() cDebug() << "ModuleManager module search path does not exist:" << path; } } - // At this point m_availableDescriptorsByModuleName is filled with + // At this point m_availableDescriptorsByModuleName is filled with // the modules that were found in the search paths. - cDebug() << "Found" + cDebug() << "Found" << m_availableDescriptorsByModuleName.count() << "modules" << m_moduleDirectoriesByModuleName.count() << "names"; emit initDone(); diff --git a/src/libcalamaresui/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp similarity index 99% rename from src/libcalamaresui/ExecutionViewStep.cpp rename to src/libcalamaresui/viewpages/ExecutionViewStep.cpp index 501995c07..e0921910d 100644 --- a/src/libcalamaresui/ExecutionViewStep.cpp +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp @@ -18,16 +18,16 @@ * along with Calamares. If not, see . */ -#include +#include "ExecutionViewStep.h" #include "Branding.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" #include "utils/Dirs.h" #include "utils/Logger.h" diff --git a/src/libcalamaresui/ExecutionViewStep.h b/src/libcalamaresui/viewpages/ExecutionViewStep.h similarity index 100% rename from src/libcalamaresui/ExecutionViewStep.h rename to src/libcalamaresui/viewpages/ExecutionViewStep.h diff --git a/src/modules/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp index 61a9c2ec2..7114f27ee 100644 --- a/src/modules/summary/SummaryPage.cpp +++ b/src/modules/summary/SummaryPage.cpp @@ -23,13 +23,13 @@ #include "SummaryViewStep.h" #include "Branding.h" -#include "ExecutionViewStep.h" #include "Settings.h" #include "ViewManager.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Logger.h" #include "utils/Retranslator.h" +#include "viewpages/ExecutionViewStep.h" #include #include From 492483921792c0a424bc97b717a714382702f74a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 12:13:40 +0100 Subject: [PATCH 14/32] [libcalamaresui] Start QmlViewStep --- src/libcalamaresui/CMakeLists.txt | 1 + src/libcalamaresui/viewpages/QmlViewStep.cpp | 87 ++++++++++++++++++++ src/libcalamaresui/viewpages/QmlViewStep.h | 61 ++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 src/libcalamaresui/viewpages/QmlViewStep.cpp create mode 100644 src/libcalamaresui/viewpages/QmlViewStep.h diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index c315a6b3e..061a401bb 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -19,6 +19,7 @@ set( calamaresui_SOURCES viewpages/BlankViewStep.cpp viewpages/ExecutionViewStep.cpp + viewpages/QmlViewStep.cpp viewpages/ViewStep.cpp widgets/ClickableLabel.cpp diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp new file mode 100644 index 000000000..060a4660e --- /dev/null +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -0,0 +1,87 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "QmlViewStep.h" + +namespace Calamares +{ + +QmlViewStep::QmlViewStep( const QString& name, QObject* parent ) + : ViewStep( parent ) + , m_name( name ) +{ +} + +QmlViewStep::~QmlViewStep() {} + +QString +QmlViewStep::prettyName() const +{ + // TODO: query the QML itself + return tr( "QML Step %1" ).arg( m_name ); +} + + +} // namespace Calamares + +bool +Calamares::QmlViewStep::isAtBeginning() const +{ + return true; +} + +bool +Calamares::QmlViewStep::isAtEnd() const +{ + return true; +} +bool +Calamares::QmlViewStep::isBackEnabled() const +{ + return true; +} + +bool +Calamares::QmlViewStep::isNextEnabled() const +{ + return true; +} + +Calamares::JobList +Calamares::QmlViewStep::jobs() const +{ + return JobList(); +} + +void +Calamares::QmlViewStep::onActivate() +{ + // TODO: call into QML +} + +void +Calamares::QmlViewStep::onLeave() +{ + // TODO: call into QML +} + +QWidget* +Calamares::QmlViewStep::widget() +{ + return nullptr; +} diff --git a/src/libcalamaresui/viewpages/QmlViewStep.h b/src/libcalamaresui/viewpages/QmlViewStep.h new file mode 100644 index 000000000..53a5882d5 --- /dev/null +++ b/src/libcalamaresui/viewpages/QmlViewStep.h @@ -0,0 +1,61 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef QMLVIEWSTEP_H +#define QMLVIEWSTEP_H + +#include "viewpages/ViewStep.h" + +namespace Calamares +{ + +/** @brief A viewstep that uses QML for the UI + * + * This is generally a **base** class for other view steps, but + * it can be used stand-alone for viewsteps that don't really have + * any functionality. + */ +class QmlViewStep : public Calamares::ViewStep +{ + Q_OBJECT + +public: + QmlViewStep( const QString& name, QObject* parent = nullptr ); + virtual ~QmlViewStep() override; + + virtual QString prettyName() const override; + + virtual QWidget* widget() override; + + virtual bool isNextEnabled() const override; + virtual bool isBackEnabled() const override; + + virtual bool isAtBeginning() const override; + virtual bool isAtEnd() const override; + + virtual void onActivate() override; + virtual void onLeave() override; + + virtual JobList jobs() const override; + +private: + QString m_name; +}; + +} // namespace Calamares +#endif From 1cc40bda83dc1245db97a6b1d54111b7faf15b28 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 12:38:46 +0100 Subject: [PATCH 15/32] [dummyqml] Stub of a QML module --- src/modules/dummyqml/CMakeLists.txt | 11 +++++++ src/modules/dummyqml/DummyQmlViewStep.cpp | 35 ++++++++++++++++++++ src/modules/dummyqml/DummyQmlViewStep.h | 40 +++++++++++++++++++++++ src/modules/dummyqml/dummyqml.qml | 12 +++++++ src/modules/dummyqml/dummyqml.qrc | 5 +++ 5 files changed, 103 insertions(+) create mode 100644 src/modules/dummyqml/CMakeLists.txt create mode 100644 src/modules/dummyqml/DummyQmlViewStep.cpp create mode 100644 src/modules/dummyqml/DummyQmlViewStep.h create mode 100644 src/modules/dummyqml/dummyqml.qml create mode 100644 src/modules/dummyqml/dummyqml.qrc diff --git a/src/modules/dummyqml/CMakeLists.txt b/src/modules/dummyqml/CMakeLists.txt new file mode 100644 index 000000000..9a7532e9e --- /dev/null +++ b/src/modules/dummyqml/CMakeLists.txt @@ -0,0 +1,11 @@ +calamares_add_plugin( dummyqml + TYPE viewmodule + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + DummyQmlViewStep.cpp + RESOURCES + dummyqml.qrc + LINK_PRIVATE_LIBRARIES + calamaresui + SHARED_LIB +) diff --git a/src/modules/dummyqml/DummyQmlViewStep.cpp b/src/modules/dummyqml/DummyQmlViewStep.cpp new file mode 100644 index 000000000..985d2985a --- /dev/null +++ b/src/modules/dummyqml/DummyQmlViewStep.cpp @@ -0,0 +1,35 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "DummyQmlViewStep.h" + +DummyQmlViewStep::DummyQmlViewStep( QObject* parent ) + : Calamares::QmlViewStep( "dummyqml", parent ) +{ +} + +DummyQmlViewStep::~DummyQmlViewStep() {} + +QString +DummyQmlViewStep::prettyName() const +{ + return tr( "Example QML page" ); +} + + +CALAMARES_PLUGIN_FACTORY_DEFINITION( DummyQmlViewStepFactory, registerPlugin< DummyQmlViewStep >(); ) diff --git a/src/modules/dummyqml/DummyQmlViewStep.h b/src/modules/dummyqml/DummyQmlViewStep.h new file mode 100644 index 000000000..ffc358fe7 --- /dev/null +++ b/src/modules/dummyqml/DummyQmlViewStep.h @@ -0,0 +1,40 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef DUMMYQMLVIEWSTEP_H +#define DUMMYQMLVIEWSTEP_H + +#include "utils/PluginFactory.h" +#include "viewpages/QmlViewStep.h" + +class DummyQmlViewStep : public Calamares::QmlViewStep +{ + Q_OBJECT + +public: + DummyQmlViewStep( QObject* parent = nullptr ); + virtual ~DummyQmlViewStep() override; + + virtual QString prettyName() const override; + +private: +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( DummyQmlViewStepFactory ) + +#endif diff --git a/src/modules/dummyqml/dummyqml.qml b/src/modules/dummyqml/dummyqml.qml new file mode 100644 index 000000000..6cab24bec --- /dev/null +++ b/src/modules/dummyqml/dummyqml.qml @@ -0,0 +1,12 @@ +import QtQuick 2.3 + +Rectangle { + width: 200 + height: 100 + color: "red" + + Text { + anchors.centerIn: parent + text: "Hello, World!" + } +} diff --git a/src/modules/dummyqml/dummyqml.qrc b/src/modules/dummyqml/dummyqml.qrc new file mode 100644 index 000000000..85b1da5ca --- /dev/null +++ b/src/modules/dummyqml/dummyqml.qrc @@ -0,0 +1,5 @@ + + + dummyqml.qml + + From 60c1d40b2077df941a6d197b2d1ab0a711bc6316 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 12:56:46 +0100 Subject: [PATCH 16/32] [libcalamaresui] Log which ViewStep is broken - a ViewStep with no widget will crash the application; print out its name before doing so. --- src/libcalamaresui/ViewManager.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 4721370b9..7492f1f8b 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -158,13 +158,6 @@ void ViewManager::insertViewStep( int before, ViewStep* step ) { m_steps.insert( before, step ); - QLayout* layout = step->widget()->layout(); - if ( layout ) - { - layout->setContentsMargins( 0, 0, 0, 0 ); - } - m_stack->insertWidget( before, step->widget() ); - connect( step, &ViewStep::enlarge, this, &ViewManager::enlarge ); connect( step, &ViewStep::nextStatusChanged, this, [this]( bool status ) { ViewStep* vs = qobject_cast< ViewStep* >( sender() ); @@ -177,6 +170,17 @@ ViewManager::insertViewStep( int before, ViewStep* step ) } } ); + if ( !step->widget() ) + { + cError() << "ViewStep" << step->moduleInstanceKey() << "has no widget."; + } + + QLayout* layout = step->widget()->layout(); + if ( layout ) + { + layout->setContentsMargins( 0, 0, 0, 0 ); + } + m_stack->insertWidget( before, step->widget() ); m_stack->setCurrentIndex( 0 ); step->widget()->setFocus(); } From 44b250809fbed389dadefdc88b2c32ff3de5249a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 13:10:55 +0100 Subject: [PATCH 17/32] [libcalamaresui] Add spinner to QmlViewStep - view step now has a widget, doesn't load QML yet --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 11 ++++++++++- src/libcalamaresui/viewpages/QmlViewStep.h | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index 060a4660e..11637d04b 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -18,13 +18,22 @@ #include "QmlViewStep.h" +#include "widgets/WaitingWidget.h" + +#include +#include + namespace Calamares { QmlViewStep::QmlViewStep( const QString& name, QObject* parent ) : ViewStep( parent ) , m_name( name ) + , m_widget( new QWidget ) + , m_spinner( new WaitingWidget( tr( "Loading ..." ) ) ) { + QVBoxLayout* layout = new QVBoxLayout( m_widget ); + layout->addWidget( m_spinner ); } QmlViewStep::~QmlViewStep() {} @@ -83,5 +92,5 @@ Calamares::QmlViewStep::onLeave() QWidget* Calamares::QmlViewStep::widget() { - return nullptr; + return m_widget; } diff --git a/src/libcalamaresui/viewpages/QmlViewStep.h b/src/libcalamaresui/viewpages/QmlViewStep.h index 53a5882d5..d1b28af35 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.h +++ b/src/libcalamaresui/viewpages/QmlViewStep.h @@ -21,6 +21,11 @@ #include "viewpages/ViewStep.h" +class QQmlComponent; +class QQuickItem; +class QQuickWidget; +class WaitingWidget; + namespace Calamares { @@ -55,6 +60,12 @@ public: private: QString m_name; + + QWidget* m_widget = nullptr; + WaitingWidget* m_spinner = nullptr; + QQuickWidget* m_qmlShow = nullptr; + QQmlComponent* m_qmlComponent = nullptr; + QQuickItem* m_qmlObject = nullptr; }; } // namespace Calamares From c03c6fc8ed9e13bff8532dee983deebf9bbd06f6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 13:39:03 +0100 Subject: [PATCH 18/32] [libcalamaresui] Qml loading - this is mostly copied from ExecutionViewStep (only the V2 QML loading), which does the same kind of thing. - loading from QRC does not work yet --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 71 ++++++++++++++++++++ src/libcalamaresui/viewpages/QmlViewStep.h | 9 ++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index 11637d04b..3cfcc7371 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -18,8 +18,14 @@ #include "QmlViewStep.h" +#include "utils/Dirs.h" +#include "utils/Logger.h" #include "widgets/WaitingWidget.h" +#include +#include +#include +#include #include #include @@ -31,9 +37,24 @@ QmlViewStep::QmlViewStep( const QString& name, QObject* parent ) , m_name( name ) , m_widget( new QWidget ) , m_spinner( new WaitingWidget( tr( "Loading ..." ) ) ) + , m_qmlWidget( new QQuickWidget ) { QVBoxLayout* layout = new QVBoxLayout( m_widget ); layout->addWidget( m_spinner ); + + m_qmlWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + m_qmlWidget->setResizeMode( QQuickWidget::SizeRootObjectToView ); + m_qmlWidget->engine()->addImportPath( CalamaresUtils::qmlModulesDir().absolutePath() ); + + // TODO: search for suitable file + QString qrcName = QStringLiteral( ":/%1.qml" ).arg( m_name ); + m_qmlFileName = qrcName; + + cDebug() << "QmlViewStep loading" << m_qmlFileName; + m_qmlComponent = new QQmlComponent( + m_qmlWidget->engine(), QUrl( m_qmlFileName ), QQmlComponent::CompilationMode::Asynchronous ); + connect( m_qmlComponent, &QQmlComponent::statusChanged, this, &QmlViewStep::loadComplete ); + cDebug() << Logger::SubEntry << "Status" << m_qmlComponent->status(); } QmlViewStep::~QmlViewStep() {} @@ -94,3 +115,53 @@ Calamares::QmlViewStep::widget() { return m_widget; } + +void +Calamares::QmlViewStep::loadComplete() +{ + cDebug() << "QML component" << m_qmlFileName << m_qmlComponent->status(); + if ( m_qmlComponent->isReady() && !m_qmlObject ) + { + cDebug() << "QML component complete" << m_qmlFileName; + // Don't do this again + disconnect( m_qmlComponent, &QQmlComponent::statusChanged, this, &QmlViewStep::loadComplete ); + + QObject* o = m_qmlComponent->create(); + m_qmlObject = qobject_cast< QQuickItem* >( o ); + if ( !m_qmlObject ) + { + cError() << Logger::SubEntry << "Could not create QML from" << m_qmlFileName; + delete o; + } + else + { + // setContent() is public API, but not documented publicly. + // It is marked \internal in the Qt sources, but does exactly + // what is needed: sets up visual parent by replacing the root + // item, and handling resizes. + m_qmlWidget->setContent( QUrl( m_qmlFileName ), m_qmlComponent, m_qmlObject ); + showQml(); + } + } +} + +void +Calamares::QmlViewStep::showQml() +{ + if ( !m_qmlWidget || !m_qmlObject ) + { + cDebug() << "showQml() called but no QML object"; + return; + } + if ( m_spinner ) + { + m_widget->layout()->removeWidget( m_spinner ); + m_widget->layout()->addWidget( m_qmlWidget ); + delete m_spinner; + m_spinner = nullptr; + } + else + { + cDebug() << "showQml() called twice"; + } +} diff --git a/src/libcalamaresui/viewpages/QmlViewStep.h b/src/libcalamaresui/viewpages/QmlViewStep.h index d1b28af35..0503f5cde 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.h +++ b/src/libcalamaresui/viewpages/QmlViewStep.h @@ -58,12 +58,19 @@ public: virtual JobList jobs() const override; +private Q_SLOTS: + void loadComplete(); + private: + /// @brief Swap out the spinner for the QQuickWidget + void showQml(); + QString m_name; + QString m_qmlFileName; QWidget* m_widget = nullptr; WaitingWidget* m_spinner = nullptr; - QQuickWidget* m_qmlShow = nullptr; + QQuickWidget* m_qmlWidget = nullptr; QQmlComponent* m_qmlComponent = nullptr; QQuickItem* m_qmlObject = nullptr; }; From e6713d456cfe71dbf27f81010903080a30f6bfb2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 13:44:26 +0100 Subject: [PATCH 19/32] [libcalamaresui] Need explicit qrc: scheme --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index 3cfcc7371..4cee7c281 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -47,7 +47,7 @@ QmlViewStep::QmlViewStep( const QString& name, QObject* parent ) m_qmlWidget->engine()->addImportPath( CalamaresUtils::qmlModulesDir().absolutePath() ); // TODO: search for suitable file - QString qrcName = QStringLiteral( ":/%1.qml" ).arg( m_name ); + QString qrcName = QStringLiteral( "qrc:/%1.qml" ).arg( m_name ); m_qmlFileName = qrcName; cDebug() << "QmlViewStep loading" << m_qmlFileName; From e7e66497d2e583d8fb082d726af70a225ee12a9e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 17:19:15 +0100 Subject: [PATCH 20/32] [libcalamaresui] Introduce search method for QML UI modules - add a sample config and documentation in dummyqml/ --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 25 ++++++++++++++++++++ src/libcalamaresui/viewpages/QmlViewStep.h | 21 ++++++++++++++++ src/modules/dummyqml/dummyqml.conf | 19 +++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 src/modules/dummyqml/dummyqml.conf diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index 4cee7c281..cf19fb2b4 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -20,6 +20,8 @@ #include "utils/Dirs.h" #include "utils/Logger.h" +#include "utils/NamedEnum.h" +#include "utils/Variant.h" #include "widgets/WaitingWidget.h" #include @@ -29,6 +31,19 @@ #include #include +static const NamedEnumTable< Calamares::QmlViewStep::QmlSearch >& +searchNames() +{ + using QmlSearch = Calamares::QmlViewStep::QmlSearch; + static NamedEnumTable< Calamares::QmlViewStep::QmlSearch > names{ + { QStringLiteral( "both" ), QmlSearch::Both }, + { QStringLiteral( "qrc" ), QmlSearch::QrcOnly }, + { QStringLiteral( "branding" ), QmlSearch::BrandingOnly } + }; + + return names; +} + namespace Calamares { @@ -165,3 +180,13 @@ Calamares::QmlViewStep::showQml() cDebug() << "showQml() called twice"; } } + +void Calamares::QmlViewStep::setConfigurationMap(const QVariantMap& configurationMap) +{ + bool ok = false; + m_searchMethod = searchNames().find( CalamaresUtils::getString( configurationMap, "search" ), ok ); + if (!ok) + { + cDebug() << "Bad QML search mode."; + } +} diff --git a/src/libcalamaresui/viewpages/QmlViewStep.h b/src/libcalamaresui/viewpages/QmlViewStep.h index 0503f5cde..38405a6a6 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.h +++ b/src/libcalamaresui/viewpages/QmlViewStep.h @@ -40,6 +40,20 @@ class QmlViewStep : public Calamares::ViewStep Q_OBJECT public: + enum class QmlSearch + { + QrcOnly, + BrandingOnly, + Both + }; + + /** @brief Creates a QML view step + * + * The name should not have an extension or schema or anything; + * just the plain name, which will be searched as "/.qml" in + * QRC files, or ".qml" in suitable branding paths. + * The search behavior depends on a QmlSearch value. + */ QmlViewStep( const QString& name, QObject* parent = nullptr ); virtual ~QmlViewStep() override; @@ -56,8 +70,12 @@ public: virtual void onActivate() override; virtual void onLeave() override; + /// @brief QML widgets don't produce jobs by default virtual JobList jobs() const override; + /// @brief Configure search paths; subclasses should call this as well + virtual void setConfigurationMap( const QVariantMap& configurationMap ) override; + private Q_SLOTS: void loadComplete(); @@ -65,6 +83,9 @@ private: /// @brief Swap out the spinner for the QQuickWidget void showQml(); + /// @brief Controls where m_name is searched + QmlSearch m_searchMethod; + QString m_name; QString m_qmlFileName; diff --git a/src/modules/dummyqml/dummyqml.conf b/src/modules/dummyqml/dummyqml.conf new file mode 100644 index 000000000..a861b68bd --- /dev/null +++ b/src/modules/dummyqml/dummyqml.conf @@ -0,0 +1,19 @@ +# The dummy QML module just displays a QML page. It doesn't +# have much in the way of own configuration, only where +# the QML file is searched. +# +# QML modules can search for the QML inside the Qt resources +# (QRC) which are compiled into the module, or in the branding +# setup for Calamares, (or both of them, with branding taking +# precedence). This allows the module to ship a default UI and +# branding to optionally introduce a replacement file. +# +# Generally, leave the search method set to "both" because if +# you don't want to brand the UI, just don't ship a branding +# QML file for it. +# +# To support instanced QML modules, searches in the branding +# directory look for the full module@instanceid name as well. +--- +search: both + From fed298b17963594afd601193c635e6e875d5bb71 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 17:41:20 +0100 Subject: [PATCH 21/32] [libcalamaresui] Defer QML loading - need a configuration before we can start loading (to support the variable search paths) - refactor showing a failure in the spinner widget. On failure, the spinner will never go away, so a message for the user is good. - stop clang-format from messing up the table of names. --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 60 ++++++++++++++------ src/libcalamaresui/viewpages/QmlViewStep.h | 2 + 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index cf19fb2b4..779a624c1 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -34,12 +34,16 @@ static const NamedEnumTable< Calamares::QmlViewStep::QmlSearch >& searchNames() { - using QmlSearch = Calamares::QmlViewStep::QmlSearch; - static NamedEnumTable< Calamares::QmlViewStep::QmlSearch > names{ - { QStringLiteral( "both" ), QmlSearch::Both }, - { QStringLiteral( "qrc" ), QmlSearch::QrcOnly }, - { QStringLiteral( "branding" ), QmlSearch::BrandingOnly } + using Search = Calamares::QmlViewStep::QmlSearch; + // *INDENT-OFF* + // clang-format off + static NamedEnumTable< Search > names { + { QStringLiteral( "both" ), Search::Both }, + { QStringLiteral( "qrc" ), Search::QrcOnly }, + { QStringLiteral( "branding" ), Search::BrandingOnly } }; + // *INDENT-ON* + // clang-format on return names; } @@ -61,15 +65,7 @@ QmlViewStep::QmlViewStep( const QString& name, QObject* parent ) m_qmlWidget->setResizeMode( QQuickWidget::SizeRootObjectToView ); m_qmlWidget->engine()->addImportPath( CalamaresUtils::qmlModulesDir().absolutePath() ); - // TODO: search for suitable file - QString qrcName = QStringLiteral( "qrc:/%1.qml" ).arg( m_name ); - m_qmlFileName = qrcName; - - cDebug() << "QmlViewStep loading" << m_qmlFileName; - m_qmlComponent = new QQmlComponent( - m_qmlWidget->engine(), QUrl( m_qmlFileName ), QQmlComponent::CompilationMode::Asynchronous ); - connect( m_qmlComponent, &QQmlComponent::statusChanged, this, &QmlViewStep::loadComplete ); - cDebug() << Logger::SubEntry << "Status" << m_qmlComponent->status(); + // QML Loading starts when the configuration for the module is set. } QmlViewStep::~QmlViewStep() {} @@ -135,6 +131,10 @@ void Calamares::QmlViewStep::loadComplete() { cDebug() << "QML component" << m_qmlFileName << m_qmlComponent->status(); + if ( m_qmlComponent->status() == QQmlComponent::Error ) + { + showFailedQml(); + } if ( m_qmlComponent->isReady() && !m_qmlObject ) { cDebug() << "QML component complete" << m_qmlFileName; @@ -181,12 +181,40 @@ Calamares::QmlViewStep::showQml() } } -void Calamares::QmlViewStep::setConfigurationMap(const QVariantMap& configurationMap) +void +Calamares::QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { bool ok = false; m_searchMethod = searchNames().find( CalamaresUtils::getString( configurationMap, "search" ), ok ); - if (!ok) + if ( !ok ) { cDebug() << "Bad QML search mode."; } + + if ( !m_qmlComponent ) + { + // TODO: search for suitable file + QString qrcName = QStringLiteral( "qrc:/X%1.qml" ).arg( m_name ); + m_qmlFileName = qrcName; + + cDebug() << "QmlViewStep" << moduleInstanceKey() << "loading" << m_qmlFileName; + m_qmlComponent = new QQmlComponent( + m_qmlWidget->engine(), QUrl( m_qmlFileName ), QQmlComponent::CompilationMode::Asynchronous ); + connect( m_qmlComponent, &QQmlComponent::statusChanged, this, &QmlViewStep::loadComplete ); + if ( m_qmlComponent->status() == QQmlComponent::Error ) + { + showFailedQml(); + } + } + else + { + cWarning() << "QML configuration set after component has loaded."; + } +} + +void +Calamares::QmlViewStep::showFailedQml() +{ + cWarning() << "QmlViewStep" << moduleInstanceKey() << "loading failed."; + m_spinner->setText( prettyName() + tr( "Loading failed." ) ); } diff --git a/src/libcalamaresui/viewpages/QmlViewStep.h b/src/libcalamaresui/viewpages/QmlViewStep.h index 38405a6a6..46ba29a53 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.h +++ b/src/libcalamaresui/viewpages/QmlViewStep.h @@ -82,6 +82,8 @@ private Q_SLOTS: private: /// @brief Swap out the spinner for the QQuickWidget void showQml(); + /// @brief Show error message in spinner. + void showFailedQml(); /// @brief Controls where m_name is searched QmlSearch m_searchMethod; From ce6d54ad9581bbb07b6818e0fb409fc57e6404fd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 17:45:09 +0100 Subject: [PATCH 22/32] [libcalamaresui] Improve failure message, unbreak loading - example loading had an X inserted in filename (to test failure) - add a space between name and failure --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index 779a624c1..569eb6cd9 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -194,7 +194,7 @@ Calamares::QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap if ( !m_qmlComponent ) { // TODO: search for suitable file - QString qrcName = QStringLiteral( "qrc:/X%1.qml" ).arg( m_name ); + QString qrcName = QStringLiteral( "qrc:/%1.qml" ).arg( m_name ); m_qmlFileName = qrcName; cDebug() << "QmlViewStep" << moduleInstanceKey() << "loading" << m_qmlFileName; @@ -216,5 +216,5 @@ void Calamares::QmlViewStep::showFailedQml() { cWarning() << "QmlViewStep" << moduleInstanceKey() << "loading failed."; - m_spinner->setText( prettyName() + tr( "Loading failed." ) ); + m_spinner->setText( prettyName() + ' ' + tr( "Loading failed." ) ); } From 04615b251c652e765503f11d0b9c9f813f9588ef Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jan 2020 17:47:02 +0100 Subject: [PATCH 23/32] [dummyqml] Make prettyName() return a sentence with . --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 2 +- src/modules/dummyqml/DummyQmlViewStep.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index 569eb6cd9..e26b02430 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -74,7 +74,7 @@ QString QmlViewStep::prettyName() const { // TODO: query the QML itself - return tr( "QML Step %1" ).arg( m_name ); + return tr( "QML Step %1." ).arg( m_name ); } diff --git a/src/modules/dummyqml/DummyQmlViewStep.cpp b/src/modules/dummyqml/DummyQmlViewStep.cpp index 985d2985a..32c1c60d0 100644 --- a/src/modules/dummyqml/DummyQmlViewStep.cpp +++ b/src/modules/dummyqml/DummyQmlViewStep.cpp @@ -28,7 +28,7 @@ DummyQmlViewStep::~DummyQmlViewStep() {} QString DummyQmlViewStep::prettyName() const { - return tr( "Example QML page" ); + return tr( "Example QML page." ); } From 7f8a31007a8e07dcd0e430b9f7443777a9b8bc9a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 13 Jan 2020 22:04:27 +0100 Subject: [PATCH 24/32] [dummyqml] Search for files - start implementation of searching-for-qml - add a *filename* configuration item, so that the filename can be set per-instance (via the config file) --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 45 ++++++++++++++++++-- src/modules/dummyqml/dummyqml.conf | 3 ++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index e26b02430..8fcc75a9b 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -181,6 +181,40 @@ Calamares::QmlViewStep::showQml() } } + +/** @brief Find a suitable QML file, given the search method and name hints + * + * Returns QString() if nothing is found (which would mean the module + * is badly configured). + */ +QString +searchQmlFile( Calamares::QmlViewStep::QmlSearch method, const QString& configuredName, const QString& moduleName ) +{ + cDebug() << "Looking for QML for" << moduleName; + for ( const QString& candidate : + QStringList { configuredName.isEmpty() ? QString() : QStringLiteral( ":/%1.qml" ).arg( configuredName ), + moduleName.isEmpty() ? QString() : QStringLiteral( ":/%1.qml" ).arg( moduleName ) } ) + { + if ( candidate.isEmpty() ) + { + continue; + } + cDebug() << Logger::SubEntry << "Looking at QML file" << candidate; + if ( QFile::exists( candidate ) ) + { + if ( candidate.startsWith( ':' ) ) + { + // Inconsistency: QFile only sees the file with :, + // but QML needs an explicit scheme (of qrc:) + return QStringLiteral( "qrc" ) + candidate; + } + return candidate; + } + } + cDebug() << Logger::SubEntry << "None found."; + return QString(); +} + void Calamares::QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { @@ -191,11 +225,14 @@ Calamares::QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap cDebug() << "Bad QML search mode."; } - if ( !m_qmlComponent ) + QString qmlFile = CalamaresUtils::getString( configurationMap, "filename" ); + if ( qmlFile.isEmpty() ) { - // TODO: search for suitable file - QString qrcName = QStringLiteral( "qrc:/%1.qml" ).arg( m_name ); - m_qmlFileName = qrcName; + cWarning() << "No QML file for module" << m_name; + } + else if ( !m_qmlComponent ) + { + m_qmlFileName = searchQmlFile( m_searchMethod, qmlFile, m_name ); cDebug() << "QmlViewStep" << moduleInstanceKey() << "loading" << m_qmlFileName; m_qmlComponent = new QQmlComponent( diff --git a/src/modules/dummyqml/dummyqml.conf b/src/modules/dummyqml/dummyqml.conf index a861b68bd..e62d35383 100644 --- a/src/modules/dummyqml/dummyqml.conf +++ b/src/modules/dummyqml/dummyqml.conf @@ -15,5 +15,8 @@ # To support instanced QML modules, searches in the branding # directory look for the full module@instanceid name as well. --- +# Search mode. Valid values are "both", "qrc" and "branding" search: both +# Name of the QML file. If not set, uses the name of the module. +filename: dummyqml From 750465153f4d6a329b97b2ed9786423b618411d9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 13 Jan 2020 22:28:21 +0100 Subject: [PATCH 25/32] [dummyqml] Improve QML searching - if the filename is an absolute path, use that - support searching in branding directory --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 25 +++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index 8fcc75a9b..44edba97d 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -18,6 +18,8 @@ #include "QmlViewStep.h" +#include "Branding.h" + #include "utils/Dirs.h" #include "utils/Logger.h" #include "utils/NamedEnum.h" @@ -190,10 +192,27 @@ Calamares::QmlViewStep::showQml() QString searchQmlFile( Calamares::QmlViewStep::QmlSearch method, const QString& configuredName, const QString& moduleName ) { + using QmlSearch = Calamares::QmlViewStep::QmlSearch; + cDebug() << "Looking for QML for" << moduleName; - for ( const QString& candidate : - QStringList { configuredName.isEmpty() ? QString() : QStringLiteral( ":/%1.qml" ).arg( configuredName ), - moduleName.isEmpty() ? QString() : QStringLiteral( ":/%1.qml" ).arg( moduleName ) } ) + QStringList candidates; + if ( configuredName.startsWith( '/' ) ) + { + candidates << configuredName; + } + if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::BrandingOnly ) ) + { + QString brandDir = Calamares::Branding::instance()->componentDirectory(); + candidates << ( configuredName.isEmpty() ? QString() + : QStringLiteral( "%1/%2.qml" ).arg( brandDir, configuredName ) ) + << ( moduleName.isEmpty() ? QString() : QStringLiteral( "%1/%2.qml" ).arg( brandDir, moduleName ) ); + } + if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::QrcOnly ) ) + { + candidates << ( configuredName.isEmpty() ? QString() : QStringLiteral( ":/%1.qml" ).arg( configuredName ) ) + << ( moduleName.isEmpty() ? QString() : QStringLiteral( ":/%1.qml" ).arg( moduleName ) ); + } + for ( const QString& candidate : candidates ) { if ( candidate.isEmpty() ) { From f2e68ddcf4dc62c38d0ffcdbbb504b7dae13cd11 Mon Sep 17 00:00:00 2001 From: demmm Date: Tue, 14 Jan 2020 12:30:22 +0100 Subject: [PATCH 26/32] adding configure option dummyqml sidebar entry can be configured and translated adding a more elaborate qml example keeping this in dummyqml for now, another commit will follow with continuation of dummyqml in a more aptly named module --- src/modules/dummyqml/DummyQmlViewStep.cpp | 20 +++++- src/modules/dummyqml/DummyQmlViewStep.h | 12 +++- src/modules/dummyqml/dummyqml.conf | 7 +++ src/modules/dummyqml/dummyqml.qml | 77 ++++++++++++++++++++--- 4 files changed, 105 insertions(+), 11 deletions(-) diff --git a/src/modules/dummyqml/DummyQmlViewStep.cpp b/src/modules/dummyqml/DummyQmlViewStep.cpp index 32c1c60d0..6bf0b4a60 100644 --- a/src/modules/dummyqml/DummyQmlViewStep.cpp +++ b/src/modules/dummyqml/DummyQmlViewStep.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2020, Adriaan de Groot + * Copyright 2020, Anke Boersma * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +19,8 @@ #include "DummyQmlViewStep.h" +#include + DummyQmlViewStep::DummyQmlViewStep( QObject* parent ) : Calamares::QmlViewStep( "dummyqml", parent ) { @@ -28,8 +31,23 @@ DummyQmlViewStep::~DummyQmlViewStep() {} QString DummyQmlViewStep::prettyName() const { - return tr( "Example QML page." ); + return m_notesName ? m_notesName->get() : tr( "Notes" ); } +void +DummyQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +{ + Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation + + bool qmlLabel_ok = false; + auto qmlLabel = CalamaresUtils::getSubMap( configurationMap, "qmlLabel", qmlLabel_ok ); + if ( qmlLabel_ok ) + { + if ( qmlLabel.contains( "notes" ) ) + { + m_notesName = new CalamaresUtils::Locale::TranslatedString( qmlLabel, "notes" ); + } + } +} CALAMARES_PLUGIN_FACTORY_DEFINITION( DummyQmlViewStepFactory, registerPlugin< DummyQmlViewStep >(); ) diff --git a/src/modules/dummyqml/DummyQmlViewStep.h b/src/modules/dummyqml/DummyQmlViewStep.h index ffc358fe7..6eb0d768e 100644 --- a/src/modules/dummyqml/DummyQmlViewStep.h +++ b/src/modules/dummyqml/DummyQmlViewStep.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2020, Adriaan de Groot + * Copyright 2020, Anke Boersma * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +20,14 @@ #ifndef DUMMYQMLVIEWSTEP_H #define DUMMYQMLVIEWSTEP_H +#include +#include "locale/TranslatableConfiguration.h" +#include "utils/CalamaresUtilsSystem.h" +#include "utils/Variant.h" #include "utils/PluginFactory.h" #include "viewpages/QmlViewStep.h" -class DummyQmlViewStep : public Calamares::QmlViewStep +class PLUGINDLLEXPORT DummyQmlViewStep : public Calamares::QmlViewStep { Q_OBJECT @@ -30,9 +35,12 @@ public: DummyQmlViewStep( QObject* parent = nullptr ); virtual ~DummyQmlViewStep() override; - virtual QString prettyName() const override; + QString prettyName() const override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; private: + CalamaresUtils::Locale::TranslatedString* m_notesName; // As it appears in the sidebar }; CALAMARES_PLUGIN_FACTORY_DECLARATION( DummyQmlViewStepFactory ) diff --git a/src/modules/dummyqml/dummyqml.conf b/src/modules/dummyqml/dummyqml.conf index e62d35383..c3581911f 100644 --- a/src/modules/dummyqml/dummyqml.conf +++ b/src/modules/dummyqml/dummyqml.conf @@ -20,3 +20,10 @@ search: both # Name of the QML file. If not set, uses the name of the module. filename: dummyqml + +# Name of the QML file. If not set, uses the name of the module. +filename: notes + +qmlLabel: + notes: "Release Notes" + notes[nl]: "Opmerkingen" diff --git a/src/modules/dummyqml/dummyqml.qml b/src/modules/dummyqml/dummyqml.qml index 6cab24bec..3cbfa65fc 100644 --- a/src/modules/dummyqml/dummyqml.qml +++ b/src/modules/dummyqml/dummyqml.qml @@ -1,12 +1,73 @@ -import QtQuick 2.3 +/* === This file is part of Calamares - === + * + * Copyright 2020, Anke Boersma + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ -Rectangle { - width: 200 - height: 100 - color: "red" +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Window 2.2 +import QtQuick.Layouts 1.3 +import QtQuick.Controls.Material 2.1 - Text { - anchors.centerIn: parent - text: "Hello, World!" +Item { + width: 740 + height: 420 + + Flickable { + id: flick + anchors.fill: parent + contentHeight: 800 + + ScrollBar.vertical: ScrollBar { + width: 10 + policy: ScrollBar.AlwaysOn + } + + TextArea { + id: intro + x: 1 + y: 0 + width: 720 + font.pointSize: 14 + textFormat: Text.RichText + antialiasing: true + activeFocusOnPress: false + wrapMode: Text.WordWrap + + text: qsTr("

Generic GNU/Linux 2017.8 LTS Soapy Sousaphone

+

This an example QML file, showing options in RichText with Flickable content.

+ +

QML with RichText can use HTML tags, Flickable content is useful for touchscreens.

+ +

This is bold text

+

This is italic text

+

This is underlined text

+

This is strikethrough

+ +

Code example: + ls -l /home

+ +

Lists:

+
    +
  • Intel CPU systems
  • +
  • AMD CPU systems
  • +
+ +

The vertical scrollbar is adjustable, current width set to 10.

") + + } } } From 32eee827440da46ef8b644a607b19a6760bbd8c8 Mon Sep 17 00:00:00 2001 From: demmm Date: Tue, 14 Jan 2020 13:08:54 +0100 Subject: [PATCH 27/32] clean-up dummyqml.conf --- src/modules/dummyqml/dummyqml.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/modules/dummyqml/dummyqml.conf b/src/modules/dummyqml/dummyqml.conf index c3581911f..48bbbc150 100644 --- a/src/modules/dummyqml/dummyqml.conf +++ b/src/modules/dummyqml/dummyqml.conf @@ -21,9 +21,6 @@ search: both # Name of the QML file. If not set, uses the name of the module. filename: dummyqml -# Name of the QML file. If not set, uses the name of the module. -filename: notes - qmlLabel: notes: "Release Notes" notes[nl]: "Opmerkingen" From 9f55cf4cf4d313cc87134e1561e78c3be14c109e Mon Sep 17 00:00:00 2001 From: demmm Date: Fri, 24 Jan 2020 15:12:10 +0100 Subject: [PATCH 28/32] part of the changes requested others fail to build, or no idea how to fix --- src/modules/dummyqml/DummyQmlViewStep.cpp | 3 +++ src/modules/dummyqml/DummyQmlViewStep.h | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/dummyqml/DummyQmlViewStep.cpp b/src/modules/dummyqml/DummyQmlViewStep.cpp index 6bf0b4a60..39c95e993 100644 --- a/src/modules/dummyqml/DummyQmlViewStep.cpp +++ b/src/modules/dummyqml/DummyQmlViewStep.cpp @@ -19,6 +19,9 @@ #include "DummyQmlViewStep.h" +#include "utils/PluginFactory.h" +#include "viewpages/QmlViewStep.h" + #include DummyQmlViewStep::DummyQmlViewStep( QObject* parent ) diff --git a/src/modules/dummyqml/DummyQmlViewStep.h b/src/modules/dummyqml/DummyQmlViewStep.h index 6eb0d768e..adcd294fa 100644 --- a/src/modules/dummyqml/DummyQmlViewStep.h +++ b/src/modules/dummyqml/DummyQmlViewStep.h @@ -20,12 +20,10 @@ #ifndef DUMMYQMLVIEWSTEP_H #define DUMMYQMLVIEWSTEP_H -#include +#include "PluginDllMacro.h" #include "locale/TranslatableConfiguration.h" #include "utils/CalamaresUtilsSystem.h" #include "utils/Variant.h" -#include "utils/PluginFactory.h" -#include "viewpages/QmlViewStep.h" class PLUGINDLLEXPORT DummyQmlViewStep : public Calamares::QmlViewStep { From 538d8d5497f8f77ed8644244717b44c2d02b8e0a Mon Sep 17 00:00:00 2001 From: demmm Date: Fri, 24 Jan 2020 15:14:51 +0100 Subject: [PATCH 29/32] address qmlLabel changes too --- src/modules/dummyqml/DummyQmlViewStep.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/modules/dummyqml/DummyQmlViewStep.cpp b/src/modules/dummyqml/DummyQmlViewStep.cpp index 39c95e993..030779f7f 100644 --- a/src/modules/dummyqml/DummyQmlViewStep.cpp +++ b/src/modules/dummyqml/DummyQmlViewStep.cpp @@ -19,9 +19,6 @@ #include "DummyQmlViewStep.h" -#include "utils/PluginFactory.h" -#include "viewpages/QmlViewStep.h" - #include DummyQmlViewStep::DummyQmlViewStep( QObject* parent ) @@ -44,13 +41,12 @@ DummyQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) bool qmlLabel_ok = false; auto qmlLabel = CalamaresUtils::getSubMap( configurationMap, "qmlLabel", qmlLabel_ok ); - if ( qmlLabel_ok ) + + if ( qmlLabel.contains( "notes" ) ) { - if ( qmlLabel.contains( "notes" ) ) - { - m_notesName = new CalamaresUtils::Locale::TranslatedString( qmlLabel, "notes" ); - } + m_notesName = new CalamaresUtils::Locale::TranslatedString( qmlLabel, "notes" ); } + } CALAMARES_PLUGIN_FACTORY_DEFINITION( DummyQmlViewStepFactory, registerPlugin< DummyQmlViewStep >(); ) From b20a957c6ef9a22d4e9e8e158a4c1678d87a26b3 Mon Sep 17 00:00:00 2001 From: demmm Date: Fri, 24 Jan 2020 15:52:59 +0100 Subject: [PATCH 30/32] restore includes in header file to amke it build --- src/modules/dummyqml/DummyQmlViewStep.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/dummyqml/DummyQmlViewStep.h b/src/modules/dummyqml/DummyQmlViewStep.h index adcd294fa..cf49436b0 100644 --- a/src/modules/dummyqml/DummyQmlViewStep.h +++ b/src/modules/dummyqml/DummyQmlViewStep.h @@ -24,6 +24,8 @@ #include "locale/TranslatableConfiguration.h" #include "utils/CalamaresUtilsSystem.h" #include "utils/Variant.h" +#include "utils/PluginFactory.h" +#include "viewpages/QmlViewStep.h" class PLUGINDLLEXPORT DummyQmlViewStep : public Calamares::QmlViewStep { From abdeb07bd332c454a8937685552a3de34183f23c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 17:14:45 +0100 Subject: [PATCH 31/32] [dummyqml] Minor polishing in Qml module - document the default filename better - mark TODO actually loading the instance-id file --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 5 +++-- src/modules/dummyqml/dummyqml.conf | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index 44edba97d..b009d1626 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -247,9 +247,10 @@ Calamares::QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap QString qmlFile = CalamaresUtils::getString( configurationMap, "filename" ); if ( qmlFile.isEmpty() ) { - cWarning() << "No QML file for module" << m_name; + // TODO use the module instance } - else if ( !m_qmlComponent ) + + if ( !m_qmlComponent ) { m_qmlFileName = searchQmlFile( m_searchMethod, qmlFile, m_name ); diff --git a/src/modules/dummyqml/dummyqml.conf b/src/modules/dummyqml/dummyqml.conf index 48bbbc150..9e7a83fdd 100644 --- a/src/modules/dummyqml/dummyqml.conf +++ b/src/modules/dummyqml/dummyqml.conf @@ -18,9 +18,12 @@ # Search mode. Valid values are "both", "qrc" and "branding" search: both -# Name of the QML file. If not set, uses the name of the module. -filename: dummyqml +# Name of the QML file. If not set, uses the name of the instance +# of the module (e.g. if you list this module in `settings.conf` +# in the *instances* section, you get *id*, otherwise it would +# normally be "dummyqml"). +# filename: dummyqml -qmlLabel: +qmlLabel: notes: "Release Notes" notes[nl]: "Opmerkingen" From 53b6113c7509572ceef98009aa7a477ff96bc456 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 5 Feb 2020 18:38:46 +0100 Subject: [PATCH 32/32] [welcome] Fix QML tests --- src/modules/welcome/qmlmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/welcome/qmlmain.cpp b/src/modules/welcome/qmlmain.cpp index 96d9d245f..a9dd1875d 100644 --- a/src/modules/welcome/qmlmain.cpp +++ b/src/modules/welcome/qmlmain.cpp @@ -49,7 +49,7 @@ int main(int argc, char **argv) Logger::setupLogLevel( Logger::LOGVERBOSE ); - std::unique_ptr< Calamares::Settings > settings_p( new Calamares::Settings( QString(), true ) ); + std::unique_ptr< Calamares::Settings > settings_p( Calamares::Settings::init( QString() ) ); std::unique_ptr< Calamares::JobQueue > jobqueue_p( new Calamares::JobQueue( nullptr ) ); Calamares::Branding defaultBrand( "src/branding/default/branding.desc" );