From 72659dc6e193d2098d9c9aaacacb0448276191da Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 3 Jul 2017 11:04:23 -0400 Subject: [PATCH 01/10] FinishedPage: don't reboot on failure If installation fails, and you end up on the last page, suppress the reboot-now checkbox. FIXES #605 --- src/modules/finished/FinishedPage.cpp | 13 +++++++++++++ src/modules/finished/FinishedPage.h | 3 +++ src/modules/finished/FinishedViewStep.cpp | 12 +++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp index 609856975..8ae459540 100644 --- a/src/modules/finished/FinishedPage.cpp +++ b/src/modules/finished/FinishedPage.cpp @@ -39,6 +39,7 @@ FinishedPage::FinishedPage( QWidget* parent ) , ui( new Ui::FinishedPage ) , m_restartSetUp( false ) { + cDebug() << "FinishedPage()"; ui->setupUi( this ); ui->mainText->setAlignment( Qt::AlignCenter ); @@ -83,6 +84,7 @@ FinishedPage::setRestartNowCommand( const QString& command ) void FinishedPage::setUpRestart() { + cDebug() << "FinishedPage::setUpRestart()"; if ( !m_restartSetUp ) { connect( qApp, &QApplication::aboutToQuit, @@ -102,3 +104,14 @@ FinishedPage::focusInEvent( QFocusEvent* e ) e->accept(); } +void +FinishedPage::onInstallationFailed( const QString& message, const QString& details ) +{ + ui->mainText->setText( tr( "

Installation Failed


" + "%1 has not been installed on your computer.
" + "The error message was: %2." ) + .arg(Calamares::Branding::instance()-> + string( Calamares::Branding::VersionedName ) ) + .arg( details ) ); + setRestartNowEnabled( false ); +} diff --git a/src/modules/finished/FinishedPage.h b/src/modules/finished/FinishedPage.h index 31930a6f1..1129c69ce 100644 --- a/src/modules/finished/FinishedPage.h +++ b/src/modules/finished/FinishedPage.h @@ -38,6 +38,9 @@ public: void setUpRestart(); +public slots: + void onInstallationFailed( const QString& message, const QString& details ); + protected: void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 1f5217f22..1c3688c59 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -17,8 +17,10 @@ */ #include "FinishedViewStep.h" - #include "FinishedPage.h" +#include "JobQueue.h" + +#include "utils/Logger.h" #include @@ -26,6 +28,11 @@ FinishedViewStep::FinishedViewStep( QObject* parent ) : Calamares::ViewStep( parent ) , m_widget( new FinishedPage() ) { + cDebug() << "FinishedViewStep()"; + + connect( Calamares::JobQueue::instance(), &Calamares::JobQueue::failed, + m_widget, &FinishedPage::onInstallationFailed ); + emit nextStatusChanged( true ); } @@ -47,6 +54,7 @@ FinishedViewStep::prettyName() const QWidget* FinishedViewStep::widget() { + cDebug() << "FinishedViewStep::widget()"; return m_widget; } @@ -94,6 +102,7 @@ FinishedViewStep::isAtEnd() const void FinishedViewStep::onActivate() { + cDebug() << "FinishedViewStep::onActivate()"; m_widget->setUpRestart(); } @@ -101,6 +110,7 @@ FinishedViewStep::onActivate() QList< Calamares::job_ptr > FinishedViewStep::jobs() const { + cDebug() << "FinishedViewStep::jobs"; return QList< Calamares::job_ptr >(); } From 09a79886227a1c47488944eb6c6db9dcfa8d889a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 3 Jul 2017 11:36:36 -0400 Subject: [PATCH 02/10] FinishedPage: add copyright, reduce warnings --- src/modules/finished/FinishedPage.cpp | 2 ++ src/modules/finished/FinishedPage.h | 1 + src/modules/finished/FinishedViewStep.cpp | 1 + 3 files changed, 4 insertions(+) diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp index 8ae459540..87862e90c 100644 --- a/src/modules/finished/FinishedPage.cpp +++ b/src/modules/finished/FinishedPage.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -107,6 +108,7 @@ FinishedPage::focusInEvent( QFocusEvent* e ) void FinishedPage::onInstallationFailed( const QString& message, const QString& details ) { + Q_UNUSED( message ); ui->mainText->setText( tr( "

Installation Failed


