Introduce and use a Calamares::Branding::setGlobals method.

The method creates a map called "branding" in the global storage, and
inserts an entry for each of the branding strings. This makes the
branding information accessible to the Python modules.

The method is called by CalamaresApplication::initJobQueue.

This is necessary because the Branding class is in libcalamaresui, so
Python modules cannot access it directly.
This commit is contained in:
Kevin Kofler 2014-11-16 04:19:53 +01:00
parent 39e2170b6d
commit 98f99fa5bf
3 changed files with 26 additions and 1 deletions

View File

@ -316,5 +316,6 @@ CalamaresApplication::onPluginsReady()
void void
CalamaresApplication::initJobQueue() CalamaresApplication::initJobQueue()
{ {
new Calamares::JobQueue( this ); Calamares::JobQueue *jobQueue = new Calamares::JobQueue( this );
Calamares::Branding::instance()->setGlobals( jobQueue->globalStorage() );
} }

View File

@ -18,6 +18,7 @@
#include "Branding.h" #include "Branding.h"
#include "GlobalStorage.h"
#include "utils/CalamaresUtils.h" #include "utils/CalamaresUtils.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/YamlUtils.h" #include "utils/YamlUtils.h"
@ -26,6 +27,7 @@
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QPixmap> #include <QPixmap>
#include <QVariantMap>
#include <yaml-cpp/yaml.h> #include <yaml-cpp/yaml.h>
@ -200,6 +202,19 @@ Branding::slideshowPaths() const
} }
void
Branding::setGlobals( GlobalStorage* globalStorage ) const
{
QVariantMap brandingMap;
brandingMap.insert( "productName", string( ProductName ) );
brandingMap.insert( "version", string( Version ) );
brandingMap.insert( "shortVersion", string( ShortVersion ) );
brandingMap.insert( "versionedName", string( VersionedName ) );
brandingMap.insert( "shortVersionedName", string( ShortVersionedName ) );
globalStorage->insert( "branding", brandingMap );
}
void void
Branding::bail( const QString& message ) Branding::bail( const QString& message )
{ {

View File

@ -30,6 +30,8 @@
namespace Calamares namespace Calamares
{ {
class GlobalStorage;
class UIDLLEXPORT Branding : public QObject class UIDLLEXPORT Branding : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -63,6 +65,13 @@ public:
QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const; QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const;
QStringList slideshowPaths() const; QStringList slideshowPaths() const;
/**
* Creates a map called "branding" in the global storage, and inserts an
* entry for each of the branding strings. This makes the branding
* information accessible to the Python modules.
*/
void setGlobals( GlobalStorage* globalStorage ) const;
private: private:
static Branding* s_instance; static Branding* s_instance;