source: calamares/trunk/fuentes/src/modules/finished/FinishedPage.cpp @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 17 months ago

sync with github

File size: 3.2 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
4 *   Copyright 2017, Adriaan de Groot <groot@kde.org>
5 *
6 *   Calamares is free software: you can redistribute it and/or modify
7 *   it under the terms of the GNU General Public License as published by
8 *   the Free Software Foundation, either version 3 of the License, or
9 *   (at your option) any later version.
10 *
11 *   Calamares is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "FinishedPage.h"
21
22#include "ui_FinishedPage.h"
23#include "CalamaresVersion.h"
24#include "utils/Logger.h"
25#include "utils/CalamaresUtilsGui.h"
26#include "utils/Retranslator.h"
27#include "ViewManager.h"
28
29#include <QApplication>
30#include <QBoxLayout>
31#include <QFocusEvent>
32#include <QLabel>
33#include <QProcess>
34
35#include "Branding.h"
36
37
38FinishedPage::FinishedPage( QWidget* parent )
39    : QWidget( parent )
40    , ui( new Ui::FinishedPage )
41    , m_restartSetUp( false )
42{
43    ui->setupUi( this );
44
45    ui->mainText->setAlignment( Qt::AlignCenter );
46    ui->mainText->setWordWrap( true );
47    ui->mainText->setOpenExternalLinks( true );
48
49    CALAMARES_RETRANSLATE(
50        ui->retranslateUi( this );
51        ui->mainText->setText( tr( "<h1>All done.</h1><br/>"
52                                   "%1 has been installed on your computer.<br/>"
53                                   "You may now restart into your new system, or continue "
54                                   "using the %2 Live environment." )
55                               .arg( *Calamares::Branding::VersionedName )
56                               .arg( *Calamares::Branding::ProductName ) );
57    )
58}
59
60
61void
62FinishedPage::setRestartNowEnabled( bool enabled )
63{
64    ui->restartCheckBox->setVisible( enabled );
65}
66
67
68void
69FinishedPage::setRestartNowChecked( bool checked )
70{
71    ui->restartCheckBox->setChecked( checked );
72}
73
74
75void
76FinishedPage::setRestartNowCommand( const QString& command )
77{
78    m_restartNowCommand = command;
79}
80
81
82void
83FinishedPage::setUpRestart()
84{
85    cDebug() << "FinishedPage::setUpRestart()";
86    if ( !m_restartSetUp )
87    {
88        connect( qApp, &QApplication::aboutToQuit,
89                 this, [this]
90        {
91            if ( ui->restartCheckBox->isVisible() &&
92                    ui->restartCheckBox->isChecked() )
93                QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } );
94        } );
95    }
96}
97
98
99void
100FinishedPage::focusInEvent( QFocusEvent* e )
101{
102    e->accept();
103}
104
105void
106FinishedPage::onInstallationFailed( const QString& message, const QString& details )
107{
108    Q_UNUSED( details );
109    ui->mainText->setText( tr( "<h1>Installation Failed</h1><br/>"
110                               "%1 has not been installed on your computer.<br/>"
111                               "The error message was: %2." )
112                           .arg( *Calamares::Branding::VersionedName )
113                           .arg( message ) );
114    setRestartNowEnabled( false );
115}
Note: See TracBrowser for help on using the repository browser.