[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.
This commit is contained in:
Adriaan de Groot 2021-09-07 17:24:24 +02:00
parent 8c84ae9ff6
commit dcfbb766dc
2 changed files with 16 additions and 7 deletions

View File

@ -24,6 +24,7 @@
#include "viewpages/BlankViewStep.h"
#include "viewpages/ExecutionViewStep.h"
#include "viewpages/ViewStep.h"
#include "widgets/TranslationFix.h"
#include <QApplication>
#include <QBoxLayout>
@ -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;
}

View File

@ -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 )
{