Merge branch 'issue-1138'

FIXES #1138
main
Adriaan de Groot 6 years ago
commit 1c12449f03

@ -25,9 +25,12 @@ This release contains contributions from (alphabetically by first name):
## Modules ## ## Modules ##
- *finished* has a new mechanism for configuring the behavior of the
*restart now* button. The old-style boolean configuration is still
supported but generates a warning. #1138
- *oemid* is a new module for configuring OEM phase-0 (image pre-mastering, - *oemid* is a new module for configuring OEM phase-0 (image pre-mastering,
or pre-deployment) things. It has limited functionality at the moment, or pre-deployment) things. It has limited functionality at the moment,
writing only a single batch-identifier file. writing only a single batch-identifier file. #943
- All Python modules now bail out gracefully on (at least some) bad - All Python modules now bail out gracefully on (at least some) bad
configurations, rather than raising an exception. The pre-release configurations, rather than raising an exception. The pre-release
scripts now test for exceptions to avoid shipping modules with scripts now test for exceptions to avoid shipping modules with

@ -1,14 +1,24 @@
# Configuration for the "finished" page, which is usually shown only at # Configuration for the "finished" page, which is usually shown only at
# the end of the installation (successful or not). # the end of the installation (successful or not).
--- ---
# The finished page can hold a "restart system now" checkbox. # Behavior of the "restart system now" button.
# If this is false, no checkbox is shown and the system is not restarted #
# when Calamares exits. # There are four usable values:
restartNowEnabled: true # - never
# Does not show the button and does not restart.
# Initial state of the checkbox "restart now". Only relevant when the # This matches the old behavior with restartNowEnabled=false.
# checkbox is shown by restartNowEnabled. # - user-unchecked
restartNowChecked: false # Shows the button, defaults to unchecked, restarts if it is checked.
# This matches the old behavior with restartNowEnabled=true and restartNowChecked=false.
# - user-checked
# Shows the button, defaults to checked, restarts if it is checked.
# This matches the old behavior with restartNowEnabled=true and restartNowChecked=true.
# - always
# Shows the button, checked, but the user cannot change it.
# This is new behavior.
#
# The three combinations of legacy values are still supported.
restartNowMode: user-unchecked
# If the checkbox is shown, and the checkbox is checked, then when # If the checkbox is shown, and the checkbox is checked, then when
# Calamares exits from the finished-page it will run this command. # Calamares exits from the finished-page it will run this command.

@ -79,16 +79,13 @@ FinishedPage::FinishedPage( QWidget* parent )
void void
FinishedPage::setRestartNowEnabled( bool enabled ) FinishedPage::setRestart( FinishedViewStep::RestartMode mode )
{ {
ui->restartCheckBox->setVisible( enabled ); using Mode = FinishedViewStep::RestartMode;
}
void ui->restartCheckBox->setVisible( mode != Mode::Never );
FinishedPage::setRestartNowChecked( bool checked ) ui->restartCheckBox->setEnabled( mode != Mode::Always );
{ ui->restartCheckBox->setChecked( ( mode == Mode::Always ) || ( mode == Mode::UserChecked ) );
ui->restartCheckBox->setChecked( checked );
} }
@ -138,5 +135,5 @@ FinishedPage::onInstallationFailed( const QString& message, const QString& detai
"The error message was: %2." ) "The error message was: %2." )
.arg( *Calamares::Branding::VersionedName ) .arg( *Calamares::Branding::VersionedName )
.arg( message ) ); .arg( message ) );
setRestartNowEnabled( false ); setRestart( FinishedViewStep::RestartMode::Never );
} }

