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>
|
2018-06-15 11:59:11 +02:00
|
|
|
* Copyright 2017-2018, 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 "FinishedPage.h"
|
|
|
|
|
|
|
|
#include "ui_FinishedPage.h"
|
|
|
|
#include "CalamaresVersion.h"
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
|
|
|
#include "utils/Retranslator.h"
|
|
|
|
#include "ViewManager.h"
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QFocusEvent>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QProcess>
|
|
|
|
|
|
|
|
#include "Branding.h"
|
2019-04-08 17:55:03 +02:00
|
|
|
#include "Settings.h"
|
2015-01-29 22:45:39 +01:00
|
|
|
|
|
|
|
FinishedPage::FinishedPage( QWidget* parent )
|
|
|
|
: QWidget( parent )
|
|
|
|
, ui( new Ui::FinishedPage )
|
|
|
|
, m_restartSetUp( false )
|
|
|
|
{
|
|
|
|
ui->setupUi( this );
|
|
|
|
|
|
|
|
ui->mainText->setAlignment( Qt::AlignCenter );
|
|
|
|
ui->mainText->setWordWrap( true );
|
|
|
|
ui->mainText->setOpenExternalLinks( true );
|
|
|
|
|
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
ui->retranslateUi( this );
|
2019-04-08 17:55:03 +02:00
|
|
|
if ( Calamares::Settings::instance()->isSetupMode() )
|
|
|
|
{
|
|
|
|
ui->mainText->setText( tr( "<h1>All done.</h1><br/>"
|
|
|
|
"%1 has been set up on your computer.<br/>"
|
|
|
|
"You may now start using your new system." )
|
2019-04-15 14:42:06 +02:00
|
|
|
.arg( *Calamares::Branding::VersionedName ) );
|
2019-04-08 17:55:03 +02:00
|
|
|
ui->restartCheckBox->setToolTip( tr ( "<html><head/><body>"
|
|
|
|
"<p>When this box is checked, your system will "
|
|
|
|
"restart immediately when you click on "
|
|
|
|
"<span style=\"font-style:italic;\">Done</span> "
|
|
|
|
"or close the setup program.</p></body></html>" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->mainText->setText( tr( "<h1>All done.</h1><br/>"
|
|
|
|
"%1 has been installed on your computer.<br/>"
|
|
|
|
"You may now restart into your new system, or continue "
|
|
|
|
"using the %2 Live environment." )
|
2019-04-15 14:42:06 +02:00
|
|
|
.arg( *Calamares::Branding::VersionedName, *Calamares::Branding::ProductName ) );
|
2019-04-08 17:55:03 +02:00
|
|
|
ui->restartCheckBox->setToolTip( tr ( "<html><head/><body>"
|
|
|
|
"<p>When this box is checked, your system will "
|
|
|
|
"restart immediately when you click on "
|
|
|
|
"<span style=\"font-style:italic;\">Done</span> "
|
|
|
|
"or close the installer.</p></body></html>" ) );
|
|
|
|
}
|
2015-01-29 22:45:39 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
FinishedPage::setRestartNowEnabled( bool enabled )
|
|
|
|
{
|
|
|
|
ui->restartCheckBox->setVisible( enabled );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
FinishedPage::setRestartNowChecked( bool checked )
|
|
|
|
{
|
|
|
|
ui->restartCheckBox->setChecked( checked );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
FinishedPage::setRestartNowCommand( const QString& command )
|
|
|
|
{
|
|
|
|
m_restartNowCommand = command;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
FinishedPage::setUpRestart()
|
|
|
|
{
|
2017-07-03 17:04:23 +02:00
|
|
|
cDebug() << "FinishedPage::setUpRestart()";
|
2015-01-29 22:45:39 +01:00
|
|
|
if ( !m_restartSetUp )
|
|
|
|
{
|
|
|
|
connect( qApp, &QApplication::aboutToQuit,
|
|
|
|
this, [this]
|
|
|
|
{
|
|
|
|
if ( ui->restartCheckBox->isVisible() &&
|
2017-09-25 16:35:58 +02:00
|
|
|
ui->restartCheckBox->isChecked() )
|
2015-02-04 11:25:01 +01:00
|
|
|
QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } );
|
2015-01-29 22:45:39 +01:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
FinishedPage::focusInEvent( QFocusEvent* e )
|
|
|
|
{
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
2017-07-03 17:04:23 +02:00
|
|
|
void
|
|
|
|
FinishedPage::onInstallationFailed( const QString& message, const QString& details )
|
|
|
|
{
|
2019-04-17 11:57:46 +02:00
|
|
|
Q_UNUSED( details )
|
2019-04-08 17:55:03 +02:00
|
|
|
if ( Calamares::Settings::instance()->isSetupMode() )
|
|
|
|
ui->mainText->setText( tr( "<h1>Setup Failed</h1><br/>"
|
|
|
|
"%1 has not been set up on your computer.<br/>"
|
|
|
|
"The error message was: %2." )
|
|
|
|
.arg( *Calamares::Branding::VersionedName )
|
|
|
|
.arg( message ) );
|
|
|
|
else
|
|
|
|
ui->mainText->setText( tr( "<h1>Installation Failed</h1><br/>"
|
|
|
|
"%1 has not been installed on your computer.<br/>"
|
|
|
|
"The error message was: %2." )
|
|
|
|
.arg( *Calamares::Branding::VersionedName )
|
|
|
|
.arg( message ) );
|
2017-07-03 17:04:23 +02:00
|
|
|
setRestartNowEnabled( false );
|
|
|
|
}
|