[packagechooser] Load translated strings from config

- Apply the *labels* from the configuration file to the
   visible strings (only the ViewStep name).
main
Adriaan de Groot 5 years ago
parent 0eae72e10f
commit 019d1c36c6

@ -32,6 +32,7 @@
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "locale/TranslatableConfiguration.h"
#include "utils/CalamaresUtilsSystem.h" #include "utils/CalamaresUtilsSystem.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Variant.h" #include "utils/Variant.h"
@ -46,6 +47,7 @@ PackageChooserViewStep::PackageChooserViewStep( QObject* parent )
, m_widget( nullptr ) , m_widget( nullptr )
, m_model( nullptr ) , m_model( nullptr )
, m_mode( PackageChooserMode::Required ) , m_mode( PackageChooserMode::Required )
, m_stepName( nullptr )
{ {
emit nextStatusChanged( false ); emit nextStatusChanged( false );
} }
@ -58,13 +60,14 @@ PackageChooserViewStep::~PackageChooserViewStep()
m_widget->deleteLater(); m_widget->deleteLater();
} }
delete m_model; delete m_model;
delete m_stepName;
} }
QString QString
PackageChooserViewStep::prettyName() const PackageChooserViewStep::prettyName() const
{ {
return tr( "Packages" ); return m_stepName ? m_stepName->get() : tr( "Packages" );
} }
@ -167,12 +170,12 @@ void
PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap ) PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
QString mode = CalamaresUtils::getString( configurationMap, "mode" ); QString mode = CalamaresUtils::getString( configurationMap, "mode" );
bool ok = false; bool mode_ok = false;
if ( !mode.isEmpty() ) if ( !mode.isEmpty() )
{ {
m_mode = roleNames().find( mode, ok ); m_mode = roleNames().find( mode, mode_ok );
} }
if ( !ok ) if ( !mode_ok )
{ {
m_mode = PackageChooserMode::Required; m_mode = PackageChooserMode::Required;
} }
@ -185,6 +188,16 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap
m_id = moduleInstanceKey().split( '@' ).last(); m_id = moduleInstanceKey().split( '@' ).last();
} }
bool labels_ok = false;
auto labels = CalamaresUtils::getSubMap( configurationMap, "labels", labels_ok );
if ( labels_ok )
{
if ( labels.contains( "step" ) )
{
m_stepName = new CalamaresUtils::Locale::TranslatedString( labels, "step" );
}
}
bool first_time = !m_model; bool first_time = !m_model;
if ( configurationMap.contains( "items" ) ) if ( configurationMap.contains( "items" ) )
{ {

@ -20,6 +20,7 @@
#define PACKAGECHOOSERVIEWSTEP_H #define PACKAGECHOOSERVIEWSTEP_H
#include "PluginDllMacro.h" #include "PluginDllMacro.h"
#include "locale/TranslatableConfiguration.h"
#include "utils/PluginFactory.h" #include "utils/PluginFactory.h"
#include "viewpages/ViewStep.h" #include "viewpages/ViewStep.h"
@ -65,6 +66,7 @@ private:
// Configuration // Configuration
PackageChooserMode m_mode; PackageChooserMode m_mode;
QString m_id; QString m_id;
CalamaresUtils::Locale::TranslatedString *m_stepName; // As it appears in the sidebar
}; };
CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserViewStepFactory ) CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserViewStepFactory )

Loading…
Cancel
Save