From d4a776e759cab0c6b1848e1958c2e382c5cfa2b9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jun 2022 11:55:03 +0200 Subject: [PATCH 1/8] [libcalamaresui] Adjust description of countdown spinner --- src/libcalamaresui/widgets/WaitingWidget.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/widgets/WaitingWidget.h b/src/libcalamaresui/widgets/WaitingWidget.h index 1b78809de..4f256259e 100644 --- a/src/libcalamaresui/widgets/WaitingWidget.h +++ b/src/libcalamaresui/widgets/WaitingWidget.h @@ -32,10 +32,10 @@ public: ~WaitingWidget() override; }; -/** @brief A spinner and a countdown next to it +/** @brief A spinner and a countdown inside it * * The spinner is sized to the text-height and displays a - * numeric countdown next to it. The countdown is updated + * numeric countdown iside the spinner. The countdown is updated * every second. The signal timeout() is sent every time * the countdown reaches 0. */ From f958a3c2f777672a0efe4fb9f6a212084cde2eb4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jun 2022 12:10:25 +0200 Subject: [PATCH 2/8] [welcome] Update the results-list when a round of checks completes When the checks were done, the widget showing the countdown-timer and results was not being informed, so it didn't update the display of the countdown timer or hide the list of problems (when there are none) so that the welcome image is shown. FIXES #1974 --- .../welcome/checker/CheckerContainer.cpp | 6 +++++- .../welcome/checker/ResultsListWidget.cpp | 19 +++++++++++++------ .../welcome/checker/ResultsListWidget.h | 6 +++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/modules/welcome/checker/CheckerContainer.cpp b/src/modules/welcome/checker/CheckerContainer.cpp index dd5a6680f..1c0c28f5c 100644 --- a/src/modules/welcome/checker/CheckerContainer.cpp +++ b/src/modules/welcome/checker/CheckerContainer.cpp @@ -71,7 +71,11 @@ CheckerContainer::requirementsComplete( bool ok ) m_waitingWidget->deleteLater(); m_waitingWidget = nullptr; // Don't delete in destructor } - if ( !m_checkerWidget ) + if ( m_checkerWidget ) + { + m_checkerWidget->requirementsComplete(); + } + else { m_checkerWidget = new ResultsListWidget( m_config, this ); m_checkerWidget->setObjectName( "requirementsChecker" ); diff --git a/src/modules/welcome/checker/ResultsListWidget.cpp b/src/modules/welcome/checker/ResultsListWidget.cpp index f07725484..b3371cee1 100644 --- a/src/modules/welcome/checker/ResultsListWidget.cpp +++ b/src/modules/welcome/checker/ResultsListWidget.cpp @@ -67,18 +67,25 @@ ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent ) } void -ResultsListWidget::requirementsChanged() +ResultsListWidget::requirementsComplete() { - // Check that all are satisfied (gives warnings if not) and - // all *mandatory* entries are satisfied (gives errors if not). - + // Check that the satisfaction of the requirements: + // - if everything is satisfied, show the welcome image + // - otherwise, if all the mandatory ones are satisfied, + // we won't be re-checking (see ModuleManager::checkRequirements) + // so hide the countdown, + // - otherwise we have unsatisfied mandatory requirements, + // so keep the countdown and the list of problems. const bool requirementsSatisfied = m_config->requirementsModel()->satisfiedRequirements(); + const bool mandatoryRequirementsSatisfied = m_config->requirementsModel()->satisfiedMandatory(); - if ( requirementsSatisfied ) + if ( mandatoryRequirementsSatisfied ) { m_countdown->stop(); m_countdown->hide(); - + } + if ( requirementsSatisfied ) + { delete m_centralWidget; m_centralWidget = nullptr; diff --git a/src/modules/welcome/checker/ResultsListWidget.h b/src/modules/welcome/checker/ResultsListWidget.h index 3bbed1090..1f2f630fb 100644 --- a/src/modules/welcome/checker/ResultsListWidget.h +++ b/src/modules/welcome/checker/ResultsListWidget.h @@ -26,10 +26,10 @@ class ResultsListWidget : public QWidget public: explicit ResultsListWidget( Config* config, QWidget* parent ); -private: - /// @brief The model of requirements changed - void requirementsChanged(); + /// @brief The model of requirements has finished a round of checking + void requirementsComplete(); +private: Config* m_config = nullptr; // UI parts, which need updating when the model changes From 26751f2acdeb13480ca1a03b416bc19007424933 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jun 2022 00:52:45 +0200 Subject: [PATCH 3/8] [welcome] After creating ResultsListWidget, update it to current model state --- src/modules/welcome/checker/CheckerContainer.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/modules/welcome/checker/CheckerContainer.cpp b/src/modules/welcome/checker/CheckerContainer.cpp index 1c0c28f5c..99b0f6375 100644 --- a/src/modules/welcome/checker/CheckerContainer.cpp +++ b/src/modules/welcome/checker/CheckerContainer.cpp @@ -71,16 +71,13 @@ CheckerContainer::requirementsComplete( bool ok ) m_waitingWidget->deleteLater(); m_waitingWidget = nullptr; // Don't delete in destructor } - if ( m_checkerWidget ) - { - m_checkerWidget->requirementsComplete(); - } - else + if ( !m_checkerWidget ) { m_checkerWidget = new ResultsListWidget( m_config, this ); m_checkerWidget->setObjectName( "requirementsChecker" ); layout()->addWidget( m_checkerWidget ); } + m_checkerWidget->requirementsComplete(); m_verdict = ok; } From 0fd0e9a1af955734affba3208b4f7b5737916d6c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jun 2022 01:00:27 +0200 Subject: [PATCH 4/8] [welcome] Add debugging checks slow-false and slow-true --- .../welcome/checker/GeneralRequirements.cpp | 18 ++++++++++++++++++ src/modules/welcome/welcome.conf | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/modules/welcome/checker/GeneralRequirements.cpp b/src/modules/welcome/checker/GeneralRequirements.cpp index 5f0124ef6..0c467124f 100644 --- a/src/modules/welcome/checker/GeneralRequirements.cpp +++ b/src/modules/welcome/checker/GeneralRequirements.cpp @@ -228,6 +228,15 @@ GeneralRequirements::checkRequirements() false, required } ); } + if ( entry == "slow-false" ) + { + sleep(3); + checkEntries.append( { entry, + [] { return tr( "is always false (slowly)" ); }, + [] { return tr( "The computer says no (slowly)." ); }, + false, + required } ); + } if ( entry == "true" ) { checkEntries.append( { entry, @@ -236,6 +245,15 @@ GeneralRequirements::checkRequirements() true, required } ); } + if ( entry == "slow-true" ) + { + sleep(3); + checkEntries.append( { entry, + [] { return tr( "is always true (slowly)" ); }, + [] { return tr( "The computer says yes (slowly)." ); }, + true, + required } ); + } if ( entry == "snark" ) { static unsigned int snark_count = 0; diff --git a/src/modules/welcome/welcome.conf b/src/modules/welcome/welcome.conf index b86231c3f..90bf9d115 100644 --- a/src/modules/welcome/welcome.conf +++ b/src/modules/welcome/welcome.conf @@ -67,9 +67,13 @@ requirements: # # Note that the last three checks are for testing-purposes only, # and shouldn't be used in production (they are only available - # when building Calamares in development mode): + # when building Calamares in development mode). There are five + # special checks: # - *false* is a check that is always false (unsatisfied) # - *true* is a check that is always true (satisfied) + # - *slow-false* takes 3 seconds, and then is false; use this one to + # show off the waiting-spinner before the first results come in + # - *slow-true* takes 3 seconds, and then is true # - *snark* is a check that is only satisfied once it has been checked # at least three times ("what I tell you three times is true"). check: From f8dd3ea133c3e5af12bea57a3312ca9a8138722c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jun 2022 01:00:40 +0200 Subject: [PATCH 5/8] [welcome] Extend schema to allow the debugging checks --- src/modules/welcome/welcome.schema.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/welcome/welcome.schema.yaml b/src/modules/welcome/welcome.schema.yaml index fbebcd968..30b3e4866 100644 --- a/src/modules/welcome/welcome.schema.yaml +++ b/src/modules/welcome/welcome.schema.yaml @@ -21,10 +21,10 @@ properties: internetCheckUrl: { type: string } check: type: array - items: { type: string, enum: [storage, ram, power, internet, root, screen], unique: true } + items: { type: string, enum: [storage, ram, power, internet, root, screen, "false", "true", "slow-false", "slow-true", snark], unique: true } required: # Key-name in the config-file type: array - items: { type: string, enum: [storage, ram, power, internet, root, screen], unique: true } + items: { type: string, enum: [storage, ram, power, internet, root, screen, "false", "true", "slow-false", "slow-true", snark], unique: true } required: [ requiredStorage, requiredRam, check ] # Schema keyword # TODO: refactor, this is reused in locale From 9f91b50553969389a2e4067c5bd01784038bc08b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jun 2022 01:04:43 +0200 Subject: [PATCH 6/8] [libcalamares] Use Q_EMIT instead of 'emit' --- src/libcalamares/modulesystem/RequirementsChecker.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcalamares/modulesystem/RequirementsChecker.cpp b/src/libcalamares/modulesystem/RequirementsChecker.cpp index b5bd91b36..dfd53175a 100644 --- a/src/libcalamares/modulesystem/RequirementsChecker.cpp +++ b/src/libcalamares/modulesystem/RequirementsChecker.cpp @@ -91,7 +91,7 @@ RequirementsChecker::addCheckedRequirements( Module* m ) m_model->addRequirementsList( l ); } - requirementsProgress( tr( "Requirements checking for module %1 is complete." ).arg( m->name() ) ); + Q_EMIT requirementsProgress( tr( "Requirements checking for module %1 is complete." ).arg( m->name() ) ); } void @@ -117,11 +117,11 @@ RequirementsChecker::reportProgress() unsigned int posInterval = ( m_progressTimer->interval() < 0 ) ? 1000 : uint( m_progressTimer->interval() ); QString waiting = tr( "Waiting for %n module(s).", "", remaining ); QString elapsed = tr( "(%n second(s))", "", m_progressTimeouts * posInterval / 1000 ); - emit requirementsProgress( waiting + QString( " " ) + elapsed ); + Q_EMIT requirementsProgress( waiting + QString( " " ) + elapsed ); } else { - emit requirementsProgress( tr( "System-requirements checking is complete." ) ); + Q_EMIT requirementsProgress( tr( "System-requirements checking is complete." ) ); } } From 42f9f07a072401a571ca1b49d2c1875c24d2a07b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jun 2022 01:27:37 +0200 Subject: [PATCH 7/8] [libcalamares] The spinner doesn't support rich text --- src/libcalamares/modulesystem/RequirementsChecker.cpp | 2 +- src/libcalamaresui/widgets/waitingspinnerwidget.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libcalamares/modulesystem/RequirementsChecker.cpp b/src/libcalamares/modulesystem/RequirementsChecker.cpp index dfd53175a..4e4a40ec4 100644 --- a/src/libcalamares/modulesystem/RequirementsChecker.cpp +++ b/src/libcalamares/modulesystem/RequirementsChecker.cpp @@ -91,7 +91,7 @@ RequirementsChecker::addCheckedRequirements( Module* m ) m_model->addRequirementsList( l ); } - Q_EMIT requirementsProgress( tr( "Requirements checking for module %1 is complete." ).arg( m->name() ) ); + Q_EMIT requirementsProgress( tr( "Requirements checking for module '%1' is complete." ).arg( m->name() ) ); } void diff --git a/src/libcalamaresui/widgets/waitingspinnerwidget.h b/src/libcalamaresui/widgets/waitingspinnerwidget.h index ce4a4cbff..29385566e 100644 --- a/src/libcalamaresui/widgets/waitingspinnerwidget.h +++ b/src/libcalamaresui/widgets/waitingspinnerwidget.h @@ -81,6 +81,10 @@ public: * With AlignBottom, the text is displayed below the spinner, * centered horizontally relative to the spinner; any other alignment * will put the text in the middle of the spinner itself. + * + * TODO: this does not support rich text. Rich text could be done + * through a QStaticText, or an HTML document. However, then + * we need to do more alignment calculations ourselves. */ void setText( const QString& text ); /** @brief Sets the alignment of text for the spinner From 7ccd7aa4e509ba691411c1fff472da281e8a5c84 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 Jun 2022 01:33:57 +0200 Subject: [PATCH 8/8] i18n: fix plurals in English while waiting for requirements-checker --- lang/calamares_en.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lang/calamares_en.ts b/lang/calamares_en.ts index ab6245471..00c38a6b5 100644 --- a/lang/calamares_en.ts +++ b/lang/calamares_en.ts @@ -283,16 +283,16 @@ Waiting for %n module(s). - Waiting for %n module(s). - Waiting for %n module(s). + Waiting for %n module. + Waiting for %n modules. (%n second(s)) - (%n second(s)) - (%n second(s)) + (%n second) + (%n seconds)