From 119f84d6c146b86fa659727bd57f64aabb810383 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Aug 2019 22:57:33 +0200 Subject: [PATCH] [welcome] Remove setupLinks() method, use generic - the generic (enum-based) setupButton() can handle all four of the buttons, so setupLinks() can go away. Only the (re)translation of the text on the button needs to be done, so move that to the main RETRANSLATE. --- src/modules/welcome/WelcomePage.cpp | 84 ++++++----------------------- 1 file changed, 15 insertions(+), 69 deletions(-) diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 35807e93c..8f989c47c 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -73,18 +73,20 @@ WelcomePage::WelcomePage( QWidget* parent ) cDebug() << "Welcome string" << Calamares::Branding::instance()->welcomeStyleCalamares() << *Calamares::Branding::VersionedName; - CALAMARES_RETRANSLATE( QString message; + CALAMARES_RETRANSLATE( + QString message; - if ( Calamares::Settings::instance()->isSetupMode() ) message - = Calamares::Branding::instance()->welcomeStyleCalamares() - ? tr( "

Welcome to the Calamares setup program for %1.

" ) - : tr( "

Welcome to %1 setup.

" ); - else message = Calamares::Branding::instance()->welcomeStyleCalamares() - ? tr( "

Welcome to the Calamares installer for %1.

" ) - : tr( "

Welcome to the %1 installer.

" ); + if ( Calamares::Settings::instance()->isSetupMode() ) message + = Calamares::Branding::instance()->welcomeStyleCalamares() + ? tr( "

Welcome to the Calamares setup program for %1.

" ) + : tr( "

Welcome to %1 setup.

" ); + else message = Calamares::Branding::instance()->welcomeStyleCalamares() + ? tr( "

Welcome to the Calamares installer for %1.

" ) + : tr( "

Welcome to the %1 installer.

" ); - ui->mainText->setText( message.arg( *Calamares::Branding::VersionedName ) ); - ui->retranslateUi( this ); ) + ui->mainText->setText( message.arg( *Calamares::Branding::VersionedName ) ); + ui->retranslateUi( this ); + ui->supportButton->setText( tr( "%1 support" ).arg( *Calamares::Branding::ShortProductName ) ); ) ui->aboutButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Information, @@ -194,56 +196,6 @@ WelcomePage::initLanguages() } -void -WelcomePage::setUpLinks( bool showSupportUrl, bool showKnownIssuesUrl, bool showReleaseNotesUrl ) -{ - using namespace Calamares; - if ( showSupportUrl && !( *Branding::SupportUrl ).isEmpty() ) - { - CALAMARES_RETRANSLATE( ui->supportButton->setText( tr( "%1 support" ).arg( *Branding::ShortProductName ) ); ) - ui->supportButton->setIcon( CalamaresUtils::defaultPixmap( - CalamaresUtils::Help, - CalamaresUtils::Original, - 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) ); - connect( ui->supportButton, &QPushButton::clicked, [] { QDesktopServices::openUrl( *Branding::SupportUrl ); } ); - } - else - { - ui->supportButton->hide(); - } - - if ( showKnownIssuesUrl && !( *Branding::KnownIssuesUrl ).isEmpty() ) - { - ui->knownIssuesButton->setIcon( CalamaresUtils::defaultPixmap( - CalamaresUtils::Bugs, - CalamaresUtils::Original, - 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) ); - connect( ui->knownIssuesButton, &QPushButton::clicked, [] { - QDesktopServices::openUrl( *Branding::KnownIssuesUrl ); - } ); - } - else - { - ui->knownIssuesButton->hide(); - } - - if ( showReleaseNotesUrl && !( *Branding::ReleaseNotesUrl ).isEmpty() ) - { - ui->releaseNotesButton->setIcon( CalamaresUtils::defaultPixmap( - CalamaresUtils::Release, - CalamaresUtils::Original, - 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) ); - connect( ui->releaseNotesButton, &QPushButton::clicked, [] { - QDesktopServices::openUrl( *Branding::ReleaseNotesUrl ); - } ); - } - else - { - ui->releaseNotesButton->hide(); - } -} - - void WelcomePage::setupButton( Button role, const QString& url ) { @@ -284,15 +236,9 @@ WelcomePage::setupButton( Button role, const QString& url ) QUrl u( url ); if ( u.isValid() ) { - auto size = 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ); - button->setIcon( CalamaresUtils::defaultPixmap( - icon, - CalamaresUtils::Original,size - ); - connect( button, &QPushButton::clicked, [u]() - { - QDesktopServices::openUrl( u ); - } ); + auto size = 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ); + button->setIcon( CalamaresUtils::defaultPixmap( icon, CalamaresUtils::Original, size ) ); + connect( button, &QPushButton::clicked, [u]() { QDesktopServices::openUrl( u ); } ); } else {