" "%1 has not been installed on your computer.
" "The error message was: %2." ) diff --git a/src/modules/finished/FinishedPage.h b/src/modules/finished/FinishedPage.h index 1129c69ce..ba3e75667 100644 --- a/src/modules/finished/FinishedPage.h +++ b/src/modules/finished/FinishedPage.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 1c3688c59..3c9bc042c 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 3ecd2f2ff62502b787800a13070eb5d2d9a1084d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 3 Jul 2017 15:39:21 -0400 Subject: [PATCH 03/10] Add self to copyright notice --- src/modules/welcome/WelcomePage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 838148a76..83a22fe47 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -78,6 +78,7 @@ WelcomePage::WelcomePage( RequirementsChecker* requirementsChecker, QWidget* par "%2
" "for %3


" "Copyright 2014-2017 Teo Mrnjavac <teo@kde.org>
" + "Copyright 2017 Adriaan de Groot <groot@kde.org>
" "Thanks to: Anke Boersma, Aurélien Gâteau, Kevin Kofler, Lisa Vitolo," " Philip Müller, Pier Luigi Fiorini, Rohan Garg and the Calamares " From ee4e4dfcccb6588a81814848eae692f0afce2478 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 3 Jul 2017 18:07:18 -0400 Subject: [PATCH 04/10] C++ trickery to make the code shorter to read. --- src/calamares/CalamaresWindow.cpp | 3 +-- src/libcalamaresui/Branding.h | 7 ++++++ src/libcalamaresui/ViewManager.cpp | 7 +++--- src/modules/partition/gui/ChoicePage.cpp | 19 ++++++--------- src/modules/welcome/WelcomePage.cpp | 23 ++++++++----------- src/modules/welcome/checker/CheckerWidget.cpp | 10 ++++---- 6 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index f8d2c15d6..260d56139 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -43,8 +43,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) CALAMARES_RETRANSLATE( setWindowTitle( tr( "%1 Installer" ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ProductName ) ) ); + .arg( *Calamares::Branding::ProductName ) ); ) using CalamaresUtils::windowMinimumHeight; diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 36534ea44..5198f44f1 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -37,6 +37,11 @@ class UIDLLEXPORT Branding : public QObject { Q_OBJECT public: + /** + * Descriptive strings in the configuration file. use + * e.g. *Branding::ProductName to get the string value for + * the product name. + */ enum StringEntry : short { ProductName, @@ -112,6 +117,8 @@ private: bool m_welcomeStyleCalamares; }; +template inline QString operator*(U e) { return Branding::instance()->string( e ); } + } #endif // BRANDING_H diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 7c9f1897d..5ed88d19f 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -237,10 +238,8 @@ ViewManager::next() tr( "The %1 installer is about to make changes to your " "disk in order to install %2.
You will not be able " "to undo these changes." ) - .arg( Calamares::Branding::instance()->string( - Calamares::Branding::ShortProductName ) ) - .arg( Calamares::Branding::instance()->string( - Calamares::Branding::ShortVersionedName ) ), + .arg( *Calamares::Branding::ShortProductName ) + .arg( *Calamares::Branding::ShortVersionedName ), tr( "&Install now" ), tr( "Go &back" ), QString(), diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index a213e62fa..6b57a23f4 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2017, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -474,8 +475,7 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current, qRound64( part->used() * 1.1 ), part->capacity() - requiredStorageB, part->capacity() / 2, - Calamares::Branding::instance()-> - string( Calamares::Branding::ProductName ) ); + *Calamares::Branding::ProductName ); if ( m_isEfi ) setupEfiSystemPartitionSelector(); @@ -775,8 +775,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) if ( !homePartitionPath->isEmpty() ) m_reuseHomeCheckBox->setText( tr( "Reuse %1 as home partition for %2." ) .arg( *homePartitionPath ) - .arg( Calamares::Branding::instance()->string( - Calamares::Branding::ShortProductName ) ) ); + .arg( *Calamares::Branding::ShortProductName ) ); delete homePartitionPath; if ( m_isEfi ) @@ -919,8 +918,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice ) .arg( m_beforePartitionBarsView->selectionModel()->currentIndex().data().toString() ) .arg( size / ( 1024 * 1024 ) ) .arg( sizeNext / ( 1024 * 1024 ) ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortProductName ) ) ); + .arg( *Calamares::Branding::ShortProductName ) ); } ); m_previewAfterFrame->show(); @@ -948,8 +946,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice ) m_afterPartitionBarsView->setNestedPartitionsMode( mode ); m_afterPartitionLabelsView = new PartitionLabelsView( m_previewAfterFrame ); m_afterPartitionLabelsView->setExtendedPartitionHidden( mode == PartitionBarsView::NoNestedPartitions ); - m_afterPartitionLabelsView->setCustomNewRootLabel( Calamares::Branding::instance()-> - string( Calamares::Branding::BootloaderEntryName ) ); + m_afterPartitionLabelsView->setCustomNewRootLabel( *Calamares::Branding::BootloaderEntryName ); PartitionModel* model = m_core->partitionModelForDevice( selectedDevice() ); @@ -1073,8 +1070,7 @@ ChoicePage::setupEfiSystemPartitionSelector() tr( "An EFI system partition cannot be found anywhere " "on this system. Please go back and use manual " "partitioning to set up %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortProductName ) ) ); + .arg( *Calamares::Branding::ShortProductName ) ); updateNextEnabled(); } else if ( efiSystemPartitions.count() == 1 ) //probably most usual situation @@ -1083,8 +1079,7 @@ ChoicePage::setupEfiSystemPartitionSelector() tr( "The EFI system partition at %1 will be used for " "starting %2." ) .arg( efiSystemPartitions.first()->partitionPath() ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortProductName ) ) ); + .arg( *Calamares::Branding::ShortProductName ) ); } else { diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 83a22fe47..423df65ad 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -54,12 +54,11 @@ WelcomePage::WelcomePage( RequirementsChecker* requirementsChecker, QWidget* par ui->mainText->setOpenExternalLinks( true ); cDebug() << "Welcome string" << Calamares::Branding::instance()->welcomeStyleCalamares() - << Calamares::Branding::instance()->string( Calamares::Branding::VersionedName ); + << *Calamares::Branding::VersionedName; CALAMARES_RETRANSLATE( ui->mainText->setText( (Calamares::Branding::instance()->welcomeStyleCalamares() ? tr( "

