diff --git a/src/modules/finished/CMakeLists.txt b/src/modules/finished/CMakeLists.txt new file mode 100644 index 000000000..ce6cfd1d8 --- /dev/null +++ b/src/modules/finished/CMakeLists.txt @@ -0,0 +1,13 @@ +include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) +calamares_add_plugin( finished + TYPE viewmodule + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + FinishedViewStep.cpp + FinishedPage.cpp + UI + FinishedPage.ui + LINK_LIBRARIES + calamaresui + SHARED_LIB +) diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp new file mode 100644 index 000000000..f95fc702a --- /dev/null +++ b/src/modules/finished/FinishedPage.cpp @@ -0,0 +1,104 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014-2015, Teo Mrnjavac + * + * 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 . + */ + +#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 +#include +#include +#include +#include + +#include "Branding.h" + + +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 ); + ui->mainText->setText( tr( "

All done.


" + "%1 has been installed on your computer.
" + "You may now restart into your new system, or continue " + "using the %2 Live environment." ) + .arg( Calamares::Branding::instance()-> + string( Calamares::Branding::VersionedName ) ) + .arg( Calamares::Branding::instance()-> + string( Calamares::Branding::ProductName ) ) ); + ) +} + + +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() +{ + if ( !m_restartSetUp ) + { + connect( qApp, &QApplication::aboutToQuit, + this, [this] + { + if ( ui->restartCheckBox->isVisible() && + ui->restartCheckBox->isChecked() ) + QProcess::execute( "/bin/sh", { m_restartNowCommand } ); + } ); + } +} + + +void +FinishedPage::focusInEvent( QFocusEvent* e ) +{ + e->accept(); +} + diff --git a/src/modules/finished/FinishedPage.h b/src/modules/finished/FinishedPage.h new file mode 100644 index 000000000..31930a6f1 --- /dev/null +++ b/src/modules/finished/FinishedPage.h @@ -0,0 +1,52 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014-2015, Teo Mrnjavac + * + * 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 . + */ + +#ifndef FINISHEDPAGE_H +#define FINISHEDPAGE_H + +#include + +namespace Ui +{ +class FinishedPage; +} + +class FinishedPage : public QWidget +{ + Q_OBJECT +public: + explicit FinishedPage( QWidget* parent = nullptr ); + + void setRestartNowEnabled( bool enabled ); + void setRestartNowChecked( bool checked ); + void setRestartNowCommand( const QString& command ); + + void setUpRestart(); + +protected: + void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus + +private: + Ui::FinishedPage* ui; + + QString m_restartNowCommand; + + bool m_restartSetUp; +}; + +#endif // FINISHEDPAGE_H diff --git a/src/modules/finished/FinishedPage.ui b/src/modules/finished/FinishedPage.ui new file mode 100644 index 000000000..09571afd3 --- /dev/null +++ b/src/modules/finished/FinishedPage.ui @@ -0,0 +1,106 @@ + + + FinishedPage + + + + 0 + 0 + 593 + 400 + + + + Form + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 50 + + + + + + + + + 3 + 0 + + + + <Calamares finished text> + + + + + + + Qt::Vertical + + + + 20 + 49 + + + + + + + + + + &Restart now + + + false + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp new file mode 100644 index 000000000..a5a77919b --- /dev/null +++ b/src/modules/finished/FinishedViewStep.cpp @@ -0,0 +1,131 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014-2015, Teo Mrnjavac + * + * 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 . + */ + +#include "FinishedViewStep.h" + +#include "FinishedPage.h" + +#include + +FinishedViewStep::FinishedViewStep( QObject* parent ) + : Calamares::ViewStep( parent ) + , m_widget( new FinishedPage() ) +{ + emit nextStatusChanged( true ); +} + + +FinishedViewStep::~FinishedViewStep() +{ + if ( m_widget && m_widget->parent() == nullptr ) + m_widget->deleteLater(); +} + + +QString +FinishedViewStep::prettyName() const +{ + return tr( "All done" ); +} + + +QWidget* +FinishedViewStep::widget() +{ + return m_widget; +} + + +void +FinishedViewStep::next() +{ + emit done(); +} + + +void +FinishedViewStep::back() +{} + + +bool +FinishedViewStep::isNextEnabled() const +{ + return false; +} + + +bool +FinishedViewStep::isBackEnabled() const +{ + return false; +} + + +bool +FinishedViewStep::isAtBeginning() const +{ + return true; +} + + +bool +FinishedViewStep::isAtEnd() const +{ + return true; +} + + +void +FinishedViewStep::onActivate() +{ + m_widget->setUpRestart(); +} + + +QList< Calamares::job_ptr > +FinishedViewStep::jobs() const +{ + return QList< Calamares::job_ptr >(); +} + + +void +FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +{ + if ( configurationMap.contains( "restartNowEnabled" ) && + configurationMap.value( "restartNowEnabled" ).type() == QVariant::Bool ) + { + bool restartNowEnabled = configurationMap.value( "restartNowEnabled" ).toBool(); + + if ( restartNowEnabled ) + { + m_widget->setRestartNowEnabled( restartNowEnabled ); + + if ( configurationMap.contains( "restartNowChecked" ) && + configurationMap.value( "restartNowChecked" ).type() == QVariant::Bool && + configurationMap.contains( "restartNowCommand" ) && + configurationMap.value( "restartNowCommand" ).type() == QVariant::String ) + { + m_widget->setRestartNowChecked( configurationMap.value( "restartNowChecked" ).toBool() ); + m_widget->setRestartNowCommand( configurationMap.value( "restartNowCommand" ).toString() ); + } + } + } +} + diff --git a/src/modules/finished/FinishedViewStep.h b/src/modules/finished/FinishedViewStep.h new file mode 100644 index 000000000..ba1f887d8 --- /dev/null +++ b/src/modules/finished/FinishedViewStep.h @@ -0,0 +1,63 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014-2015, Teo Mrnjavac + * + * 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 . + */ + +#ifndef FINISHEDPAGEPLUGIN_H +#define FINISHEDPAGEPLUGIN_H + +#include + +#include "viewpages/ViewStep.h" +#include "PluginDllMacro.h" + +class FinishedPage; + +class PLUGINDLLEXPORT FinishedViewStep : public Calamares::ViewStep +{ + Q_OBJECT + Q_PLUGIN_METADATA( IID "calamares.ViewModule/1.0" ) + + Q_INTERFACES( Calamares::ViewStep ) + +public: + explicit FinishedViewStep( QObject* parent = nullptr ); + virtual ~FinishedViewStep(); + + QString prettyName() const override; + + QWidget* widget() override; + + void next() override; + void back() override; + + bool isNextEnabled() const override; + bool isBackEnabled() const override; + + bool isAtBeginning() const override; + bool isAtEnd() const override; + + void onActivate() override; + + QList< Calamares::job_ptr > jobs() const override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; + +private: + FinishedPage* m_widget; +}; + +#endif // FINISHEDPAGEPLUGIN_H diff --git a/src/modules/finished/finished.conf b/src/modules/finished/finished.conf new file mode 100644 index 000000000..f93acb587 --- /dev/null +++ b/src/modules/finished/finished.conf @@ -0,0 +1,4 @@ +--- +restartNowEnabled: true +restartNowChecked: false +restartNowCommand: "systemctl -i reboot" diff --git a/src/modules/finished/module.desc b/src/modules/finished/module.desc new file mode 100644 index 000000000..bc3e628c6 --- /dev/null +++ b/src/modules/finished/module.desc @@ -0,0 +1,7 @@ +# Module metadata file for greeting viewmodule +# Syntax is YAML 1.2 +--- +type: "view" #core or view +name: "finished" #the module name. must be unique and same as the parent directory +interface: "qtplugin" #can be: qtplugin, python, process, ... +load: "libcalamares_viewmodule_finished.so"