Merge pull request #1647 from demmm/calamares

[finishedq] adding QML finished module
This commit is contained in:
Adriaan de Groot 2021-03-05 12:24:16 +01:00 committed by GitHub
commit 1739d8f15f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 341 additions and 0 deletions

View File

@ -0,0 +1,34 @@
# === This file is part of Calamares - <https://calamares.io> ===
#
# SPDX-FileCopyrightText: 2021 Anke Boersma <demm@kaosx.us>
# 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
)

View File

@ -0,0 +1,100 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
* SPDX-FileCopyrightText: 2017 2019, Adriaan de Groot <groot@kde.org>
* SPDX-FileCopyrightText: 2019 Collabora Ltd <arnaud.ferraris@collabora.com>
* SPDX-FileCopyrightText: 2021 Anke Boersma <demm@kaosx.us>
* 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 <QApplication>
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 );
}

View File

@ -0,0 +1,60 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
* SPDX-FileCopyrightText: 2021 Anke Boersma <demm@kaosx.us>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*/
#ifndef FINISHEDQMLVIEWSTEP_H
#define FINISHEDQMLVIEWSTEP_H
#include <QObject>
#include "Config.h"
#include "DllMacro.h"
#include "utils/PluginFactory.h"
#include "viewpages/QmlViewStep.h"
#include <QVariant>
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

View File

@ -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

View File

@ -0,0 +1,106 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* SPDX-FileCopyrightText: 2021 Anke Boersma <demm@kaosx.us>
* 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.<br/>
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("<p>A full log of the install is available as installation.log in the home directory of the Live user.<br/>
This log is copied to /var/log/installation.log of the target system.</p>")
}
}
}

View File

@ -0,0 +1,6 @@
<RCC>
<qresource>
<file>finishedq.qml</file>
<file>seedling.svg</file>
</qresource>
</RCC>

View File

@ -0,0 +1 @@
<svg aria-hidden="true" focusable="false" data-icon="seedling" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M64 96H0c0 123.7 100.3 224 224 224v144c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16V320C288 196.3 187.7 96 64 96zm384-64c-84.2 0-157.4 46.5-195.7 115.2 27.7 30.2 48.2 66.9 59 107.6C424 243.1 512 147.9 512 32h-64z"></path></svg>

After

Width:  |  Height:  |  Size: 384 B