[partition] Repair translation of labels
There was an accumulation of connected slots when the current device changed (CALAMARES_RETRANSLATE **adds** one). Instead, extract the translated messages and carry the necessary information (number of entries, and if just one, its name) in the ChoicePage object. Although you can't effectively change the translation / current language while looking at the ChoicePage, it is best to be future-proof.
This commit is contained in:
parent
6ded13a917
commit
e52b220a69
@ -140,6 +140,7 @@ ChoicePage::retranslate()
|
|||||||
|
|
||||||
updateSwapChoicesTr();
|
updateSwapChoicesTr();
|
||||||
updateChoiceButtonsTr();
|
updateChoiceButtonsTr();
|
||||||
|
updateActionDescriptionsTr();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Sets the @p model for the given @p box and adjusts UI sizes to match.
|
/** @brief Sets the @p model for the given @p box and adjusts UI sizes to match.
|
||||||
@ -1341,27 +1342,10 @@ ChoicePage::setupActions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( osproberEntriesForCurrentDevice.count() == 0 )
|
m_osproberEntriesCount = osproberEntriesForCurrentDevice.count();
|
||||||
|
if ( m_osproberEntriesCount == 0 )
|
||||||
{
|
{
|
||||||
CALAMARES_RETRANSLATE(
|
m_osproberOneEntryName.clear();
|
||||||
cDebug() << "Setting texts for 0 osprober entries";
|
|
||||||
m_messageLabel->setText( tr( "This storage device does not seem to have an operating system on it. "
|
|
||||||
"What would you like to do?<br/>"
|
|
||||||
"You will be able to review and confirm your choices "
|
|
||||||
"before any change is made to the storage device." ) );
|
|
||||||
|
|
||||||
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
|
||||||
"This will <font color=\"red\">delete</font> all data "
|
|
||||||
"currently present on the selected storage device." ) );
|
|
||||||
|
|
||||||
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
|
||||||
"The installer will shrink a partition to make room for %1." )
|
|
||||||
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
|
||||||
|
|
||||||
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
|
||||||
"Replaces a partition with %1." )
|
|
||||||
.arg( Calamares::Branding::instance()->shortVersionedName() ) ); );
|
|
||||||
|
|
||||||
m_replaceButton->hide();
|
m_replaceButton->hide();
|
||||||
m_alongsideButton->hide();
|
m_alongsideButton->hide();
|
||||||
m_grp->setExclusive( false );
|
m_grp->setExclusive( false );
|
||||||
@ -1369,78 +1353,16 @@ ChoicePage::setupActions()
|
|||||||
m_alongsideButton->setChecked( false );
|
m_alongsideButton->setChecked( false );
|
||||||
m_grp->setExclusive( true );
|
m_grp->setExclusive( true );
|
||||||
}
|
}
|
||||||
else if ( osproberEntriesForCurrentDevice.count() == 1 )
|
else if ( m_osproberEntriesCount == 1 )
|
||||||
{
|
{
|
||||||
QString osName = osproberEntriesForCurrentDevice.first().prettyName;
|
m_osproberOneEntryName = osproberEntriesForCurrentDevice.first().prettyName;
|
||||||
|
|
||||||
if ( !osName.isEmpty() )
|
|
||||||
{
|
|
||||||
CALAMARES_RETRANSLATE(
|
|
||||||
cDebug() << "Setting texts for 1 non-empty osprober entry";
|
|
||||||
m_messageLabel->setText( tr( "This storage device has %1 on it. "
|
|
||||||
"What would you like to do?<br/>"
|
|
||||||
"You will be able to review and confirm your choices "
|
|
||||||
"before any change is made to the storage device." )
|
|
||||||
.arg( osName ) );
|
|
||||||
|
|
||||||
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
|
||||||
"The installer will shrink a partition to make room for %1." )
|
|
||||||
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
|
||||||
|
|
||||||
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
|
||||||
"This will <font color=\"red\">delete</font> all data "
|
|
||||||
"currently present on the selected storage device." ) );
|
|
||||||
|
|
||||||
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
|
||||||
"Replaces a partition with %1." )
|
|
||||||
.arg( Calamares::Branding::instance()->shortVersionedName() ) ); );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CALAMARES_RETRANSLATE(
|
|
||||||
cDebug() << "Setting texts for 1 empty osprober entry";
|
|
||||||
m_messageLabel->setText( tr( "This storage device already has an operating system on it. "
|
|
||||||
"What would you like to do?<br/>"
|
|
||||||
"You will be able to review and confirm your choices "
|
|
||||||
"before any change is made to the storage device." ) );
|
|
||||||
|
|
||||||
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
|
||||||
"The installer will shrink a partition to make room for %1." )
|
|
||||||
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
|
||||||
|
|
||||||
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
|
||||||
"This will <font color=\"red\">delete</font> all data "
|
|
||||||
"currently present on the selected storage device." ) );
|
|
||||||
|
|
||||||
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
|
||||||
"Replaces a partition with %1." )
|
|
||||||
.arg( Calamares::Branding::instance()->shortVersionedName() ) ); );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// osproberEntriesForCurrentDevice has at least 2 items.
|
// osproberEntriesForCurrentDevice has at least 2 items.
|
||||||
|
m_osproberOneEntryName.clear();
|
||||||
CALAMARES_RETRANSLATE(
|
|
||||||
cDebug() << "Setting texts for >= 2 osprober entries";
|
|
||||||
|
|
||||||
m_messageLabel->setText( tr( "This storage device has multiple operating systems on it. "
|
|
||||||
"What would you like to do?<br/>"
|
|
||||||
"You will be able to review and confirm your choices "
|
|
||||||
"before any change is made to the storage device." ) );
|
|
||||||
|
|
||||||
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
|
||||||
"The installer will shrink a partition to make room for %1." )
|
|
||||||
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
|
||||||
|
|
||||||
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
|
||||||
"This will <font color=\"red\">delete</font> all data "
|
|
||||||
"currently present on the selected storage device." ) );
|
|
||||||
|
|
||||||
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
|
||||||
"Replaces a partition with %1." )
|
|
||||||
.arg( Calamares::Branding::instance()->shortVersionedName() ) ); );
|
|
||||||
}
|
}
|
||||||
|
updateActionDescriptionsTr();
|
||||||
|
|
||||||
#ifdef DEBUG_PARTITION_UNSAFE
|
#ifdef DEBUG_PARTITION_UNSAFE
|
||||||
#ifdef DEBUG_PARTITION_BAIL_OUT
|
#ifdef DEBUG_PARTITION_BAIL_OUT
|
||||||
@ -1778,3 +1700,96 @@ ChoicePage::shouldShowEncryptWidget( Config::InstallChoice choice ) const
|
|||||||
= choice == InstallChoice::Erase || choice == InstallChoice::Alongside || choice == InstallChoice::Replace;
|
= choice == InstallChoice::Erase || choice == InstallChoice::Alongside || choice == InstallChoice::Replace;
|
||||||
return suitableChoice && m_enableEncryptionWidget && suitableFS;
|
return suitableChoice && m_enableEncryptionWidget && suitableFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ChoicePage::updateActionDescriptionsTr()
|
||||||
|
{
|
||||||
|
if ( m_osproberEntriesCount == 0 )
|
||||||
|
{
|
||||||
|
cDebug() << "Setting texts for 0 osprober entries";
|
||||||
|
m_messageLabel->setText( tr( "This storage device does not seem to have an operating system on it. "
|
||||||
|
"What would you like to do?<br/>"
|
||||||
|
"You will be able to review and confirm your choices "
|
||||||
|
"before any change is made to the storage device." ) );
|
||||||
|
|
||||||
|
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
||||||
|
"This will <font color=\"red\">delete</font> all data "
|
||||||
|
"currently present on the selected storage device." ) );
|
||||||
|
|
||||||
|
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
||||||
|
"The installer will shrink a partition to make room for %1." )
|
||||||
|
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
||||||
|
|
||||||
|
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
||||||
|
"Replaces a partition with %1." )
|
||||||
|
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
||||||
|
}
|
||||||
|
if ( m_osproberEntriesCount == 1 )
|
||||||
|
{
|
||||||
|
if ( !m_osproberOneEntryName.isEmpty() )
|
||||||
|
{
|
||||||
|
cDebug() << "Setting texts for 1 non-empty osprober entry";
|
||||||
|
m_messageLabel->setText( tr( "This storage device has %1 on it. "
|
||||||
|
"What would you like to do?<br/>"
|
||||||
|
"You will be able to review and confirm your choices "
|
||||||
|
"before any change is made to the storage device." )
|
||||||
|
.arg( m_osproberOneEntryName ) );
|
||||||
|
|
||||||
|
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
||||||
|
"The installer will shrink a partition to make room for %1." )
|
||||||
|
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
||||||
|
|
||||||
|
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
||||||
|
"This will <font color=\"red\">delete</font> all data "
|
||||||
|
"currently present on the selected storage device." ) );
|
||||||
|
|
||||||
|
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
||||||
|
"Replaces a partition with %1." )
|
||||||
|
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cDebug() << "Setting texts for 1 empty osprober entry";
|
||||||
|
m_messageLabel->setText( tr( "This storage device already has an operating system on it. "
|
||||||
|
"What would you like to do?<br/>"
|
||||||
|
"You will be able to review and confirm your choices "
|
||||||
|
"before any change is made to the storage device." ) );
|
||||||
|
|
||||||
|
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
||||||
|
"The installer will shrink a partition to make room for %1." )
|
||||||
|
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
||||||
|
|
||||||
|
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
||||||
|
"This will <font color=\"red\">delete</font> all data "
|
||||||
|
"currently present on the selected storage device." ) );
|
||||||
|
|
||||||
|
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
||||||
|
"Replaces a partition with %1." )
|
||||||
|
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( m_osproberEntriesCount >= 2 )
|
||||||
|
{
|
||||||
|
cDebug() << "Setting texts for >= 2 osprober entries";
|
||||||
|
|
||||||
|
m_messageLabel->setText( tr( "This storage device has multiple operating systems on it. "
|
||||||
|
"What would you like to do?<br/>"
|
||||||
|
"You will be able to review and confirm your choices "
|
||||||
|
"before any change is made to the storage device." ) );
|
||||||
|
|
||||||
|
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
||||||
|
"The installer will shrink a partition to make room for %1." )
|
||||||
|
.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
||||||
|
|
||||||
|
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
||||||
|
"This will <font color=\"red\">delete</font> all data "
|
||||||
|
"currently present on the selected storage device." ) );
|
||||||
|
|
||||||
|
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
||||||
|
"Replaces a partition with %1." ) );
|
||||||
|
}
|
||||||
|
if ( m_osproberEntriesCount < 0 )
|
||||||
|
{
|
||||||
|
cWarning() << "Invalid osprober count, labels and buttons not updated.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -136,6 +136,7 @@ private:
|
|||||||
// Translations support
|
// Translations support
|
||||||
void updateSwapChoicesTr();
|
void updateSwapChoicesTr();
|
||||||
void updateChoiceButtonsTr();
|
void updateChoiceButtonsTr();
|
||||||
|
void updateActionDescriptionsTr();
|
||||||
|
|
||||||
Config* m_config;
|
Config* m_config;
|
||||||
bool m_nextEnabled;
|
bool m_nextEnabled;
|
||||||
@ -168,6 +169,8 @@ private:
|
|||||||
QPointer< QComboBox > m_efiComboBox;
|
QPointer< QComboBox > m_efiComboBox;
|
||||||
|
|
||||||
int m_lastSelectedDeviceIndex = -1;
|
int m_lastSelectedDeviceIndex = -1;
|
||||||
|
int m_osproberEntriesCount = -1;
|
||||||
|
QString m_osproberOneEntryName;
|
||||||
|
|
||||||
bool m_enableEncryptionWidget = false;
|
bool m_enableEncryptionWidget = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user