diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp
index e9bd79c9d..99a50c017 100644
--- a/src/modules/partition/gui/ChoicePage.cpp
+++ b/src/modules/partition/gui/ChoicePage.cpp
@@ -140,6 +140,7 @@ ChoicePage::retranslate()
updateSwapChoicesTr();
updateChoiceButtonsTr();
+ updateActionDescriptionsTr();
}
/** @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(
- 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?
"
- "You will be able to review and confirm your choices "
- "before any change is made to the storage device." ) );
-
- m_eraseButton->setText( tr( "Erase disk
"
- "This will delete all data "
- "currently present on the selected storage device." ) );
-
- m_alongsideButton->setText( tr( "Install alongside
"
- "The installer will shrink a partition to make room for %1." )
- .arg( Calamares::Branding::instance()->shortVersionedName() ) );
-
- m_replaceButton->setText( tr( "Replace a partition
"
- "Replaces a partition with %1." )
- .arg( Calamares::Branding::instance()->shortVersionedName() ) ); );
-
+ m_osproberOneEntryName.clear();
m_replaceButton->hide();
m_alongsideButton->hide();
m_grp->setExclusive( false );
@@ -1369,78 +1353,16 @@ ChoicePage::setupActions()
m_alongsideButton->setChecked( false );
m_grp->setExclusive( true );
}
- else if ( osproberEntriesForCurrentDevice.count() == 1 )
+ else if ( m_osproberEntriesCount == 1 )
{
- QString osName = 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?
"
- "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( "Install alongside
"
- "The installer will shrink a partition to make room for %1." )
- .arg( Calamares::Branding::instance()->shortVersionedName() ) );
-
- m_eraseButton->setText( tr( "Erase disk
"
- "This will delete all data "
- "currently present on the selected storage device." ) );
-
- m_replaceButton->setText( tr( "Replace a partition
"
- "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?
"
- "You will be able to review and confirm your choices "
- "before any change is made to the storage device." ) );
-
- m_alongsideButton->setText( tr( "Install alongside
"
- "The installer will shrink a partition to make room for %1." )
- .arg( Calamares::Branding::instance()->shortVersionedName() ) );
-
- m_eraseButton->setText( tr( "Erase disk
"
- "This will delete all data "
- "currently present on the selected storage device." ) );
-
- m_replaceButton->setText( tr( "Replace a partition
"
- "Replaces a partition with %1." )
- .arg( Calamares::Branding::instance()->shortVersionedName() ) ); );
- }
+ m_osproberOneEntryName = osproberEntriesForCurrentDevice.first().prettyName;
}
else
{
// osproberEntriesForCurrentDevice has at least 2 items.
-
- 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?
"
- "You will be able to review and confirm your choices "
- "before any change is made to the storage device." ) );
-
- m_alongsideButton->setText( tr( "Install alongside
"
- "The installer will shrink a partition to make room for %1." )
- .arg( Calamares::Branding::instance()->shortVersionedName() ) );
-
- m_eraseButton->setText( tr( "Erase disk
"
- "This will delete all data "
- "currently present on the selected storage device." ) );
-
- m_replaceButton->setText( tr( "Replace a partition
"
- "Replaces a partition with %1." )
- .arg( Calamares::Branding::instance()->shortVersionedName() ) ); );
+ m_osproberOneEntryName.clear();
}
+ updateActionDescriptionsTr();
#ifdef DEBUG_PARTITION_UNSAFE
#ifdef DEBUG_PARTITION_BAIL_OUT
@@ -1778,3 +1700,96 @@ ChoicePage::shouldShowEncryptWidget( Config::InstallChoice choice ) const
= choice == InstallChoice::Erase || choice == InstallChoice::Alongside || choice == InstallChoice::Replace;
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?
"
+ "You will be able to review and confirm your choices "
+ "before any change is made to the storage device." ) );
+
+ m_eraseButton->setText( tr( "Erase disk
"
+ "This will delete all data "
+ "currently present on the selected storage device." ) );
+
+ m_alongsideButton->setText( tr( "Install alongside
"
+ "The installer will shrink a partition to make room for %1." )
+ .arg( Calamares::Branding::instance()->shortVersionedName() ) );
+
+ m_replaceButton->setText( tr( "Replace a partition
"
+ "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?
"
+ "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( "Install alongside
"
+ "The installer will shrink a partition to make room for %1." )
+ .arg( Calamares::Branding::instance()->shortVersionedName() ) );
+
+ m_eraseButton->setText( tr( "Erase disk
"
+ "This will delete all data "
+ "currently present on the selected storage device." ) );
+
+ m_replaceButton->setText( tr( "Replace a partition
"
+ "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?
"
+ "You will be able to review and confirm your choices "
+ "before any change is made to the storage device." ) );
+
+ m_alongsideButton->setText( tr( "Install alongside
"
+ "The installer will shrink a partition to make room for %1." )
+ .arg( Calamares::Branding::instance()->shortVersionedName() ) );
+
+ m_eraseButton->setText( tr( "Erase disk
"
+ "This will delete all data "
+ "currently present on the selected storage device." ) );
+
+ m_replaceButton->setText( tr( "Replace a partition
"
+ "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?
"
+ "You will be able to review and confirm your choices "
+ "before any change is made to the storage device." ) );
+
+ m_alongsideButton->setText( tr( "Install alongside
"
+ "The installer will shrink a partition to make room for %1." )
+ .arg( Calamares::Branding::instance()->shortVersionedName() ) );
+
+ m_eraseButton->setText( tr( "Erase disk
"
+ "This will delete all data "
+ "currently present on the selected storage device." ) );
+
+ m_replaceButton->setText( tr( "Replace a partition
"
+ "Replaces a partition with %1." ) );
+ }
+ if ( m_osproberEntriesCount < 0 )
+ {
+ cWarning() << "Invalid osprober count, labels and buttons not updated.";
+ }
+}
diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h
index 7deb4dec6..1917ef049 100644
--- a/src/modules/partition/gui/ChoicePage.h
+++ b/src/modules/partition/gui/ChoicePage.h
@@ -136,6 +136,7 @@ private:
// Translations support
void updateSwapChoicesTr();
void updateChoiceButtonsTr();
+ void updateActionDescriptionsTr();
Config* m_config;
bool m_nextEnabled;
@@ -168,6 +169,8 @@ private:
QPointer< QComboBox > m_efiComboBox;
int m_lastSelectedDeviceIndex = -1;
+ int m_osproberEntriesCount = -1;
+ QString m_osproberOneEntryName;
bool m_enableEncryptionWidget = false;