diff --git a/src/modules/summaryq/CMakeLists.txt b/src/modules/summaryq/CMakeLists.txt new file mode 100644 index 000000000..0df854140 --- /dev/null +++ b/src/modules/summaryq/CMakeLists.txt @@ -0,0 +1,22 @@ +if( NOT WITH_QML ) + calamares_skip_module( "summaryq (QML is not supported in this build)" ) + return() +endif() + +set( _summary ${CMAKE_CURRENT_SOURCE_DIR}/../summary ) +include_directories( ${_finished} ) + +include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) +calamares_add_plugin( summaryq + TYPE viewmodule + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + SummaryQmlViewStep.cpp + Config.cpp + UI + RESOURCES + summaryq.qrc + LINK_PRIVATE_LIBRARIES + calamaresui + SHARED_LIB +) diff --git a/src/modules/summaryq/Config.cpp b/src/modules/summaryq/Config.cpp new file mode 100644 index 000000000..64e43a0ba --- /dev/null +++ b/src/modules/summaryq/Config.cpp @@ -0,0 +1,114 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2020, Camilo Higuita + * SPDX-FileCopyrightText: 2021 Anke Boersma + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#include "Config.h" +#include "SummaryQmlViewStep.h" + +#include "Branding.h" +#include "Settings.h" +#include "ViewManager.h" + +#include "utils/CalamaresUtilsGui.h" +#include "utils/Logger.h" +#include "utils/Retranslator.h" +#include "viewpages/ExecutionViewStep.h" + +SummaryModel::SummaryModel(QObject* parent) : QAbstractListModel(parent) +{} + +QHash SummaryModel::roleNames() const +{ + return { { Qt::DisplayRole, "title" }, { Qt::UserRole, "message" } }; +} + +QVariant SummaryModel::data(const QModelIndex& index, int role) const +{ + if ( !index.isValid() ) + { + return QVariant(); + } + const auto item = m_summary.at( index.row() ); + return role == Qt::DisplayRole ? item->title : item->message; +} + +int SummaryModel::rowCount(const QModelIndex&) const +{ + return m_summary.count(); +} + +void SummaryModel::setSummary(const Calamares::ViewStepList& steps) +{ + m_summary.clear(); + Q_EMIT beginResetModel(); + + for ( Calamares::ViewStep* step : steps ) + { + QString text = step->prettyStatus(); + QWidget* widget = step->createSummaryWidget(); + + if ( text.isEmpty() && !widget ) + continue; + + m_summary << new StepSummary {step->prettyName(), text}; + + } + Q_EMIT endResetModel(); +} + +Config::Config(QObject *parent) : QObject(parent) +, m_thisViewStep(static_cast(parent)) +, m_summary( new SummaryModel(this) ) +{ + m_title = m_thisViewStep->prettyName(); + + if ( Calamares::Settings::instance()->isSetupMode() ) + m_message =( tr( "This is an overview of what will happen once you start " + "the setup procedure." ) ); + else + m_message = ( tr( "This is an overview of what will happen once you start " + "the install procedure." ) ); +} + +void Config::componentComplete() +{ + refresh(); +} + +void Config::refresh() +{ + m_summary->setSummary( stepsForSummary( Calamares::ViewManager::instance()->viewSteps() )); +} + +void Config::init() +{ + refresh(); +} + +Calamares::ViewStepList Config::stepsForSummary( const Calamares::ViewStepList& allSteps ) const +{ + Calamares::ViewStepList steps; + for ( Calamares::ViewStep* step : allSteps ) + { + if ( qobject_cast< Calamares::ExecutionViewStep* >( step ) ) + { + steps.clear(); + continue; + } + + if ( m_thisViewStep == step ) + break; + + steps.append( step ); + } + + return steps; +} + + diff --git a/src/modules/summaryq/Config.h b/src/modules/summaryq/Config.h new file mode 100644 index 000000000..162ff2c5f --- /dev/null +++ b/src/modules/summaryq/Config.h @@ -0,0 +1,75 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2019-2020, Adriaan de Groot + * SPDX-FileCopyrightText: 2020, Camilo Higuita + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#ifndef SUMMARY_CONFIG_H +#define SUMMARY_CONFIG_H + +#include +#include +#include +#include "viewpages/ViewStep.h" + +class SummaryQmlViewStep; + +struct StepSummary +{ + QString title; + QString message; +}; + +class SummaryModel : public QAbstractListModel +{ + Q_OBJECT +public: + explicit SummaryModel(QObject *parent = nullptr); + int rowCount( const QModelIndex& = QModelIndex() ) const override; + QVariant data( const QModelIndex& index, int role ) const override; + + void setSummary(const Calamares::ViewStepList &steps); + +protected: + QHash< int, QByteArray > roleNames() const override; +private: + QVector m_summary; +}; + +class Config : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_PROPERTY(QString message MEMBER m_message NOTIFY messageChanged CONSTANT) + Q_PROPERTY(QString title MEMBER m_title NOTIFY titleChanged CONSTANT) + Q_PROPERTY(SummaryModel * summaryModel READ summaryModel CONSTANT FINAL) + +public: + explicit Config(QObject *parent = nullptr); + virtual void componentComplete() override; + virtual void classBegin() override {} + + void refresh(); + void init(); + + SummaryModel * summaryModel() const + { + return m_summary; + } + +private: + Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const; + const SummaryQmlViewStep* m_thisViewStep; + SummaryModel *m_summary; + + QString m_message; + QString m_title; + +signals: + void messageChanged(); + void titleChanged(); +}; +#endif diff --git a/src/modules/summaryq/SummaryQmlViewStep.cpp b/src/modules/summaryq/SummaryQmlViewStep.cpp new file mode 100644 index 000000000..8f7360212 --- /dev/null +++ b/src/modules/summaryq/SummaryQmlViewStep.cpp @@ -0,0 +1,75 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2014-2015, Teo Mrnjavac + * SPDX-FileCopyrightText: 2020, Camilo Higuita + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#include "SummaryQmlViewStep.h" + +CALAMARES_PLUGIN_FACTORY_DEFINITION( SummaryQmlViewStepFactory, registerPlugin(); ) + +SummaryQmlViewStep::SummaryQmlViewStep( QObject* parent ) + : Calamares::QmlViewStep( parent ) + , m_config( new Config( this ) ) +{ + emit nextStatusChanged( true ); +} + + +SummaryQmlViewStep::~SummaryQmlViewStep() +{ + +} + +QString +SummaryQmlViewStep::prettyName() const +{ + return tr( "Summary" ); +} + + +bool +SummaryQmlViewStep::isNextEnabled() const +{ + return true; +} + + +bool +SummaryQmlViewStep::isBackEnabled() const +{ + return true; +} + + +bool +SummaryQmlViewStep::isAtBeginning() const +{ + return true; +} + + +bool +SummaryQmlViewStep::isAtEnd() const +{ + return true; +} + + +QList< Calamares::job_ptr > +SummaryQmlViewStep::jobs() const +{ + return QList< Calamares::job_ptr >(); +} + + +void +SummaryQmlViewStep::onActivate() +{ + m_config->init(); +} + diff --git a/src/modules/summaryq/SummaryQmlViewStep.h b/src/modules/summaryq/SummaryQmlViewStep.h new file mode 100644 index 000000000..f42ec9f5c --- /dev/null +++ b/src/modules/summaryq/SummaryQmlViewStep.h @@ -0,0 +1,55 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2014-2015, Teo Mrnjavac + * SPDX-FileCopyrightText: 2020, Camilo Higuita + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#ifndef SUMMARYQMLVIEWSTEP_H +#define SUMMARYQMLVIEWSTEP_H + +#include "Config.h" +#include "utils/PluginFactory.h" +#include "viewpages/QmlViewStep.h" +#include "DllMacro.h" + +#include + +class SummaryPage; + +class PLUGINDLLEXPORT SummaryQmlViewStep : public Calamares::QmlViewStep +{ + Q_OBJECT + +public: + explicit SummaryQmlViewStep( QObject* parent = nullptr ); + virtual ~SummaryQmlViewStep() override; + + QString prettyName() const override; + + + bool isNextEnabled() const override; + bool isBackEnabled() const override; + + bool isAtBeginning() const override; + bool isAtEnd() const override; + + QList< Calamares::job_ptr > jobs() const override; + + void onActivate() override; + + QObject * getConfig() override + { + return m_config; + } + +private: + Config *m_config; +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( SummaryQmlViewStepFactory ) + +#endif // SUMMARYQMLVIEWSTEP_H diff --git a/src/modules/summaryq/img/keyboard.svg b/src/modules/summaryq/img/keyboard.svg new file mode 100644 index 000000000..6227b788b --- /dev/null +++ b/src/modules/summaryq/img/keyboard.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/summaryq/img/keyboard.svg.license b/src/modules/summaryq/img/keyboard.svg.license new file mode 100644 index 000000000..e59dc6f9c --- /dev/null +++ b/src/modules/summaryq/img/keyboard.svg.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2021 KDE Visual Design Group +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/summaryq/img/lokalize.svg b/src/modules/summaryq/img/lokalize.svg new file mode 100644 index 000000000..83a7c9dcf --- /dev/null +++ b/src/modules/summaryq/img/lokalize.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/summaryq/img/lokalize.svg.license b/src/modules/summaryq/img/lokalize.svg.license new file mode 100644 index 000000000..e59dc6f9c --- /dev/null +++ b/src/modules/summaryq/img/lokalize.svg.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2021 KDE Visual Design Group +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/summaryq/summaryq.qml b/src/modules/summaryq/summaryq.qml new file mode 100644 index 000000000..626a42c40 --- /dev/null +++ b/src/modules/summaryq/summaryq.qml @@ -0,0 +1,112 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Anke Boersma + * SPDX-License-Identifier: GPL-3.0-or-later + * + * 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.13 +import QtQuick.Layouts 1.3 +import org.kde.kirigami 2.7 as Kirigami +import QtGraphicalEffects 1.0 +import QtQuick.Window 2.3 + +Kirigami.ScrollablePage { + width: 860 //parent.width //860 + height: 640 //parent.height //640 + + Kirigami.Theme.backgroundColor: "#EFF0F1" + Kirigami.Theme.textColor: "#1F1F1F" + + header: Kirigami.Heading { + Layout.fillWidth: true + height: 100 + horizontalAlignment: Qt.AlignHCenter + color: Kirigami.Theme.textColor + font.weight: Font.Medium + font.pointSize: 12 + text: config.message + + } + + RowLayout { + width: parent.width + + Component { + id: _delegate + + Rectangle { + id: rect + border.color: "#BDC3C7" + width: parent.width - 80 + implicitHeight: message.implicitHeight + title.implicitHeight + 20 + anchors.horizontalCenter: parent.horizontalCenter + + Item { + width: parent.width - 80 + implicitHeight: message.implicitHeight + title.implicitHeight + 20 + + Kirigami.FormLayout { + + GridLayout { + anchors { + //left: parent.left + top: parent.top + right: parent.right + } + rowSpacing: Kirigami.Units.largeSpacing + columnSpacing: Kirigami.Units.largeSpacing + columns: width > Kirigami.Units.gridUnit * 20 ? 4 : 2 + + Image { + id: image + Layout.maximumHeight: Kirigami.Units.iconSizes.huge + Layout.preferredWidth: height + Layout.alignment: Qt.AlignTop + fillMode: Image.PreserveAspectFit + source: index === 0 ? "img/lokalize.svg" + : ( index === 1 ? "img/keyboard.svg" + : ( index === 2 ? "qrc:/data/images/partition-manual.svg" + : "qrc:/data/images/partition-partition.svg" ) ) + } + ColumnLayout { + + Label { + id: title + Layout.fillWidth: true + wrapMode: Text.WordWrap + text: model.title + font.weight: Font.Medium + font.pointSize: 16 + } + Rectangle { + height: 2 + width: 200 + border.color: "#BDC3C7" + } + Label { + id: message + Layout.fillWidth: true + text: model.message + } + } + } + } + } + } + } + } + + ListView { + anchors.fill: parent + spacing: 20 + model: config.summaryModel + delegate: _delegate + } +} diff --git a/src/modules/summaryq/summaryq.qrc b/src/modules/summaryq/summaryq.qrc new file mode 100644 index 000000000..62bfe7899 --- /dev/null +++ b/src/modules/summaryq/summaryq.qrc @@ -0,0 +1,7 @@ + + + summaryq.qml + img/keyboard.svg + img/lokalize.svg + +