diff --git a/src/modules/packagechooser/Config.cpp b/src/modules/packagechooser/Config.cpp index 106ae4538..f66f16824 100644 --- a/src/modules/packagechooser/Config.cpp +++ b/src/modules/packagechooser/Config.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * SPDX-FileCopyrightText: 2021 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. @@ -99,7 +100,8 @@ Config::updateGlobalStorage( const QStringList& selected ) const { if ( m_method == PackageChooserMethod::Legacy ) { - QString value = selected.join( ',' ); + //QString value = selected.join( ',' ); + QString value = ( m_pkgc ); Calamares::JobQueue::instance()->globalStorage()->insert( m_id, value ); cDebug() << m_id<< "selected" << value; } @@ -116,6 +118,18 @@ Config::updateGlobalStorage( const QStringList& selected ) const } } +void +Config::setPkgc( const QString& pkgc ) +{ + m_pkgc = pkgc; + emit pkgcChanged( m_pkgc ); +} + +QString +Config::prettyStatus() const +{ + return tr( "Install option: %1" ).arg( m_pkgc ); +} static void fillModel( PackageListModel* model, const QVariantList& items ) @@ -183,6 +197,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) PackageChooserMode::Required ); m_method = PackageChooserMethodNames().find( CalamaresUtils::getString( configurationMap, "method" ), PackageChooserMethod::Legacy ); + m_pkgc = CalamaresUtils::getString( configurationMap, "pkgc" ); if ( m_method == PackageChooserMethod::Legacy ) { diff --git a/src/modules/packagechooser/Config.h b/src/modules/packagechooser/Config.h index 5959e3ea4..b343a8cb2 100644 --- a/src/modules/packagechooser/Config.h +++ b/src/modules/packagechooser/Config.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * SPDX-FileCopyrightText: 2021 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. @@ -39,6 +40,9 @@ class Config : public Calamares::ModuleSystem::Config { Q_OBJECT + Q_PROPERTY( QString pkgc READ pkgc WRITE setPkgc NOTIFY pkgcChanged ) + Q_PROPERTY( QString prettyStatus READ prettyStatus NOTIFY prettyStatusChanged FINAL ) + public: Config( QObject* parent = nullptr ); ~Config() override; @@ -74,6 +78,15 @@ public: /// As updateGlobalStorage() with an empty selection list void fillGSSecondaryConfiguration() const { updateGlobalStorage( QStringList() ); } + QString pkgc() const { return m_pkgc; } + void setPkgc( const QString& pkgc ); + + QString prettyStatus() const; + +signals: + void pkgcChanged( QString pkgc ); + void prettyStatusChanged(); + private: PackageListModel* m_model = nullptr; QModelIndex m_defaultModelIndex; @@ -86,6 +99,8 @@ private: QString m_id; /// Value to use for id if none is set in the config file Calamares::ModuleSystem::InstanceKey m_defaultId; + /// QML selection + QString m_pkgc; }; diff --git a/src/modules/packagechooserq/CMakeLists.txt b/src/modules/packagechooserq/CMakeLists.txt new file mode 100644 index 000000000..0d98c7d1e --- /dev/null +++ b/src/modules/packagechooserq/CMakeLists.txt @@ -0,0 +1,69 @@ +# === This file is part of Calamares - === +# +# SPDX-FileCopyrightText: 2020 Adriaan de Groot +# SPDX-FileCopyrightText: 2021 Anke Boersma +# SPDX-License-Identifier: BSD-2-Clause +# +if( NOT WITH_QML ) + calamares_skip_module( "packagechooserq (QML is not supported in this build)" ) + return() +endif() + +find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Core ) + +# Add optional libraries here +set( USER_EXTRA_LIB ) + +# include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../packagechooser ) +set( _packagechooser ${CMAKE_CURRENT_SOURCE_DIR}/../packagechooser ) +include_directories( ${_packagechooser} ) + +### OPTIONAL AppData XML support in PackageModel +# +# +# TODO:3.3:WITH->BUILD (this doesn't affect the ABI offered by Calamares) +option( WITH_APPDATA "Support appdata: items in PackageChooser (requires QtXml)" ON ) +if ( WITH_APPDATA ) + find_package(Qt5 COMPONENTS Xml) + if ( Qt5Xml_FOUND ) + add_definitions( -DHAVE_APPDATA ) + list( APPEND _extra_libraries Qt5::Xml ) + list( APPEND _extra_src ItemAppData.cpp ) + endif() +endif() + +### OPTIONAL AppStream support in PackageModel +# +# +option( WITH_APPSTREAM "Support appstream: items in PackageChooser (requires libappstream-qt)" ON ) +if ( WITH_APPSTREAM ) + find_package(AppStreamQt) + set_package_properties( + AppStreamQt PROPERTIES + DESCRIPTION "Support for AppStream (cache) data" + URL "https://github.com/ximion/appstream" + PURPOSE "AppStream provides package data" + TYPE OPTIONAL + ) + if ( AppStreamQt_FOUND ) + add_definitions( -DHAVE_APPSTREAM ) + list( APPEND _extra_libraries AppStreamQt ) + list( APPEND _extra_src ItemAppStream.cpp ) + endif() +endif() + +calamares_add_plugin( packagechooserq + TYPE viewmodule + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + PackageChooserQmlViewStep.cpp + ${_packagechooser}/Config.cpp + ${_packagechooser}/PackageModel.cpp + ${_packagechooser}/ItemAppData.cpp + RESOURCES + packagechooserq.qrc + LINK_PRIVATE_LIBRARIES + calamaresui + ${_extra_libraries} + SHARED_LIB +) diff --git a/src/modules/packagechooserq/PackageChooserQmlViewStep.cpp b/src/modules/packagechooserq/PackageChooserQmlViewStep.cpp new file mode 100644 index 000000000..109260ca9 --- /dev/null +++ b/src/modules/packagechooserq/PackageChooserQmlViewStep.cpp @@ -0,0 +1,86 @@ +/* === This file is part of Calamares - === + * + * 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. + * + */ + +#include "PackageChooserQmlViewStep.h" + +#include "GlobalStorage.h" +#include "JobQueue.h" +#include "locale/TranslatableConfiguration.h" +#include "utils/CalamaresUtilsSystem.h" +#include "utils/Logger.h" +#include "utils/Variant.h" + +CALAMARES_PLUGIN_FACTORY_DEFINITION( PackageChooserQmlViewStepFactory, registerPlugin< PackageChooserQmlViewStep >(); ) + +PackageChooserQmlViewStep::PackageChooserQmlViewStep( QObject* parent ) + : Calamares::QmlViewStep( parent ) + , m_config( new Config( this ) ) +{ + emit nextStatusChanged( true ); +} + +QString +PackageChooserQmlViewStep::prettyName() const +{ + return tr( "Packages" ); +} + +QString +PackageChooserQmlViewStep::prettyStatus() const +{ + //QString option = m_pkgc; + //return tr( "Install option: %1" ).arg( option ); + return m_config->prettyStatus(); +} + +bool +PackageChooserQmlViewStep::isNextEnabled() const +{ + return true; +} + +bool +PackageChooserQmlViewStep::isBackEnabled() const +{ + return true; +} + +bool +PackageChooserQmlViewStep::isAtBeginning() const +{ + return true; +} + +bool +PackageChooserQmlViewStep::isAtEnd() const +{ + return true; +} + +Calamares::JobList +PackageChooserQmlViewStep::jobs() const +{ + Calamares::JobList l; + return l; +} + +void +PackageChooserQmlViewStep::onLeave() +{ + m_config->fillGSSecondaryConfiguration(); +} + +void +PackageChooserQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +{ + m_config->setDefaultId( moduleInstanceKey() ); + m_config->setConfigurationMap( configurationMap ); + Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last +} diff --git a/src/modules/packagechooserq/PackageChooserQmlViewStep.h b/src/modules/packagechooserq/PackageChooserQmlViewStep.h new file mode 100644 index 000000000..1ac2451c2 --- /dev/null +++ b/src/modules/packagechooserq/PackageChooserQmlViewStep.h @@ -0,0 +1,58 @@ +/* === This file is part of Calamares - === + * + * 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 PACKAGECHOOSERQMLVIEWSTEP_H +#define PACKAGECHOOSERQMLVIEWSTEP_H + +// Config from packagechooser module +#include "Config.h" + +#include "DllMacro.h" +#include "locale/TranslatableConfiguration.h" +#include "utils/PluginFactory.h" +#include "viewpages/QmlViewStep.h" + +#include + +class Config; +class PackageChooserPage; + +class PLUGINDLLEXPORT PackageChooserQmlViewStep : public Calamares::QmlViewStep +{ + Q_OBJECT + +public: + explicit PackageChooserQmlViewStep( QObject* parent = nullptr ); + + QString prettyName() const override; + QString prettyStatus() const override; + + bool isNextEnabled() const override; + bool isBackEnabled() const override; + + bool isAtBeginning() const override; + bool isAtEnd() const override; + + //void onActivate() override; + void onLeave() override; + + Calamares::JobList jobs() const override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; + + QObject* getConfig() override { return m_config; } + +private: + Config* m_config; +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserQmlViewStepFactory ) + +#endif // PACKAGECHOOSERQMLVIEWSTEP_H diff --git a/src/modules/packagechooserq/images/libreoffice.jpg b/src/modules/packagechooserq/images/libreoffice.jpg new file mode 100644 index 000000000..e216cc77a Binary files /dev/null and b/src/modules/packagechooserq/images/libreoffice.jpg differ diff --git a/src/modules/packagechooserq/images/libreoffice.jpg.license b/src/modules/packagechooserq/images/libreoffice.jpg.license new file mode 100644 index 000000000..5f43e650d --- /dev/null +++ b/src/modules/packagechooserq/images/libreoffice.jpg.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2020 demmm +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/packagechooserq/images/no-selection.png b/src/modules/packagechooserq/images/no-selection.png new file mode 100644 index 000000000..b32d21702 Binary files /dev/null and b/src/modules/packagechooserq/images/no-selection.png differ diff --git a/src/modules/packagechooserq/images/no-selection.png.license b/src/modules/packagechooserq/images/no-selection.png.license new file mode 100644 index 000000000..5f43e650d --- /dev/null +++ b/src/modules/packagechooserq/images/no-selection.png.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2020 demmm +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/packagechooserq/images/plasma.png b/src/modules/packagechooserq/images/plasma.png new file mode 100644 index 000000000..e9e35a528 Binary files /dev/null and b/src/modules/packagechooserq/images/plasma.png differ diff --git a/src/modules/packagechooserq/images/plasma.png.license b/src/modules/packagechooserq/images/plasma.png.license new file mode 100644 index 000000000..16c11f071 --- /dev/null +++ b/src/modules/packagechooserq/images/plasma.png.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2021 pngegg +SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/modules/packagechooserq/packagechooserq.conf b/src/modules/packagechooserq/packagechooserq.conf new file mode 100644 index 000000000..fc45e4fa9 --- /dev/null +++ b/src/modules/packagechooserq/packagechooserq.conf @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +# Configuration for the low-density software chooser +--- +# Software selection mode, to set whether the software packages +# can be chosen singly, or multiply. +# +# Possible modes are "optional", "required" (for zero-or-one or exactly-one) +# or "optionalmultiple", "requiredmultiple" (for zero-or-more +# or one-or-more). +mode: required + +# Software installation method: +# +# - "legacy" or "custom" or "contextualprocess" +# When set to "legacy", writes a GlobalStorage value for the choice that +# has been made. The key is *packagechooser_*. Normally, the module's +# instance name is used; see the *instances* section of `settings.conf`. +# If there is just one packagechooser module, and no special instance is set, +# resulting GS key is probably *packagechooser@packagechooser*. +# You can set *id* to change that, but it is not recommended. +# +# The GS value is a comma-separated list of the IDs of the selected +# packages, or an empty string if none is selected. +# +# With "legacy" installation, you should have a contextualprocess or similar +# module somewhere in the `exec` phase to process the GlobalStorage key +# and actually **do** something for the packages. +# +# - "packages" +# When set to "packages", writes GlobalStorage values suitable for +# consumption by the *packages* module (which should appear later +# in the `exec` section. These package settings will then be handed +# off to whatever package manager is configured there. +# The *id* key is not used. +# +# There is no need to put this module in the `exec` section. There +# are no jobs that this module provides. You should put **other** +# modules, either *contextualprocess* or *packages* or some custom +# module, in the `exec` section to do the actual work. +method: legacy +# The *id* key is used only in "legacy" mode +# id: "" + +# The *pkgc* is used for setting the default selection in the QML view +pkgc: libreoffice + diff --git a/src/modules/packagechooserq/packagechooserq.qml b/src/modules/packagechooserq/packagechooserq.qml new file mode 100644 index 000000000..cf7454fe9 --- /dev/null +++ b/src/modules/packagechooserq/packagechooserq.qml @@ -0,0 +1,254 @@ +/* === 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.15 +import QtQuick.Layouts 1.3 + +Item { + width: parent.width + height: parent.height + + Rectangle { + anchors.fill: parent + color: "#f2f2f2" + + ButtonGroup { + id: switchGroup + } + + Column { + id: column + anchors.centerIn: parent + spacing: 5 + + Rectangle { + //id: rectangle + width: 700 + height: 150 + color: "#ffffff" + radius: 10 + border.width: 0 + Text { + width: 450 + height: 104 + anchors.centerIn: parent + text: qsTr("LibreOffice is a powerful and free office suite, used by millions of people around the world. It includes several applications that make it the most versatile Free and Open Source office suite on the market.
+ Default option.") + font.pointSize: 10 + anchors.verticalCenterOffset: -10 + anchors.horizontalCenterOffset: 100 + wrapMode: Text.WordWrap + } + + Switch { + id: element2 + x: 500 + y: 110 + width: 187 + height: 14 + text: qsTr("LibreOffice") + checked: true + hoverEnabled: true + ButtonGroup.group: switchGroup + + indicator: Rectangle { + implicitWidth: 40 + implicitHeight: 14 + radius: 10 + color: element2.checked ? "#3498db" : "#B9B9B9" + border.color: element2.checked ? "#3498db" : "#cccccc" + + Rectangle { + x: element2.checked ? parent.width - width : 0 + y: (parent.height - height) / 2 + width: 20 + height: 20 + radius: 10 + color: element2.down ? "#cccccc" : "#ffffff" + border.color: element2.checked ? (element1.down ? "#3498db" : "#3498db") : "#999999" + } + } + + onCheckedChanged: { + if ( ! checked ) { + print("L not used") + } + else { + config.pkgc = "libreoffice" + print( config.pkgc ) + } + } + } + + Image { + id: image2 + x: 8 + y: 25 + height: 100 + fillMode: Image.PreserveAspectFit + source: "images/libreoffice.jpg" + } + } + + Rectangle { + width: 700 + height: 150 + radius: 10 + border.width: 0 + Text { + width: 450 + height: 104 + anchors.centerIn: parent + text: qsTr("If you don't want to install an office suite, just select No Office Suite. You can always add one (or more) later on your installed system as the need arrives.") + font.pointSize: 10 + anchors.verticalCenterOffset: -10 + anchors.horizontalCenterOffset: 100 + wrapMode: Text.WordWrap + } + + Switch { + id: element1 + x: 500 + y: 110 + width: 187 + height: 14 + text: qsTr("No Office Suite") + checked: false + hoverEnabled: true + ButtonGroup.group: switchGroup + + indicator: Rectangle { + implicitWidth: 40 + implicitHeight: 14 + radius: 10 + color: element1.checked ? "#3498db" : "#B9B9B9" + border.color: element1.checked ? "#3498db" : "#cccccc" + + Rectangle { + x: element1.checked ? parent.width - width : 0 + y: (parent.height - height) / 2 + width: 20 + height: 20 + radius: 10 + color: element1.down ? "#cccccc" : "#ffffff" + border.color: element1.checked ? (element1.down ? "#3498db" : "#3498db") : "#999999" + } + } + + onCheckedChanged: { + if ( ! checked ) { + print("not used") + //console.log("removed") + } + else { + print("No Office Suite") + config.pkgc = "no_office_suite" + } + } + } + + Image { + id: image + x: 8 + y: 25 + height: 100 + fillMode: Image.PreserveAspectFit + source: "images/no-selection.png" + } + + } + + Rectangle { + width: 700 + height: 150 + color: "#ffffff" + radius: 10 + border.width: 0 + Text { + width: 450 + height: 104 + anchors.centerIn: parent + text: qsTr("Create a minimal Desktop install, remove all extra applications and decide later on what you would like to add to your system. Examples of what won't be on such an install, there will be no Office Suite, no media players, no image viewer or print support. It will be just a desktop, file browser, package manager, text editor and simple web-browser.") + font.pointSize: 10 + anchors.verticalCenterOffset: -10 + anchors.horizontalCenterOffset: 100 + wrapMode: Text.WordWrap + } + + Switch { + id: element3 + x: 500 + y: 110 + width: 187 + height: 14 + text: qsTr("Minimal Install") + checked: false + hoverEnabled: true + ButtonGroup.group: switchGroup + + indicator: Rectangle { + implicitWidth: 40 + implicitHeight: 14 + radius: 10 + color: element3.checked ? "#3498db" : "#B9B9B9" + border.color: element3.checked ? "#3498db" : "#cccccc" + + Rectangle { + x: element3.checked ? parent.width - width : 0 + y: (parent.height - height) / 2 + width: 20 + height: 20 + radius: 10 + color: element3.down ? "#cccccc" : "#ffffff" + border.color: element3.checked ? (element3.down ? "#3498db" : "#3498db") : "#999999" + } + } + + onCheckedChanged: { + if ( ! checked ) { + print("M not used") + } + else { + print("minimal") + config.pkgc = "minimal_install" + } + } + } + + Image { + id: image3 + x: 8 + y: 25 + height: 100 + fillMode: Image.PreserveAspectFit + source: "images/plasma.png" + } + } + + Rectangle { + width: 700 + height: 25 + color: "#f2f2f2" + border.width: 0 + Text { + height: 25 + anchors.centerIn: parent + text: qsTr("Please select an option for your install, or use the default: LibreOffice included.") + font.pointSize: 10 + wrapMode: Text.WordWrap + } + } + } + } + +} diff --git a/src/modules/packagechooserq/packagechooserq.qrc b/src/modules/packagechooserq/packagechooserq.qrc new file mode 100644 index 000000000..1b892dce1 --- /dev/null +++ b/src/modules/packagechooserq/packagechooserq.qrc @@ -0,0 +1,8 @@ + + + packagechooserq.qml + images/libreoffice.jpg + images/no-selection.png + images/plasma.png + + diff --git a/src/modules/partition/Config.cpp b/src/modules/partition/Config.cpp index 82c0ad846..508231a75 100644 --- a/src/modules/partition/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -227,7 +227,8 @@ fillGSConfigurationEFI( Calamares::GlobalStorage* gs, const QVariantMap& configu QString firmwareType( PartUtils::isEfiSystem() ? QStringLiteral( "efi" ) : QStringLiteral( "bios" ) ); gs->insert( "firmwareType", firmwareType ); - gs->insert( "efiSystemPartition", CalamaresUtils::getString( configurationMap, "efiSystemPartition", QStringLiteral( "/boot/efi" ) ) ); + gs->insert( "efiSystemPartition", + CalamaresUtils::getString( configurationMap, "efiSystemPartition", QStringLiteral( "/boot/efi" ) ) ); // Read and parse key efiSystemPartitionSize if ( configurationMap.contains( "efiSystemPartitionSize" ) ) @@ -243,7 +244,7 @@ fillGSConfigurationEFI( Calamares::GlobalStorage* gs, const QVariantMap& configu } void -Config::fillConfigurationFSTypes(const QVariantMap& configurationMap) +Config::fillConfigurationFSTypes( const QVariantMap& configurationMap ) { Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); @@ -256,15 +257,16 @@ Config::fillConfigurationFSTypes(const QVariantMap& configurationMap) if ( fsName.isEmpty() ) { cWarning() << "Partition-module setting *defaultFileSystemType* is missing, will use ext4"; - fsRealName = PartUtils::canonicalFilesystemName( QStringLiteral("ext4"), &fsType ); + fsRealName = PartUtils::canonicalFilesystemName( QStringLiteral( "ext4" ), &fsType ); } else { fsRealName = PartUtils::canonicalFilesystemName( fsName, &fsType ); if ( fsType == FileSystem::Type::Unknown ) { - cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << fsName << ") using ext4 instead"; - fsRealName = PartUtils::canonicalFilesystemName( QStringLiteral("ext4"), &fsType ); + cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << fsName + << ") using ext4 instead"; + fsRealName = PartUtils::canonicalFilesystemName( QStringLiteral( "ext4" ), &fsType ); } else if ( fsRealName != fsName ) { @@ -326,7 +328,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) m_requiredPartitionTableType = CalamaresUtils::getStringList( configurationMap, "requiredPartitionTableType" ); gs->insert( "requiredPartitionTableType", m_requiredPartitionTableType ); - fillGSConfigurationEFI(gs, configurationMap); + fillGSConfigurationEFI( gs, configurationMap ); fillConfigurationFSTypes( configurationMap ); } diff --git a/src/modules/partition/Config.h b/src/modules/partition/Config.h index 3365403fa..5f7e46821 100644 --- a/src/modules/partition/Config.h +++ b/src/modules/partition/Config.h @@ -27,7 +27,8 @@ class Config : public QObject Q_PROPERTY( SwapChoice swapChoice READ swapChoice WRITE setSwapChoice NOTIFY swapChoiceChanged ) ///@brief Name of the FS that will be used when erasing type disk (e.g. "default filesystem") - Q_PROPERTY( QString eraseModeFilesystem READ eraseFsType WRITE setEraseFsTypeChoice NOTIFY eraseModeFilesystemChanged ) + Q_PROPERTY( + QString eraseModeFilesystem READ eraseFsType WRITE setEraseFsTypeChoice NOTIFY eraseModeFilesystemChanged ) Q_PROPERTY( bool allowManualPartitioning READ allowManualPartitioning CONSTANT FINAL ) @@ -134,7 +135,7 @@ public Q_SLOTS: void setInstallChoice( InstallChoice ); void setSwapChoice( int ); ///< Translates a button ID or so to SwapChoice void setSwapChoice( SwapChoice ); - void setEraseFsTypeChoice( const QString& filesystemName ); ///< See property eraseModeFilesystem + void setEraseFsTypeChoice( const QString& filesystemName ); ///< See property eraseModeFilesystem Q_SIGNALS: void installChoiceChanged( InstallChoice ); diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index 29e6524d9..1fe7bdfab 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -109,13 +109,142 @@ PartitionViewStep::prettyName() const return tr( "Partitions" ); } - -QWidget* -PartitionViewStep::widget() +/** @brief Gather the pretty descriptions of all the partitioning jobs + * + * Returns a QStringList of each job's pretty description, including + * empty strings and duplicates. The list is in-order of how the + * jobs will be run. + */ +static QStringList +jobDescriptions( const Calamares::JobList& jobs ) { - return m_widget; + QStringList jobsLines; + for ( const Calamares::job_ptr& job : qAsConst( jobs ) ) + { + if ( !job->prettyDescription().isEmpty() ) + { + jobsLines.append( job->prettyDescription() ); + } + } + return jobsLines; } +/** @brief A top-level description of what @p choice does + * + * Returns a (branded) string describing what @p choice will do. + */ +static QString +modeDescription( Config::InstallChoice choice ) +{ + const auto* branding = Calamares::Branding::instance(); + static const char context[] = "PartitionViewStep"; + + switch ( choice ) + { + case Config::InstallChoice::Alongside: + return QCoreApplication::translate( context, "Install %1 alongside another operating system." ) + .arg( branding->shortVersionedName() ); + break; + case Config::InstallChoice::Erase: + return QCoreApplication::translate( context, "Erase disk and install %1." ) + .arg( branding->shortVersionedName() ); + break; + case Config::InstallChoice::Replace: + return QCoreApplication::translate( context, "Replace a partition with %1." ) + .arg( branding->shortVersionedName() ); + break; + case Config::InstallChoice::NoChoice: + case Config::InstallChoice::Manual: + return QCoreApplication::translate( context, "Manual partitioning." ); + } + return QString(); +} + +/** @brief A top-level description of what @p choice does to disk @p info + * + * Returns a (branded, and device-specific) string describing what + * will be done to device @p info when @p choice is made. The @p listLength + * is used to provide context; when more than one disk is in use, the description + * works differently. + */ +static QString +diskDescription( int listLength, const PartitionCoreModule::SummaryInfo& info, Config::InstallChoice choice ) +{ + const auto* branding = Calamares::Branding::instance(); + static const char context[] = "PartitionViewStep"; + + if ( listLength == 1 ) // this is the only disk preview + { + switch ( choice ) + { + case Config::Alongside: + return QCoreApplication::translate( + context, + "Install %1 alongside another operating system on disk " + "%2 (%3)." ) + .arg( branding->shortVersionedName() ) + .arg( info.deviceNode ) + .arg( info.deviceName ); + break; + case Config::Erase: + return QCoreApplication::translate( context, + "Erase disk %2 (%3) and install %1." ) + .arg( branding->shortVersionedName() ) + .arg( info.deviceNode ) + .arg( info.deviceName ); + break; + case Config::Replace: + return QCoreApplication::translate( + context, "Replace a partition on disk %2 (%3) with %1." ) + .arg( branding->shortVersionedName() ) + .arg( info.deviceNode ) + .arg( info.deviceName ); + break; + case Config::NoChoice: + case Config::Manual: + return QCoreApplication::translate( + context, "Manual partitioning on disk %1 (%2)." ) + .arg( info.deviceNode ) + .arg( info.deviceName ); + } + return QString(); + } + else // multiple disk previews! + { + return QCoreApplication::translate( context, "Disk %1 (%2)" ) + .arg( info.deviceNode ) + .arg( info.deviceName ); + } +} + +QString +PartitionViewStep::prettyStatus() const +{ + QString jobsLabel, modeText, diskInfoLabel; + + const Config::InstallChoice choice = m_config->installChoice(); + const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo(); + + cDebug() << "Summary for Partition" << list.length() << choice; + if ( list.length() > 1 ) // There are changes on more than one disk + { + modeText = modeDescription( choice ); + } + + for ( const auto& info : list ) + { + // TODO: this overwrites each iteration + diskInfoLabel = diskDescription( list.length(), info, choice ); + } + + const QStringList jobsLines = jobDescriptions( jobs() ); + if ( !jobsLines.isEmpty() ) + { + jobsLabel = jobsLines.join( "
" ); + } + + return diskInfoLabel + "
" + jobsLabel; +} QWidget* PartitionViewStep::createSummaryWidget() const @@ -132,73 +261,19 @@ PartitionViewStep::createSummaryWidget() const formLayout->setContentsMargins( MARGIN, 0, MARGIN, MARGIN ); mainLayout->addLayout( formLayout ); - const auto* branding = Calamares::Branding::instance(); - QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo(); + const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo(); if ( list.length() > 1 ) // There are changes on more than one disk { //NOTE: all of this should only happen when Manual partitioning is active. // Any other choice should result in a list.length() == 1. QLabel* modeLabel = new QLabel; formLayout->addRow( modeLabel ); - QString modeText; - switch ( choice ) - { - case Config::InstallChoice::Alongside: - modeText = tr( "Install %1 alongside another operating system." ) - .arg( branding->shortVersionedName() ); - break; - case Config::InstallChoice::Erase: - modeText = tr( "Erase disk and install %1." ).arg( branding->shortVersionedName() ); - break; - case Config::InstallChoice::Replace: - modeText = tr( "Replace a partition with %1." ).arg( branding->shortVersionedName() ); - break; - case Config::InstallChoice::NoChoice: - case Config::InstallChoice::Manual: - modeText = tr( "Manual partitioning." ); - } - modeLabel->setText( modeText ); + modeLabel->setText( modeDescription( choice ) ); } for ( const auto& info : list ) { QLabel* diskInfoLabel = new QLabel; - if ( list.length() == 1 ) // this is the only disk preview - { - QString modeText; - switch ( choice ) - { - case Config::InstallChoice::Alongside: - modeText = tr( "Install %1 alongside another operating system on disk " - "%2 (%3)." ) - .arg( branding->shortVersionedName() ) - .arg( info.deviceNode ) - .arg( info.deviceName ); - break; - case Config::InstallChoice::Erase: - modeText = tr( "Erase disk %2 (%3) and install %1." ) - .arg( branding->shortVersionedName() ) - .arg( info.deviceNode ) - .arg( info.deviceName ); - break; - case Config::InstallChoice::Replace: - modeText = tr( "Replace a partition on disk %2 (%3) with %1." ) - .arg( branding->shortVersionedName() ) - .arg( info.deviceNode ) - .arg( info.deviceName ); - break; - case Config::InstallChoice::NoChoice: - case Config::InstallChoice::Manual: - modeText = tr( "Manual partitioning on disk %1 (%2)." ) - .arg( info.deviceNode ) - .arg( info.deviceName ); - } - diskInfoLabel->setText( modeText ); - } - else // multiple disk previews! - { - diskInfoLabel->setText( - tr( "Disk %1 (%2)" ).arg( info.deviceNode ).arg( info.deviceName ) ); - } + diskInfoLabel->setText( diskDescription( list.length(), info, choice ) ); formLayout->addRow( diskInfoLabel ); PartitionBarsView* preview; @@ -243,14 +318,7 @@ PartitionViewStep::createSummaryWidget() const field->addWidget( previewLabels ); formLayout->addRow( tr( "After:" ), field ); } - QStringList jobsLines; - foreach ( const Calamares::job_ptr& job, jobs() ) - { - if ( !job->prettyDescription().isEmpty() ) - { - jobsLines.append( job->prettyDescription() ); - } - } + const QStringList jobsLines = jobDescriptions( jobs() ); if ( !jobsLines.isEmpty() ) { QLabel* jobsLabel = new QLabel( widget ); @@ -265,6 +333,11 @@ PartitionViewStep::createSummaryWidget() const return widget; } +QWidget* +PartitionViewStep::widget() +{ + return m_widget; +} void PartitionViewStep::next() @@ -599,8 +672,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) QFuture< void > future = QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule ); m_future->setFuture( future ); - m_core->initLayout( m_config->defaultFsType(), - configurationMap.value( "partitionLayout" ).toList() ); + m_core->initLayout( m_config->defaultFsType(), configurationMap.value( "partitionLayout" ).toList() ); } diff --git a/src/modules/partition/PartitionViewStep.h b/src/modules/partition/PartitionViewStep.h index 9f3da9f3d..ecba73f45 100644 --- a/src/modules/partition/PartitionViewStep.h +++ b/src/modules/partition/PartitionViewStep.h @@ -43,6 +43,7 @@ public: ~PartitionViewStep() override; QString prettyName() const override; + QString prettyStatus() const override; QWidget* createSummaryWidget() const override; QWidget* widget() override; diff --git a/src/modules/summary/CMakeLists.txt b/src/modules/summary/CMakeLists.txt index 2c30dc31a..e3c1a381c 100644 --- a/src/modules/summary/CMakeLists.txt +++ b/src/modules/summary/CMakeLists.txt @@ -8,8 +8,9 @@ calamares_add_plugin( summary TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES - SummaryViewStep.cpp + Config.cpp SummaryPage.cpp + SummaryViewStep.cpp UI SHARED_LIB NO_CONFIG diff --git a/src/modules/summary/Config.cpp b/src/modules/summary/Config.cpp new file mode 100644 index 000000000..5110e09a6 --- /dev/null +++ b/src/modules/summary/Config.cpp @@ -0,0 +1,127 @@ +/* === 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 "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< int, QByteArray > +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::setSummaryList( const Calamares::ViewStepList& steps, bool withWidgets ) +{ + Q_EMIT beginResetModel(); + m_summary.clear(); + + for ( Calamares::ViewStep* step : steps ) + { + QString text = step->prettyStatus(); + QWidget* widget = withWidgets ? step->createSummaryWidget() : nullptr; + + if ( text.isEmpty() && !widget ) + { + continue; + } + + m_summary << StepSummary { step->prettyName(), text, widget }; + } + Q_EMIT endResetModel(); +} + +Config::Config( QObject* parent ) + : QObject( parent ) + , m_summary( new SummaryModel( this ) ) + +{ + CALAMARES_RETRANSLATE_SLOT( &Config::retranslate ); + retranslate(); +} + +void +Config::retranslate() +{ + m_title = tr( "Summary" ); + + 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." ); + } + Q_EMIT titleChanged( m_title ); + Q_EMIT messageChanged( m_message ); +} + +void +Config::collectSummaries( const Calamares::ViewStep* upToHere ) +{ + Calamares::ViewStepList steps; + for ( Calamares::ViewStep* step : Calamares::ViewManager::instance()->viewSteps() ) + { + // *Assume* that if there's an exec step in the sequence, + // we don't need a summary for steps before it. This works in + // practice if there's a summary step before each exec -- + // and in practice, there's only one of each. + if ( qobject_cast< Calamares::ExecutionViewStep* >( step ) ) + { + steps.clear(); + continue; + } + + // Having reached the parent view-step of the Config object, + // we know we're providing a summary of steps up until this + // view step, so we now have steps since the previous exec, up + // to this summary. + if ( upToHere == step ) + { + break; + } + + steps.append( step ); + } + + m_summary->setSummaryList( steps ); +} diff --git a/src/modules/summary/Config.h b/src/modules/summary/Config.h new file mode 100644 index 000000000..15604d933 --- /dev/null +++ b/src/modules/summary/Config.h @@ -0,0 +1,96 @@ +/* === 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 "viewpages/ViewStep.h" + +#include +#include +#include + +class Config; + +/** @brief Data for one step + * + * A step generally has a text description, but **may** have a + * QWidget. There is no ownership of the QWidget, that is assumed + * to be handed off to some owning parent-widget. + */ +struct StepSummary +{ + QString title; + QString message; + QWidget* widget = nullptr; +}; + +class SummaryModel : public QAbstractListModel +{ + Q_OBJECT + friend class Config; + +public: + explicit SummaryModel( QObject* parent = nullptr ); + int rowCount( const QModelIndex& = QModelIndex() ) const override; + QVariant data( const QModelIndex& index, int role ) const override; + +protected: + QHash< int, QByteArray > roleNames() const override; + +private: + /** @brief Sets the model data from @p steps + * + * Replaces the list of summaries with summaries given by + * the jobs and ViewSteps objects in @p steps. If @p withWidgets + * is @c true, then also queries for widget summaries alongside + * the text summaries for each step. + */ + void setSummaryList( const Calamares::ViewStepList& steps, bool withWidgets = false ); + + QVector< StepSummary > m_summary; +}; + +class Config : public QObject +{ + Q_OBJECT + + ///@brief Name of this summary (generally, "Summary") + Q_PROPERTY( QString title READ title NOTIFY titleChanged ) + ///@brief Description of what the summary means + Q_PROPERTY( QString message READ message NOTIFY messageChanged ) + + Q_PROPERTY( QAbstractListModel* summaryModel READ summaryModel CONSTANT FINAL ) + +public: + explicit Config( QObject* parent = nullptr ); + + ///@brief Called later, to load the model once all viewsteps are there + void collectSummaries( const Calamares::ViewStep* upToHere ); + + QAbstractListModel* summaryModel() const { return m_summary; } + + QString title() const { return m_title; } + QString message() const { return m_message; } + +private: + Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const; + void retranslate(); + + SummaryModel* m_summary; + + QString m_title; + QString m_message; + +Q_SIGNALS: + void titleChanged( QString title ); + void messageChanged( QString message ); +}; +#endif diff --git a/src/modules/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp index b56793e7e..8abfb8804 100644 --- a/src/modules/summary/SummaryPage.cpp +++ b/src/modules/summary/SummaryPage.cpp @@ -29,7 +29,7 @@ static const int SECTION_SPACING = 12; -SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent ) +SummaryPage::SummaryPage( Config* config, const SummaryViewStep* thisViewStep, QWidget* parent ) : QWidget() , m_thisViewStep( thisViewStep ) , m_contentWidget( nullptr ) @@ -37,6 +37,7 @@ SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent ) { Q_UNUSED( parent ) + this->setObjectName( "summaryStep" ); Q_ASSERT( m_thisViewStep ); @@ -45,11 +46,8 @@ SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent ) QLabel* headerLabel = new QLabel( this ); headerLabel->setObjectName( "summaryTitle" ); - CALAMARES_RETRANSLATE( if ( Calamares::Settings::instance()->isSetupMode() ) - headerLabel->setText( tr( "This is an overview of what will happen once you start " - "the setup procedure." ) ); - else headerLabel->setText( tr( "This is an overview of what will happen once you start " - "the install procedure." ) ); ); + headerLabel->setText( config->message() ); + connect( config, &Config::messageChanged, headerLabel, &QLabel::setText ); layout->addWidget( headerLabel ); layout->addWidget( m_scrollArea ); m_scrollArea->setWidgetResizable( true ); @@ -63,12 +61,45 @@ SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent ) } +static QLabel* +createTitleLabel( const QString& text, const QFont& titleFont ) +{ + QLabel* label = new QLabel( text ); + label->setObjectName( "summaryItemTitle" ); + label->setFont( titleFont ); + label->setContentsMargins( 0, 0, 0, 0 ); + + return label; +} + +static QLabel* +createBodyLabel( const QString& text, const QPalette& bodyPalette ) +{ + QLabel* label = new QLabel; + label->setObjectName( "summaryItemBody" ); + label->setMargin( CalamaresUtils::defaultFontHeight() / 2 ); + label->setAutoFillBackground( true ); + label->setPalette( bodyPalette ); + label->setText( text ); + return label; +} + // Adds a widget for those ViewSteps that want a summary; // see SummaryPage documentation and also ViewStep docs. void SummaryPage::onActivate() { - createContentWidget(); + delete m_contentWidget; // It might have been created previously + m_contentWidget = new QWidget; + m_layout = new QVBoxLayout( m_contentWidget ); + CalamaresUtils::unmarginLayout( m_layout ); + + QFont titleFont = font(); + titleFont.setWeight( QFont::Light ); + titleFont.setPointSize( CalamaresUtils::defaultFontSize() * 2 ); + + QPalette bodyPalette( palette() ); + bodyPalette.setColor( WindowBackground, palette().window().color().lighter( 108 ) ); bool first = true; const Calamares::ViewStepList steps = stepsForSummary( Calamares::ViewManager::instance()->viewSteps() ); @@ -92,7 +123,7 @@ SummaryPage::onActivate() m_layout->addSpacing( SECTION_SPACING ); } - m_layout->addWidget( createTitleLabel( step->prettyName() ) ); + m_layout->addWidget( createTitleLabel( step->prettyName(), titleFont ) ); QHBoxLayout* itemBodyLayout = new QHBoxLayout; m_layout->addSpacing( CalamaresUtils::defaultFontHeight() / 2 ); m_layout->addLayout( itemBodyLayout ); @@ -102,7 +133,7 @@ SummaryPage::onActivate() CalamaresUtils::unmarginLayout( itemBodyLayout ); if ( !text.isEmpty() ) { - itemBodyCoreLayout->addWidget( createBodyLabel( text ) ); + itemBodyCoreLayout->addWidget( createBodyLabel( text, bodyPalette ) ); } if ( widget ) { @@ -156,40 +187,9 @@ SummaryPage::stepsForSummary( const Calamares::ViewStepList& allSteps ) const return steps; } - void -SummaryPage::createContentWidget() +SummaryPage::onLeave() { delete m_contentWidget; - m_contentWidget = new QWidget; - m_layout = new QVBoxLayout( m_contentWidget ); - CalamaresUtils::unmarginLayout( m_layout ); -} - -QLabel* -SummaryPage::createTitleLabel( const QString& text ) const -{ - QLabel* label = new QLabel( text ); - label->setObjectName( "summaryItemTitle" ); - QFont fnt = font(); - fnt.setWeight( QFont::Light ); - fnt.setPointSize( CalamaresUtils::defaultFontSize() * 2 ); - label->setFont( fnt ); - label->setContentsMargins( 0, 0, 0, 0 ); - - return label; -} - -QLabel* -SummaryPage::createBodyLabel( const QString& text ) const -{ - QLabel* label = new QLabel; - label->setObjectName( "summaryItemBody" ); - label->setMargin( CalamaresUtils::defaultFontHeight() / 2 ); - QPalette pal( palette() ); - pal.setColor( WindowBackground, palette().window().color().lighter( 108 ) ); - label->setAutoFillBackground( true ); - label->setPalette( pal ); - label->setText( text ); - return label; + m_contentWidget = nullptr; } diff --git a/src/modules/summary/SummaryPage.h b/src/modules/summary/SummaryPage.h index 1adb67017..7d98cc711 100644 --- a/src/modules/summary/SummaryPage.h +++ b/src/modules/summary/SummaryPage.h @@ -14,10 +14,13 @@ #include +class Config; +class SummaryViewStep; + class QLabel; class QScrollArea; class QVBoxLayout; -class SummaryViewStep; + /** @brief Provide a summary view with to-be-done action descriptions. * @@ -42,10 +45,12 @@ class SummaryPage : public QWidget { Q_OBJECT public: - explicit SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent = nullptr ); + explicit SummaryPage( Config* config, const SummaryViewStep* thisViewStep, QWidget* parent = nullptr ); + /// @brief Create contents showing all of the summary void onActivate(); - void createContentWidget(); + /// @brief Clean up the widgets + void onLeave(); private: Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const; @@ -55,9 +60,6 @@ private: QVBoxLayout* m_layout = nullptr; QWidget* m_contentWidget = nullptr; - QLabel* createTitleLabel( const QString& text ) const; - QLabel* createBodyLabel( const QString& text ) const; - QScrollArea* m_scrollArea; }; diff --git a/src/modules/summary/SummaryViewStep.cpp b/src/modules/summary/SummaryViewStep.cpp index c5b6841ed..d4e439ae3 100644 --- a/src/modules/summary/SummaryViewStep.cpp +++ b/src/modules/summary/SummaryViewStep.cpp @@ -15,7 +15,8 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( SummaryViewStepFactory, registerPlugin< Sum SummaryViewStep::SummaryViewStep( QObject* parent ) : Calamares::ViewStep( parent ) - , m_widget( new SummaryPage( this ) ) + , m_config( new Config( this ) ) + , m_widget( new SummaryPage( m_config, this ) ) { emit nextStatusChanged( true ); } @@ -27,13 +28,14 @@ SummaryViewStep::~SummaryViewStep() { m_widget->deleteLater(); } + delete m_config; } QString SummaryViewStep::prettyName() const { - return tr( "Summary" ); + return m_config->title(); } @@ -72,16 +74,17 @@ SummaryViewStep::isAtEnd() const } -QList< Calamares::job_ptr > +Calamares::JobList SummaryViewStep::jobs() const { - return QList< Calamares::job_ptr >(); + return {}; } void SummaryViewStep::onActivate() { + m_config->collectSummaries( this ); m_widget->onActivate(); } @@ -89,5 +92,5 @@ SummaryViewStep::onActivate() void SummaryViewStep::onLeave() { - m_widget->createContentWidget(); + m_widget->onLeave(); } diff --git a/src/modules/summary/SummaryViewStep.h b/src/modules/summary/SummaryViewStep.h index c89efc42f..e2ee0566e 100644 --- a/src/modules/summary/SummaryViewStep.h +++ b/src/modules/summary/SummaryViewStep.h @@ -10,12 +10,11 @@ #ifndef SUMMARYPAGEPLUGIN_H #define SUMMARYPAGEPLUGIN_H -#include - -#include "utils/PluginFactory.h" -#include "viewpages/ViewStep.h" +#include "Config.h" #include "DllMacro.h" +#include "utils/PluginFactory.h" +#include "viewpages/ViewStep.h" class SummaryPage; @@ -37,13 +36,14 @@ public: bool isAtBeginning() const override; bool isAtEnd() const override; - QList< Calamares::job_ptr > jobs() const override; + Calamares::JobList jobs() const override; void onActivate() override; void onLeave() override; private: - SummaryPage* m_widget; + Config* m_config = nullptr; + SummaryPage* m_widget = nullptr; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( SummaryViewStepFactory ) diff --git a/src/modules/summaryq/CMakeLists.txt b/src/modules/summaryq/CMakeLists.txt new file mode 100644 index 000000000..cdf520b24 --- /dev/null +++ b/src/modules/summaryq/CMakeLists.txt @@ -0,0 +1,21 @@ +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( ${_summary} ) + +calamares_add_plugin( summaryq + TYPE viewmodule + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + SummaryQmlViewStep.cpp + ${_summary}/Config.cpp + UI + RESOURCES + summaryq.qrc + LINK_PRIVATE_LIBRARIES + calamaresui + SHARED_LIB +) diff --git a/src/modules/summaryq/SummaryQmlViewStep.cpp b/src/modules/summaryq/SummaryQmlViewStep.cpp new file mode 100644 index 000000000..23e18a861 --- /dev/null +++ b/src/modules/summaryq/SummaryQmlViewStep.cpp @@ -0,0 +1,73 @@ +/* === 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::SummaryQmlViewStep( QObject* parent ) + : Calamares::QmlViewStep( parent ) + , m_config( new Config( this ) ) +{ + emit nextStatusChanged( true ); +} + + +SummaryQmlViewStep::~SummaryQmlViewStep() {} + +QString +SummaryQmlViewStep::prettyName() const +{ + return m_config->title(); +} + + +bool +SummaryQmlViewStep::isNextEnabled() const +{ + return true; +} + + +bool +SummaryQmlViewStep::isBackEnabled() const +{ + return true; +} + + +bool +SummaryQmlViewStep::isAtBeginning() const +{ + return true; +} + + +bool +SummaryQmlViewStep::isAtEnd() const +{ + return true; +} + + +Calamares::JobList +SummaryQmlViewStep::jobs() const +{ + return {}; +} + + +void +SummaryQmlViewStep::onActivate() +{ + // Collect the steps before this one: those need to have their + // summary (text or widget) displayed. + m_config->collectSummaries( this ); +} diff --git a/src/modules/summaryq/SummaryQmlViewStep.h b/src/modules/summaryq/SummaryQmlViewStep.h new file mode 100644 index 000000000..8668d0afe --- /dev/null +++ b/src/modules/summaryq/SummaryQmlViewStep.h @@ -0,0 +1,49 @@ +/* === 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 "DllMacro.h" +#include "utils/PluginFactory.h" +#include "viewpages/QmlViewStep.h" + +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; + + Calamares::JobList 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 + +