[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.
main
Adriaan de Groot 4 years ago
parent 8c84ae9ff6
commit dcfbb766dc

@ -24,6 +24,7 @@
#include "viewpages/BlankViewStep.h" #include "viewpages/BlankViewStep.h"
#include "viewpages/ExecutionViewStep.h" #include "viewpages/ExecutionViewStep.h"
#include "viewpages/ViewStep.h" #include "viewpages/ViewStep.h"
#include "widgets/TranslationFix.h"
#include <QApplication> #include <QApplication>
#include <QBoxLayout> #include <QBoxLayout>
@ -82,6 +83,12 @@ ViewManager::ViewManager( QObject* parent )
connect( JobQueue::instance(), &JobQueue::finished, this, &ViewManager::next ); connect( JobQueue::instance(), &JobQueue::finished, this, &ViewManager::next );
CALAMARES_RETRANSLATE_SLOT( &ViewManager::updateButtonLabels ); 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->setStandardButtons( QMessageBox::Yes | QMessageBox::No );
msgBox->setDefaultButton( QMessageBox::No ); msgBox->setDefaultButton( QMessageBox::No );
msgBox->button( QMessageBox::Yes )->setText( tr( "&Yes" ) );
msgBox->button( QMessageBox::No )->setText( tr( "&No" ) );
} }
else else
{ {
msgBox->setStandardButtons( QMessageBox::Close ); msgBox->setStandardButtons( QMessageBox::Close );
msgBox->setDefaultButton( QMessageBox::Close ); msgBox->setDefaultButton( QMessageBox::Close );
msgBox->button( QMessageBox::Close )->setText( tr( "&Close" ) );
} }
Calamares::fixButtonLabels( msgBox );
msgBox->show(); msgBox->show();
cDebug() << "Calamares will quit when the dialog closes."; cDebug() << "Calamares will quit when the dialog closes.";
@ -516,8 +521,7 @@ ViewManager::confirmCancelInstallation()
"The installer will quit and all changes will be lost." ); "The installer will quit and all changes will be lost." );
QMessageBox mb( QMessageBox::Question, title, question, QMessageBox::Yes | QMessageBox::No, m_widget ); QMessageBox mb( QMessageBox::Question, title, question, QMessageBox::Yes | QMessageBox::No, m_widget );
mb.setDefaultButton( QMessageBox::No ); mb.setDefaultButton( QMessageBox::No );
mb.button( QMessageBox::Yes )->setText( tr( "&Yes" ) ); Calamares::fixButtonLabels( &mb );
mb.button( QMessageBox::No )->setText( tr( "&No" ) );
int response = mb.exec(); int response = mb.exec();
return response == QMessageBox::Yes; return response == QMessageBox::Yes;
} }

@ -24,8 +24,13 @@ fixButtonLabels( QMessageBox* box )
return; return;
} }
static std::pair< decltype( QMessageBox::Ok ), const char* > maps[] static std::pair< decltype( QMessageBox::Ok ), const char* > maps[] = {
= { { QMessageBox::Ok, QT_TRANSLATE_NOOP( "StandardButtons", "&OK" ) } }; { 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 ) for ( auto [ sb, label ] : maps )
{ {

Loading…
Cancel
Save