From 98f99fa5bf0f9b7dcf026f24543cd38adc7f0d17 Mon Sep 17 00:00:00 2001 From: Kevin Kofler Date: Sun, 16 Nov 2014 04:19:53 +0100 Subject: [PATCH] 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. --- src/calamares/CalamaresApplication.cpp | 3 ++- src/libcalamaresui/Branding.cpp | 15 +++++++++++++++ src/libcalamaresui/Branding.h | 9 +++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index c7851d6b7..78b16e3bb 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -316,5 +316,6 @@ CalamaresApplication::onPluginsReady() void CalamaresApplication::initJobQueue() { - new Calamares::JobQueue( this ); + Calamares::JobQueue *jobQueue = new Calamares::JobQueue( this ); + Calamares::Branding::instance()->setGlobals( jobQueue->globalStorage() ); } diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index b1672f899..8943f9ea9 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -18,6 +18,7 @@ #include "Branding.h" +#include "GlobalStorage.h" #include "utils/CalamaresUtils.h" #include "utils/Logger.h" #include "utils/YamlUtils.h" @@ -26,6 +27,7 @@ #include #include #include +#include #include @@ -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 Branding::bail( const QString& message ) { diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index d86c92878..991aafa39 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -30,6 +30,8 @@ namespace Calamares { +class GlobalStorage; + class UIDLLEXPORT Branding : public QObject { Q_OBJECT @@ -63,6 +65,13 @@ public: QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) 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: static Branding* s_instance;