diff --git a/src/modules/finishedq/CMakeLists.txt b/src/modules/finishedq/CMakeLists.txt new file mode 100644 index 000000000..e1db7c767 --- /dev/null +++ b/src/modules/finishedq/CMakeLists.txt @@ -0,0 +1,34 @@ +# === This file is part of Calamares - === +# +# SPDX-FileCopyrightText: 2021 Anke Boersma +# SPDX-License-Identifier: BSD-2-Clause +# +if( NOT WITH_QML ) + calamares_skip_module( "finishedq (QML is not supported in this build)" ) + return() +endif() + +find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED DBus Network ) + +find_package( KF5Plasma CONFIG) +set_package_properties(KF5Plasma PROPERTIES + DESCRIPTION "Used for running commands in QML" + TYPE RUNTIME +) + +set( _finished ${CMAKE_CURRENT_SOURCE_DIR}/../finished ) +include_directories( ${_finished} ) + +calamares_add_plugin( finishedq + TYPE viewmodule + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + FinishedQmlViewStep.cpp + ${_finished}/Config.cpp + RESOURCES + finishedq.qrc + LINK_PRIVATE_LIBRARIES + calamaresui + Qt5::DBus + SHARED_LIB +) diff --git a/src/modules/finishedq/FinishedQmlViewStep.cpp b/src/modules/finishedq/FinishedQmlViewStep.cpp new file mode 100644 index 000000000..81a8004ca --- /dev/null +++ b/src/modules/finishedq/FinishedQmlViewStep.cpp @@ -0,0 +1,100 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac + * SPDX-FileCopyrightText: 2017 2019, Adriaan de Groot + * SPDX-FileCopyrightText: 2019 Collabora Ltd + * SPDX-FileCopyrightText: 2021 Anke Boersma + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#include "FinishedQmlViewStep.h" + +#include "Config.h" + +#include "JobQueue.h" +#include + +CALAMARES_PLUGIN_FACTORY_DEFINITION( FinishedQmlViewStepFactory, registerPlugin< FinishedQmlViewStep >(); ) + +FinishedQmlViewStep::FinishedQmlViewStep( QObject* parent ) + : Calamares::QmlViewStep( parent ) + , m_config( new Config( this ) ) + , m_installFailed( false ) +{ + auto jq = Calamares::JobQueue::instance(); + connect( jq, &Calamares::JobQueue::failed, this, &FinishedQmlViewStep::onInstallationFailed ); + + emit nextStatusChanged( true ); +} + +QString +FinishedQmlViewStep::prettyName() const +{ + return tr( "Finish" ); +} + +bool +FinishedQmlViewStep::isNextEnabled() const +{ + return false; +} + + +bool +FinishedQmlViewStep::isBackEnabled() const +{ + return false; +} + + +bool +FinishedQmlViewStep::isAtBeginning() const +{ + return true; +} + + +bool +FinishedQmlViewStep::isAtEnd() const +{ + return true; +} + + +void +FinishedQmlViewStep::onActivate() +{ + m_config->doNotify( m_installFailed ); + //connect( qApp, &QApplication::aboutToQuit, m_config, &Config::doRestart ); + QmlViewStep::onActivate(); +} + + +Calamares::JobList +FinishedQmlViewStep::jobs() const +{ + return Calamares::JobList(); +} + +QObject* +FinishedQmlViewStep::getConfig() +{ + return m_config; +} + +void +FinishedQmlViewStep::onInstallationFailed( const QString& message, const QString& details ) +{ + m_installFailed = true; + m_config->setRestartNowMode( Config::RestartMode::Never ); +} + +void +FinishedQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +{ + m_config->setConfigurationMap( configurationMap ); + Calamares::QmlViewStep::setConfigurationMap( configurationMap ); +} diff --git a/src/modules/finishedq/FinishedQmlViewStep.h b/src/modules/finishedq/FinishedQmlViewStep.h new file mode 100644 index 000000000..e8eb58215 --- /dev/null +++ b/src/modules/finishedq/FinishedQmlViewStep.h @@ -0,0 +1,60 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac + * SPDX-FileCopyrightText: 2019 Adriaan de Groot + * SPDX-FileCopyrightText: 2021 Anke Boersma + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#ifndef FINISHEDQMLVIEWSTEP_H +#define FINISHEDQMLVIEWSTEP_H + +#include + +#include "Config.h" + +#include "DllMacro.h" +#include "utils/PluginFactory.h" +#include "viewpages/QmlViewStep.h" + +#include + +class Config; + +class PLUGINDLLEXPORT FinishedQmlViewStep : public Calamares::QmlViewStep +{ + Q_OBJECT + +public: + explicit FinishedQmlViewStep( QObject* parent = nullptr ); + + QString prettyName() const override; + + bool isNextEnabled() const override; + bool isBackEnabled() const override; + + bool isAtBeginning() const override; + bool isAtEnd() const override; + + void onActivate() override; + + Calamares::JobList jobs() const override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; + QObject* getConfig() override; + +public slots: + void onInstallationFailed( const QString& message, const QString& details ); + +private: + Config* m_config; + + bool m_installFailed; // Track if onInstallationFailed() was called +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( FinishedQmlViewStepFactory ) + +#endif diff --git a/src/modules/finishedq/finishedq.conf b/src/modules/finishedq/finishedq.conf new file mode 100644 index 000000000..9cd42b016 --- /dev/null +++ b/src/modules/finishedq/finishedq.conf @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +# Configuration for the "finishedq" page, which is usually shown only at +# the end of the installation (successful or not). +--- +# 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 +# Calamares exits from the finished-page it will run this command. +# If not set, falls back to "shutdown -r now". +restartNowCommand: "systemctl -i reboot" + +# When the last page is (successfully) reached, send a DBus notification +# to the desktop that the installation is done. This works only if the +# user as whom Calamares is run, can reach the regular desktop session bus. +notifyOnFinished: false diff --git a/src/modules/finishedq/finishedq.qml b/src/modules/finishedq/finishedq.qml new file mode 100644 index 000000000..215626a1c --- /dev/null +++ b/src/modules/finishedq/finishedq.qml @@ -0,0 +1,106 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Anke Boersma + * SPDX-License-Identifier: GPL-3.0-or-later + * License-Filename: LICENSE + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +import io.calamares.core 1.0 +import io.calamares.ui 1.0 + +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.3 +import org.kde.kirigami 2.7 as Kirigami +import QtGraphicalEffects 1.0 +import QtQuick.Window 2.3 + +import org.kde.plasma.core 2.0 as PlasmaCore + +Page { + + id: finished + + width: parent.width + height: parent.height + + header: Kirigami.Heading { + width: parent.width + height: 100 + id: header + Layout.fillWidth: true + horizontalAlignment: Qt.AlignHCenter + color: Kirigami.Theme.textColor + level: 1 + text: qsTr("Installation Completed") + + Text { + anchors.top: header.bottom + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + font.pointSize: 12 + text: qsTr("%1 has been installed on your computer.
+ You may now restart into your new system, or continue using the Live environment.").arg(Branding.string(Branding.ProductName)) + } + + Image { + source: "seedling.svg" + anchors.top: header.bottom + anchors.topMargin: 80 + anchors.horizontalCenter: parent.horizontalCenter + width: 64 + height: 64 + mipmap: true + } + } + + RowLayout { + Layout.alignment: Qt.AlignRight|Qt.AlignVCenter + anchors.centerIn: parent + spacing: 6 + + PlasmaCore.DataSource { + id: executer + engine: "executable" + onNewData: {executer.disconnectSource(sourceName);} + } + + Button { + id: button + text: qsTr("Close Installer") + icon.name: "application-exit" + onClicked: { ViewManager.quit(); } + //onClicked: console.log("close calamares"); + } + + Button { + text: qsTr("Restart System") + icon.name: "system-reboot" + //onClicked: { config.doRestart(); } + onClicked: { + executer.connectSource("systemctl -i reboot"); + } + } + } + + Item { + + Layout.fillHeight: true + Layout.fillWidth: true + anchors.bottom: parent.bottom + anchors.bottomMargin : 100 + anchors.horizontalCenter: parent.horizontalCenter + + Text { + anchors.centerIn: parent + anchors.top: parent.top + horizontalAlignment: Text.AlignHCenter + text: qsTr("

A full log of the install is available as installation.log in the home directory of the Live user.
+ This log is copied to /var/log/installation.log of the target system.

") + } + } + +} diff --git a/src/modules/finishedq/finishedq.qrc b/src/modules/finishedq/finishedq.qrc new file mode 100644 index 000000000..e0918eb7f --- /dev/null +++ b/src/modules/finishedq/finishedq.qrc @@ -0,0 +1,6 @@ + + + finishedq.qml + seedling.svg + + diff --git a/src/modules/finishedq/seedling.svg b/src/modules/finishedq/seedling.svg new file mode 100644 index 000000000..8f3501b17 --- /dev/null +++ b/src/modules/finishedq/seedling.svg @@ -0,0 +1 @@ +