[netinstall] Move other translation parts to Config

main
Adriaan de Groot
parent cf7391696e
commit 335ccbc149

@ -168,10 +168,18 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
// Get the translations, if any // Get the translations, if any
bool bogus = false; bool bogus = false;
auto label = CalamaresUtils::getSubMap( configurationMap, "label", bogus ); auto label = CalamaresUtils::getSubMap( configurationMap, "label", bogus );
// Use a different class name for translation lookup because the
// .. table of strings lives in NetInstallViewStep.cpp and moving them
// .. around is annoying for translators.
static const char className[] = "NetInstallViewStep";
if ( label.contains( "sidebar" ) ) if ( label.contains( "sidebar" ) )
{ {
m_sidebarLabel = new CalamaresUtils::Locale::TranslatedString( label, "sidebar", metaObject()->className() ); m_sidebarLabel = new CalamaresUtils::Locale::TranslatedString( label, "sidebar", className );
}
if ( label.contains( "title" ) )
{
m_titleLabel = new CalamaresUtils::Locale::TranslatedString( label, "title", className );
} }
// Lastly, load the groups data // Lastly, load the groups data

@ -34,39 +34,12 @@ NetInstallPage::NetInstallPage( Config* c, QWidget* parent )
ui->groupswidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents ); ui->groupswidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
ui->groupswidget->setModel( c->model() ); ui->groupswidget->setModel( c->model() );
connect( c, &Config::statusChanged, this, &NetInstallPage::setStatus ); connect( c, &Config::statusChanged, this, &NetInstallPage::setStatus );
connect( c, &Config::titleLabelChanged, this, &NetInstallPage::setTitle );
connect( c, &Config::statusReady, this, &NetInstallPage::expandGroups ); connect( c, &Config::statusReady, this, &NetInstallPage::expandGroups );
setPageTitle( nullptr );
CALAMARES_RETRANSLATE_SLOT( &NetInstallPage::retranslate )
} }
NetInstallPage::~NetInstallPage() {} NetInstallPage::~NetInstallPage() {}
void
NetInstallPage::setPageTitle( CalamaresUtils::Locale::TranslatedString* t )
{
m_title.reset( t );
if ( !m_title )
{
ui->label->hide();
}
else
{
ui->label->show();
}
retranslate();
}
void
NetInstallPage::retranslate()
{
if ( m_title )
{
ui->label->setText( m_title->get() ); // That's get() on the TranslatedString
}
ui->netinst_status->setText( m_config->status() );
}
void void
NetInstallPage::expandGroups() NetInstallPage::expandGroups()
{ {
@ -88,6 +61,20 @@ NetInstallPage::setStatus( QString s )
ui->netinst_status->setText( s ); ui->netinst_status->setText( s );
} }
void
NetInstallPage::setTitle( QString title )
{
if ( title.isEmpty() )
{
ui->label->hide();
}
else
{
ui->label->setText( title ); // That's get() on the TranslatedString
ui->label->show();
}
}
void void
NetInstallPage::onActivate() NetInstallPage::onActivate()
{ {

@ -37,22 +37,11 @@ public:
NetInstallPage( Config* config, QWidget* parent = nullptr ); NetInstallPage( Config* config, QWidget* parent = nullptr );
~NetInstallPage() override; ~NetInstallPage() override;
/** @brief Sets the page title
*
* In situations where there is more than one netinstall page,
* or you want some explanatory title above the treeview,
* set the page title. This page takes ownership of the
* TranslatedString object.
*
* Set to nullptr to remove the title.
*/
void setPageTitle( CalamaresUtils::Locale::TranslatedString* );
void onActivate(); void onActivate();
public slots: public slots:
void retranslate();
void setStatus( QString s ); void setStatus( QString s );
void setTitle( QString title );
/** @brief Expand entries that should be pre-expanded. /** @brief Expand entries that should be pre-expanded.
* *
@ -64,8 +53,6 @@ public slots:
private: private:
Config* m_config; Config* m_config;
Ui::Page_NetInst* ui; Ui::Page_NetInst* ui;
std::unique_ptr< CalamaresUtils::Locale::TranslatedString > m_title; // Above the treeview
}; };
#endif // NETINSTALLPAGE_H #endif // NETINSTALLPAGE_H

@ -49,6 +49,9 @@ NetInstallViewStep::prettyName() const
// This is a table of "standard" labels for this module. If you use them // This is a table of "standard" labels for this module. If you use them
// in the label: sidebar: section of the config file, the existing // in the label: sidebar: section of the config file, the existing
// translations can be used. // translations can be used.
//
// These translations still live here, even though the lookup
// code is in the Config class.
tr( "Package selection" ); tr( "Package selection" );
tr( "Office software" ); tr( "Office software" );
tr( "Office package" ); tr( "Office package" );
@ -200,13 +203,4 @@ void
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap ) NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
m_config.setConfigurationMap( configurationMap ); m_config.setConfigurationMap( configurationMap );
bool bogus = false;
auto label = CalamaresUtils::getSubMap( configurationMap, "label", bogus );
if ( label.contains( "title" ) )
{
m_widget->setPageTitle(
new CalamaresUtils::Locale::TranslatedString( label, "title", metaObject()->className() ) );
}
} }

Loading…
Cancel
Save