2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2015-01-29 22:45:39 +01:00
|
|
|
*
|
|
|
|
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
2017-07-03 17:36:36 +02:00
|
|
|
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
2019-04-08 17:55:03 +02:00
|
|
|
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
|
2015-01-29 22:45:39 +01:00
|
|
|
*
|
|
|
|
* Calamares is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "FinishedViewStep.h"
|
|
|
|
#include "FinishedPage.h"
|
2017-07-03 17:04:23 +02:00
|
|
|
#include "JobQueue.h"
|
|
|
|
|
|
|
|
#include "utils/Logger.h"
|
2015-01-29 22:45:39 +01:00
|
|
|
|
2017-08-21 23:48:27 +02:00
|
|
|
#include <QtDBus/QDBusConnection>
|
|
|
|
#include <QtDBus/QDBusInterface>
|
|
|
|
#include <QtDBus/QDBusReply>
|
2015-01-29 22:45:39 +01:00
|
|
|
#include <QVariantMap>
|
|
|
|
|
2017-08-21 23:48:27 +02:00
|
|
|
#include "Branding.h"
|
2019-04-08 17:55:03 +02:00
|
|
|
#include "Settings.h"
|
2017-08-21 23:48:27 +02:00
|
|
|
|
2015-01-29 22:45:39 +01:00
|
|
|
FinishedViewStep::FinishedViewStep( QObject* parent )
|
|
|
|
: Calamares::ViewStep( parent )
|
|
|
|
, m_widget( new FinishedPage() )
|
2017-08-23 11:25:07 +02:00
|
|
|
, installFailed( false )
|
2017-09-25 16:22:03 +02:00
|
|
|
, m_notifyOnFinished( false )
|
2015-01-29 22:45:39 +01:00
|
|
|
{
|
2017-08-23 11:25:07 +02:00
|
|
|
auto jq = Calamares::JobQueue::instance();
|
|
|
|
connect( jq, &Calamares::JobQueue::failed,
|
2017-08-21 23:48:27 +02:00
|
|
|
m_widget, &FinishedPage::onInstallationFailed );
|
2017-08-23 11:25:07 +02:00
|
|
|
connect( jq, &Calamares::JobQueue::failed,
|
|
|
|
this, &FinishedViewStep::onInstallationFailed );
|
2017-07-03 17:04:23 +02:00
|
|
|
|
2015-01-29 22:45:39 +01:00
|
|
|
emit nextStatusChanged( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FinishedViewStep::~FinishedViewStep()
|
|
|
|
{
|
|
|
|
if ( m_widget && m_widget->parent() == nullptr )
|
|
|
|
m_widget->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
FinishedViewStep::prettyName() const
|
|
|
|
{
|
2015-09-09 18:45:52 +02:00
|
|
|
return tr( "Finish" );
|
2015-01-29 22:45:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget*
|
|
|
|
FinishedViewStep::widget()
|
|
|
|
{
|
|
|
|
return m_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
FinishedViewStep::isNextEnabled() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
FinishedViewStep::isBackEnabled() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
FinishedViewStep::isAtBeginning() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
FinishedViewStep::isAtEnd() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-08-21 23:48:27 +02:00
|
|
|
void
|
|
|
|
FinishedViewStep::sendNotification()
|
|
|
|
{
|
2017-08-23 11:25:07 +02:00
|
|
|
// If the installation failed, don't send notification popup;
|
|
|
|
// there's a (modal) dialog popped up with the failure notice.
|
2017-09-25 16:35:58 +02:00
|
|
|
if ( installFailed )
|
2017-08-23 11:25:07 +02:00
|
|
|
return;
|
|
|
|
|
2017-08-21 23:48:27 +02:00
|
|
|
QDBusInterface notify( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" );
|
|
|
|
if ( notify.isValid() )
|
|
|
|
{
|
|
|
|
QDBusReply<uint> r = notify.call( "Notify",
|
|
|
|
QString( "Calamares" ),
|
|
|
|
QVariant( 0U ),
|
|
|
|
QString( "calamares" ),
|
2019-04-08 17:55:03 +02:00
|
|
|
Calamares::Settings::instance()->isSetupMode()
|
|
|
|
? tr( "Setup Complete" )
|
|
|
|
: tr( "Installation Complete" ),
|
|
|
|
Calamares::Settings::instance()->isSetupMode()
|
|
|
|
? tr( "The setup of %1 is complete." ).arg( *Calamares::Branding::VersionedName )
|
|
|
|
: tr( "The installation of %1 is complete." ).arg( *Calamares::Branding::VersionedName ),
|
2017-08-21 23:48:27 +02:00
|
|
|
QStringList(),
|
|
|
|
QVariantMap(),
|
|
|
|
QVariant( 0 )
|
|
|
|
);
|
|
|
|
if ( !r.isValid() )
|
|
|
|
cDebug() << "Could not call notify for end of installation." << r.error();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cDebug() << "Could not get dbus interface for notifications." << notify.lastError();
|
|
|
|
}
|
|
|
|
|
2015-01-29 22:45:39 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
FinishedViewStep::onActivate()
|
|
|
|
{
|
|
|
|
m_widget->setUpRestart();
|
2017-08-21 23:48:27 +02:00
|
|
|
|
2017-09-25 16:22:03 +02:00
|
|
|
if ( m_notifyOnFinished )
|
|
|
|
sendNotification();
|
2015-01-29 22:45:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QList< Calamares::job_ptr >
|
|
|
|
FinishedViewStep::jobs() const
|
|
|
|
{
|
|
|
|
return QList< Calamares::job_ptr >();
|
|
|
|
}
|
|
|
|
|
2017-08-23 11:25:07 +02:00
|
|
|
void
|
|
|
|
FinishedViewStep::onInstallationFailed( const QString& message, const QString& details )
|
|
|
|
{
|
2017-09-25 16:35:58 +02:00
|
|
|
Q_UNUSED( message );
|
|
|
|
Q_UNUSED( details );
|
2017-08-23 11:25:07 +02:00
|
|
|
installFailed = true;
|
|
|
|
}
|
2015-01-29 22:45:39 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
{
|
|
|
|
if ( configurationMap.contains( "restartNowEnabled" ) &&
|
2017-08-21 23:48:27 +02:00
|
|
|
configurationMap.value( "restartNowEnabled" ).type() == QVariant::Bool )
|
2015-01-29 22:45:39 +01:00
|
|
|
{
|
|
|
|
bool restartNowEnabled = configurationMap.value( "restartNowEnabled" ).toBool();
|
|
|
|
|
2015-11-06 14:57:01 +01:00
|
|
|
m_widget->setRestartNowEnabled( restartNowEnabled );
|
2015-01-29 22:45:39 +01:00
|
|
|
if ( restartNowEnabled )
|
|
|
|
{
|
|
|
|
if ( configurationMap.contains( "restartNowChecked" ) &&
|
2017-08-21 23:48:27 +02:00
|
|
|
configurationMap.value( "restartNowChecked" ).type() == QVariant::Bool )
|
2015-01-29 22:45:39 +01:00
|
|
|
m_widget->setRestartNowChecked( configurationMap.value( "restartNowChecked" ).toBool() );
|
2016-06-09 17:23:40 +02:00
|
|
|
|
|
|
|
if ( configurationMap.contains( "restartNowCommand" ) &&
|
2017-08-21 23:48:27 +02:00
|
|
|
configurationMap.value( "restartNowCommand" ).type() == QVariant::String )
|
2015-01-29 22:45:39 +01:00
|
|
|
m_widget->setRestartNowCommand( configurationMap.value( "restartNowCommand" ).toString() );
|
2016-06-09 17:23:40 +02:00
|
|
|
else
|
2017-10-04 13:13:33 +02:00
|
|
|
m_widget->setRestartNowCommand( "shutdown -r now" );
|
2015-01-29 22:45:39 +01:00
|
|
|
}
|
|
|
|
}
|
2017-09-25 16:22:03 +02:00
|
|
|
if ( configurationMap.contains( "notifyOnFinished" ) &&
|
2017-09-25 16:35:58 +02:00
|
|
|
configurationMap.value( "notifyOnFinished" ).type() == QVariant::Bool )
|
2017-09-25 16:22:03 +02:00
|
|
|
m_notifyOnFinished = configurationMap.value( "notifyOnFinished" ).toBool();
|
2015-01-29 22:45:39 +01:00
|
|
|
}
|
|
|
|
|
2015-09-09 18:45:52 +02:00
|
|
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( FinishedViewStepFactory, registerPlugin<FinishedViewStep>(); )
|