Merge branch 'qml-globalstorage'

- Make GlobalStorage generally available to QML modules (as Global
  from io.calamares.core)
This commit is contained in:
Adriaan de Groot 2020-05-01 14:38:05 +02:00
commit 7d8e54ba47
16 changed files with 29 additions and 20 deletions

View File

@ -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();

View File

@ -98,7 +98,7 @@ ProcessJobModule::ProcessJobModule()
}
ProcessJobModule::~ProcessJobModule() {}
ProcessJobModule::~ProcessJobModule() { }
} // namespace Calamares

View File

@ -80,7 +80,7 @@ PythonJobModule::PythonJobModule()
}
PythonJobModule::~PythonJobModule() {}
PythonJobModule::~PythonJobModule() { }
} // namespace Calamares

View File

@ -188,6 +188,6 @@ PythonQtViewModule::PythonQtViewModule()
{
}
PythonQtViewModule::~PythonQtViewModule() {}
PythonQtViewModule::~PythonQtViewModule() { }
} // namespace Calamares

View File

@ -40,7 +40,7 @@ ImageRegistry::instance()
}
ImageRegistry::ImageRegistry() {}
ImageRegistry::ImageRegistry() { }
QIcon

View File

@ -19,6 +19,8 @@
#include "Qml.h"
#include "Branding.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "ViewManager.h"
#include "utils/Logger.h"
@ -69,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 ); } );
}
}
@ -160,10 +162,14 @@ 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();
} );
qmlRegisterSingletonType< Calamares::GlobalStorage >(
"io.calamares.core", 1, 0, "Global", []( QQmlEngine*, QJSEngine* ) -> QObject* {
return Calamares::JobQueue::instance()->globalStorage();
} );
}
}

View File

@ -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).
*/

View File

@ -62,7 +62,7 @@ BlankViewStep::BlankViewStep( const QString& title,
m_widget->setLayout( layout );
}
BlankViewStep::~BlankViewStep() {}
BlankViewStep::~BlankViewStep() { }
QString
BlankViewStep::prettyName() const

View File

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

View File

@ -44,7 +44,7 @@ class PythonQtJob : public Calamares::Job
{
Q_OBJECT
public:
virtual ~PythonQtJob() {}
virtual ~PythonQtJob() { }
QString prettyName() const override;
QString prettyDescription() const override;

View File

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

View File

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

View File

@ -28,7 +28,7 @@ ViewStep::ViewStep( QObject* parent )
}
ViewStep::~ViewStep() {}
ViewStep::~ViewStep() { }
QString

View File

@ -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"

View File

@ -33,7 +33,7 @@ ClickableLabel::ClickableLabel( const QString& text, QWidget* parent )
}
ClickableLabel::~ClickableLabel() {}
ClickableLabel::~ClickableLabel() { }
void

View File

@ -26,7 +26,7 @@ FixedAspectRatioLabel::FixedAspectRatioLabel( QWidget* parent )
}
FixedAspectRatioLabel::~FixedAspectRatioLabel() {}
FixedAspectRatioLabel::~FixedAspectRatioLabel() { }
void