@ -22,6 +22,8 @@
#include <QWidget> #include <QWidget>
#include "FinishedViewStep.h"
namespace Ui namespace Ui
{ {
class FinishedPage; class FinishedPage;
@ -33,8 +35,7 @@ class FinishedPage : public QWidget
public: public:
explicit FinishedPage( QWidget* parent = nullptr ); explicit FinishedPage( QWidget* parent = nullptr );
void setRestartNowEnabled( bool enabled ); void setRestart( FinishedViewStep::RestartMode mode );
void setRestartNowChecked( bool checked );
void setRestartNowCommand( const QString& command ); void setRestartNowCommand( const QString& command );
void setUpRestart(); void setUpRestart();

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com> * Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
@ -20,17 +20,34 @@
#include "FinishedViewStep.h" #include "FinishedViewStep.h"
#include "FinishedPage.h" #include "FinishedPage.h"
#include "Branding.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "Settings.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/NamedEnum.h"
#include "utils/Variant.h"
#include <QtDBus/QDBusConnection> #include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusInterface> #include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply> #include <QtDBus/QDBusReply>
#include <QVariantMap> #include <QVariantMap>
#include "Branding.h" static const NamedEnumTable< FinishedViewStep::RestartMode >&
#include "Settings.h" modeNames()
{
using Mode = FinishedViewStep::RestartMode;
static const NamedEnumTable< Mode > names{
{ QStringLiteral( "never" ), Mode::Never },
{ QStringLiteral( "user-unchecked" ), Mode::UserUnchecked },
{ QStringLiteral( "user-checked" ), Mode::UserChecked },
{ QStringLiteral( "always" ), Mode::Always }
} ;
return names;
}
FinishedViewStep::FinishedViewStep( QObject* parent ) FinishedViewStep::FinishedViewStep( QObject* parent )
: Calamares::ViewStep( parent ) : Calamares::ViewStep( parent )
@ -122,10 +139,10 @@ FinishedViewStep::sendNotification()
QVariant( 0 ) QVariant( 0 )
); );
if ( !r.isValid() ) if ( !r.isValid() )
cDebug() << "Could not call notify for end of installation." << r.error(); cWarning() << "Could not call org.freedesktop.Notifications.Notify at end of installation." << r.error();
} }
else else
cDebug() << "Could not get dbus interface for notifications." << notify.lastError(); cWarning() << "Could not get dbus interface for notifications at end of installation." << notify.lastError();
} }
@ -156,28 +173,41 @@ FinishedViewStep::onInstallationFailed( const QString& message, const QString& d
void void
FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap ) FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
if ( configurationMap.contains( "restartNowEnabled" ) && RestartMode mode = RestartMode::Never;
configurationMap.value( "restartNowEnabled" ).type() == QVariant::Bool )
{
bool restartNowEnabled = configurationMap.value( "restartNowEnabled" ).toBool();
m_widget->setRestartNowEnabled( restartNowEnabled ); QString restartMode = CalamaresUtils::getString( configurationMap, "restartNowMode" );
if ( restartNowEnabled ) if ( restartMode.isEmpty() )
{ {
if ( configurationMap.contains( "restartNowChecked" ) && if ( configurationMap.contains( "restartNowEnabled" ) )
configurationMap.value( "restartNowChecked" ).type() == QVariant::Bool ) cWarning() << "Configuring the finished module with deprecated restartNowEnabled settings";
m_widget->setRestartNowChecked( configurationMap.value( "restartNowChecked" ).toBool() );
bool restartNowEnabled = CalamaresUtils::getBool( configurationMap, "restartNowEnabled", false );
bool restartNowChecked = CalamaresUtils::getBool( configurationMap, "restartNowChecked", false );
if ( configurationMap.contains( "restartNowCommand" ) && if ( !restartNowEnabled )
configurationMap.value( "restartNowCommand" ).type() == QVariant::String ) mode = RestartMode::Never;
m_widget->setRestartNowCommand( configurationMap.value( "restartNowCommand" ).toString() );
else else
m_widget->setRestartNowCommand( "shutdown -r now" ); mode = restartNowChecked ? RestartMode::UserChecked : RestartMode::UserUnchecked;
} }
else
{
bool ok = false;
mode = modeNames().find( restartMode, ok );
if ( !ok )
cWarning() << "Configuring the finished module with bad restartNowMode" << restartMode;
} }
if ( configurationMap.contains( "notifyOnFinished" ) &&
configurationMap.value( "notifyOnFinished" ).type() == QVariant::Bool ) m_widget->setRestart( mode );
m_notifyOnFinished = configurationMap.value( "notifyOnFinished" ).toBool();
if ( mode != RestartMode::Never )
{
QString restartNowCommand = CalamaresUtils::getString( configurationMap, "restartNowCommand" );
if ( restartNowCommand.isEmpty() )
restartNowCommand = QStringLiteral( "shutdown -r now" );
m_widget->setRestartNowCommand( restartNowCommand );
}
m_notifyOnFinished = CalamaresUtils::getBool( configurationMap, "notifyOnFinished", false );
} }
CALAMARES_PLUGIN_FACTORY_DEFINITION( FinishedViewStepFactory, registerPlugin<FinishedViewStep>(); ) CALAMARES_PLUGIN_FACTORY_DEFINITION( FinishedViewStepFactory, registerPlugin<FinishedViewStep>(); )

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,15 +17,15 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FINISHEDPAGEPLUGIN_H #ifndef FINISHEDVIEWSTEP_H
#define FINISHEDPAGEPLUGIN_H #define FINISHEDVIEWSTEP_H
#include <QObject> #include <QObject>
#include <utils/PluginFactory.h> #include "utils/PluginFactory.h"
#include <viewpages/ViewStep.h> #include "viewpages/ViewStep.h"
#include <PluginDllMacro.h> #include "PluginDllMacro.h"
class FinishedPage; class FinishedPage;
@ -33,6 +34,14 @@ class PLUGINDLLEXPORT FinishedViewStep : public Calamares::ViewStep
Q_OBJECT Q_OBJECT
public: public:
enum class RestartMode
{
Never=0, ///< @brief Don't show button, just exit
UserUnchecked, ///< @brief Show button, starts unchecked
UserChecked, ///< @brief Show button, starts checked
Always ///< @brief Show button, can't change, checked
};
explicit FinishedViewStep( QObject* parent = nullptr ); explicit FinishedViewStep( QObject* parent = nullptr );
virtual ~FinishedViewStep() override; virtual ~FinishedViewStep() override;
@ -70,4 +79,4 @@ private:
CALAMARES_PLUGIN_FACTORY_DECLARATION( FinishedViewStepFactory ) CALAMARES_PLUGIN_FACTORY_DECLARATION( FinishedViewStepFactory )
#endif // FINISHEDPAGEPLUGIN_H #endif