Welcome to the Calamares installer for %1.

" ) : tr( "

Welcome to the %1 installer.

" )) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) ); + .arg( *Calamares::Branding::VersionedName ) ); ui->retranslateUi( this ); ) @@ -90,8 +89,7 @@ WelcomePage::WelcomePage( RequirementsChecker* requirementsChecker, QWidget* par ) .arg( CALAMARES_APPLICATION_NAME ) .arg( CALAMARES_VERSION ) - .arg( Calamares::Branding::instance()->string( - Calamares::Branding::VersionedName ) ), + .arg( *Calamares::Branding::VersionedName ), QMessageBox::Ok, this ); mb.setIconPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Squid, @@ -194,12 +192,11 @@ WelcomePage::setUpLinks( bool showSupportUrl, bool showReleaseNotesUrl ) { using namespace Calamares; - Branding* b = Branding::instance(); - if ( showSupportUrl && !b->string( Branding::SupportUrl ).isEmpty() ) + if ( showSupportUrl && !( *Branding::SupportUrl ).isEmpty() ) { CALAMARES_RETRANSLATE( ui->supportButton->setText( tr( "%1 support" ) - .arg( b->string( Branding::ShortProductName ) ) ); + .arg( *Branding::ShortProductName ) ); ) ui->supportButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Help, CalamaresUtils::Original, @@ -207,7 +204,7 @@ WelcomePage::setUpLinks( bool showSupportUrl, CalamaresUtils::defaultFontHeight() ) ) ); connect( ui->supportButton, &QPushButton::clicked, [] { - QDesktopServices::openUrl( Branding::instance()->string( Branding::SupportUrl ) ); + QDesktopServices::openUrl( *Branding::SupportUrl ); } ); } else @@ -215,7 +212,7 @@ WelcomePage::setUpLinks( bool showSupportUrl, ui->supportButton->hide(); } - if ( showKnownIssuesUrl && !b->string( Branding::KnownIssuesUrl ).isEmpty() ) + if ( showKnownIssuesUrl && !( *Branding::KnownIssuesUrl ).isEmpty() ) { ui->knownIssuesButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Bugs, CalamaresUtils::Original, @@ -223,7 +220,7 @@ WelcomePage::setUpLinks( bool showSupportUrl, CalamaresUtils::defaultFontHeight() ) ) ); connect( ui->knownIssuesButton, &QPushButton::clicked, [] { - QDesktopServices::openUrl( Branding::instance()->string( Branding::KnownIssuesUrl ) ); + QDesktopServices::openUrl( *Branding::KnownIssuesUrl ); } ); } else @@ -231,7 +228,7 @@ WelcomePage::setUpLinks( bool showSupportUrl, ui->knownIssuesButton->hide(); } - if ( showReleaseNotesUrl && !b->string( Branding::ReleaseNotesUrl ).isEmpty() ) + if ( showReleaseNotesUrl && !( *Branding::ReleaseNotesUrl ).isEmpty() ) { ui->releaseNotesButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Release, CalamaresUtils::Original, @@ -239,7 +236,7 @@ WelcomePage::setUpLinks( bool showSupportUrl, CalamaresUtils::defaultFontHeight() ) ) ); connect( ui->releaseNotesButton, &QPushButton::clicked, [] { - QDesktopServices::openUrl( Branding::instance()->string( Branding::ReleaseNotesUrl ) ); + QDesktopServices::openUrl( *Branding::ReleaseNotesUrl ); } ); } else diff --git a/src/modules/welcome/checker/CheckerWidget.cpp b/src/modules/welcome/checker/CheckerWidget.cpp index 10051b2f1..9b6ec7806 100644 --- a/src/modules/welcome/checker/CheckerWidget.cpp +++ b/src/modules/welcome/checker/CheckerWidget.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,8 +97,7 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries ) "requirements for installing %1.
" "Installation cannot continue. " "
Details..." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) ); + .arg( *Calamares::Branding::ShortVersionedName ) ); ) textLabel->setOpenExternalLinks( false ); connect( textLabel, &QLabel::linkActivated, @@ -114,8 +114,7 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries ) "recommended requirements for installing %1.
" "Installation can continue, but some features " "might be disabled." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) ); + .arg( *Calamares::Branding::ShortVersionedName ) ); ) } } @@ -141,8 +140,7 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries ) CALAMARES_RETRANSLATE( textLabel->setText( tr( "This program will ask you some questions and " "set up %2 on your computer." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ProductName ) ) ); + .arg( *Calamares::Branding::ProductName ) ); textLabel->setAlignment( Qt::AlignCenter ); ) } From c4f955874d53a55d620e00e554529ed1d8c40726 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 4 Jul 2017 03:36:42 -0400 Subject: [PATCH 05/10] QLabel::setPixmap() isn't virtual, don't make it so. --- src/libcalamaresui/widgets/FixedAspectRatioLabel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcalamaresui/widgets/FixedAspectRatioLabel.h b/src/libcalamaresui/widgets/FixedAspectRatioLabel.h index 71fc6e9d3..4483576f6 100644 --- a/src/libcalamaresui/widgets/FixedAspectRatioLabel.h +++ b/src/libcalamaresui/widgets/FixedAspectRatioLabel.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +31,7 @@ public: virtual ~FixedAspectRatioLabel(); public slots: - virtual void setPixmap( const QPixmap &pixmap ); + void setPixmap( const QPixmap &pixmap ); void resizeEvent( QResizeEvent* event ) override; private: From 44e6955f1980e6fcc41f4db2f6df4db7526d9000 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 4 Jul 2017 04:30:08 -0400 Subject: [PATCH 06/10] Feature: allow disable welcome-logo resizing --- src/branding/default/branding.desc | 4 ++++ src/libcalamaresui/Branding.cpp | 7 +------ src/libcalamaresui/Branding.h | 4 +++- src/modules/welcome/checker/CheckerWidget.cpp | 16 +++++++++++++--- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index 22443c350..ae47e1662 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -8,6 +8,10 @@ componentName: default # same distribution. welcomeStyleCalamares: false +# Should the welcome image (productWelcome, below) be scaled +# up beyond its natural size? +welcomeExpandingLogo: true + strings: productName: Generic GNU/Linux shortProductName: Generic diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index da6cce9f3..25102d3fd 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -110,6 +110,7 @@ Branding::Branding( const QString& brandingFilePath, bail( "Syntax error in strings map." ); m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false ); + m_welcomeExpandingLogo = doc[ "welcomeExpandingLogo" ].as< bool >( true ); QVariantMap strings = CalamaresUtils::yamlMapToVariant( doc[ "strings" ] ).toMap(); @@ -276,12 +277,6 @@ Branding::slideshowPath() const return m_slideshowPath; } -bool -Branding::welcomeStyleCalamares() const -{ - return m_welcomeStyleCalamares; -} - void Branding::setGlobals( GlobalStorage* globalStorage ) const { diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 5198f44f1..c56db2db2 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -88,7 +88,8 @@ public: QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const; QString slideshowPath() const; - bool welcomeStyleCalamares() const; + bool welcomeStyleCalamares() const { return m_welcomeStyleCalamares; } + bool welcomeExpandingLogo() const { return m_welcomeExpandingLogo; } /** * Creates a map called "branding" in the global storage, and inserts an @@ -115,6 +116,7 @@ private: QString m_translationsPathPrefix; bool m_welcomeStyleCalamares; + bool m_welcomeExpandingLogo; }; template inline QString operator*(U e) { return Branding::instance()->string( e ); } diff --git a/src/modules/welcome/checker/CheckerWidget.cpp b/src/modules/welcome/checker/CheckerWidget.cpp index 9b6ec7806..500ab6f85 100644 --- a/src/modules/welcome/checker/CheckerWidget.cpp +++ b/src/modules/welcome/checker/CheckerWidget.cpp @@ -128,13 +128,23 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries ) imagePath( Calamares::Branding::ProductWelcome ) ); if ( !theImage.isNull() ) { - FixedAspectRatioLabel* imageLabel = new FixedAspectRatioLabel; + QLabel* imageLabel; + if ( Calamares::Branding::instance()->welcomeExpandingLogo() ) + { + FixedAspectRatioLabel *p = new FixedAspectRatioLabel; + p->setPixmap( theImage ); + imageLabel = p; + } + else + { + imageLabel = new QLabel; + imageLabel->setPixmap( theImage ); + } + imageLabel->setContentsMargins( 4, CalamaresUtils::defaultFontHeight() * 3 / 4, 4, 4 ); m_mainLayout->addWidget( imageLabel ); imageLabel->setAlignment( Qt::AlignCenter ); imageLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - - imageLabel->setPixmap( theImage ); } } CALAMARES_RETRANSLATE( From 232bbe18bcfe23c5edecc4c2c3d508b3f1325e82 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 4 Jul 2017 05:32:05 -0400 Subject: [PATCH 07/10] Be more verbose while scanning devices --- src/modules/partition/core/PartitionCoreModule.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 608508d60..6afae1f09 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -153,19 +153,27 @@ PartitionCoreModule::doInit() { FileSystemFactory::init(); + using DeviceList = QList< Device* >; + CoreBackend* backend = CoreBackendManager::self()->backend(); - QList< Device* > devices = backend->scanDevices( true ); + DeviceList devices = backend->scanDevices( true ); + + cDebug() << "Winnowing" << devices.count() << "devices."; // Remove the device which contains / from the list - for ( QList< Device* >::iterator it = devices.begin(); it != devices.end(); ) + for ( DeviceList::iterator it = devices.begin(); it != devices.end(); ) if ( ! (*it) || hasRootPartition( *it ) || (*it)->deviceNode().startsWith( "/dev/zram") || isIso9660( *it ) ) + { + cDebug() << " .. Winnowing" << ( (*it) ? (*it)->deviceNode() : QString( "" ) ); it = devices.erase( it ); + } else ++it; - cDebug() << "LIST OF DETECTED DEVICES:\nnode\tcapacity\tname\tprettyName"; + cDebug() << "LIST OF DETECTED DEVICES:"; + cDebug() << "node\tcapacity\tname\tprettyName"; for ( auto device : devices ) { auto deviceInfo = new DeviceInfo( device ); From d3f624f818ca8185659436cd3a4d68c4962d4834 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 4 Jul 2017 08:14:30 -0400 Subject: [PATCH 08/10] FinishedPage: no modal pop-ups in a slot Switch the failure popup to non-modal, and quit the application when the pop-up is closed. This allows signals to be delivered to other slots connected to JobQueue::failed. --- src/libcalamaresui/ViewManager.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 5ed88d19f..4a8b7acf5 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -178,22 +178,23 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail cLog() << "- message:" << message; cLog() << "- details:" << details; - QMessageBox msgBox; - msgBox.setIcon( QMessageBox::Critical ); - msgBox.setWindowTitle( tr("Error") ); - msgBox.setText( "" + tr( "Installation Failed" ) + "" ); - msgBox.setStandardButtons( QMessageBox::Close ); + QMessageBox* msgBox = new QMessageBox(); + msgBox->setIcon( QMessageBox::Critical ); + msgBox->setWindowTitle( tr("Error") ); + msgBox->setText( "" + tr( "Installation Failed" ) + "" ); + msgBox->setStandardButtons( QMessageBox::Close ); + msgBox->button( QMessageBox::Close )->setText( tr( "&Close" ) ); QString text = "

