From dc523525c26e24eeeadfb15527ebaccab6d28654 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 1 May 2020 09:15:46 +0200 Subject: [PATCH 1/3] [libcalamaresui] Register the right type for ViewManager (C&P typo) --- src/libcalamaresui/utils/Qml.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcalamaresui/utils/Qml.cpp b/src/libcalamaresui/utils/Qml.cpp index 0b2c84616..246bf9c78 100644 --- a/src/libcalamaresui/utils/Qml.cpp +++ b/src/libcalamaresui/utils/Qml.cpp @@ -160,7 +160,7 @@ registerCalamaresModels() "io.calamares.ui", 1, 0, "Branding", []( QQmlEngine*, QJSEngine* ) -> QObject* { return Calamares::Branding::instance(); } ); - qmlRegisterSingletonType< Calamares::Branding >( + qmlRegisterSingletonType< Calamares::ViewManager >( "io.calamares.core", 1, 0, "ViewManager", []( QQmlEngine*, QJSEngine* ) -> QObject* { return Calamares::ViewManager::instance(); } ); From 8af17fafe1883240a03889c64858a8549976b6f2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 1 May 2020 09:58:38 +0200 Subject: [PATCH 2/3] [libcalamaresui] Register Global Storage (as 'Global') for QML --- src/libcalamares/GlobalStorage.h | 10 ++++++---- src/libcalamaresui/utils/Qml.cpp | 6 ++++++ src/libcalamaresui/utils/Qml.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libcalamares/GlobalStorage.h b/src/libcalamares/GlobalStorage.h index bef9ec1cc..2a59009f7 100644 --- a/src/libcalamares/GlobalStorage.h +++ b/src/libcalamares/GlobalStorage.h @@ -39,12 +39,8 @@ public: //NOTE: thread safety is guaranteed by JobQueue, which executes jobs one by one. // If at any time jobs become concurrent, this class must be made thread-safe. - bool contains( const QString& key ) const; - int count() const; void insert( const QString& key, const QVariant& value ); - QStringList keys() const; int remove( const QString& key ); - QVariant value( const QString& key ) const; /// @brief dump keys and values to the debug log void debugDump() const; @@ -83,6 +79,12 @@ public: */ const QVariantMap& data() const { return m; } +public Q_SLOTS: + bool contains( const QString& key ) const; + int count() const; + QStringList keys() const; + QVariant value( const QString& key ) const; + signals: void changed(); diff --git a/src/libcalamaresui/utils/Qml.cpp b/src/libcalamaresui/utils/Qml.cpp index 246bf9c78..2c1cc0c49 100644 --- a/src/libcalamaresui/utils/Qml.cpp +++ b/src/libcalamaresui/utils/Qml.cpp @@ -19,6 +19,8 @@ #include "Qml.h" #include "Branding.h" +#include "GlobalStorage.h" +#include "JobQueue.h" #include "ViewManager.h" #include "utils/Logger.h" @@ -164,6 +166,10 @@ registerCalamaresModels() "io.calamares.core", 1, 0, "ViewManager", []( QQmlEngine*, QJSEngine* ) -> QObject* { return Calamares::ViewManager::instance(); } ); + qmlRegisterSingletonType< Calamares::GlobalStorage >( + "io.calamares.core", 1, 0, "Global", []( QQmlEngine*, QJSEngine* ) -> QObject* { + return Calamares::JobQueue::instance()->globalStorage(); + } ); } } diff --git a/src/libcalamaresui/utils/Qml.h b/src/libcalamaresui/utils/Qml.h index b109d8381..33b44b9ea 100644 --- a/src/libcalamaresui/utils/Qml.h +++ b/src/libcalamaresui/utils/Qml.h @@ -36,6 +36,7 @@ namespace CalamaresUtils * The following objects are made available globally: * - `io.calamares.ui.Branding` (an object, see Branding.h) * - `io.calamares.core.ViewManager` (a model, see ViewManager.h) + * - `io.calamares.core.Global` (an object, see GlobalStorage.h) * Additionally, modules based on QmlViewStep have a context * property `config` referring to that module's configuration (if any). */ From 0e71957b748b97f6219ab943f64c6fe9681bfa8c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 1 May 2020 10:01:24 +0200 Subject: [PATCH 3/3] [libcalamaresui] Apply coding style --- src/libcalamaresui/modulesystem/ProcessJobModule.cpp | 2 +- src/libcalamaresui/modulesystem/PythonJobModule.cpp | 2 +- src/libcalamaresui/modulesystem/PythonQtViewModule.cpp | 2 +- src/libcalamaresui/utils/ImageRegistry.cpp | 2 +- src/libcalamaresui/utils/Qml.cpp | 4 ++-- src/libcalamaresui/viewpages/BlankViewStep.cpp | 2 +- src/libcalamaresui/viewpages/PythonQtGlobalStorageWrapper.h | 2 +- src/libcalamaresui/viewpages/PythonQtJob.h | 2 +- src/libcalamaresui/viewpages/PythonQtUtilsWrapper.h | 2 +- src/libcalamaresui/viewpages/QmlViewStep.cpp | 2 +- src/libcalamaresui/viewpages/ViewStep.cpp | 2 +- src/libcalamaresui/viewpages/ViewStep.h | 2 +- src/libcalamaresui/widgets/ClickableLabel.cpp | 2 +- src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.cpp b/src/libcalamaresui/modulesystem/ProcessJobModule.cpp index 405d9efd8..3fb0579d3 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.cpp +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.cpp @@ -98,7 +98,7 @@ ProcessJobModule::ProcessJobModule() } -ProcessJobModule::~ProcessJobModule() {} +ProcessJobModule::~ProcessJobModule() { } } // namespace Calamares diff --git a/src/libcalamaresui/modulesystem/PythonJobModule.cpp b/src/libcalamaresui/modulesystem/PythonJobModule.cpp index 38ec76bfe..d5d5563c7 100644 --- a/src/libcalamaresui/modulesystem/PythonJobModule.cpp +++ b/src/libcalamaresui/modulesystem/PythonJobModule.cpp @@ -80,7 +80,7 @@ PythonJobModule::PythonJobModule() } -PythonJobModule::~PythonJobModule() {} +PythonJobModule::~PythonJobModule() { } } // namespace Calamares diff --git a/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp b/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp index b59126eaa..b94414d4a 100644 --- a/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp +++ b/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp @@ -188,6 +188,6 @@ PythonQtViewModule::PythonQtViewModule() { } -PythonQtViewModule::~PythonQtViewModule() {} +PythonQtViewModule::~PythonQtViewModule() { } } // namespace Calamares diff --git a/src/libcalamaresui/utils/ImageRegistry.cpp b/src/libcalamaresui/utils/ImageRegistry.cpp index a08bbfc7d..1778de745 100644 --- a/src/libcalamaresui/utils/ImageRegistry.cpp +++ b/src/libcalamaresui/utils/ImageRegistry.cpp @@ -40,7 +40,7 @@ ImageRegistry::instance() } -ImageRegistry::ImageRegistry() {} +ImageRegistry::ImageRegistry() { } QIcon diff --git a/src/libcalamaresui/utils/Qml.cpp b/src/libcalamaresui/utils/Qml.cpp index 2c1cc0c49..5f3264da9 100644 --- a/src/libcalamaresui/utils/Qml.cpp +++ b/src/libcalamaresui/utils/Qml.cpp @@ -71,14 +71,14 @@ addExpansions( QmlSearch method, QStringList& candidates, const QStringList& nam std::transform( names.constBegin(), names.constEnd(), std::back_inserter( candidates ), - [&]( const QString& s ) { return s.isEmpty() ? QString() : bPath.arg( brandDir, s ); } ); + [ & ]( const QString& s ) { return s.isEmpty() ? QString() : bPath.arg( brandDir, s ); } ); } if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::QrcOnly ) ) { std::transform( names.constBegin(), names.constEnd(), std::back_inserter( candidates ), - [&]( const QString& s ) { return s.isEmpty() ? QString() : qrPath.arg( s ); } ); + [ & ]( const QString& s ) { return s.isEmpty() ? QString() : qrPath.arg( s ); } ); } } diff --git a/src/libcalamaresui/viewpages/BlankViewStep.cpp b/src/libcalamaresui/viewpages/BlankViewStep.cpp index af10c7a99..68eba5385 100644 --- a/src/libcalamaresui/viewpages/BlankViewStep.cpp +++ b/src/libcalamaresui/viewpages/BlankViewStep.cpp @@ -62,7 +62,7 @@ BlankViewStep::BlankViewStep( const QString& title, m_widget->setLayout( layout ); } -BlankViewStep::~BlankViewStep() {} +BlankViewStep::~BlankViewStep() { } QString BlankViewStep::prettyName() const diff --git a/src/libcalamaresui/viewpages/PythonQtGlobalStorageWrapper.h b/src/libcalamaresui/viewpages/PythonQtGlobalStorageWrapper.h index 946f93e97..5ccc4e21d 100644 --- a/src/libcalamaresui/viewpages/PythonQtGlobalStorageWrapper.h +++ b/src/libcalamaresui/viewpages/PythonQtGlobalStorageWrapper.h @@ -40,7 +40,7 @@ class GlobalStorage : public QObject Q_OBJECT public: explicit GlobalStorage( Calamares::GlobalStorage* gs ); - virtual ~GlobalStorage() {} + virtual ~GlobalStorage() { } public slots: bool contains( const QString& key ) const; diff --git a/src/libcalamaresui/viewpages/PythonQtJob.h b/src/libcalamaresui/viewpages/PythonQtJob.h index a73e7eb82..bab073430 100644 --- a/src/libcalamaresui/viewpages/PythonQtJob.h +++ b/src/libcalamaresui/viewpages/PythonQtJob.h @@ -44,7 +44,7 @@ class PythonQtJob : public Calamares::Job { Q_OBJECT public: - virtual ~PythonQtJob() {} + virtual ~PythonQtJob() { } QString prettyName() const override; QString prettyDescription() const override; diff --git a/src/libcalamaresui/viewpages/PythonQtUtilsWrapper.h b/src/libcalamaresui/viewpages/PythonQtUtilsWrapper.h index 19b8b623d..96de6fe9c 100644 --- a/src/libcalamaresui/viewpages/PythonQtUtilsWrapper.h +++ b/src/libcalamaresui/viewpages/PythonQtUtilsWrapper.h @@ -33,7 +33,7 @@ class Utils : public QObject Q_OBJECT public: explicit Utils( QObject* parent = nullptr ); - virtual ~Utils() {} + virtual ~Utils() { } public slots: void debug( const QString& s ) const; diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index 7140cd10f..f92ef47e7 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -88,7 +88,7 @@ QmlViewStep::QmlViewStep( QObject* parent ) // QML Loading starts when the configuration for the module is set. } -QmlViewStep::~QmlViewStep() {} +QmlViewStep::~QmlViewStep() { } QString QmlViewStep::prettyName() const diff --git a/src/libcalamaresui/viewpages/ViewStep.cpp b/src/libcalamaresui/viewpages/ViewStep.cpp index 11cfa2beb..82f8688dc 100644 --- a/src/libcalamaresui/viewpages/ViewStep.cpp +++ b/src/libcalamaresui/viewpages/ViewStep.cpp @@ -28,7 +28,7 @@ ViewStep::ViewStep( QObject* parent ) } -ViewStep::~ViewStep() {} +ViewStep::~ViewStep() { } QString diff --git a/src/libcalamaresui/viewpages/ViewStep.h b/src/libcalamaresui/viewpages/ViewStep.h index 88adb83f5..707bc0b3b 100644 --- a/src/libcalamaresui/viewpages/ViewStep.h +++ b/src/libcalamaresui/viewpages/ViewStep.h @@ -20,8 +20,8 @@ #ifndef VIEWSTEP_H #define VIEWSTEP_H -#include "Job.h" #include "DllMacro.h" +#include "Job.h" #include "modulesystem/InstanceKey.h" #include "modulesystem/Requirement.h" diff --git a/src/libcalamaresui/widgets/ClickableLabel.cpp b/src/libcalamaresui/widgets/ClickableLabel.cpp index 62985acf8..6e6f54459 100644 --- a/src/libcalamaresui/widgets/ClickableLabel.cpp +++ b/src/libcalamaresui/widgets/ClickableLabel.cpp @@ -33,7 +33,7 @@ ClickableLabel::ClickableLabel( const QString& text, QWidget* parent ) } -ClickableLabel::~ClickableLabel() {} +ClickableLabel::~ClickableLabel() { } void diff --git a/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp b/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp index c495ca5bb..cf72c9924 100644 --- a/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp +++ b/src/libcalamaresui/widgets/FixedAspectRatioLabel.cpp @@ -26,7 +26,7 @@ FixedAspectRatioLabel::FixedAspectRatioLabel( QWidget* parent ) } -FixedAspectRatioLabel::~FixedAspectRatioLabel() {} +FixedAspectRatioLabel::~FixedAspectRatioLabel() { } void