@ -1,14 +1,37 @@
# Configuration for the "finished" page, which is usually shown only at # Configuration for the "finished" page, which is usually shown only at
# the end of the installation (successful or not). # the end of the installation (successful or not).
--- ---
# DEPRECATED
#
# The finished page can hold a "restart system now" checkbox. # The finished page can hold a "restart system now" checkbox.
# If this is false, no checkbox is shown and the system is not restarted # If this is false, no checkbox is shown and the system is not restarted
# when Calamares exits. # when Calamares exits.
restartNowEnabled: true # restartNowEnabled: true
# DEPRECATED
#
# Initial state of the checkbox "restart now". Only relevant when the # Initial state of the checkbox "restart now". Only relevant when the
# checkbox is shown by restartNowEnabled. # checkbox is shown by restartNowEnabled.
restartNowChecked: false # restartNowChecked: false
# Behavior of the "restart system now" button.
#
# There are four usable values:
# - never
# Does not show the button and does not restart.
# This matches the old behavior with restartNowEnabled=false.
# - user-unchecked
# Shows the button, defaults to unchecked, restarts if it is checked.
# This matches the old behavior with restartNowEnabled=true and restartNowChecked=false.
# - user-checked
# Shows the button, defaults to checked, restarts if it is checked.
# This matches the old behavior with restartNowEnabled=true and restartNowChecked=true.
# - always
# Shows the button, checked, but the user cannot change it.
# This is new behavior.
#
# The three combinations of legacy values are still supported.
restartNowMode: user-unchecked
# If the checkbox is shown, and the checkbox is checked, then when # If the checkbox is shown, and the checkbox is checked, then when
# Calamares exits from the finished-page it will run this command. # Calamares exits from the finished-page it will run this command.

Loading…
Cancel
Save