" + message + "

"; if ( !details.isEmpty() ) { text += "

" + details + "

"; } - msgBox.setInformativeText( text ); + msgBox->setInformativeText( text ); - msgBox.exec(); - cLog() << "Calamares will now quit."; - qApp->quit(); + connect(msgBox, &QMessageBox::buttonClicked, qApp, &QApplication::quit); + cLog() << "Calamares will quit when the dialog closes."; + msgBox->show(); } From 5a3bbe8088b049252ca00950c36b0c1996c1dc09 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 4 Jul 2017 08:16:28 -0400 Subject: [PATCH 09/10] FinishedPage: show message instead of details on failure --- src/modules/finished/FinishedPage.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp index 87862e90c..dd83e5e3e 100644 --- a/src/modules/finished/FinishedPage.cpp +++ b/src/modules/finished/FinishedPage.cpp @@ -108,12 +108,11 @@ FinishedPage::focusInEvent( QFocusEvent* e ) void FinishedPage::onInstallationFailed( const QString& message, const QString& details ) { - Q_UNUSED( message ); + Q_UNUSED( details ); ui->mainText->setText( tr( "

Installation Failed


" "%1 has not been installed on your computer.
" "The error message was: %2." ) - .arg(Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) - .arg( details ) ); + .arg( *Calamares::Branding::VersionedName ) + .arg( message ) ); setRestartNowEnabled( false ); } From 3c3c0f99f8e24803c7ee60296192b478fbc71e51 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 4 Jul 2017 08:29:31 -0400 Subject: [PATCH 10/10] C++ trickery, part two: shorten code --- src/modules/finished/FinishedPage.cpp | 6 ++-- src/modules/partition/gui/ChoicePage.cpp | 24 +++++---------- .../partition/gui/PartitionViewStep.cpp | 27 ++++++----------- src/modules/partition/gui/ReplaceWidget.cpp | 30 +++++++------------ .../partition/jobs/FillGlobalStorageJob.cpp | 6 ++-- 5 files changed, 31 insertions(+), 62 deletions(-) diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp index dd83e5e3e..bfaad165d 100644 --- a/src/modules/finished/FinishedPage.cpp +++ b/src/modules/finished/FinishedPage.cpp @@ -53,10 +53,8 @@ FinishedPage::FinishedPage( QWidget* parent ) "%1 has been installed on your computer.
" "You may now restart into your new system, or continue " "using the %2 Live environment." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ProductName ) ) ); + .arg( *Calamares::Branding::VersionedName ) + .arg( *Calamares::Branding::ProductName ) ); ) } diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 6b57a23f4..16a4547fc 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -1180,13 +1180,11 @@ ChoicePage::setupActions() m_alongsideButton->setText( tr( "Install alongside
" "The installer will shrink a partition to make room for %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) ); + .arg( *Calamares::Branding::ShortVersionedName ) ); m_replaceButton->setText( tr( "Replace a partition
" "Replaces a partition with %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) ); + .arg( *Calamares::Branding::ShortVersionedName ) ); ) m_replaceButton->hide(); @@ -1211,8 +1209,7 @@ ChoicePage::setupActions() m_alongsideButton->setText( tr( "Install alongside
" "The installer will shrink a partition to make room for %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) ); + .arg( *Calamares::Branding::ShortVersionedName ) ); m_eraseButton->setText( tr( "Erase disk
" "This will delete all data " @@ -1221,8 +1218,7 @@ ChoicePage::setupActions() m_replaceButton->setText( tr( "Replace a partition
" "Replaces a partition with %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) ); + .arg( *Calamares::Branding::ShortVersionedName ) ); ) } else @@ -1235,8 +1231,7 @@ ChoicePage::setupActions() m_alongsideButton->setText( tr( "Install alongside
" "The installer will shrink a partition to make room for %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) ); + .arg( *Calamares::Branding::ShortVersionedName ) ); m_eraseButton->setText( tr( "Erase disk
" "This will delete all data " @@ -1244,8 +1239,7 @@ ChoicePage::setupActions() m_replaceButton->setText( tr( "Replace a partition
" "Replaces a partition with %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) ); + .arg( *Calamares::Branding::ShortVersionedName ) ); ) } @@ -1273,8 +1267,7 @@ ChoicePage::setupActions() m_alongsideButton->setText( tr( "Install alongside
" "The installer will shrink a partition to make room for %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) ); + .arg( *Calamares::Branding::ShortVersionedName ) ); m_eraseButton->setText( tr( "Erase disk
" "This will delete all data " @@ -1282,8 +1275,7 @@ ChoicePage::setupActions() m_replaceButton->setText( tr( "Replace a partition
" "Replaces a partition with %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) ); + .arg( *Calamares::Branding::ShortVersionedName ) ); ) m_replaceButton->show(); diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index e234134a8..b7dd7724a 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -156,18 +156,15 @@ PartitionViewStep::createSummaryWidget() const { case ChoicePage::Alongside: modeText = tr( "Install %1 alongside another operating system." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ); + .arg( *Calamares::Branding::ShortVersionedName ); break; case ChoicePage::Erase: modeText = tr( "Erase disk and install %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ); + .arg( *Calamares::Branding::ShortVersionedName ); break; case ChoicePage::Replace: modeText = tr( "Replace a partition with %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ); + .arg( *Calamares::Branding::ShortVersionedName ); break; case ChoicePage::NoChoice: case ChoicePage::Manual: @@ -185,22 +182,19 @@ PartitionViewStep::createSummaryWidget() const { case ChoicePage::Alongside: modeText = tr( "Install %1 alongside another operating system on disk %2 (%3)." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) + .arg( *Calamares::Branding::ShortVersionedName ) .arg( info.deviceNode ) .arg( info.deviceName ); break; case ChoicePage::Erase: modeText = tr( "Erase disk %2 (%3) and install %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) + .arg( *Calamares::Branding::ShortVersionedName ) .arg( info.deviceNode ) .arg( info.deviceName ); break; case ChoicePage::Replace: modeText = tr( "Replace a partition on disk %2 (%3) with %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortVersionedName ) ) + .arg( *Calamares::Branding::ShortVersionedName ) .arg( info.deviceNode ) .arg( info.deviceName ); break; @@ -252,8 +246,7 @@ PartitionViewStep::createSummaryWidget() const previewLabels->setModel( info.partitionModelAfter ); preview->setSelectionMode( QAbstractItemView::NoSelection ); previewLabels->setSelectionMode( QAbstractItemView::NoSelection ); - previewLabels->setCustomNewRootLabel( Calamares::Branding::instance()-> - string( Calamares::Branding::BootloaderEntryName ) ); + previewLabels->setCustomNewRootLabel( *Calamares::Branding::BootloaderEntryName ); info.partitionModelAfter->setParent( widget ); field = new QVBoxLayout; CalamaresUtils::unmarginLayout( field ); @@ -412,8 +405,7 @@ PartitionViewStep::onLeave() "%2.

" "You can continue without setting up an EFI system " "partition but your system may fail to start." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortProductName ) ) + .arg( *Calamares::Branding::ShortProductName ) .arg( espMountPoint ); } else if ( esp && !esp->activeFlags().testFlag( PartitionTable::FlagEsp ) ) @@ -428,8 +420,7 @@ PartitionViewStep::onLeave() "

" "You can continue without setting the flag but your " "system may fail to start." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortProductName ) ) + .arg( *Calamares::Branding::ShortProductName ) .arg( espMountPoint ); } diff --git a/src/modules/partition/gui/ReplaceWidget.cpp b/src/modules/partition/gui/ReplaceWidget.cpp index 5a0a1837d..1057127cd 100644 --- a/src/modules/partition/gui/ReplaceWidget.cpp +++ b/src/modules/partition/gui/ReplaceWidget.cpp @@ -134,8 +134,7 @@ ReplaceWidget::onPartitionSelected() tr( "Select where to install %1.
" "Warning: this will delete all files " "on the selected partition." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) ); + .arg( *Calamares::Branding::VersionedName ) ); setNextEnabled( false ); return; } @@ -168,8 +167,7 @@ ReplaceWidget::onPartitionSelected() updateStatus( CalamaresUtils::Fail, tr( "%1 cannot be installed on empty space. Please select an " "existing partition." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) ); + .arg( *Calamares::Branding::VersionedName ) ); setNextEnabled( false ); return; } @@ -179,8 +177,7 @@ ReplaceWidget::onPartitionSelected() updateStatus( CalamaresUtils::Fail, tr( "%1 cannot be installed on an extended partition. Please select an " "existing primary or logical partition." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) ); + .arg( *Calamares::Branding::VersionedName ) ); setNextEnabled( false ); return; } @@ -189,8 +186,7 @@ ReplaceWidget::onPartitionSelected() { updateStatus( CalamaresUtils::Fail, tr( "%1 cannot be installed on this partition." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) ); + .arg( *Calamares::Branding::VersionedName ) ); setNextEnabled( false ); return; } @@ -232,8 +228,7 @@ ReplaceWidget::onPartitionSelected() "The partition %1 is too small for %2. Please select a partition " "with capacity at least %3 GiB." ) .arg( partition->partitionPath() ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) + .arg( *Calamares::Branding::VersionedName ) .arg( requiredSpaceB / ( 1024. * 1024. * 1024. ), 0, 'f', 1 ) .arg( prettyName ) ); @@ -256,8 +251,7 @@ ReplaceWidget::onPartitionSelected() "An EFI system partition cannot be found anywhere " "on this system. Please go back and use manual " "partitioning to set up %1." ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortProductName ) ) + .arg( *Calamares::Branding::ShortProductName ) .arg( prettyName ) ); setNextEnabled( false ); } @@ -268,16 +262,14 @@ ReplaceWidget::onPartitionSelected() "%1 will be installed on %2.
" "Warning: all data on partition " "%2 will be lost.") - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) + .arg( *Calamares::Branding::VersionedName ) .arg( partition->partitionPath() ) .arg( prettyName ) ); m_ui->bootStatusLabel->show(); m_ui->bootStatusLabel->setText( tr( "The EFI system partition at %1 will be used for starting %2." ) .arg( efiSystemPartitions.first()->partitionPath() ) - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::ShortProductName ) ) ); + .arg( *Calamares::Branding::ShortProductName ) ); setNextEnabled( true ); } else @@ -287,8 +279,7 @@ ReplaceWidget::onPartitionSelected() "%1 will be installed on %2.
" "Warning: all data on partition " "%2 will be lost.") - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) + .arg( *Calamares::Branding::VersionedName ) .arg( partition->partitionPath() ) .arg( prettyName ) ); m_ui->bootStatusLabel->show(); @@ -312,8 +303,7 @@ ReplaceWidget::onPartitionSelected() "%1 will be installed on %2.
" "Warning: all data on partition " "%2 will be lost.") - .arg( Calamares::Branding::instance()-> - string( Calamares::Branding::VersionedName ) ) + .arg( *Calamares::Branding::VersionedName ) .arg( partition->partitionPath() ) .arg( prettyName ) ); setNextEnabled( true ); diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index db59528a4..5662f5e57 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -145,8 +145,7 @@ FillGlobalStorageJob::prettyDescription() const { if ( mountPoint == "/" ) lines.append( tr( "Install %1 on new %2 system partition." ) - .arg( Calamares::Branding::instance()->string( - Calamares::Branding::ShortProductName ) ) + .arg( *Calamares::Branding::ShortProductName ) .arg( fsType ) ); else lines.append( tr( "Set up new %2 partition with mount point " @@ -159,8 +158,7 @@ FillGlobalStorageJob::prettyDescription() const if ( mountPoint == "/" ) lines.append( tr( "Install %2 on %3 system partition %1." ) .arg( path ) - .arg( Calamares::Branding::instance()->string( - Calamares::Branding::ShortProductName ) ) + .arg( *Calamares::Branding::ShortProductName ) .arg( fsType ) ); else lines.append( tr( "Set up %3 partition %1 with mount point "