From dcfbb766dcf089e482700bf397d4ceeda8e1cefa Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Sep 2021 17:24:24 +0200 Subject: [PATCH] [libcalamaresui] Use fixed standard-buttons labels Move some of the texts to the new TranslationFix, from ViewManager, and use them. Keep them in ViewManager, too, so that the translations with context ViewManager are not removed just now. --- src/libcalamaresui/ViewManager.cpp | 14 +++++++++----- src/libcalamaresui/widgets/TranslationFix.cpp | 9 +++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index f6edbfc2a..57570ad64 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -24,6 +24,7 @@ #include "viewpages/BlankViewStep.h" #include "viewpages/ExecutionViewStep.h" #include "viewpages/ViewStep.h" +#include "widgets/TranslationFix.h" #include #include @@ -82,6 +83,12 @@ ViewManager::ViewManager( QObject* parent ) connect( JobQueue::instance(), &JobQueue::finished, this, &ViewManager::next ); CALAMARES_RETRANSLATE_SLOT( &ViewManager::updateButtonLabels ); + +#ifdef PRESERVE_FOR_TRANSLATION_PURPOSES + tr( "&Yes" ); + tr( "&No" ); + tr( "&Close" ); +#endif } @@ -176,15 +183,13 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail { msgBox->setStandardButtons( QMessageBox::Yes | QMessageBox::No ); msgBox->setDefaultButton( QMessageBox::No ); - msgBox->button( QMessageBox::Yes )->setText( tr( "&Yes" ) ); - msgBox->button( QMessageBox::No )->setText( tr( "&No" ) ); } else { msgBox->setStandardButtons( QMessageBox::Close ); msgBox->setDefaultButton( QMessageBox::Close ); - msgBox->button( QMessageBox::Close )->setText( tr( "&Close" ) ); } + Calamares::fixButtonLabels( msgBox ); msgBox->show(); cDebug() << "Calamares will quit when the dialog closes."; @@ -516,8 +521,7 @@ ViewManager::confirmCancelInstallation() "The installer will quit and all changes will be lost." ); QMessageBox mb( QMessageBox::Question, title, question, QMessageBox::Yes | QMessageBox::No, m_widget ); mb.setDefaultButton( QMessageBox::No ); - mb.button( QMessageBox::Yes )->setText( tr( "&Yes" ) ); - mb.button( QMessageBox::No )->setText( tr( "&No" ) ); + Calamares::fixButtonLabels( &mb ); int response = mb.exec(); return response == QMessageBox::Yes; } diff --git a/src/libcalamaresui/widgets/TranslationFix.cpp b/src/libcalamaresui/widgets/TranslationFix.cpp index 6bd2900be..1262fceb5 100644 --- a/src/libcalamaresui/widgets/TranslationFix.cpp +++ b/src/libcalamaresui/widgets/TranslationFix.cpp @@ -24,8 +24,13 @@ fixButtonLabels( QMessageBox* box ) return; } - static std::pair< decltype( QMessageBox::Ok ), const char* > maps[] - = { { QMessageBox::Ok, QT_TRANSLATE_NOOP( "StandardButtons", "&OK" ) } }; + static std::pair< decltype( QMessageBox::Ok ), const char* > maps[] = { + { QMessageBox::Ok, QT_TRANSLATE_NOOP( "StandardButtons", "&OK" ) }, + { QMessageBox::Yes, QT_TRANSLATE_NOOP( "StandardButtons", "&Yes" ) }, + { QMessageBox::No, QT_TRANSLATE_NOOP( "StandardButtons", "&No" ) }, + { QMessageBox::Cancel, QT_TRANSLATE_NOOP( "StandardButtons", "&Cancel" ) }, + { QMessageBox::Close, QT_TRANSLATE_NOOP( "StandardButtons", "&Close" ) }, + }; for ( auto [ sb, label ] : maps ) {