From 599c72badeb8f9ef1c749a7f9b0d273e39af436c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 28 Mar 2020 10:48:13 +0100 Subject: [PATCH 01/47] Changes: post-release housekeeping --- CHANGES | 12 ++++++++++++ CMakeLists.txt | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index e5958750f..a24325308 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,18 @@ contributors are listed. Note that Calamares does not have a historical changelog -- this log starts with version 3.2.0. The release notes on the website will have to do for older versions. +# 3.2.22 (unreleased) # + +This release contains contributions from (alphabetically by first name): + - No external contributors yet + +## Core ## + - No core changes yet + +## Modules ## + - No module changes yet + + # 3.2.21 (2020-03-27) # This release contains contributions from (alphabetically by first name): diff --git a/CMakeLists.txt b/CMakeLists.txt index 837010be4..d70863929 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,10 +40,10 @@ cmake_minimum_required( VERSION 3.3 FATAL_ERROR ) project( CALAMARES - VERSION 3.2.21 + VERSION 3.2.22 LANGUAGES C CXX ) -set( CALAMARES_VERSION_RC 0 ) # Set to 0 during release cycle, 1 during development +set( CALAMARES_VERSION_RC 1 ) # Set to 0 during release cycle, 1 during development ### OPTIONS # From 7c56a506329a6e3913fff209d7370aba0d38de08 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 28 Mar 2020 11:18:31 +0100 Subject: [PATCH 02/47] [netinstall] Expand documentation of groups format --- src/modules/netinstall/README.md | 11 ++++++++--- src/modules/netinstall/netinstall.conf | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/netinstall/README.md b/src/modules/netinstall/README.md index cda4b6c88..cb6159d95 100644 --- a/src/modules/netinstall/README.md +++ b/src/modules/netinstall/README.md @@ -19,7 +19,9 @@ least should contain a *groupsUrl* key: The URL must point to a YAML file, the *groups* file. See below for the format of that groups file. The URL may be a local file (e.g. -scheme `file:///`) or a regular HTTP(s) URL. +scheme `file:///`) or a regular HTTP(s) URL. The URL has one special +case: the literal string `local` is used to indicate that the groups +data is contained in the `netinstall.conf` file itself. ## Groups Configuration @@ -47,13 +49,16 @@ More keys (per group) are supported: - *selected*: if true, display the group as selected. Defaults to false. - *critical*: if true, make the installation process fail if installing any of the packages in the group fails. Otherwise, just log a warning. - Defaults to false. + Defaults to false. If not set in a subgroup (see below), inherits from + the parent group. - *immutable*: if true, the state of the group (and all its subgroups) cannot be changed; it really only makes sense in combination with *selected* set to true. This only affects the user-interface. - *expanded*: if true, the group is shown in an expanded form (that is, not-collapsed) in the treeview on start. This only affects the user- - interface. + interface. Only top-level groups are show expanded-initially. + - *immutable*: if true, the group cannot be changed (packages selected + or deselected) and no checkboxes are shown for the group. - *subgroups*: if present this follows the same structure as the top level of the YAML file, allowing there to be sub-groups of packages to an arbitary depth diff --git a/src/modules/netinstall/netinstall.conf b/src/modules/netinstall/netinstall.conf index 82e12d558..5eeef905c 100644 --- a/src/modules/netinstall/netinstall.conf +++ b/src/modules/netinstall/netinstall.conf @@ -54,6 +54,8 @@ label: # If, and only if, *groupsUrl* is set to the literal string `local`, # groups data is read from this file. The value of *groups* must be # a list, with the same format as the regular `netinstall.yaml` file. +# See the `README.md` file in the *netinstall* module for documentation +# on the format of groups data. # # This is recommended only for small static package lists. groups: From 83f5f9e1a73dc01c5436d2718b701aad6deda896 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 28 Mar 2020 11:45:44 +0100 Subject: [PATCH 03/47] [libcalamares] Introduce generic delete-later class Don't bother with QScopeGuard just right now, since I can't find a use-case in the Calamares codebase. FIXES #1358 --- src/libcalamares/utils/RAII.h | 43 +++++++++++++++++++++++++++++++ src/modules/netinstall/Config.cpp | 18 ++----------- 2 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 src/libcalamares/utils/RAII.h diff --git a/src/libcalamares/utils/RAII.h b/src/libcalamares/utils/RAII.h new file mode 100644 index 000000000..cff97bcef --- /dev/null +++ b/src/libcalamares/utils/RAII.h @@ -0,0 +1,43 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Adriaan de Groot + * + * 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 UTILS_RAII_H +#define UTILS_RAII_H + +#include + +#include + +/// @brief Convenience to zero out and deleteLater of any QObject-derived-class +template< typename T > +struct cqDeleter +{ + T*& p; + + ~cqDeleter() + { + static_assert( std::is_base_of::value, "Not a QObject-class" ); + if ( p ) + { + p->deleteLater(); + } + p = nullptr; + } +}; + +#endif diff --git a/src/modules/netinstall/Config.cpp b/src/modules/netinstall/Config.cpp index 78718add1..556cb1cf9 100644 --- a/src/modules/netinstall/Config.cpp +++ b/src/modules/netinstall/Config.cpp @@ -23,6 +23,7 @@ #include "network/Manager.h" #include "utils/Logger.h" +#include "utils/RAII.h" #include "utils/Yaml.h" #include @@ -96,21 +97,6 @@ Config::loadGroupList( const QUrl& url ) } } -/// @brief Convenience to zero out and deleteLater on the reply, used in dataIsHere -struct ReplyDeleter -{ - QNetworkReply*& p; - - ~ReplyDeleter() - { - if ( p ) - { - p->deleteLater(); - } - p = nullptr; - } -}; - void Config::receivedGroupData() { @@ -123,7 +109,7 @@ Config::receivedGroupData() cDebug() << "NetInstall group data received" << m_reply->size() << "bytes from" << m_reply->url(); - ReplyDeleter d { m_reply }; + cqDeleter< QNetworkReply > d{ m_reply }; // If m_required is *false* then we still say we're ready // even if the reply is corrupt or missing. From b271ed19b7c067f7ec0443da59839e8eaba75f63 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 28 Mar 2020 12:49:34 +0100 Subject: [PATCH 04/47] [partition] Fix typo in message --- src/modules/partition/gui/PartitionViewStep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index 6a1cde3a6..ed35fafa4 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -471,7 +471,7 @@ PartitionViewStep::onLeave() "

" "To configure a GPT partition table on BIOS, " "(if not done so already) go back " - "and set the partion table to GPT, next create a 8 MB " + "and set the partition table to GPT, next create a 8 MB " "unformatted partition with the " "bios_grub flag enabled.

" "An unformatted 8 MB partition is necessary " From b8962cec2dde6eee9579c220ad1eb7a12edf38f6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 30 Mar 2020 13:11:08 +0200 Subject: [PATCH 05/47] [libcalamaresui] Expose currentStepIndex --- src/libcalamaresui/ViewManager.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index a4bedd7bc..3ca02bc55 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -37,6 +37,8 @@ namespace Calamares class UIDLLEXPORT ViewManager : public QAbstractListModel { Q_OBJECT + Q_PROPERTY( int currentStepIndex READ currentStepIndex NOTIFY currentStepChanged FINAL ) + public: /** * @brief instance access to the ViewManager singleton. From aad79f664eaed90776e1dd843cb85ef0a885333a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 30 Mar 2020 14:10:20 +0200 Subject: [PATCH 06/47] [libcalamaresui] Expose currentIndex also as model data --- src/libcalamaresui/ViewManager.cpp | 2 ++ src/libcalamaresui/ViewManager.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 9972c3af9..1499e3653 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -559,6 +559,8 @@ ViewManager::data( const QModelIndex& index, int role ) const { return QVariant(); } + case ProgressTreeItemCurrentIndex: + return m_currentStep; case ProgressTreeItemCurrentRole: return currentStep() == step; case ProgressTreeItemCompletedRole: diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 3ca02bc55..2c12aac6b 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -154,7 +154,8 @@ public: enum Role { ProgressTreeItemCurrentRole = Qt::UserRole + 11, ///< Is this the *current* step? - ProgressTreeItemCompletedRole = Qt::UserRole + 12 ///< Are we past this one? + ProgressTreeItemCompletedRole = Qt::UserRole + 12, ///< Are we past this one? + ProgressTreeItemCurrentIndex = Qt::UserRole + 13 ///< Index (row) of the current step }; QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; From 3d7e5bc90d7d8a4af073e268ac52bc862beeb74e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 30 Mar 2020 14:14:10 +0200 Subject: [PATCH 07/47] [libcalamaresui] Expose just currentIndex - drop the current and completed roles, and expose only the currentIndex. QML can use the QObject property on the model, while QWidgets can call internally through the model's data() function. - we don't need to provide role names for this, so drop that bit. - simplify the delegate code while here. --- .../progresstree/ProgressTreeDelegate.cpp | 5 +--- src/libcalamaresui/ViewManager.cpp | 26 ------------------- src/libcalamaresui/ViewManager.h | 4 --- 3 files changed, 1 insertion(+), 34 deletions(-) diff --git a/src/calamares/progresstree/ProgressTreeDelegate.cpp b/src/calamares/progresstree/ProgressTreeDelegate.cpp index e7041d1b9..574777ed8 100644 --- a/src/calamares/progresstree/ProgressTreeDelegate.cpp +++ b/src/calamares/progresstree/ProgressTreeDelegate.cpp @@ -85,10 +85,7 @@ ProgressTreeDelegate::paintViewStep( QPainter* painter, font.setBold( false ); painter->setFont( font ); - bool isCurrent = false; - isCurrent = index.data( Calamares::ViewManager::ProgressTreeItemCurrentRole ).toBool(); - - if ( isCurrent ) + if ( index.row() == index.data( Calamares::ViewManager::ProgressTreeItemCurrentIndex ).toInt() ) { painter->setPen( Calamares::Branding::instance()->styleString( Calamares::Branding::SidebarTextSelect ) ); QString textHighlight diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 1499e3653..f0c7d5965 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -561,23 +561,6 @@ ViewManager::data( const QModelIndex& index, int role ) const } case ProgressTreeItemCurrentIndex: return m_currentStep; - case ProgressTreeItemCurrentRole: - return currentStep() == step; - case ProgressTreeItemCompletedRole: - // Every step *before* the current step is considered "complete" - for ( const auto* otherstep : m_steps ) - { - if ( otherstep == currentStep() ) - { - break; - } - if ( otherstep == step ) - { - return true; - } - } - // .. and the others (including current) are not. - return false; default: return QVariant(); } @@ -594,13 +577,4 @@ ViewManager::rowCount( const QModelIndex& parent ) const return m_steps.length(); } -QHash< int, QByteArray > -ViewManager::roleNames() const -{ - auto h = QAbstractListModel::roleNames(); - h.insert( ProgressTreeItemCurrentRole, "current" ); - h.insert( ProgressTreeItemCompletedRole, "completed" ); - return h; -} - } // namespace Calamares diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 2c12aac6b..f16419dcd 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -153,15 +153,11 @@ public: */ enum Role { - ProgressTreeItemCurrentRole = Qt::UserRole + 11, ///< Is this the *current* step? - ProgressTreeItemCompletedRole = Qt::UserRole + 12, ///< Are we past this one? ProgressTreeItemCurrentIndex = Qt::UserRole + 13 ///< Index (row) of the current step }; QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; int rowCount( const QModelIndex& parent = QModelIndex() ) const override; - - QHash< int, QByteArray > roleNames() const override; }; } // namespace Calamares From fff4caf0de84e8b2f3d183b2f1478feb9c0ae59f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 30 Mar 2020 14:16:25 +0200 Subject: [PATCH 08/47] [libcalamaresui] Apply coding style - while here, update copyright --- src/calamares/progresstree/ProgressTreeDelegate.cpp | 4 ++-- src/libcalamaresui/ViewManager.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calamares/progresstree/ProgressTreeDelegate.cpp b/src/calamares/progresstree/ProgressTreeDelegate.cpp index 574777ed8..7b7101f5d 100644 --- a/src/calamares/progresstree/ProgressTreeDelegate.cpp +++ b/src/calamares/progresstree/ProgressTreeDelegate.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017, 2019, Adriaan de Groot + * Copyright 2017, 2019-2020, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +19,10 @@ #include "ProgressTreeDelegate.h" +#include "Branding.h" #include "CalamaresApplication.h" #include "CalamaresWindow.h" #include "ViewManager.h" -#include "Branding.h" #include "utils/CalamaresUtilsGui.h" #include diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index f0c7d5965..93f23bd2f 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -3,7 +3,7 @@ * Copyright 2019, Dominic Hayes * Copyright 2019, Gabriel Craciunescu * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017-2018, Adriaan de Groot + * Copyright 2017-2018, 2020, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From eda2e4e10a34b6935766c8e20e535f1c2221b404 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 30 Mar 2020 14:22:27 +0200 Subject: [PATCH 09/47] [calamares] Tweak looks of basic-QML-sidebar - Use the new currentStepIndex (suggested by Camilo) to see if something is selected / current. --- src/calamares/calamares-sidebar.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calamares/calamares-sidebar.qml b/src/calamares/calamares-sidebar.qml index a486bdb17..aa794e94a 100644 --- a/src/calamares/calamares-sidebar.qml +++ b/src/calamares/calamares-sidebar.qml @@ -26,7 +26,8 @@ Repeater { color: "black" Text { - color: completed ? "green" : "yellow" + anchors.centerIn: parent + color: index == ViewManager.currentStepIndex ? "green" : "yellow" text: display } } From c10ef9e3bc10fd36440e1bfd6b15deca38f77b9d Mon Sep 17 00:00:00 2001 From: demmm Date: Mon, 30 Mar 2020 21:21:36 +0200 Subject: [PATCH 10/47] [welcome] Improve welcomeq visuals - set image to fill - keep aspect ratio - don't hardcode text color - variation in icons used - expand header text to check fit --- src/modules/welcomeq/welcomeq.qml | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/modules/welcomeq/welcomeq.qml b/src/modules/welcomeq/welcomeq.qml index 3275836a7..77f379da6 100644 --- a/src/modules/welcomeq/welcomeq.qml +++ b/src/modules/welcomeq/welcomeq.qml @@ -31,7 +31,7 @@ Page header: Item { width: parent.width - height: 150 + height: parent.height Text { @@ -39,7 +39,7 @@ Page anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top // In QML, QString::arg() only takes one argument - text: qsTr("

%1 %2

").arg(Branding.string(Branding.ProductName)).arg(Branding.string(Branding.Version)) + text: qsTr("

Welcome to the %1 %2 installer

").arg(Branding.string(Branding.ProductName)).arg(Branding.string(Branding.Version)) } Image { @@ -49,10 +49,9 @@ Page // .. otherwise the path is interpreted relative to the "call site", which // .. might be the QRC file. source: "file:/" + Branding.imagePath(Branding.ProductWelcome) - height: Math.min(100, parent.height) - width: height sourceSize.width: width sourceSize.height: height + fillMode: Image.PreserveAspectFit } RowLayout @@ -73,9 +72,9 @@ Page { Layout.fillWidth: true text: qsTr("About") - icon.name: "documentinfo" + icon.name: "dialog-information" Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) - Kirigami.Theme.textColor: "#fff" + Kirigami.Theme.textColor: Kirigami.Theme.textColor visible: false onClicked: { } // TODO: show an about-Calamares window @@ -84,9 +83,9 @@ Page { Layout.fillWidth: true text: qsTr("Support") - icon.name: "documentinfo" + icon.name: "system-help" Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) - Kirigami.Theme.textColor: "#fff" + Kirigami.Theme.textColor: Kirigami.Theme.textColor visible: config.helpUrl.isValid onClicked: Qt.openUrlExternally(config.helpUrl) @@ -95,9 +94,9 @@ Page { Layout.fillWidth: true text: qsTr("Known issues") - icon.name: "documentinfo" + icon.name: "tools-report-bug" Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) - Kirigami.Theme.textColor: "#fff" + Kirigami.Theme.textColor: Kirigami.Theme.textColor visible: config.issuesUrl.isValid onClicked: Qt.openUrlExternally(config.issuesUrl) @@ -106,9 +105,9 @@ Page { Layout.fillWidth: true text: qsTr("Release notes") - icon.name: "documentinfo" + icon.name: "folder-text" Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) - Kirigami.Theme.textColor: "#fff" + Kirigami.Theme.textColor: Kirigami.Theme.textColor visible: config.notesUrl.isValid onClicked: Qt.openUrlExternally(config.notesUrl) @@ -117,9 +116,9 @@ Page { Layout.fillWidth: true text: qsTr("Donate") - icon.name: "documentinfo" + icon.name: "taxes-finances" Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) - Kirigami.Theme.textColor: "#fff" + Kirigami.Theme.textColor: Kirigami.Theme.textColor visible: config.donateUrl.isValid onClicked: Qt.openUrlExternally(config.donateUrl) From 4ddd1ecceb83b760fb5d680ce17cb8c0dbe1e485 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Mar 2020 22:13:30 +0200 Subject: [PATCH 11/47] [libcalamares] Move Requirement to libcalamares - This isn't a UI component: a requirement can be checked and reported-on without a UI entirely. --- src/libcalamares/CMakeLists.txt | 1 + .../modulesystem/Requirement.cpp | 0 .../modulesystem/Requirement.h | 2 ++ src/libcalamaresui/CMakeLists.txt | 1 - src/libcalamaresui/modulesystem/Module.h | 4 ++-- src/libcalamaresui/modulesystem/ModuleManager.h | 3 +-- src/libcalamaresui/modulesystem/RequirementsChecker.cpp | 5 ++--- src/libcalamaresui/modulesystem/RequirementsChecker.h | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) rename src/{libcalamaresui => libcalamares}/modulesystem/Requirement.cpp (100%) rename src/{libcalamaresui => libcalamares}/modulesystem/Requirement.h (98%) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 608768a97..a663552f0 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -39,6 +39,7 @@ set( libSources # Modules modulesystem/InstanceKey.cpp + modulesystem/Requirement.cpp # Network service network/Manager.cpp diff --git a/src/libcalamaresui/modulesystem/Requirement.cpp b/src/libcalamares/modulesystem/Requirement.cpp similarity index 100% rename from src/libcalamaresui/modulesystem/Requirement.cpp rename to src/libcalamares/modulesystem/Requirement.cpp diff --git a/src/libcalamaresui/modulesystem/Requirement.h b/src/libcalamares/modulesystem/Requirement.h similarity index 98% rename from src/libcalamaresui/modulesystem/Requirement.h rename to src/libcalamares/modulesystem/Requirement.h index 3f8d1a54b..da3cf29dd 100644 --- a/src/libcalamaresui/modulesystem/Requirement.h +++ b/src/libcalamares/modulesystem/Requirement.h @@ -18,6 +18,8 @@ #ifndef CALAMARES_REQUIREMENT_H #define CALAMARES_REQUIREMENT_H +#include "DllMacro.h" + #include #include #include diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index c603ca22d..ed50d777b 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -9,7 +9,6 @@ set( calamaresui_SOURCES modulesystem/Module.cpp modulesystem/ModuleManager.cpp modulesystem/ProcessJobModule.cpp - modulesystem/Requirement.cpp modulesystem/RequirementsChecker.cpp modulesystem/ViewModule.cpp diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index 0891f8a25..5455916e4 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -20,12 +20,12 @@ #ifndef CALAMARES_MODULE_H #define CALAMARES_MODULE_H -#include "Job.h" -#include "Requirement.h" #include "DllMacro.h" +#include "Job.h" #include "modulesystem/Descriptor.h" #include "modulesystem/InstanceKey.h" +#include "modulesystem/Requirement.h" #include #include diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index be485c01d..fdb63cd87 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -22,8 +22,7 @@ #include "modulesystem/Descriptor.h" #include "modulesystem/InstanceKey.h" - -#include "Requirement.h" +#include "modulesystem/Requirement.h" #include #include diff --git a/src/libcalamaresui/modulesystem/RequirementsChecker.cpp b/src/libcalamaresui/modulesystem/RequirementsChecker.cpp index 41281c9b9..b941adee1 100644 --- a/src/libcalamaresui/modulesystem/RequirementsChecker.cpp +++ b/src/libcalamaresui/modulesystem/RequirementsChecker.cpp @@ -19,17 +19,16 @@ #include "RequirementsChecker.h" #include "Module.h" -#include "Requirement.h" +#include "modulesystem/Requirement.h" #include "utils/Logger.h" -#include - #include #include #include #include +#include namespace Calamares { diff --git a/src/libcalamaresui/modulesystem/RequirementsChecker.h b/src/libcalamaresui/modulesystem/RequirementsChecker.h index 2e1708016..7cda10fbc 100644 --- a/src/libcalamaresui/modulesystem/RequirementsChecker.h +++ b/src/libcalamaresui/modulesystem/RequirementsChecker.h @@ -18,7 +18,7 @@ #ifndef CALAMARES_REQUIREMENTSCHECKER_H #define CALAMARES_REQUIREMENTSCHECKER_H -#include "Requirement.h" +#include "modulesystem/Requirement.h" #include #include From e04f87fe9510d3f7576ec9563f9cbfbd3a86d28b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Mar 2020 22:44:02 +0200 Subject: [PATCH 12/47] [libcalamaresui] Refactor moduleFromDescriptor - this function lives in Module -- and is the only thing typing Module to the ViewSteps and JobTypes. Split it out into its own funciton. Nothing else in Module needs to befriend the ViewSteps, so we move the friend declaration around a bit as well. - while here, apply coding style. This is prep-work for moving module to libcalamares. --- src/calamares/testmain.cpp | 2 +- src/libcalamaresui/CMakeLists.txt | 1 + .../modulesystem/CppJobModule.h | 8 +- src/libcalamaresui/modulesystem/Module.cpp | 108 +----------- src/libcalamaresui/modulesystem/Module.h | 23 ++- .../modulesystem/ModuleFactory.cpp | 154 ++++++++++++++++++ .../modulesystem/ModuleFactory.h | 47 ++++++ .../modulesystem/ModuleManager.cpp | 9 +- .../modulesystem/ProcessJobModule.h | 6 +- .../modulesystem/PythonJobModule.h | 6 +- .../modulesystem/PythonQtViewModule.h | 8 +- src/libcalamaresui/modulesystem/ViewModule.h | 8 +- 12 files changed, 249 insertions(+), 131 deletions(-) create mode 100644 src/libcalamaresui/modulesystem/ModuleFactory.cpp create mode 100644 src/libcalamaresui/modulesystem/ModuleFactory.h diff --git a/src/calamares/testmain.cpp b/src/calamares/testmain.cpp index 0845218eb..8dcf41faa 100644 --- a/src/calamares/testmain.cpp +++ b/src/calamares/testmain.cpp @@ -183,7 +183,7 @@ load_module( const ModuleConfig& moduleConfig ) cDebug() << "Module" << moduleName << "job-configuration:" << configFile; - Calamares::Module* module = Calamares::Module::fromDescriptor( descriptor, name, configFile, moduleDirectory ); + Calamares::Module* module = Calamares::moduleFromDescriptor( descriptor, name, configFile, moduleDirectory ); return module; } diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index ed50d777b..da4e4b42b 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -7,6 +7,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/libcalamares ${CMAKE_BINARY_DIR}/sr set( calamaresui_SOURCES modulesystem/CppJobModule.cpp modulesystem/Module.cpp + modulesystem/ModuleFactory.cpp modulesystem/ModuleManager.cpp modulesystem/ProcessJobModule.cpp modulesystem/RequirementsChecker.cpp diff --git a/src/libcalamaresui/modulesystem/CppJobModule.h b/src/libcalamaresui/modulesystem/CppJobModule.h index d97443a8a..8f7cfb03a 100644 --- a/src/libcalamaresui/modulesystem/CppJobModule.h +++ b/src/libcalamaresui/modulesystem/CppJobModule.h @@ -21,8 +21,8 @@ #ifndef CALAMARES_CPPJOBMODULE_H #define CALAMARES_CPPJOBMODULE_H -#include "Module.h" #include "DllMacro.h" +#include "Module.h" class QPluginLoader; @@ -42,12 +42,16 @@ protected: void initFrom( const QVariantMap& moduleDescriptor ) override; private: - friend class Module; //so only the superclass can instantiate explicit CppJobModule(); virtual ~CppJobModule() override; QPluginLoader* m_loader; job_ptr m_job; + + friend Module* Calamares::moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, + const QString& instanceId, + const QString& configFileName, + const QString& moduleDirectory ); }; } // namespace Calamares diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 35b1508f1..08a46e546 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -66,111 +66,6 @@ Module::initFrom( const Calamares::ModuleSystem::Descriptor& moduleDescriptor, c } } -Module* -Module::fromDescriptor( const Calamares::ModuleSystem::Descriptor& moduleDescriptor, - const QString& instanceId, - const QString& configFileName, - const QString& moduleDirectory ) -{ - std::unique_ptr< Module > m; - - QString typeString = moduleDescriptor.value( "type" ).toString(); - QString intfString = moduleDescriptor.value( "interface" ).toString(); - - if ( typeString.isEmpty() || intfString.isEmpty() ) - { - cError() << "Bad module descriptor format" << instanceId; - return nullptr; - } - if ( ( typeString == "view" ) || ( typeString == "viewmodule" ) ) - { - if ( intfString == "qtplugin" ) - { - m.reset( new ViewModule() ); - } - else if ( intfString == "pythonqt" ) - { -#ifdef WITH_PYTHONQT - m.reset( new PythonQtViewModule() ); -#else - cError() << "PythonQt view modules are not supported in this version of Calamares."; -#endif - } - else - { - cError() << "Bad interface" << intfString << "for module type" << typeString; - } - } - else if ( typeString == "job" ) - { - if ( intfString == "qtplugin" ) - { - m.reset( new CppJobModule() ); - } - else if ( intfString == "process" ) - { - m.reset( new ProcessJobModule() ); - } - else if ( intfString == "python" ) - { -#ifdef WITH_PYTHON - m.reset( new PythonJobModule() ); -#else - cError() << "Python modules are not supported in this version of Calamares."; -#endif - } - else - { - cError() << "Bad interface" << intfString << "for module type" << typeString; - } - } - else - { - cError() << "Bad module type" << typeString; - } - - if ( !m ) - { - cError() << "Bad module type (" << typeString << ") or interface string (" << intfString << ") for module " - << instanceId; - return nullptr; - } - - QDir moduleDir( moduleDirectory ); - if ( moduleDir.exists() && moduleDir.isReadable() ) - { - m->m_directory = moduleDir.absolutePath(); - } - else - { - cError() << "Bad module directory" << moduleDirectory << "for" << instanceId; - return nullptr; - } - - m->initFrom( moduleDescriptor, instanceId ); - if ( !m->m_key.isValid() ) - { - cError() << "Module" << instanceId << "invalid ID"; - return nullptr; - } - - m->initFrom( moduleDescriptor ); - if ( !configFileName.isEmpty() ) - { - try - { - m->loadConfigurationFile( configFileName ); - } - catch ( YAML::Exception& e ) - { - cError() << "YAML parser error " << e.what(); - return nullptr; - } - } - return m.release(); -} - - static QStringList moduleConfigurationCandidates( bool assumeBuildDir, const QString& moduleName, const QString& configFileName ) { @@ -211,7 +106,8 @@ moduleConfigurationCandidates( bool assumeBuildDir, const QString& moduleName, c return paths; } -void Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Exception +void +Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Exception { QStringList configCandidates = moduleConfigurationCandidates( Settings::instance()->debugMode(), name(), configFileName ); diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index 5455916e4..67b76601a 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -33,6 +33,12 @@ namespace Calamares { +class Module; +Module* moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, + const QString& instanceId, + const QString& configFileName, + const QString& moduleDirectory ); + /** * @brief The Module class is a common supertype for Calamares modules. @@ -68,18 +74,6 @@ public: PythonQt // Views only, available as enum even if PythonQt isn't used }; - /** - * @brief fromDescriptor creates a new Module object of the correct type. - * @param moduleDescriptor a module descriptor, already parsed into a variant map. - * @param instanceId the instance id of the new module instance. - * @param configFileName the name of the configuration file to read. - * @param moduleDirectory the path to the directory with this module's files. - * @return a pointer to an object of a subtype of Module. - */ - static Module* fromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, - const QString& instanceId, - const QString& configFileName, - const QString& moduleDirectory ); virtual ~Module(); /** @@ -193,6 +187,11 @@ private: QString m_directory; ModuleSystem::InstanceKey m_key; + + friend Module* Calamares::moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, + const QString& instanceId, + const QString& configFileName, + const QString& moduleDirectory ); }; } // namespace Calamares diff --git a/src/libcalamaresui/modulesystem/ModuleFactory.cpp b/src/libcalamaresui/modulesystem/ModuleFactory.cpp new file mode 100644 index 000000000..f3b46eab7 --- /dev/null +++ b/src/libcalamaresui/modulesystem/ModuleFactory.cpp @@ -0,0 +1,154 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017-2018, Adriaan de Groot + * + * 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 "ModuleFactory.h" + +#include "CalamaresConfig.h" +#include "CppJobModule.h" +#include "ProcessJobModule.h" +#include "ViewModule.h" + +#include "utils/Dirs.h" +#include "utils/Logger.h" +#include "utils/NamedEnum.h" +#include "utils/Yaml.h" + +#ifdef WITH_PYTHON +#include "PythonJobModule.h" +#endif + +#ifdef WITH_PYTHONQT +#include "PythonQtViewModule.h" +#endif + +#include +#include +#include +#include + + +namespace Calamares +{ + +Module* +moduleFromDescriptor( const Calamares::ModuleSystem::Descriptor& moduleDescriptor, + const QString& instanceId, + const QString& configFileName, + const QString& moduleDirectory ) +{ + std::unique_ptr< Module > m; + + QString typeString = moduleDescriptor.value( "type" ).toString(); + QString intfString = moduleDescriptor.value( "interface" ).toString(); + + if ( typeString.isEmpty() || intfString.isEmpty() ) + { + cError() << "Bad module descriptor format" << instanceId; + return nullptr; + } + if ( ( typeString == "view" ) || ( typeString == "viewmodule" ) ) + { + if ( intfString == "qtplugin" ) + { + m.reset( new ViewModule() ); + } + else if ( intfString == "pythonqt" ) + { +#ifdef WITH_PYTHONQT + m.reset( new PythonQtViewModule() ); +#else + cError() << "PythonQt view modules are not supported in this version of Calamares."; +#endif + } + else + { + cError() << "Bad interface" << intfString << "for module type" << typeString; + } + } + else if ( typeString == "job" ) + { + if ( intfString == "qtplugin" ) + { + m.reset( new CppJobModule() ); + } + else if ( intfString == "process" ) + { + m.reset( new ProcessJobModule() ); + } + else if ( intfString == "python" ) + { +#ifdef WITH_PYTHON + m.reset( new PythonJobModule() ); +#else + cError() << "Python modules are not supported in this version of Calamares."; +#endif + } + else + { + cError() << "Bad interface" << intfString << "for module type" << typeString; + } + } + else + { + cError() << "Bad module type" << typeString; + } + + if ( !m ) + { + cError() << "Bad module type (" << typeString << ") or interface string (" << intfString << ") for module " + << instanceId; + return nullptr; + } + + QDir moduleDir( moduleDirectory ); + if ( moduleDir.exists() && moduleDir.isReadable() ) + { + m->m_directory = moduleDir.absolutePath(); + } + else + { + cError() << "Bad module directory" << moduleDirectory << "for" << instanceId; + return nullptr; + } + + m->initFrom( moduleDescriptor, instanceId ); + if ( !m->m_key.isValid() ) + { + cError() << "Module" << instanceId << "invalid ID"; + return nullptr; + } + + m->initFrom( moduleDescriptor ); + if ( !configFileName.isEmpty() ) + { + try + { + m->loadConfigurationFile( configFileName ); + } + catch ( YAML::Exception& e ) + { + cError() << "YAML parser error " << e.what(); + return nullptr; + } + } + return m.release(); +} + + +} // namespace Calamares diff --git a/src/libcalamaresui/modulesystem/ModuleFactory.h b/src/libcalamaresui/modulesystem/ModuleFactory.h new file mode 100644 index 000000000..8184967d2 --- /dev/null +++ b/src/libcalamaresui/modulesystem/ModuleFactory.h @@ -0,0 +1,47 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot + * + * 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 CALAMARES_MODULEFACTORY_H +#define CALAMARES_MODULEFACTORY_H + +#include "DllMacro.h" + +#include "modulesystem/Descriptor.h" +#include "modulesystem/Module.h" + +#include + +namespace Calamares +{ + +/** + * @brief fromDescriptor creates a new Module object of the correct type. + * @param moduleDescriptor a module descriptor, already parsed into a variant map. + * @param instanceId the instance id of the new module instance. + * @param configFileName the name of the configuration file to read. + * @param moduleDirectory the path to the directory with this module's files. + * @return a pointer to an object of a subtype of Module. + */ +UIDLLEXPORT Module* moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, + const QString& instanceId, + const QString& configFileName, + const QString& moduleDirectory ); +} // namespace Calamares + +#endif // CALAMARES_MODULEFACTORY_H diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index f88d5999d..cd79afad4 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -285,10 +285,11 @@ ModuleManager::loadModules() } else { - thisModule = Module::fromDescriptor( descriptor, - instanceKey.id(), - configFileName, - m_moduleDirectoriesByModuleName.value( instanceKey.module() ) ); + thisModule + = Calamares::moduleFromDescriptor( descriptor, + instanceKey.id(), + configFileName, + m_moduleDirectoriesByModuleName.value( instanceKey.module() ) ); if ( !thisModule ) { cError() << "Module" << instanceKey.toString() << "cannot be created from descriptor" diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.h b/src/libcalamaresui/modulesystem/ProcessJobModule.h index da2badbd0..5be5de837 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.h +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.h @@ -42,7 +42,6 @@ protected: void initFrom( const QVariantMap& moduleDescriptor ) override; private: - friend class Module; explicit ProcessJobModule(); virtual ~ProcessJobModule() override; @@ -51,6 +50,11 @@ private: std::chrono::seconds m_secondsTimeout; bool m_runInChroot; job_ptr m_job; + + friend Module* Calamares::moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, + const QString& instanceId, + const QString& configFileName, + const QString& moduleDirectory ); }; } // namespace Calamares diff --git a/src/libcalamaresui/modulesystem/PythonJobModule.h b/src/libcalamaresui/modulesystem/PythonJobModule.h index 295ab5942..8f65daa48 100644 --- a/src/libcalamaresui/modulesystem/PythonJobModule.h +++ b/src/libcalamaresui/modulesystem/PythonJobModule.h @@ -39,13 +39,17 @@ protected: void initFrom( const QVariantMap& moduleDescriptor ) override; private: - friend class Module; explicit PythonJobModule(); virtual ~PythonJobModule() override; QString m_scriptFileName; QString m_workingPath; job_ptr m_job; + + friend Module* Calamares::moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, + const QString& instanceId, + const QString& configFileName, + const QString& moduleDirectory ); }; } // namespace Calamares diff --git a/src/libcalamaresui/modulesystem/PythonQtViewModule.h b/src/libcalamaresui/modulesystem/PythonQtViewModule.h index 33b8d041b..64cc0f8a9 100644 --- a/src/libcalamaresui/modulesystem/PythonQtViewModule.h +++ b/src/libcalamaresui/modulesystem/PythonQtViewModule.h @@ -19,8 +19,8 @@ #ifndef CALAMARES_PYTHONQTVIEWMODULE_H #define CALAMARES_PYTHONQTVIEWMODULE_H -#include "Module.h" #include "DllMacro.h" +#include "Module.h" namespace Calamares { @@ -40,7 +40,6 @@ protected: void initFrom( const QVariantMap& moduleDescriptor ) override; private: - friend class Module; //so only the superclass can instantiate explicit PythonQtViewModule(); virtual ~PythonQtViewModule(); @@ -48,6 +47,11 @@ private: QString m_scriptFileName; QString m_workingPath; + + friend Module* Calamares::moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, + const QString& instanceId, + const QString& configFileName, + const QString& moduleDirectory ); }; } // namespace Calamares diff --git a/src/libcalamaresui/modulesystem/ViewModule.h b/src/libcalamaresui/modulesystem/ViewModule.h index c1ee8ff69..958b99c1c 100644 --- a/src/libcalamaresui/modulesystem/ViewModule.h +++ b/src/libcalamaresui/modulesystem/ViewModule.h @@ -20,8 +20,8 @@ #ifndef CALAMARES_VIEWMODULE_H #define CALAMARES_VIEWMODULE_H -#include "Module.h" #include "DllMacro.h" +#include "Module.h" class QPluginLoader; @@ -45,12 +45,16 @@ protected: void initFrom( const QVariantMap& moduleDescriptor ) override; private: - friend class Module; //so only the superclass can instantiate explicit ViewModule(); virtual ~ViewModule() override; QPluginLoader* m_loader; ViewStep* m_viewStep = nullptr; + + friend Module* Calamares::moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, + const QString& instanceId, + const QString& configFileName, + const QString& moduleDirectory ); }; } // namespace Calamares From 76555840228eb2005e4cd5e28727d710db6bac43 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Mar 2020 22:56:42 +0200 Subject: [PATCH 13/47] [libcalamaresui] Move Module to libcalamares - The Module class has no UI-specific code in it; it's all about loading and data-management. Move it out of the UI library. --- src/libcalamares/CMakeLists.txt | 1 + .../modulesystem/Module.cpp | 12 ------------ .../modulesystem/Module.h | 2 +- src/libcalamaresui/CMakeLists.txt | 1 - src/libcalamaresui/modulesystem/CppJobModule.h | 2 +- src/libcalamaresui/modulesystem/ModuleManager.cpp | 2 +- src/libcalamaresui/modulesystem/ProcessJobModule.h | 3 +-- src/libcalamaresui/modulesystem/PythonJobModule.h | 3 +-- .../modulesystem/RequirementsChecker.cpp | 3 +-- src/libcalamaresui/modulesystem/ViewModule.h | 2 +- 10 files changed, 8 insertions(+), 23 deletions(-) rename src/{libcalamaresui => libcalamares}/modulesystem/Module.cpp (96%) rename src/{libcalamaresui => libcalamares}/modulesystem/Module.h (99%) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index a663552f0..90f9f9046 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -39,6 +39,7 @@ set( libSources # Modules modulesystem/InstanceKey.cpp + modulesystem/Module.cpp modulesystem/Requirement.cpp # Network service diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamares/modulesystem/Module.cpp similarity index 96% rename from src/libcalamaresui/modulesystem/Module.cpp rename to src/libcalamares/modulesystem/Module.cpp index 08a46e546..9620299ec 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamares/modulesystem/Module.cpp @@ -20,30 +20,18 @@ #include "Module.h" #include "CalamaresConfig.h" -#include "CppJobModule.h" -#include "ProcessJobModule.h" #include "Settings.h" -#include "ViewModule.h" #include "utils/Dirs.h" #include "utils/Logger.h" #include "utils/NamedEnum.h" #include "utils/Yaml.h" -#ifdef WITH_PYTHON -#include "PythonJobModule.h" -#endif - -#ifdef WITH_PYTHONQT -#include "PythonQtViewModule.h" -#endif - #include #include #include #include - static const char EMERGENCY[] = "emergency"; namespace Calamares diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamares/modulesystem/Module.h similarity index 99% rename from src/libcalamaresui/modulesystem/Module.h rename to src/libcalamares/modulesystem/Module.h index 67b76601a..ba4533fae 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamares/modulesystem/Module.h @@ -46,7 +46,7 @@ Module* moduleFromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, * takes care of creating an object of the correct type starting from a module * descriptor structure. */ -class UIDLLEXPORT Module +class DLLEXPORT Module { public: /** diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index da4e4b42b..1f554fceb 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -6,7 +6,6 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/libcalamares ${CMAKE_BINARY_DIR}/sr set( calamaresui_SOURCES modulesystem/CppJobModule.cpp - modulesystem/Module.cpp modulesystem/ModuleFactory.cpp modulesystem/ModuleManager.cpp modulesystem/ProcessJobModule.cpp diff --git a/src/libcalamaresui/modulesystem/CppJobModule.h b/src/libcalamaresui/modulesystem/CppJobModule.h index 8f7cfb03a..2fd82433c 100644 --- a/src/libcalamaresui/modulesystem/CppJobModule.h +++ b/src/libcalamaresui/modulesystem/CppJobModule.h @@ -22,7 +22,7 @@ #define CALAMARES_CPPJOBMODULE_H #include "DllMacro.h" -#include "Module.h" +#include "modulesystem/Module.h" class QPluginLoader; diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index cd79afad4..aa05c6843 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -19,11 +19,11 @@ #include "ModuleManager.h" -#include "Module.h" #include "RequirementsChecker.h" #include "Settings.h" #include "ViewManager.h" +#include "modulesystem/Module.h" #include "utils/Logger.h" #include "utils/Yaml.h" #include "viewpages/ExecutionViewStep.h" diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.h b/src/libcalamaresui/modulesystem/ProcessJobModule.h index 5be5de837..87c6e2da8 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.h +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.h @@ -20,9 +20,8 @@ #ifndef CALAMARES_PROCESSJOBMODULE_H #define CALAMARES_PROCESSJOBMODULE_H -#include "Module.h" - #include "DllMacro.h" +#include "modulesystem/Module.h" #include diff --git a/src/libcalamaresui/modulesystem/PythonJobModule.h b/src/libcalamaresui/modulesystem/PythonJobModule.h index 8f65daa48..85f25ab74 100644 --- a/src/libcalamaresui/modulesystem/PythonJobModule.h +++ b/src/libcalamaresui/modulesystem/PythonJobModule.h @@ -19,9 +19,8 @@ #ifndef CALAMARES_PYTHONJOBMODULE_H #define CALAMARES_PYTHONJOBMODULE_H -#include "Module.h" - #include "DllMacro.h" +#include "modulesystem/Module.h" namespace Calamares { diff --git a/src/libcalamaresui/modulesystem/RequirementsChecker.cpp b/src/libcalamaresui/modulesystem/RequirementsChecker.cpp index b941adee1..97a4c912f 100644 --- a/src/libcalamaresui/modulesystem/RequirementsChecker.cpp +++ b/src/libcalamaresui/modulesystem/RequirementsChecker.cpp @@ -18,8 +18,7 @@ #include "RequirementsChecker.h" -#include "Module.h" - +#include "modulesystem/Module.h" #include "modulesystem/Requirement.h" #include "utils/Logger.h" diff --git a/src/libcalamaresui/modulesystem/ViewModule.h b/src/libcalamaresui/modulesystem/ViewModule.h index 958b99c1c..1d24ca811 100644 --- a/src/libcalamaresui/modulesystem/ViewModule.h +++ b/src/libcalamaresui/modulesystem/ViewModule.h @@ -21,7 +21,7 @@ #define CALAMARES_VIEWMODULE_H #include "DllMacro.h" -#include "Module.h" +#include "modulesystem/Module.h" class QPluginLoader; From 1765412b610e411e2dff41bfe8ca2a91e28fe160 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Mar 2020 23:13:13 +0200 Subject: [PATCH 14/47] [libcalamaresui] Move RequirementsChecker to libcalamares - the checker only collects and calls requirements; it has no UI component, and only manages data (and a thread to do the checking). Move it out of the UI library. --- src/libcalamares/CMakeLists.txt | 1 + .../modulesystem/RequirementsChecker.cpp | 0 .../modulesystem/RequirementsChecker.h | 3 +-- src/libcalamaresui/CMakeLists.txt | 1 - src/libcalamaresui/modulesystem/ModuleManager.cpp | 4 ++-- 5 files changed, 4 insertions(+), 5 deletions(-) rename src/{libcalamaresui => libcalamares}/modulesystem/RequirementsChecker.cpp (100%) rename src/{libcalamaresui => libcalamares}/modulesystem/RequirementsChecker.h (99%) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 90f9f9046..c7bb96266 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -41,6 +41,7 @@ set( libSources modulesystem/InstanceKey.cpp modulesystem/Module.cpp modulesystem/Requirement.cpp + modulesystem/RequirementsChecker.cpp # Network service network/Manager.cpp diff --git a/src/libcalamaresui/modulesystem/RequirementsChecker.cpp b/src/libcalamares/modulesystem/RequirementsChecker.cpp similarity index 100% rename from src/libcalamaresui/modulesystem/RequirementsChecker.cpp rename to src/libcalamares/modulesystem/RequirementsChecker.cpp diff --git a/src/libcalamaresui/modulesystem/RequirementsChecker.h b/src/libcalamares/modulesystem/RequirementsChecker.h similarity index 99% rename from src/libcalamaresui/modulesystem/RequirementsChecker.h rename to src/libcalamares/modulesystem/RequirementsChecker.h index 7cda10fbc..450495dc1 100644 --- a/src/libcalamaresui/modulesystem/RequirementsChecker.h +++ b/src/libcalamares/modulesystem/RequirementsChecker.h @@ -25,7 +25,6 @@ #include #include - namespace Calamares { @@ -44,7 +43,7 @@ public: RequirementsChecker( QVector< Module* > modules, QObject* parent = nullptr ); virtual ~RequirementsChecker() override; -public slots: +public Q_SLOTS: /// @brief Start checking all the requirements void run(); diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index 1f554fceb..e813b0009 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -9,7 +9,6 @@ set( calamaresui_SOURCES modulesystem/ModuleFactory.cpp modulesystem/ModuleManager.cpp modulesystem/ProcessJobModule.cpp - modulesystem/RequirementsChecker.cpp modulesystem/ViewModule.cpp utils/CalamaresUtilsGui.cpp diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index aa05c6843..8d4b2342f 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -19,11 +19,11 @@ #include "ModuleManager.h" -#include "RequirementsChecker.h" -#include "Settings.h" #include "ViewManager.h" +#include "Settings.h" #include "modulesystem/Module.h" +#include "modulesystem/RequirementsChecker.h" #include "utils/Logger.h" #include "utils/Yaml.h" #include "viewpages/ExecutionViewStep.h" From d8ecd302e1e3a3ce55773c30dd8e8f404f196e73 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Mar 2020 23:19:51 +0200 Subject: [PATCH 15/47] [libcalamares] Apply coding style - minor space issues - drop a blank line after moc-warnings.h to avoid if being sorted downwards, after the MOC file it's protecting --- src/libcalamares/PythonJobApi.cpp | 6 +++--- src/libcalamares/modulesystem/InstanceKey.h | 3 +-- src/libcalamares/modulesystem/Tests.cpp | 1 + src/libcalamares/network/Manager.cpp | 1 + src/libcalamares/network/Tests.cpp | 3 ++- src/libcalamares/utils/RAII.h | 4 ++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libcalamares/PythonJobApi.cpp b/src/libcalamares/PythonJobApi.cpp index cf7984c87..ecca466fe 100644 --- a/src/libcalamares/PythonJobApi.cpp +++ b/src/libcalamares/PythonJobApi.cpp @@ -65,9 +65,9 @@ mount( const std::string& device_path, const std::string& options ) { return CalamaresUtils::Partition::mount( QString::fromStdString( device_path ), - QString::fromStdString( mount_point ), - QString::fromStdString( filesystem_name ), - QString::fromStdString( options ) ); + QString::fromStdString( mount_point ), + QString::fromStdString( filesystem_name ), + QString::fromStdString( options ) ); } diff --git a/src/libcalamares/modulesystem/InstanceKey.h b/src/libcalamares/modulesystem/InstanceKey.h index 495401903..724827330 100644 --- a/src/libcalamares/modulesystem/InstanceKey.h +++ b/src/libcalamares/modulesystem/InstanceKey.h @@ -94,8 +94,7 @@ private: } }; -QDebug& -operator <<( QDebug& s, const Calamares::ModuleSystem::InstanceKey& i ); +QDebug& operator<<( QDebug& s, const Calamares::ModuleSystem::InstanceKey& i ); } // namespace ModuleSystem } // namespace Calamares diff --git a/src/libcalamares/modulesystem/Tests.cpp b/src/libcalamares/modulesystem/Tests.cpp index e7301a0be..b1fab7ffc 100644 --- a/src/libcalamares/modulesystem/Tests.cpp +++ b/src/libcalamares/modulesystem/Tests.cpp @@ -138,4 +138,5 @@ ModuleSystemTests::testBadFromStringCases() QTEST_GUILESS_MAIN( ModuleSystemTests ) #include "utils/moc-warnings.h" + #include "Tests.moc" diff --git a/src/libcalamares/network/Manager.cpp b/src/libcalamares/network/Manager.cpp index 1d58efba9..6e8a1e93d 100644 --- a/src/libcalamares/network/Manager.cpp +++ b/src/libcalamares/network/Manager.cpp @@ -286,4 +286,5 @@ Manager::asynchronousGet( const QUrl& url, const CalamaresUtils::Network::Reques } // namespace CalamaresUtils #include "utils/moc-warnings.h" + #include "Manager.moc" diff --git a/src/libcalamares/network/Tests.cpp b/src/libcalamares/network/Tests.cpp index 830545b96..dc893a9c9 100644 --- a/src/libcalamares/network/Tests.cpp +++ b/src/libcalamares/network/Tests.cpp @@ -47,6 +47,7 @@ NetworkTests::testPing() using namespace CalamaresUtils::Network; Logger::setupLogLevel( Logger::LOGVERBOSE ); auto& nam = Manager::instance(); - auto canPing_www_kde_org = nam.synchronousPing( QUrl( "https://www.kde.org" ), RequestOptions( RequestOptions::FollowRedirect ) ); + auto canPing_www_kde_org + = nam.synchronousPing( QUrl( "https://www.kde.org" ), RequestOptions( RequestOptions::FollowRedirect ) ); QVERIFY( canPing_www_kde_org ); } diff --git a/src/libcalamares/utils/RAII.h b/src/libcalamares/utils/RAII.h index cff97bcef..4d8210a25 100644 --- a/src/libcalamares/utils/RAII.h +++ b/src/libcalamares/utils/RAII.h @@ -24,14 +24,14 @@ #include /// @brief Convenience to zero out and deleteLater of any QObject-derived-class -template< typename T > +template < typename T > struct cqDeleter { T*& p; ~cqDeleter() { - static_assert( std::is_base_of::value, "Not a QObject-class" ); + static_assert( std::is_base_of< QObject, T >::value, "Not a QObject-class" ); if ( p ) { p->deleteLater(); From d4083c9bbbe8324b950f6a5fa4c521b976e193ad Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Apr 2020 11:07:23 +0200 Subject: [PATCH 16/47] [libcalamaresui] Add "hidden" as alias for "none" in sidebar settings --- src/libcalamaresui/Branding.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 5c41f5ea2..a1634520b 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -422,6 +422,7 @@ Branding::initSimpleSettings( const YAML::Node& doc ) static const NamedEnumTable< SidebarFlavor > sidebarFlavorNames { { QStringLiteral( "widget" ), SidebarFlavor::Widget }, { QStringLiteral( "none" ), SidebarFlavor::None }, + { QStringLiteral( "hidden" ), SidebarFlavor::None }, { QStringLiteral( "qml" ), SidebarFlavor::Qml } }; // clang-format on From 57e6864902329c25565c0a856536079bd5d5e341 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Apr 2020 11:13:41 +0200 Subject: [PATCH 17/47] [libcalamaresui] Add panel flavor - rename enum to more general PanelFlavor - introduce branding settings for navigation (e.g. for switching the navigation buttons off, or using QML) --- src/branding/default/branding.desc | 8 +++++++- src/calamares/CalamaresWindow.cpp | 6 +++--- src/libcalamaresui/Branding.cpp | 16 +++++++++++----- src/libcalamaresui/Branding.h | 11 +++++++---- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index e7b9d9898..365af30e9 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -44,9 +44,15 @@ windowPlacement: center # Kind of sidebar (panel on the left, showing progress). # - "widget" or unset, use traditional sidebar (logo, items) # - "none", hide it entirely -# - "qml", use sidebar.qml from branding folder +# - "qml", use calamares-sidebar.qml from branding folder sidebar: widget +# Kind of navigation (button panel on the bottom). +# - "widget" or unset, use traditional navigation +# - "none", hide it entirely +# - "qml", use calamares-navigation.qml from branding folder +navigation: widget + # These are strings shown to the user in the user interface. # There is no provision for translating them -- since they # are names, the string is included as-is. diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index f2ff42aa8..f05bdc7d4 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -191,15 +191,15 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) QWidget* sideBox = nullptr; switch ( branding->sidebarFlavor() ) { - case Calamares::Branding::SidebarFlavor::Widget: + case Calamares::Branding::PanelFlavor::Widget: sideBox = getWidgetSidebar( qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) ); break; - case Calamares::Branding::SidebarFlavor::Qml: + case Calamares::Branding::PanelFlavor::Qml: sideBox = getQmlSidebar( qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) ); break; - case Calamares::Branding::SidebarFlavor::None: + case Calamares::Branding::PanelFlavor::None: sideBox = nullptr; } if ( sideBox ) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index a1634520b..25fab307e 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -419,11 +419,11 @@ Branding::initSimpleSettings( const YAML::Node& doc ) { QStringLiteral( "free" ), WindowPlacement::Free }, { QStringLiteral( "center" ), WindowPlacement::Center } }; - static const NamedEnumTable< SidebarFlavor > sidebarFlavorNames { - { QStringLiteral( "widget" ), SidebarFlavor::Widget }, - { QStringLiteral( "none" ), SidebarFlavor::None }, - { QStringLiteral( "hidden" ), SidebarFlavor::None }, - { QStringLiteral( "qml" ), SidebarFlavor::Qml } + static const NamedEnumTable< PanelFlavor > sidebarFlavorNames { + { QStringLiteral( "widget" ), PanelFlavor::Widget }, + { QStringLiteral( "none" ), PanelFlavor::None }, + { QStringLiteral( "hidden" ), PanelFlavor::None }, + { QStringLiteral( "qml" ), PanelFlavor::Qml } }; // clang-format on // *INDENT-ON* @@ -449,6 +449,12 @@ Branding::initSimpleSettings( const YAML::Node& doc ) cWarning() << "Branding module-setting *sidebar* interpreted as" << sidebarFlavorNames.find( m_sidebarFlavor, ok ); } + m_navigationFlavor = sidebarFlavorNames.find( getString( doc, "navigation" ), ok); + if ( !ok ) + { + cWarning() << "Branding module-setting *navigation* interpreted as" + << sidebarFlavorNames.find( m_navigationFlavor, ok ); + } QString windowSize = getString( doc, "windowSize" ); if ( !windowSize.isEmpty() ) diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 88f658473..b7ba637d6 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -124,13 +124,13 @@ public: }; Q_ENUM( WindowPlacement ) ///@brief What kind of sidebar to use in the main window - enum class SidebarFlavor + enum class PanelFlavor { None, Widget, Qml }; - Q_ENUM( SidebarFlavor ) + Q_ENUM( PanelFlavor ) static Branding* instance(); @@ -185,7 +185,9 @@ public: bool windowPlacementCentered() const { return m_windowPlacement == WindowPlacement::Center; } ///@brief Which sidebar flavor is configured - SidebarFlavor sidebarFlavor() const { return m_sidebarFlavor; } + PanelFlavor sidebarFlavor() const { return m_sidebarFlavor; } + ///@brief Which navigation flavor is configured + PanelFlavor navigationFlavor() const { return m_navigationFlavor; } /** * Creates a map called "branding" in the global storage, and inserts an @@ -227,7 +229,8 @@ private: WindowDimension m_windowHeight, m_windowWidth; WindowPlacement m_windowPlacement; - SidebarFlavor m_sidebarFlavor = SidebarFlavor::Widget; + PanelFlavor m_sidebarFlavor = PanelFlavor::Widget; + PanelFlavor m_navigationFlavor = PanelFlavor::Widget; }; template < typename U > From 6c8aa5da63839cadc5e3f697c7aa732d6b7485e1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Apr 2020 11:26:09 +0200 Subject: [PATCH 18/47] [libcalamaresui] Remove commented-out code --- src/libcalamaresui/ViewManager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 93f23bd2f..dda757fda 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -123,8 +123,6 @@ ViewManager::ViewManager( QObject* parent ) { m_quit->setVisible( false ); } - - // onInstallationFailed( "Title of Failure", "Body of Failure"); // for testing paste functionality } From d4f903b95ce3e78a316d07eb8f5d0a55f228f0f4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Apr 2020 11:35:27 +0200 Subject: [PATCH 19/47] [calamares] Create navigation panel in CalamaresWindow - this is a non-functional duplicate panel, so it looks funny --- src/calamares/CalamaresWindow.cpp | 59 ++++++++++++++++++++++++++++++- src/calamares/CalamaresWindow.h | 5 +++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index f05bdc7d4..054fb8639 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -143,6 +143,43 @@ CalamaresWindow::getQmlSidebar( int desiredWidth ) return w; } +/** @brief Get a button-sized icon. */ +static inline QPixmap +getButtonIcon( const QString& name ) +{ + return Calamares::Branding::instance()->image( name, QSize( 22, 22 ) ); +} + +QWidget* +CalamaresWindow::getWidgetNavigation() +{ + QWidget* navigation = new QWidget( this ); + + // Create buttons and sets an initial icon; the icons may change + auto* back = new QPushButton( getButtonIcon( QStringLiteral( "go-previous" ) ), tr( "&Back" ), navigation ); + back->setObjectName( "view-button-back" ); + auto* next = new QPushButton( getButtonIcon( QStringLiteral( "go-next" ) ), tr( "&Next" ), navigation ); + next->setObjectName( "view-button-next" ); + auto* quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), navigation ); + quit->setObjectName( "view-button-cancel" ); + + QBoxLayout* bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget( back ); + bottomLayout->addWidget( next ); + bottomLayout->addSpacing( 12 ); + bottomLayout->addWidget( quit ); + + navigation->setLayout( bottomLayout ); + return navigation; +} + +QWidget* +CalamaresWindow::getQmlNavigation() +{ + return nullptr; +} + CalamaresWindow::CalamaresWindow( QWidget* parent ) : QWidget( parent ) , m_debugWindow( nullptr ) @@ -219,9 +256,29 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) // and requires an extra show() (at least with KWin/X11) which // is too annoying. Instead, leave it up to ignoring-the-quit- // event, which is also the ViewManager's responsibility. + QBoxLayout* contentsLayout = new QVBoxLayout; + contentsLayout->addWidget( m_viewManager->centralWidget() ); + QWidget* navigation = nullptr; + switch ( branding->navigationFlavor() ) + { + case Calamares::Branding::PanelFlavor::Widget: + navigation = getWidgetNavigation(); + break; + case Calamares::Branding::PanelFlavor::Qml: + navigation = getQmlNavigation(); + break; + case Calamares::Branding::PanelFlavor::None: + navigation = nullptr; + } + if ( navigation ) + { + contentsLayout->addWidget( navigation ); + } + + mainLayout->addLayout( contentsLayout ); - mainLayout->addWidget( m_viewManager->centralWidget() ); CalamaresUtils::unmarginLayout( mainLayout ); + CalamaresUtils::unmarginLayout( contentsLayout ); setStyleSheet( Calamares::Branding::instance()->stylesheet() ); } diff --git a/src/calamares/CalamaresWindow.h b/src/calamares/CalamaresWindow.h index 5cbbdfca6..d6592c99a 100644 --- a/src/calamares/CalamaresWindow.h +++ b/src/calamares/CalamaresWindow.h @@ -51,9 +51,14 @@ protected: virtual void closeEvent( QCloseEvent* e ) override; private: + // Two variations on sidebar (the progress view) QWidget* getWidgetSidebar( int desiredWidth ); QWidget* getQmlSidebar( int desiredWidth ); + // Two variations on navigation (buttons at bottom) + QWidget* getWidgetNavigation(); + QWidget* getQmlNavigation(); + QPointer< Calamares::DebugWindow > m_debugWindow; // Managed by self Calamares::ViewManager* m_viewManager; }; From 02fc4ce806fcdeeb8157f39fbb8b7a1190e00b21 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Apr 2020 15:06:11 +0200 Subject: [PATCH 20/47] [calamares] Load QML navigation --- src/calamares/CalamaresWindow.cpp | 6 +++- src/calamares/calamares-navigation.qml | 47 ++++++++++++++++++++++++++ src/calamares/calamares.qrc | 1 + 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/calamares/calamares-navigation.qml diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 054fb8639..9c6626a3e 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -177,7 +177,11 @@ CalamaresWindow::getWidgetNavigation() QWidget* CalamaresWindow::getQmlNavigation() { - return nullptr; + CalamaresUtils::registerCalamaresModels(); + QQuickWidget* w = new QQuickWidget( this ); + w->setSource( QUrl( + CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) ); + return w; } CalamaresWindow::CalamaresWindow( QWidget* parent ) diff --git a/src/calamares/calamares-navigation.qml b/src/calamares/calamares-navigation.qml new file mode 100644 index 000000000..0831a9b6a --- /dev/null +++ b/src/calamares/calamares-navigation.qml @@ -0,0 +1,47 @@ +import io.calamares.ui 1.0 +import io.calamares.core 1.0 + +import QtQuick 2.3 +import QtQuick.Controls 2.10 +import QtQuick.Layouts 1.3 +import org.kde.kirigami 2.7 as Kirigami + +Row { + id: buttonBar + height: 64 + + Button + { + Layout.fillWidth: true + text: qsTr("Back") + icon.name: "next" + Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) + Kirigami.Theme.textColor: Kirigami.Theme.textColor + + visible: true + onClicked: { } + } + Button + { + Layout.fillWidth: true + text: qsTr("Next") + icon.name: "next" + Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) + Kirigami.Theme.textColor: Kirigami.Theme.textColor + + visible: true + onClicked: { } + } + Button + { + Layout.fillWidth: true + text: qsTr("Quit") + icon.name: "quit" + Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) + Kirigami.Theme.textColor: Kirigami.Theme.textColor + + visible: true + onClicked: { } + } + +} diff --git a/src/calamares/calamares.qrc b/src/calamares/calamares.qrc index fdcd5e05d..17db2e08a 100644 --- a/src/calamares/calamares.qrc +++ b/src/calamares/calamares.qrc @@ -1,5 +1,6 @@ calamares-sidebar.qml + calamares-navigation.qml From 2dcf265c408804d516d84c2f95c66bcb4825078a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Apr 2020 15:13:08 +0200 Subject: [PATCH 21/47] [calamares] Give QML navigation bar a fixed height --- src/calamares/CalamaresWindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 9c6626a3e..f29485ea9 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -179,6 +179,8 @@ CalamaresWindow::getQmlNavigation() { CalamaresUtils::registerCalamaresModels(); QQuickWidget* w = new QQuickWidget( this ); + w->setFixedHeight( 64 ); + w->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); w->setSource( QUrl( CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) ); return w; From 9f66b63c00fa997bc6052ff89034b3ec1abc00f1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Apr 2020 15:30:47 +0200 Subject: [PATCH 22/47] [calamares] Indulge in template-fu to refactor - since we've got two blocks of code copy-pasted, which both decide to call one or the other of two member functions based on a flavor value, turn that into a templated function. - passing member functions looks a bit weird, and calling them is syntactically surprising, but it cuts down the code a lot. --- src/calamares/CalamaresWindow.cpp | 59 +++++++++++++++++-------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index f29485ea9..9ec5a7405 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -186,6 +186,31 @@ CalamaresWindow::getQmlNavigation() return w; } +/**@brief Picks one of two methods to call + * + * Calls method (member function) @p widget or @p qml with arguments @p a + * on the given window, based on the flavor. + */ +template < typename widgetMaker, typename... args > +QWidget* +flavoredWidget( Calamares::Branding::PanelFlavor flavor, + CalamaresWindow* w, + widgetMaker widget, + widgetMaker qml, + args... a ) +{ + // Member-function calling syntax is (object.*member)(args) + switch ( flavor ) + { + case Calamares::Branding::PanelFlavor::Widget: + return ( w->*widget )( a... ); + case Calamares::Branding::PanelFlavor::Qml: + return ( w->*qml )( a... ); + case Calamares::Branding::PanelFlavor::None: + return nullptr; + } +} + CalamaresWindow::CalamaresWindow( QWidget* parent ) : QWidget( parent ) , m_debugWindow( nullptr ) @@ -231,20 +256,12 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) QBoxLayout* mainLayout = new QHBoxLayout; setLayout( mainLayout ); - QWidget* sideBox = nullptr; - switch ( branding->sidebarFlavor() ) - { - case Calamares::Branding::PanelFlavor::Widget: - sideBox = getWidgetSidebar( - qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) ); - break; - case Calamares::Branding::PanelFlavor::Qml: - sideBox = getQmlSidebar( - qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) ); - break; - case Calamares::Branding::PanelFlavor::None: - sideBox = nullptr; - } + QWidget* sideBox = flavoredWidget( + branding->sidebarFlavor(), + this, + &CalamaresWindow::getWidgetSidebar, + &CalamaresWindow::getQmlSidebar, + qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) ); if ( sideBox ) { mainLayout->addWidget( sideBox ); @@ -264,18 +281,8 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) // event, which is also the ViewManager's responsibility. QBoxLayout* contentsLayout = new QVBoxLayout; contentsLayout->addWidget( m_viewManager->centralWidget() ); - QWidget* navigation = nullptr; - switch ( branding->navigationFlavor() ) - { - case Calamares::Branding::PanelFlavor::Widget: - navigation = getWidgetNavigation(); - break; - case Calamares::Branding::PanelFlavor::Qml: - navigation = getQmlNavigation(); - break; - case Calamares::Branding::PanelFlavor::None: - navigation = nullptr; - } + QWidget* navigation = flavoredWidget( + branding->navigationFlavor(), this, &CalamaresWindow::getWidgetNavigation, &CalamaresWindow::getQmlNavigation ); if ( navigation ) { contentsLayout->addWidget( navigation ); From b3f59cee256e1110b412297e29a6f3fb84accd6e Mon Sep 17 00:00:00 2001 From: demmm Date: Wed, 1 Apr 2020 16:19:00 +0200 Subject: [PATCH 23/47] filling About in QML, button still disabled using Loader, can be reused for other widgets conversion leave onClick example with full path, commneted out title text for About is hardcoded, discuss option to make this configurable in welcome.conf background color hardcoded, tested to work well in dark themes too --- src/modules/welcomeq/about.qml | 121 ++++++++++++++++++ .../welcomeq/img/chevron-left-solid.svg | 1 + src/modules/welcomeq/img/squid.png | Bin 0 -> 8313 bytes src/modules/welcomeq/welcomeq.qml | 17 ++- src/modules/welcomeq/welcomeq.qrc | 3 + 5 files changed, 138 insertions(+), 4 deletions(-) create mode 100644 src/modules/welcomeq/about.qml create mode 100644 src/modules/welcomeq/img/chevron-left-solid.svg create mode 100644 src/modules/welcomeq/img/squid.png diff --git a/src/modules/welcomeq/about.qml b/src/modules/welcomeq/about.qml new file mode 100644 index 000000000..f301c6659 --- /dev/null +++ b/src/modules/welcomeq/about.qml @@ -0,0 +1,121 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Anke Boersma + * + * 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 . + */ + +import io.calamares.ui 1.0 + +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 + +Item { + width: parent.width + height: parent.height + focus: true + + property var appName: "Calamares" + property var appVersion: "3.2.22" + + Rectangle { + id: textArea + x: 28 + y: 14 + anchors.fill: parent + color: "#f2f2f2" + + Column { + id: column + x: 130 + y: 40 + + + Rectangle { + width: 560 + height: 250 + radius: 10 + border.width: 0 + + Text { + width: 400 + height: 250 + anchors.centerIn: parent + text: qsTr("

%1


+ %2
+ for %3


+ Copyright 2014-2017 Teo Mrnjavac <teo@kde.org>
+ Copyright 2017-2020 Adriaan de Groot <groot@kde.org>
+ Thanks to the Calamares team + and the Calamares + translators team.

+ Calamares + development is sponsored by
+ Blue Systems - + Liberating Software." ) + .arg(appName) + .arg(appVersion) + .arg(Branding.string(Branding.VersionedName)) + + onLinkActivated: Qt.openUrlExternally(link) + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.NoButton + cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor + } + + font.pointSize: 10 + anchors.verticalCenterOffset: 10 + anchors.horizontalCenterOffset: 40 + wrapMode: Text.WordWrap + } + + Image { + id: image + x: 8 + y: 12 + height: 100 + fillMode: Image.PreserveAspectFit + source: "img/squid.png" + } + + } + + } + + ToolButton { + id: toolButton + x: 19 + y: 29 + width: 105 + height: 48 + text: qsTr("Back") + hoverEnabled: true + onClicked: load.source = "" + + Image { + id: image1 + x: 0 + y: 13 + width: 22 + height: 22 + source: "img/chevron-left-solid.svg" + fillMode: Image.PreserveAspectFit + } + } + } + +} diff --git a/src/modules/welcomeq/img/chevron-left-solid.svg b/src/modules/welcomeq/img/chevron-left-solid.svg new file mode 100644 index 000000000..41061c287 --- /dev/null +++ b/src/modules/welcomeq/img/chevron-left-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/welcomeq/img/squid.png b/src/modules/welcomeq/img/squid.png new file mode 100644 index 0000000000000000000000000000000000000000..452e4450c56c10cda33dcc9c5d03753ace458862 GIT binary patch literal 8313 zcmd6NXIE3*^Y%$0gd#1J04hx>q7XU=Lg*m9b1NOBD!qt82&ggiqDZeQRRmO|6RLn9 zMGz2a2I&Zf8X(|5{$4*H;K^E9XU~;6vu9s3d(LDhv8Kkl=jeIp0RT9sucu`W03hlR z1i)d`i(O!uJM{t$($KerQ(qBqH#}9Q^Vj~7d2f!uynjDv`1ix(nX#3V-}C>?dEr>@ z9|$!h22gGzR|N60?cBbERn-W|)m>5b0xUnCtN}x_aN`)U{L+lvfVvw}8i?sbxdG5r z=RN=~*p&ie(ZUHp`0oK{lTu>?7TmQ~3%X{29gG)as^@#xk1P zMyU$VorzFC*;*i>rF!Atlge}tOT z7p4@tOPo#K-Dw{Xgw;z|CpfNB0j4IG$I36>DYFusq7C^2M!pHEtm#k$^8};a)NSHc z<3fqFg9=R&`+(32Jm1m}0#@wi885oE^Y zs-GbIh2|QjWEs`qetUrT&MgrZQ8z%qoSHB4e}8vP{W;=`S)w=NDs}B-`Fm7A;B6)x z!Ep-P-uOFj$R_tdc6u@3;h$|KY0OGl%+B~y$Fk6PToXX-E(mOQ*; z3KRjipn#phT@tg=H}k%aJ=WSz0YT9UM6T}d&|(%s`xof1Eg%aWl>#CgN>b5LXfZnh zEf1>yhf;OPdTLa(A4=rMsQ=i)stb>Zy8)`wfu!bRHbUO;Wd+w$kL|eNp27m+Jn85k zh~~{|e>dwFbd5O+?MF4xxAzyr`|L2{dq#^+H3hwC&3N!&#W8&UBvR?`=tDx1LeyT~ ziyio9H?X}XY(d6?IbuKofwv0dkEwB7UTt;kr7F#t=P!@hFyf@M(7pfspEl$dBi4J+ z_Cc@X82S0Xx`6c&1ih=1{m|>tjQr>{UvMlUYRvtS8`$68Dfr ztc2G0ELmsq;HC6jlgLDJZ=*g87BOyXbl z&7N%?P3WlBgb)=)vV{GMq6=)^g!J(Bz-;uJB&wP2#|_!&DI#qrYn05lglvEtoq*4w zbJL~>7Gyj7%4c8h16*|M46$C{*$9Q7-roW51ur0__uK2SGk|p@xiWG^F0lU#Qsw0H zTebQ%=C+s_+rK|@K>e&#ZP0jh%sQ!vU7ZzenAP;xr%fB&x@nPVMT%bx88R(@7=hBJ zI)GGbhM1*Tk{I4Of!zQpk#gabU=qVuU#dXI?tS|(C27UM&~C!cwGTcn~baLpFHIJ?at$fHZ00loS`X*@du6HP6Z1dXzxbkS(P8i~vMW z43mWxA^PcgDix>te*EnqeFI12TBZBvGy7OI9knJZ@Cd>)4(-NVuVU2M46&a8bK`1P zumdr9rj3~ba;gX#!1pXmcDxcg%76`p! za&w0dqo62>VSOeJ<^tnJ<7_`e-|=IH54+XCEClKn_xR_&RLdvmyQ>&peTsUb`YH^d zF>O8tgQ$Upc_l%mCC_kb7F!OK*(CLDF}6ZD|4aPSA~?+ zN6p5e_Uu~f92$`E0{mc4CW_(J-`ZiUpRnE`0V%tePh&ey_%e zTDv{fEwH1xpiex)efQG%Fu(b$w=o>R>p!ixRw1u-Wh5T@!G=2x_O=Yq> zjj9x)uQJ^~uS@hRFkvQUaCscRwV@htMPdc|p)+$~ zMk1s`%Zne3J8I;=??JhNQI3yvqE%~ed!LaXUNPalbNtV^)+7qhtk^{xvPGRlL|jdt zx$vil$|gRa+fr%g;x&9XLF>UbF@yQ{kAG+z(o|`uVt3kSjGBG(y5ZB;n6?I>o|-Jh ze)Mr-2Gz8#2VXVxDe?})jIsZ67N@BkkTukQ0<_*OwPGiiW!a*1*X%XzfldYbipFYe zyJV5vuXI+D3}*`&6bHZy`o#f=?zdHA?||V?jhs(3gK8dJgA68_fD)HzZh@$hXL_&BCRNxAFO3D=%pc&S3bTYUiYC#$Qm4!=kKN0%+^&zvqoF>IhOLCy!q*ib(Hxv-gVagp#D2OQqX_$|Ktrc$Hld(nBhT-MAR~GM55%wkT2RVrm7e3-9zggJS2S zs3Dn3wYb$w&F2nkl6I%%##}DY_(c;-2%3uRFNZ`IXjda45o zQ_MiSDd{T_&BV4Kx?M8%>*$1bpz7A4Z8hchA%mv2=aILK$OcGWIqdp#8d~V6c+*?W zNuL8B$<&ACGX{4943fdqta$v5?2>3HSgZA}s;Ik*aSR#61L0?jsi+tUR60~}6<&UY z=cAIz_PC;=Z)rC%Rtgc6*8MLSbed-DW6JEEK$qFSJX_xw`S5kU+LM#5^Rp$rtk~I&9x9%Hf`C zKHO;5H{oFiv6PoQ)8mg1!+;X0V_j!@M&J9xOm1bv^Ne4>ELm7F`gWxTXT8`p`-L&F z4@}rT#)OWD1w zYAdSgOkfNF;Rie02bCkZW}`o-+XFG4($OEDo=SgU!SgR%-O?WuEHK7n7@Y!m6e)^R zl_t>z54i6x%N5>&?$M(f7?Ih)Cu>NK1kHQ|O-+D83NQZSpuXEW%HK_L%Ets`Q4KJ> zM|*LWZJ;r5+mDb zzjB}!pTTrNtM1ksIVeGFs=-Sp)ZxB>yzlgR{XNzuP>qlY_Qu}1g1 zfuRnCpEvu_=BS*X68oGH!QOa?;c)VHTEQ!C_W2dgoMfQGRZ}R9*yJdYT#S+G}_j~N{uZ66YV&j3^7&NY9@>{D45>iICh^vBslQ&mzm zHm%ho|J|vY{5A#Gw$~Avhj%`^R?sn`teT^QKruqpP6-7I`;!jmD0W?4LgdrK7UltA zVek!;nlbFINc&dPHFgpNz4b?E;V=@k`d;mY?3B;LB9%W&3q8z0uInagyO=z%O%wGN z*`d_iMWASl5^1qLJv0<@2d)3|U>17#<=k0mRH!b$(uS4iJb~lxPCEMCp+?pN?j~pK zy=Lk0T^*X72Q=$Z82Yjo8aMoYt~v}}n~(1N?>1Gi-28FKexP<@Shn(JqCzp8s5mrR zD^%lY0HTc{n_gd3lFglxr>z^(*LEiT! z={Pcj{u&w?yUfqErskfE_ghSzbo+q^)G{U7%Qa2&Tf|e|D0h}=hA#}1S$!T&7l2M# z9AaC4?s`UXdG_f4;yaO8cJ~kx*BtTpT^MydrN_0T>h*0#Epr>17}2EFvpudARXZ^b zi+>2_S39MTOP+_cIwT*%*al7N;QL&Ei9UJzo#c3C7ZTYZGcPB;%@|Bp3jV_{EYii@ zwbO}WR5|+P2R_2kD?Tky+nm}pb--L5r{8f2{(Gtzvh%7@=FRZD%sSuF8Xt}P>?DWI z1;ojAZzn}%Xs{ru#eqWkiHklR*5Y#RZy_CTWaek@ohl!zI+l=IM@pG@-s_^sL`}sT zK}^CgjL>FZW$wLJA)S`RJIMr+x$Ym$FuR8Oa=v`&isZhS)TGyjl95Tw%E~H>2LTJY ziwn_^hUKP>$S;%gYP8ECHCz{WWP02F+h0}FvVT1Oay(9P|4)>2)V*`<$er+WjpwiN z9^`aM5*}Apw+>BmgB)o=-)kXGk#BE^r1i_^zEhZfGvPh5&oXhzEg`TmA@ zVw$wITj#G8XnXqxtUcV?__g_E1RRU#O+HbEE%X(CS?OFFq-o?m0Yi`?1fpAa ziw5w#b@0NSwr6wmDrNi)!5%x-OBqbkV~HzreVlQZ6mPFkuDl=_&%n^OTpE3{D)LSH z?~Wjw?#1iK+^4?&Kmz2OH%CI&@S4!^%Uf0LCSQ(!(BSWrm|3q~sfJ8gia*_FVamjq zR#}^gvKNYeICn=4iDR9Y00Kw1{B*PotfWfMvZ>!DEGttb%8eixKX&3q5Qsby_*Yse zjmA~92pG!g_N$W|W5;^Gj*BP)F1tRYBlono^HZIzZU*mi+>RKC*W+BGC|>DnoI6s= zrM>6xKVHG{D=>VWX|Mg=oq>f?cPcrkiTrI>U#+yvp#mD@AlpL=#GOH&dTG9{JN`kT z{22qObiw^Q>EesZFw^<_SxU@?Zb_5h>HwZ?N@&a_%u(j8Djip_eW57*(5?3qlPaf? z@=ng|pI%fJoIq8d#K!uevJr4KO)dNh8?BQ%seQU9l_s4=r3Ccv}wwwcDK^VDsh7)TIbnpFA z&aMWGzdd%l+jM)k`HP1%^?VAp+mZX)Tr6}pIzlx$X!r+fh!g;H2?(=5HH@C1I0;SW* z>5FfqtPJDz!^vjD)W_<0*bGv~>f`Ho4`^?0RDWpWdcX1G{60d?^INUGTFsdA=`u{W z(Gq8-K)IJ3d1hA=WaG)a=GohmVF!C6))uAqr0efr?`Ac?b#^GFvMlwxxayPRKQ{qv zYiL}+dxOt|fpNx)Tmk_zR`%I8E!C@d!G{$mlt zjy<_3kmy97eTA;su%J;J?A$(ND#Xhll75pLrU3R#Z#`9zl}<2_BnZwtxaab1{hQ*+ zOc3M<)6tz`sJ`?gDWAQoyvkfFIV;F%le(+@T4A4m35bqW!!Qy+*_-RkrM}0?{#E>m*kF;f zi4LpGNKkoGLq`WY&AC|C)PbcM-!9mBCCaJMHQe+X_(I9}z+Z8_R5GPxVdO7Qgjqfa?7b^1l*TKYEJ%=$(VvaeOc>?&6MBk`HS zES&?As$`LIil2Y0?4DF#=B?tc41>XHoX3P)0`^3`RaH3}IB=EKjhxC7aLjq5(_kzs zwy@~|Z3(S{3z@7c3cBhbRuCd!+;);vmR$8EpG;$@e(y(!t>`2wI8ZHOb_E0=yVe-g z@N2wn@O)lIJIXC3^F&A%LwjI%FWv`W+VE+K4J*fpmR* zKisioWA`Mw;}2|DQwC_4jkYKiHp^7Oatxm;=*-P9)XKi%U4IgAHTNOHc>9=T{SktN z!SI~~CfXU9nU$~gv!}r2sDoAtb!u*MG_EuGb5EPEr&DPgYE#$OEjj6vYX|^wJ%UUs z1U|_N*YP)*lZ#!Q{?}ptZi9;3RM8hcHpu-;YCX}o;Qh@<&d}JXvy8Vdy##fzE`(J5 z$P9TVsZst=*(=hM<|g$tF5vWz?ac8*taS}9Uo3%RNXfm#!}RTQ6e<$#TCIvJvKV%C zT1K_E+RRw>DinX%a=Gf;2uhdZx|J>(dtHMx(EBN|>Fr{jP4YsbLK5*;?4l@Ve15NY z1HK+4puU&gRTUQ=59DvD`tGUvxAaB^~* zUg0z=e{Lp`QB;2AgB_Er>mu?3Z~T`-d^Z4~CqoR4sEh@nK2_m_d9p4!Rhp%eA3h37 z`ri1T<;^?Fw_>b@jc=$&=(9zA`V*pC_}2JMxouM+#BZ^M)(gL2ou>}T1 z+U_(vcbbBaW_kju{DOv>-Zg@W3a_&Cae2wlhAxu~yb|Q{#4j>f&p0vKs!ByG4HjEU z{6~Cxuj%9aX`Rni!&3emNSX3FjAFxOOsQ&*(vwp8aYWdTUyHDWmwBsjQU0?yLNhol zw!+J{EkeoN-Myn~*0?9{vBK<;cICp?JU;WLT|bMDC31?9;iH1Tl?(frYqlvZVzVvI zaC!$Wy0@%lzM- z{RxyA?Pvbq)K&S{_JEL9*jt%fAhJuu0*FbN0TyYIR-Tz{t|urG!W)4$-^#C0`K`<<4A8a+j;hh z8wB8jSN!OmZ#RMIm`_@f7r38vB5(Gj*{cCOU6|&%S8p@IEe)pT?;E|U;qxr>Si5NA z9L0#&=0fX?$tFnNhLv0ijbis)XR@UWMP7*~h;3$+?oZ=R1NCy>)y&8L{K?A5bnbiD z=0|5jnOQ~+ft3A$?j%o({=`+|)qB99EE`u_8!$LLd^;5Y3_c9ORW?H)i7&^OYmIFO za{o*)o#eqJblxgukEJP1&tKE*>H=h%A)&fAD-0lsuA+f?{gYbo*^9TIf6bMMKH}#2 zoy?qC1+k?!vXHtiANS-a94PLfE4m$a^5V$L;}SamJ#Ks@<43)1kdyr9lAud&`SZ*; z9IOLrDv_T1z_WQmW9I0~WXgIuX-IN?`bFb&_ejn@!yCP+wuvCwXBKh^2}wl_HBQNN znJAPdThr>U!Hw~x6Uu?CZPN+GKuQq>r*UzrsU7x9X6=)aDfYd-wtJg_$=2c&^1X7U zfptIvn^59~=Kvz_opZfl`p6vn|;kv(0Mi|%Dw|AUResXn39Cqe3@iFD1Brb26B_N>Ka*Kx!EJg z|AZW>U`bB`nNH2qK51#3bbM`|x=wSgQcP^qM74Gs+()H7x=5h8z&lJ+Z1XVBPL&x| zXkLEnN@ === * * Copyright 2020, Adriaan de Groot + * Copyright 2020, Anke Boersma * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +33,7 @@ Page { width: parent.width height: parent.height - + Text { id: welcomeTopText @@ -75,9 +76,12 @@ Page icon.name: "dialog-information" Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) Kirigami.Theme.textColor: Kirigami.Theme.textColor - - visible: false - onClicked: { } // TODO: show an about-Calamares window + + visible: true + onClicked: { + //onClicked: load.source = "file:/usr/share/calamares/branding/kaos_branding/show.qml" + onClicked: load.source = "about.qml" + } } Button { @@ -124,5 +128,10 @@ Page onClicked: Qt.openUrlExternally(config.donateUrl) } } + Loader + { + id:load + anchors.fill: parent + } } } diff --git a/src/modules/welcomeq/welcomeq.qrc b/src/modules/welcomeq/welcomeq.qrc index 772bf7e88..84e598a27 100644 --- a/src/modules/welcomeq/welcomeq.qrc +++ b/src/modules/welcomeq/welcomeq.qrc @@ -1,5 +1,8 @@ welcomeq.qml + about.qml + img/squid.png + img/chevron-left-solid.svg From 2c2bba5525acfd746eac30495e412ccb8cbf53c9 Mon Sep 17 00:00:00 2001 From: demmm Date: Wed, 1 Apr 2020 16:21:43 +0200 Subject: [PATCH 24/47] actually set About button to false... --- src/modules/welcomeq/welcomeq.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/welcomeq/welcomeq.qml b/src/modules/welcomeq/welcomeq.qml index 0de01f333..90de189d3 100644 --- a/src/modules/welcomeq/welcomeq.qml +++ b/src/modules/welcomeq/welcomeq.qml @@ -33,7 +33,7 @@ Page { width: parent.width height: parent.height - + Text { id: welcomeTopText @@ -77,7 +77,7 @@ Page Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) Kirigami.Theme.textColor: Kirigami.Theme.textColor - visible: true + visible: false onClicked: { //onClicked: load.source = "file:/usr/share/calamares/branding/kaos_branding/show.qml" onClicked: load.source = "about.qml" From c638343c189de9b3e41b2428875630c7a8cf4c72 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Apr 2020 18:45:25 +0200 Subject: [PATCH 25/47] [libcalamares] Give ViewManager a real quit() slot - instead of creating a lambda, give ViewManager a real slot - hook up the new navigation buttons to the next, back, quit slots --- src/calamares/CalamaresWindow.cpp | 3 +++ src/libcalamaresui/ViewManager.cpp | 17 +++++++++++------ src/libcalamaresui/ViewManager.h | 9 ++++++++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 9ec5a7405..22025dccb 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -158,10 +158,13 @@ CalamaresWindow::getWidgetNavigation() // Create buttons and sets an initial icon; the icons may change auto* back = new QPushButton( getButtonIcon( QStringLiteral( "go-previous" ) ), tr( "&Back" ), navigation ); back->setObjectName( "view-button-back" ); + connect( back, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::back ); auto* next = new QPushButton( getButtonIcon( QStringLiteral( "go-next" ) ), tr( "&Next" ), navigation ); next->setObjectName( "view-button-next" ); + connect( next, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::next ); auto* quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), navigation ); quit->setObjectName( "view-button-cancel" ); + connect( quit, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::quit ); QBoxLayout* bottomLayout = new QHBoxLayout; bottomLayout->addStretch(); diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index dda757fda..2b0c59e49 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -108,14 +108,9 @@ ViewManager::ViewManager( QObject* parent ) connect( m_next, &QPushButton::clicked, this, &ViewManager::next ); connect( m_back, &QPushButton::clicked, this, &ViewManager::back ); + connect( m_quit, &QPushButton::clicked, this, &ViewManager::quit ); m_back->setEnabled( false ); - connect( m_quit, &QPushButton::clicked, this, [this]() { - if ( this->confirmCancelInstallation() ) - { - qApp->quit(); - } - } ); connect( JobQueue::instance(), &JobQueue::failed, this, &ViewManager::onInstallationFailed ); connect( JobQueue::instance(), &JobQueue::finished, this, &ViewManager::next ); @@ -476,6 +471,16 @@ ViewManager::back() updateButtonLabels(); } + +void +ViewManager::quit() +{ + if ( confirmCancelInstallation() ) + { + qApp->quit(); + } +} + bool ViewManager::confirmCancelInstallation() { diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index f16419dcd..a3f1918e5 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -92,7 +92,7 @@ public: */ bool confirmCancelInstallation(); -public slots: +public Q_SLOTS: /** * @brief next moves forward to the next page of the current ViewStep (if any), * or to the first page of the next ViewStep if the current ViewStep doesn't @@ -107,6 +107,13 @@ public slots: */ void back(); + /** + * @brief Probably quit + * + * Asks for confirmation if necessary. Terminates the application. + */ + void quit(); + /** * @brief onInstallationFailed displays an error message when a fatal failure * happens in a ViewStep. From 8920be6bca003448085cd5ca5d3910b7002d3149 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 12:04:24 +0200 Subject: [PATCH 26/47] [libcalamaresui] Remove *next* button from ViewManager - add properties for the next button (enabled, label, icon...) - update those properties as normal - connect to the properties in the UI implementation --- src/calamares/CalamaresWindow.cpp | 14 +++++++++++++ src/libcalamaresui/ViewManager.cpp | 32 ++++++++++++++++++------------ src/libcalamaresui/ViewManager.h | 24 +++++++++++++++++++++- 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 22025dccb..a3bdf2683 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -150,6 +150,16 @@ getButtonIcon( const QString& name ) return Calamares::Branding::instance()->image( name, QSize( 22, 22 ) ); } +static inline void +setButtonIcon( QPushButton* button, const QString& name ) +{ + auto icon = getButtonIcon( name ); + if ( button && !icon.isNull() ) + { + button->setIcon( icon ); + } +} + QWidget* CalamaresWindow::getWidgetNavigation() { @@ -162,6 +172,10 @@ CalamaresWindow::getWidgetNavigation() auto* next = new QPushButton( getButtonIcon( QStringLiteral( "go-next" ) ), tr( "&Next" ), navigation ); next->setObjectName( "view-button-next" ); connect( next, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::next ); + connect( m_viewManager, &Calamares::ViewManager::nextEnabledChanged, next, &QPushButton::setEnabled ); + connect( m_viewManager, &Calamares::ViewManager::nextLabelChanged, next, &QPushButton::setText ); + connect( + m_viewManager, &Calamares::ViewManager::nextIconChanged, this, [=]( QString n ) { setButtonIcon( next, n ); } ); auto* quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), navigation ); quit->setObjectName( "view-button-cancel" ); connect( quit, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::quit ); diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 2b0c59e49..74a1b6bee 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -91,8 +91,6 @@ ViewManager::ViewManager( QObject* parent ) // Create buttons and sets an initial icon; the icons may change m_back = new QPushButton( getButtonIcon( QStringLiteral( "go-previous" ) ), tr( "&Back" ), m_widget ); m_back->setObjectName( "view-button-back" ); - m_next = new QPushButton( getButtonIcon( QStringLiteral( "go-next" ) ), tr( "&Next" ), m_widget ); - m_next->setObjectName( "view-button-next" ); m_quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), m_widget ); m_quit->setObjectName( "view-button-cancel" ); @@ -102,11 +100,9 @@ ViewManager::ViewManager( QObject* parent ) mainLayout->addLayout( bottomLayout ); bottomLayout->addStretch(); bottomLayout->addWidget( m_back ); - bottomLayout->addWidget( m_next ); bottomLayout->addSpacing( 12 ); bottomLayout->addWidget( m_quit ); - connect( m_next, &QPushButton::clicked, this, &ViewManager::next ); connect( m_back, &QPushButton::clicked, this, &ViewManager::back ); connect( m_quit, &QPushButton::clicked, this, &ViewManager::quit ); m_back->setEnabled( false ); @@ -142,7 +138,8 @@ ViewManager::addViewStep( ViewStep* step ) // If this is the first inserted view step, update status of "Next" button if ( m_steps.count() == 1 ) { - m_next->setEnabled( step->isNextEnabled() ); + m_nextEnabled = step->isNextEnabled(); + emit nextEnabledChanged( m_nextEnabled ); } } @@ -153,13 +150,15 @@ ViewManager::insertViewStep( int before, ViewStep* step ) emit beginInsertRows( QModelIndex(), before, before ); m_steps.insert( before, step ); connect( step, &ViewStep::enlarge, this, &ViewManager::enlarge ); + // TODO: this can be a regular slot connect( step, &ViewStep::nextStatusChanged, this, [this]( bool status ) { ViewStep* vs = qobject_cast< ViewStep* >( sender() ); if ( vs ) { if ( vs == m_steps.at( m_currentStep ) ) { - m_next->setEnabled( status ); + m_nextEnabled = status; + emit nextEnabledChanged( m_nextEnabled ); } } } ); @@ -364,7 +363,8 @@ ViewManager::next() { // Reached the end in a weird state (e.g. no finished step after an exec) executing = false; - m_next->setEnabled( false ); + m_nextEnabled = false; + emit nextEnabledChanged( m_nextEnabled ); m_back->setEnabled( false ); } updateCancelEnabled( !settings->disableCancel() && !( executing && settings->disableCancelDuringExec() ) ); @@ -376,7 +376,8 @@ ViewManager::next() if ( m_currentStep < m_steps.count() ) { - m_next->setEnabled( !executing && m_steps.at( m_currentStep )->isNextEnabled() ); + m_nextEnabled = !executing && m_steps.at( m_currentStep )->isNextEnabled(); + emit nextEnabledChanged( m_nextEnabled ); m_back->setEnabled( !executing && m_steps.at( m_currentStep )->isBackEnabled() ); } @@ -399,13 +400,17 @@ ViewManager::updateButtonLabels() // If we're going into the execution step / install phase, other message if ( stepIsExecute( m_steps, m_currentStep + 1 ) ) { - m_next->setText( nextIsInstallationStep ); - setButtonIcon( m_next, "run-install" ); + m_nextLabel = nextIsInstallationStep; + m_nextIcon = "run-install"; + emit nextLabelChanged( m_nextLabel ); + emit nextIconChanged( m_nextIcon ); } else { - m_next->setText( tr( "&Next" ) ); - setButtonIcon( m_next, "go-next" ); + m_nextLabel = tr( "&Next" ); + m_nextIcon = "go-next"; + emit nextLabelChanged( m_nextLabel ); + emit nextIconChanged( m_nextIcon ); } // Going back is always simple @@ -460,7 +465,8 @@ ViewManager::back() return; } - m_next->setEnabled( m_steps.at( m_currentStep )->isNextEnabled() ); + m_nextEnabled = m_steps.at( m_currentStep )->isNextEnabled(); + emit nextEnabledChanged( m_nextEnabled ); m_back->setEnabled( m_steps.at( m_currentStep )->isBackEnabled() ); if ( m_currentStep == 0 && m_steps.first()->isAtBeginning() ) diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index a3f1918e5..4e2d5e9e0 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -38,6 +38,9 @@ class UIDLLEXPORT ViewManager : public QAbstractListModel { Q_OBJECT Q_PROPERTY( int currentStepIndex READ currentStepIndex NOTIFY currentStepChanged FINAL ) + Q_PROPERTY( bool nextEnabled READ nextEnabled NOTIFY nextEnabledChanged FINAL ) + Q_PROPERTY( QString nextLabel READ nextLabel NOTIFY nextLabelChanged FINAL ) + Q_PROPERTY( QString nextIcon READ nextIcon NOTIFY nextIconChanged FINAL ) public: /** @@ -99,6 +102,18 @@ public Q_SLOTS: * have any more pages. */ void next(); + bool nextEnabled() const + { + return m_nextEnabled; ///< Is the next-button to be enabled + } + QString nextLabel() const + { + return m_nextLabel; ///< What should be displayed on the next-button + } + QString nextIcon() const + { + return m_nextIcon; ///< Name of the icon to show + } /** * @brief back moves backward to the previous page of the current ViewStep (if any), @@ -133,6 +148,10 @@ signals: void enlarge( QSize enlarge ) const; // See ViewStep::enlarge() void cancelEnabled( bool enabled ) const; + void nextEnabledChanged( bool ) const; + void nextLabelChanged( QString ) const; + void nextIconChanged( QString ) const; + private: explicit ViewManager( QObject* parent = nullptr ); virtual ~ViewManager() override; @@ -149,9 +168,12 @@ private: QWidget* m_widget; QStackedWidget* m_stack; QPushButton* m_back; - QPushButton* m_next; QPushButton* m_quit; + bool m_nextEnabled = false; + QString m_nextLabel; + QString m_nextIcon; ///< Name of icon to show on button + public: /** @section Model * From 38deb66e42a1481f7eec72d51efea1ac85875731 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 12:31:14 +0200 Subject: [PATCH 27/47] [libcalamaresui] Remove *back* button from ViewManager - Now the back button should be done by clients as well - Refactor in CalamaresWindow to avoid leaking local button pointers to surrounding code. - Add macro UPDATE_BUTTON_PROPERTY for convenience in ViewManager (ugh, macro) to change a value and emit corresponding update signal. --- src/calamares/CalamaresWindow.cpp | 49 ++++++++++++++++++------------ src/libcalamaresui/ViewManager.cpp | 49 ++++++++++++------------------ src/libcalamaresui/ViewManager.h | 26 +++++++++++++++- 3 files changed, 75 insertions(+), 49 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index a3bdf2683..991d81dd3 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -164,28 +164,39 @@ QWidget* CalamaresWindow::getWidgetNavigation() { QWidget* navigation = new QWidget( this ); - - // Create buttons and sets an initial icon; the icons may change - auto* back = new QPushButton( getButtonIcon( QStringLiteral( "go-previous" ) ), tr( "&Back" ), navigation ); - back->setObjectName( "view-button-back" ); - connect( back, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::back ); - auto* next = new QPushButton( getButtonIcon( QStringLiteral( "go-next" ) ), tr( "&Next" ), navigation ); - next->setObjectName( "view-button-next" ); - connect( next, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::next ); - connect( m_viewManager, &Calamares::ViewManager::nextEnabledChanged, next, &QPushButton::setEnabled ); - connect( m_viewManager, &Calamares::ViewManager::nextLabelChanged, next, &QPushButton::setText ); - connect( - m_viewManager, &Calamares::ViewManager::nextIconChanged, this, [=]( QString n ) { setButtonIcon( next, n ); } ); - auto* quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), navigation ); - quit->setObjectName( "view-button-cancel" ); - connect( quit, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::quit ); - QBoxLayout* bottomLayout = new QHBoxLayout; bottomLayout->addStretch(); - bottomLayout->addWidget( back ); - bottomLayout->addWidget( next ); + + // Create buttons and sets an initial icon; the icons may change + { + auto* back = new QPushButton( getButtonIcon( QStringLiteral( "go-previous" ) ), tr( "&Back" ), navigation ); + back->setObjectName( "view-button-back" ); + connect( back, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::back ); + connect( m_viewManager, &Calamares::ViewManager::backEnabledChanged, back, &QPushButton::setEnabled ); + connect( m_viewManager, &Calamares::ViewManager::backLabelChanged, back, &QPushButton::setText ); + connect( m_viewManager, &Calamares::ViewManager::backIconChanged, this, [=]( QString n ) { + setButtonIcon( back, n ); + } ); + bottomLayout->addWidget( back ); + } + { + auto* next = new QPushButton( getButtonIcon( QStringLiteral( "go-next" ) ), tr( "&Next" ), navigation ); + next->setObjectName( "view-button-next" ); + connect( next, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::next ); + connect( m_viewManager, &Calamares::ViewManager::nextEnabledChanged, next, &QPushButton::setEnabled ); + connect( m_viewManager, &Calamares::ViewManager::nextLabelChanged, next, &QPushButton::setText ); + connect( m_viewManager, &Calamares::ViewManager::nextIconChanged, this, [=]( QString n ) { + setButtonIcon( next, n ); + } ); + bottomLayout->addWidget( next ); + } bottomLayout->addSpacing( 12 ); - bottomLayout->addWidget( quit ); + { + auto* quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), navigation ); + quit->setObjectName( "view-button-cancel" ); + connect( quit, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::quit ); + bottomLayout->addWidget( quit ); + } navigation->setLayout( bottomLayout ); return navigation; diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 74a1b6bee..a73580fa9 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -38,6 +38,12 @@ #include #include +#define UPDATE_BUTTON_PROPERTY( name, value ) \ + { \ + m_##name = value; \ + emit name##Changed( m_##name ); \ + } + namespace Calamares { @@ -89,8 +95,6 @@ ViewManager::ViewManager( QObject* parent ) mainLayout->addWidget( m_stack ); // Create buttons and sets an initial icon; the icons may change - m_back = new QPushButton( getButtonIcon( QStringLiteral( "go-previous" ) ), tr( "&Back" ), m_widget ); - m_back->setObjectName( "view-button-back" ); m_quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), m_widget ); m_quit->setObjectName( "view-button-cancel" ); @@ -99,13 +103,9 @@ ViewManager::ViewManager( QObject* parent ) QBoxLayout* bottomLayout = new QHBoxLayout; mainLayout->addLayout( bottomLayout ); bottomLayout->addStretch(); - bottomLayout->addWidget( m_back ); - bottomLayout->addSpacing( 12 ); bottomLayout->addWidget( m_quit ); - connect( m_back, &QPushButton::clicked, this, &ViewManager::back ); connect( m_quit, &QPushButton::clicked, this, &ViewManager::quit ); - m_back->setEnabled( false ); connect( JobQueue::instance(), &JobQueue::failed, this, &ViewManager::onInstallationFailed ); connect( JobQueue::instance(), &JobQueue::finished, this, &ViewManager::next ); @@ -363,9 +363,8 @@ ViewManager::next() { // Reached the end in a weird state (e.g. no finished step after an exec) executing = false; - m_nextEnabled = false; - emit nextEnabledChanged( m_nextEnabled ); - m_back->setEnabled( false ); + UPDATE_BUTTON_PROPERTY( nextEnabled, false ) + UPDATE_BUTTON_PROPERTY( backEnabled, false ) } updateCancelEnabled( !settings->disableCancel() && !( executing && settings->disableCancelDuringExec() ) ); } @@ -376,9 +375,8 @@ ViewManager::next() if ( m_currentStep < m_steps.count() ) { - m_nextEnabled = !executing && m_steps.at( m_currentStep )->isNextEnabled(); - emit nextEnabledChanged( m_nextEnabled ); - m_back->setEnabled( !executing && m_steps.at( m_currentStep )->isBackEnabled() ); + UPDATE_BUTTON_PROPERTY( nextEnabled, !executing && m_steps.at( m_currentStep )->isNextEnabled() ) + UPDATE_BUTTON_PROPERTY( backEnabled, !executing && m_steps.at( m_currentStep )->isBackEnabled() ) } updateButtonLabels(); @@ -400,21 +398,17 @@ ViewManager::updateButtonLabels() // If we're going into the execution step / install phase, other message if ( stepIsExecute( m_steps, m_currentStep + 1 ) ) { - m_nextLabel = nextIsInstallationStep; - m_nextIcon = "run-install"; - emit nextLabelChanged( m_nextLabel ); - emit nextIconChanged( m_nextIcon ); + UPDATE_BUTTON_PROPERTY( nextLabel, nextIsInstallationStep ) + UPDATE_BUTTON_PROPERTY( nextIcon, "run-install" ) } else { - m_nextLabel = tr( "&Next" ); - m_nextIcon = "go-next"; - emit nextLabelChanged( m_nextLabel ); - emit nextIconChanged( m_nextIcon ); + UPDATE_BUTTON_PROPERTY( nextLabel, tr( "&Next" ) ) + UPDATE_BUTTON_PROPERTY( nextIcon, "go-next" ) } // Going back is always simple - m_back->setText( tr( "&Back" ) ); + UPDATE_BUTTON_PROPERTY( backLabel, tr( "&Back" ) ) // Cancel button changes label at the end if ( isAtVeryEnd( m_steps, m_currentStep ) ) @@ -465,14 +459,11 @@ ViewManager::back() return; } - m_nextEnabled = m_steps.at( m_currentStep )->isNextEnabled(); - emit nextEnabledChanged( m_nextEnabled ); - m_back->setEnabled( m_steps.at( m_currentStep )->isBackEnabled() ); - - if ( m_currentStep == 0 && m_steps.first()->isAtBeginning() ) - { - m_back->setEnabled( false ); - } + UPDATE_BUTTON_PROPERTY( nextEnabled, m_steps.at( m_currentStep )->isNextEnabled() ) + UPDATE_BUTTON_PROPERTY( backEnabled, + ( m_currentStep == 0 && m_steps.first()->isAtBeginning() ) + ? false + : m_steps.at( m_currentStep )->isBackEnabled() ) updateButtonLabels(); } diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 4e2d5e9e0..00a7509bb 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -38,10 +38,15 @@ class UIDLLEXPORT ViewManager : public QAbstractListModel { Q_OBJECT Q_PROPERTY( int currentStepIndex READ currentStepIndex NOTIFY currentStepChanged FINAL ) + Q_PROPERTY( bool nextEnabled READ nextEnabled NOTIFY nextEnabledChanged FINAL ) Q_PROPERTY( QString nextLabel READ nextLabel NOTIFY nextLabelChanged FINAL ) Q_PROPERTY( QString nextIcon READ nextIcon NOTIFY nextIconChanged FINAL ) + Q_PROPERTY( bool backEnabled READ backEnabled NOTIFY backEnabledChanged FINAL ) + Q_PROPERTY( QString backLabel READ backLabel NOTIFY backLabelChanged FINAL ) + Q_PROPERTY( QString backIcon READ backIcon NOTIFY backIconChanged FINAL ) + public: /** * @brief instance access to the ViewManager singleton. @@ -121,6 +126,18 @@ public Q_SLOTS: * have any pages before the current one. */ void back(); + bool backEnabled() const + { + return m_backEnabled; ///< Is the back-button to be enabled + } + QString backLabel() const + { + return m_backLabel; ///< What should be displayed on the back-button + } + QString backIcon() const + { + return m_backIcon; ///< Name of the icon to show + } /** * @brief Probably quit @@ -152,6 +169,10 @@ signals: void nextLabelChanged( QString ) const; void nextIconChanged( QString ) const; + void backEnabledChanged( bool ) const; + void backLabelChanged( QString ) const; + void backIconChanged( QString ) const; + private: explicit ViewManager( QObject* parent = nullptr ); virtual ~ViewManager() override; @@ -167,13 +188,16 @@ private: QWidget* m_widget; QStackedWidget* m_stack; - QPushButton* m_back; QPushButton* m_quit; bool m_nextEnabled = false; QString m_nextLabel; QString m_nextIcon; ///< Name of icon to show on button + bool m_backEnabled = false; + QString m_backLabel; + QString m_backIcon; + public: /** @section Model * From 0c71c7c23ff5a11867c840d751b0dde925077410 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 12:36:45 +0200 Subject: [PATCH 28/47] [calamares] Set initial states of next, back buttons --- src/calamares/CalamaresWindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 991d81dd3..9f35fbdf1 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -171,6 +171,7 @@ CalamaresWindow::getWidgetNavigation() { auto* back = new QPushButton( getButtonIcon( QStringLiteral( "go-previous" ) ), tr( "&Back" ), navigation ); back->setObjectName( "view-button-back" ); + back->setEnabled( m_viewManager->backEnabled() ); connect( back, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::back ); connect( m_viewManager, &Calamares::ViewManager::backEnabledChanged, back, &QPushButton::setEnabled ); connect( m_viewManager, &Calamares::ViewManager::backLabelChanged, back, &QPushButton::setText ); @@ -182,6 +183,7 @@ CalamaresWindow::getWidgetNavigation() { auto* next = new QPushButton( getButtonIcon( QStringLiteral( "go-next" ) ), tr( "&Next" ), navigation ); next->setObjectName( "view-button-next" ); + next->setEnabled( m_viewManager->nextEnabled() ); connect( next, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::next ); connect( m_viewManager, &Calamares::ViewManager::nextEnabledChanged, next, &QPushButton::setEnabled ); connect( m_viewManager, &Calamares::ViewManager::nextLabelChanged, next, &QPushButton::setText ); From 91d0ba1007035f2286d5356f16d80f85d359d66d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 13:44:49 +0200 Subject: [PATCH 29/47] [libcalamaresui] Remove *quit* button from ViewManager - Mostly like the other buttons - Also show/hide the button and set tooltip --- src/calamares/CalamaresWindow.cpp | 7 ++++++ src/libcalamaresui/ViewManager.cpp | 37 +++++++++++------------------- src/libcalamaresui/ViewManager.h | 37 +++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 25 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 9f35fbdf1..eadf56f16 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -197,6 +197,13 @@ CalamaresWindow::getWidgetNavigation() auto* quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), navigation ); quit->setObjectName( "view-button-cancel" ); connect( quit, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::quit ); + connect( m_viewManager, &Calamares::ViewManager::quitEnabledChanged, quit, &QPushButton::setEnabled ); + connect( m_viewManager, &Calamares::ViewManager::quitLabelChanged, quit, &QPushButton::setText ); + connect( m_viewManager, &Calamares::ViewManager::quitIconChanged, this, [=]( QString n ) { + setButtonIcon( quit, n ); + } ); + connect( m_viewManager, &Calamares::ViewManager::quitTooltipChanged, quit, &QPushButton::setToolTip ); + connect( m_viewManager, &Calamares::ViewManager::quitVisibleChanged, quit, &QPushButton::setVisible ); bottomLayout->addWidget( quit ); } diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index a73580fa9..4aaa56b35 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -94,26 +94,12 @@ ViewManager::ViewManager( QObject* parent ) m_stack->setContentsMargins( 0, 0, 0, 0 ); mainLayout->addWidget( m_stack ); - // Create buttons and sets an initial icon; the icons may change - m_quit = new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ), tr( "&Cancel" ), m_widget ); - m_quit->setObjectName( "view-button-cancel" ); - CALAMARES_RETRANSLATE_SLOT( &ViewManager::updateButtonLabels ) - QBoxLayout* bottomLayout = new QHBoxLayout; - mainLayout->addLayout( bottomLayout ); - bottomLayout->addStretch(); - bottomLayout->addWidget( m_quit ); - - connect( m_quit, &QPushButton::clicked, this, &ViewManager::quit ); - connect( JobQueue::instance(), &JobQueue::failed, this, &ViewManager::onInstallationFailed ); connect( JobQueue::instance(), &JobQueue::finished, this, &ViewManager::next ); - if ( Calamares::Settings::instance()->disableCancel() ) - { - m_quit->setVisible( false ); - } + UPDATE_BUTTON_PROPERTY( quitVisible, !Calamares::Settings::instance()->disableCancel() ) } @@ -413,28 +399,31 @@ ViewManager::updateButtonLabels() // Cancel button changes label at the end if ( isAtVeryEnd( m_steps, m_currentStep ) ) { - m_quit->setText( tr( "&Done" ) ); - m_quit->setToolTip( quitOnCompleteTooltip ); - m_quit->setVisible( true ); // At end, always visible and enabled. - setButtonIcon( m_quit, "dialog-ok-apply" ); + UPDATE_BUTTON_PROPERTY( quitLabel, tr( "&Done" ) ) + UPDATE_BUTTON_PROPERTY( quitTooltip, quitOnCompleteTooltip ) + UPDATE_BUTTON_PROPERTY( quitVisible, true ) + UPDATE_BUTTON_PROPERTY( quitIcon, "dialog-ok-apply" ) updateCancelEnabled( true ); + // FIXME +#if 0 if ( settings->quitAtEnd() ) { m_quit->click(); } +#endif } else { if ( settings->disableCancel() ) { - m_quit->setVisible( false ); // In case we went back from final + UPDATE_BUTTON_PROPERTY( quitVisible, false ) } updateCancelEnabled( !settings->disableCancel() && !( stepIsExecute( m_steps, m_currentStep ) && settings->disableCancelDuringExec() ) ); - m_quit->setText( tr( "&Cancel" ) ); - m_quit->setToolTip( cancelBeforeInstallationTooltip ); - setButtonIcon( m_quit, "dialog-cancel" ); + UPDATE_BUTTON_PROPERTY( quitLabel, tr( "&Cancel" ) ) + UPDATE_BUTTON_PROPERTY( quitTooltip, cancelBeforeInstallationTooltip ) + UPDATE_BUTTON_PROPERTY( quitIcon, "dialog-cancel" ) } } @@ -516,7 +505,7 @@ ViewManager::confirmCancelInstallation() void ViewManager::updateCancelEnabled( bool enabled ) { - m_quit->setEnabled( enabled ); + UPDATE_BUTTON_PROPERTY( quitEnabled, enabled ) emit cancelEnabled( enabled ); } diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 00a7509bb..ad9376f1a 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -47,6 +47,13 @@ class UIDLLEXPORT ViewManager : public QAbstractListModel Q_PROPERTY( QString backLabel READ backLabel NOTIFY backLabelChanged FINAL ) Q_PROPERTY( QString backIcon READ backIcon NOTIFY backIconChanged FINAL ) + Q_PROPERTY( bool quitEnabled READ quitEnabled NOTIFY quitEnabledChanged FINAL ) + Q_PROPERTY( QString quitLabel READ quitLabel NOTIFY quitLabelChanged FINAL ) + Q_PROPERTY( QString quitIcon READ quitIcon NOTIFY quitIconChanged FINAL ) + Q_PROPERTY( QString quitTooltip READ quitTooltip NOTIFY quitTooltipChanged FINAL ) + + Q_PROPERTY( bool quitVisible READ quitVisible NOTIFY quitVisibleChanged FINAL ) + public: /** * @brief instance access to the ViewManager singleton. @@ -145,6 +152,23 @@ public Q_SLOTS: * Asks for confirmation if necessary. Terminates the application. */ void quit(); + bool quitEnabled() const + { + return m_quitEnabled; ///< Is the quit-button to be enabled + } + QString quitLabel() const + { + return m_quitLabel; ///< What should be displayed on the quit-button + } + QString quitIcon() const + { + return m_quitIcon; ///< Name of the icon to show + } + bool quitVisible() const + { + return m_quitVisible; ///< Should the quit-button be visible + } + QString quitTooltip() const { return m_quitTooltip; } /** * @brief onInstallationFailed displays an error message when a fatal failure @@ -173,6 +197,12 @@ signals: void backLabelChanged( QString ) const; void backIconChanged( QString ) const; + void quitEnabledChanged( bool ) const; + void quitLabelChanged( QString ) const; + void quitIconChanged( QString ) const; + void quitVisibleChanged( bool ) const; + void quitTooltipChanged( QString ) const; + private: explicit ViewManager( QObject* parent = nullptr ); virtual ~ViewManager() override; @@ -188,7 +218,6 @@ private: QWidget* m_widget; QStackedWidget* m_stack; - QPushButton* m_quit; bool m_nextEnabled = false; QString m_nextLabel; @@ -198,6 +227,12 @@ private: QString m_backLabel; QString m_backIcon; + bool m_quitEnabled = false; + QString m_quitLabel; + QString m_quitIcon; + QString m_quitTooltip; + bool m_quitVisible = true; + public: /** @section Model * From c755c7ed98fd612f15d284bf05cfa357cd9e15cf Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 13:54:14 +0200 Subject: [PATCH 30/47] [libcalamaresui] restore quit-at-very-end functionality - This doesn't need to go indirectly through a button --- src/libcalamaresui/ViewManager.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 4aaa56b35..79b4a244f 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -404,13 +404,10 @@ ViewManager::updateButtonLabels() UPDATE_BUTTON_PROPERTY( quitVisible, true ) UPDATE_BUTTON_PROPERTY( quitIcon, "dialog-ok-apply" ) updateCancelEnabled( true ); - // FIXME -#if 0 if ( settings->quitAtEnd() ) { - m_quit->click(); + quit(); } -#endif } else { From 476a576ddaa51892ac4dd10a01b315f7102af54b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 15:48:43 +0200 Subject: [PATCH 31/47] [libcalamaresui] Ensure all button labels are accurate - since lots of state is updated when the labels change, call that in the constructor so that any QML bindings get current values. --- src/libcalamaresui/ViewManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 79b4a244f..e80d4afd8 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -94,12 +94,12 @@ ViewManager::ViewManager( QObject* parent ) m_stack->setContentsMargins( 0, 0, 0, 0 ); mainLayout->addWidget( m_stack ); - CALAMARES_RETRANSLATE_SLOT( &ViewManager::updateButtonLabels ) + updateButtonLabels(); connect( JobQueue::instance(), &JobQueue::failed, this, &ViewManager::onInstallationFailed ); connect( JobQueue::instance(), &JobQueue::finished, this, &ViewManager::next ); - UPDATE_BUTTON_PROPERTY( quitVisible, !Calamares::Settings::instance()->disableCancel() ) + CALAMARES_RETRANSLATE_SLOT( &ViewManager::updateButtonLabels ) } From ff37792dc95b24b63663b5beebf572653d539adf Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 15:49:27 +0200 Subject: [PATCH 32/47] [calamares] Resize QML to width of parent window --- src/calamares/CalamaresWindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index eadf56f16..a97d2dccf 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -138,6 +138,7 @@ CalamaresWindow::getQmlSidebar( int desiredWidth ) QQuickWidget* w = new QQuickWidget( this ); w->setFixedWidth( desiredWidth ); w->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + w->setResizeMode( QQuickWidget::SizeRootObjectToView ); w->setSource( QUrl( CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) ); return w; @@ -218,6 +219,7 @@ CalamaresWindow::getQmlNavigation() QQuickWidget* w = new QQuickWidget( this ); w->setFixedHeight( 64 ); w->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + w->setResizeMode( QQuickWidget::SizeRootObjectToView ); w->setSource( QUrl( CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) ); return w; From 1038de899b3ce2661e243b8ab541f97e929e8812 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 16:22:39 +0200 Subject: [PATCH 33/47] [calamares] Update sidebar and navigation QML - use the right colors (from branding, not from desktop theme) - apply branding logo --- src/calamares/calamares-navigation.qml | 78 +++++++++++++++----------- src/calamares/calamares-sidebar.qml | 56 ++++++++++-------- 2 files changed, 76 insertions(+), 58 deletions(-) diff --git a/src/calamares/calamares-navigation.qml b/src/calamares/calamares-navigation.qml index 0831a9b6a..c7cd91835 100644 --- a/src/calamares/calamares-navigation.qml +++ b/src/calamares/calamares-navigation.qml @@ -4,44 +4,54 @@ import io.calamares.core 1.0 import QtQuick 2.3 import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 -import org.kde.kirigami 2.7 as Kirigami -Row { - id: buttonBar - height: 64 +Rectangle { + id: navigationBar; + color: Branding.styleString( Branding.SidebarBackground ); - Button - { - Layout.fillWidth: true - text: qsTr("Back") - icon.name: "next" - Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) - Kirigami.Theme.textColor: Kirigami.Theme.textColor + RowLayout { + id: buttonBar + height: 64; + anchors.fill: parent; - visible: true - onClicked: { } - } - Button - { - Layout.fillWidth: true - text: qsTr("Next") - icon.name: "next" - Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) - Kirigami.Theme.textColor: Kirigami.Theme.textColor + Item + { + Layout.fillWidth: true; + } - visible: true - onClicked: { } - } - Button - { - Layout.fillWidth: true - text: qsTr("Quit") - icon.name: "quit" - Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) - Kirigami.Theme.textColor: Kirigami.Theme.textColor + Button + { + text: ViewManager.backLabel; + icon.name: ViewManager.backIcon; - visible: true - onClicked: { } - } + enabled: ViewManager.backEnabled; + visible: true; + onClicked: { ViewManager.back(); } + } + Button + { + text: ViewManager.nextLabel; + icon.name: ViewManager.nextIcon; + enabled: ViewManager.nextEnabled; + visible: true; + onClicked: { ViewManager.next(); } + } + Button + { + Layout.leftMargin: 3 * buttonBar.spacing; // little gap from back/next + Layout.rightMargin: 2 * buttonBar.spacing + text: ViewManager.quitLabel; + icon.name: ViewManager.quitIcon; + + ToolTip.visible: hovered + ToolTip.timeout: 5000 + ToolTip.delay: 1000 + ToolTip.text: ViewManager.quitTooltip; + + enabled: ViewManager.quitEnabled; + visible: ViewManager.quitVisible; + onClicked: { ViewManager.quit(); } + } + } } diff --git a/src/calamares/calamares-sidebar.qml b/src/calamares/calamares-sidebar.qml index aa794e94a..e57cd3323 100644 --- a/src/calamares/calamares-sidebar.qml +++ b/src/calamares/calamares-sidebar.qml @@ -1,36 +1,44 @@ -import QtQuick 2.3 import io.calamares.ui 1.0 import io.calamares.core 1.0 -Column { +import QtQuick 2.3 +import QtQuick.Layouts 1.3 Rectangle { - id: hello - width: 200 - height: 100 - color: "red" + id: sideBar; + color: Branding.styleString( Branding.SidebarBackground ); - Text { - anchors.centerIn: parent - text: Branding.string(Branding.VersionedName) - } -} + ColumnLayout { + anchors.fill: parent; + spacing: 0; -/* perhaps we could show a branding image here */ + Image { + id: logo + width: 80; + height: width; // square + anchors.horizontalCenter: parent.horizontalCenter; + source: "file:/" + Branding.imagePath(Branding.ProductLogo); + sourceSize.width: width; + sourceSize.height: height; + } -Repeater { - model: ViewManager - Rectangle { - width: 200 - height: 75 - color: "black" + Repeater { + model: ViewManager + Rectangle { + width: 200; + height: 75; + color: Branding.styleString( index == ViewManager.currentStepIndex ? Branding.SidebarTextHighlight : Branding.SidebarBackground ); - Text { - anchors.centerIn: parent - color: index == ViewManager.currentStepIndex ? "green" : "yellow" - text: display + Text { + anchors.centerIn: parent; + color: Branding.styleString( index == ViewManager.currentStepIndex ? Branding.SidebarTextSelect : Branding.SidebarText ); + text: display; + } + } + } + + Item { + Layout.fillHeight: true; } } } - -} From 510f9352e7aaaf50568900ff30b28f7874608510 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 16:45:04 +0200 Subject: [PATCH 34/47] [calamares] Tweak QML sidebar - some margins and extra space - left-align text - progress lozenges instead of pointy rectangles --- src/calamares/calamares-sidebar.qml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/calamares/calamares-sidebar.qml b/src/calamares/calamares-sidebar.qml index e57cd3323..183a9acb2 100644 --- a/src/calamares/calamares-sidebar.qml +++ b/src/calamares/calamares-sidebar.qml @@ -13,10 +13,12 @@ Rectangle { spacing: 0; Image { - id: logo + Layout.topMargin: 12; + Layout.bottomMargin: 12; + Layout.alignment: Qt.AlignHCenter | Qt.AlignTop + id: logo; width: 80; height: width; // square - anchors.horizontalCenter: parent.horizontalCenter; source: "file:/" + Branding.imagePath(Branding.ProductLogo); sourceSize.width: width; sourceSize.height: height; @@ -25,12 +27,15 @@ Rectangle { Repeater { model: ViewManager Rectangle { - width: 200; - height: 75; + Layout.leftMargin: 12; + width: parent.width - 24; + height: 35; + radius: 6; color: Branding.styleString( index == ViewManager.currentStepIndex ? Branding.SidebarTextHighlight : Branding.SidebarBackground ); Text { - anchors.centerIn: parent; + anchors.verticalCenter: parent.verticalCenter; + x: parent.x + 12; color: Branding.styleString( index == ViewManager.currentStepIndex ? Branding.SidebarTextSelect : Branding.SidebarText ); text: display; } From 61a56336a133881f2efb3dd75f1c51091613a6bd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 17:19:12 +0200 Subject: [PATCH 35/47] Changes: document QML work, thanks Anke --- CHANGES | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index a24325308..3a6ebd0f3 100644 --- a/CHANGES +++ b/CHANGES @@ -6,13 +6,20 @@ website will have to do for older versions. # 3.2.22 (unreleased) # This release contains contributions from (alphabetically by first name): - - No external contributors yet + - Anke Boersma ## Core ## - - No core changes yet + - Both the sidebar (on the left) and the navigation buttons (along the + bottom of the window) can now be configured to use the traditional + *widgets*, to use *qml*, or *hidden* from view (hiding the navigation + is not recommended unless you have a pure-QML UI to run inside + Calamares). The example QML that is compiled into Calamares has + been improved. To use your own QML, put files `calamares-sidebar.qml` + or `calamares-navigation.qml` into the branding directory. ## Modules ## - - No module changes yet + - The *welcomeq* module has been improved with better layout and + nicer buttons in the example QML form. (Thanks to Anke Boersma) # 3.2.21 (2020-03-27) # From e2fee799570c93de1bff4de72600d9a3908ef13f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 17:49:08 +0200 Subject: [PATCH 36/47] [libcalamaresui] Set icon on back-button --- src/libcalamaresui/ViewManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index e80d4afd8..9bfb31e43 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -395,6 +395,7 @@ ViewManager::updateButtonLabels() // Going back is always simple UPDATE_BUTTON_PROPERTY( backLabel, tr( "&Back" ) ) + UPDATE_BUTTON_PROPERTY( backIcon, "go-back" ) // Cancel button changes label at the end if ( isAtVeryEnd( m_steps, m_currentStep ) ) From 34292618d88323a71838c1fcb3d42bb08d740e64 Mon Sep 17 00:00:00 2001 From: demmm Date: Thu, 2 Apr 2020 20:16:05 +0200 Subject: [PATCH 37/47] welcomeq buttons connecting minor spelling corrections --- src/modules/welcomeq/WelcomeQmlViewStep.cpp | 4 ++-- src/modules/welcomeq/welcomeq.qml | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.cpp b/src/modules/welcomeq/WelcomeQmlViewStep.cpp index 0961ce67f..c1046b506 100644 --- a/src/modules/welcomeq/WelcomeQmlViewStep.cpp +++ b/src/modules/welcomeq/WelcomeQmlViewStep.cpp @@ -139,10 +139,10 @@ WelcomeQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) m_config->setReleaseNotesUrl( jobOrBrandingSetting( Branding::ReleaseNotesUrl, configurationMap, "showReleaseNotesUrl" ) ); m_config->setDonateUrl( CalamaresUtils::getString( configurationMap, "showDonateUrl" ) ); - // TODO: expand Config class and set the remaining fields // with the configurationMap all those properties can be accesed withouth having to declare a property, get and setter for each + // TODO: expand Config class and set the remaining fields // with the configurationMap all those properties can be accessed without having to declare a property, get and setter for each // TODO: figure out how the requirements (held by ModuleManager) should be accessible - // to QML as a odel. //will be model as a qvariantmap containing a alert level and the message string + // to QML as a model. //will be model as a qvariantmap containing a alert level and the message string if ( configurationMap.contains( "requirements" ) && configurationMap.value( "requirements" ).type() == QVariant::Map ) { diff --git a/src/modules/welcomeq/welcomeq.qml b/src/modules/welcomeq/welcomeq.qml index 90de189d3..729b61b28 100644 --- a/src/modules/welcomeq/welcomeq.qml +++ b/src/modules/welcomeq/welcomeq.qml @@ -91,8 +91,8 @@ Page Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) Kirigami.Theme.textColor: Kirigami.Theme.textColor - visible: config.helpUrl.isValid - onClicked: Qt.openUrlExternally(config.helpUrl) + visible: config.supportUrl !== "" + onClicked: Qt.openUrlExternally(config.supportUrl) } Button { @@ -102,8 +102,8 @@ Page Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) Kirigami.Theme.textColor: Kirigami.Theme.textColor - visible: config.issuesUrl.isValid - onClicked: Qt.openUrlExternally(config.issuesUrl) + visible: config.knownIssuesUrl !== "" + onClicked: Qt.openUrlExternally(config.knownIssuesUrl) } Button { @@ -113,8 +113,8 @@ Page Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) Kirigami.Theme.textColor: Kirigami.Theme.textColor - visible: config.notesUrl.isValid - onClicked: Qt.openUrlExternally(config.notesUrl) + visible: config.releaseNotesUrl !== "" + onClicked: Qt.openUrlExternally(config.releaseNotesUrl) } Button { @@ -124,7 +124,7 @@ Page Kirigami.Theme.backgroundColor: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.4) Kirigami.Theme.textColor: Kirigami.Theme.textColor - visible: config.donateUrl.isValid + visible: config.donateUrl !== "" onClicked: Qt.openUrlExternally(config.donateUrl) } } From e5562a50694a553206433ea4008285561da9f61c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 21:33:07 +0200 Subject: [PATCH 38/47] [libcalamares] Move RequirementsModel to libcalamares (1/2) - Add the model and support code to libcalamares. The model still has some cruft that should be in the Welcome config. --- src/libcalamares/CMakeLists.txt | 1 + .../modulesystem/RequirementsModel.cpp | 81 ++++++++++++++++++ .../modulesystem/RequirementsModel.h | 85 +++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 src/libcalamares/modulesystem/RequirementsModel.cpp create mode 100644 src/libcalamares/modulesystem/RequirementsModel.h diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index c7bb96266..91dce96cd 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -42,6 +42,7 @@ set( libSources modulesystem/Module.cpp modulesystem/Requirement.cpp modulesystem/RequirementsChecker.cpp + modulesystem/RequirementsModel.cpp # Network service network/Manager.cpp diff --git a/src/libcalamares/modulesystem/RequirementsModel.cpp b/src/libcalamares/modulesystem/RequirementsModel.cpp new file mode 100644 index 000000000..4cd065dd7 --- /dev/null +++ b/src/libcalamares/modulesystem/RequirementsModel.cpp @@ -0,0 +1,81 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019-2020, Adriaan de Groot + * + * 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 "RequirementsModel.h" + +namespace Calamares +{ + +void +RequirementsModel::setRequirementsList( const Calamares::RequirementsList& requirements ) +{ + emit beginResetModel(); + m_requirements = requirements; + + auto isUnSatisfied = []( const Calamares::RequirementEntry& e ) { return !e.satisfied; }; + auto isMandatoryAndUnSatisfied = []( const Calamares::RequirementEntry& e ) { return e.mandatory && !e.satisfied; }; + + m_satisfiedRequirements = std::none_of( m_requirements.begin(), m_requirements.end(), isUnSatisfied ); + m_satisfiedMandatory = std::none_of( m_requirements.begin(), m_requirements.end(), isMandatoryAndUnSatisfied ); + + emit satisfiedRequirementsChanged( m_satisfiedRequirements ); + emit satisfiedMandatoryChanged(); + emit endResetModel(); +} + +int +RequirementsModel::rowCount( const QModelIndex& ) const +{ + return m_requirements.count(); +} + +QVariant +RequirementsModel::data( const QModelIndex& index, int role ) const +{ + const auto requirement = m_requirements.at( index.row() ); + + switch ( role ) + { + case Roles::Name: + return requirement.name; + case Roles::Details: + return requirement.enumerationText(); + case Roles::NegatedText: + return requirement.negatedText(); + case Roles::Satisfied: + return requirement.satisfied; + case Roles::Mandatory: + return requirement.mandatory; + default: + return QVariant(); + } +} + +QHash< int, QByteArray > +RequirementsModel::roleNames() const +{ + static QHash< int, QByteArray > roles; + roles[ Roles::Name ] = "name"; + roles[ Roles::Details ] = "details"; + roles[ Roles::NegatedText ] = "negatedText"; + roles[ Roles::Satisfied ] = "satisfied"; + roles[ Roles::Mandatory ] = "mandatory"; + return roles; +} + +} // namespace Calamares diff --git a/src/libcalamares/modulesystem/RequirementsModel.h b/src/libcalamares/modulesystem/RequirementsModel.h new file mode 100644 index 000000000..47f80e3ae --- /dev/null +++ b/src/libcalamares/modulesystem/RequirementsModel.h @@ -0,0 +1,85 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019-2020, Adriaan de Groot + * + * 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 CALAMARES_REQUIREMENTSMODEL_H +#define CALAMARES_REQUIREMENTSMODEL_H + +#include "Requirement.h" + +#include "DllMacro.h" + +#include + +namespace Calamares +{ + +class DLLEXPORT RequirementsModel : public QAbstractListModel +{ + Q_OBJECT + Q_PROPERTY( bool satisfiedRequirements READ satisfiedRequirements NOTIFY satisfiedRequirementsChanged FINAL ) + Q_PROPERTY( bool satisfiedMandatory READ satisfiedMandatory NOTIFY satisfiedMandatoryChanged FINAL ) + +public: + using QAbstractListModel::QAbstractListModel; + + enum Roles : short + { + Name, + Satisfied, + Mandatory, + Details, + NegatedText, + HasDetails + }; + + bool satisfiedRequirements() const { return m_satisfiedRequirements; } + bool satisfiedMandatory() const { return m_satisfiedMandatory; } + + const Calamares::RequirementEntry& getEntry( const int& index ) const + { + if ( index > count() || index < 0 ) + { + return *( new Calamares::RequirementEntry() ); + } + + return m_requirements.at( index ); + } + + void setRequirementsList( const Calamares::RequirementsList& requirements ); + + QVariant data( const QModelIndex& index, int role ) const override; + int rowCount( const QModelIndex& ) const override; + int count() const { return m_requirements.count(); } + +protected: + QHash< int, QByteArray > roleNames() const override; + +private: + Calamares::RequirementsList m_requirements; + bool m_satisfiedRequirements = false; + bool m_satisfiedMandatory = false; + +signals: + void satisfiedRequirementsChanged( bool value ); + void satisfiedMandatoryChanged(); + void warningMessageChanged(); +}; + +} // namespace Calamares + +#endif From 3bf69c9da8c296589994220525588a002f5f9eab Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 21:38:29 +0200 Subject: [PATCH 39/47] [calamares] Pacify gcc --- src/calamares/CalamaresWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index a97d2dccf..5d4565406 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -248,6 +248,7 @@ flavoredWidget( Calamares::Branding::PanelFlavor flavor, case Calamares::Branding::PanelFlavor::None: return nullptr; } + NOTREACHED return nullptr; // All enum values handled above } CalamaresWindow::CalamaresWindow( QWidget* parent ) From ca7733c8e43f71c8f85216012d250ae0a2ce21c2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 21:52:05 +0200 Subject: [PATCH 40/47] [welcome] Drop RequirementsModel - Use the one from libcalamares - Massage warning message into Config after it was removed from the model --- src/modules/welcome/Config.cpp | 154 ++++++------------ src/modules/welcome/Config.h | 80 ++------- .../welcome/checker/CheckerContainer.cpp | 2 +- .../welcome/checker/CheckerContainer.h | 4 +- .../welcome/checker/ResultsListWidget.cpp | 10 +- .../welcome/checker/ResultsListWidget.h | 4 +- 6 files changed, 69 insertions(+), 185 deletions(-) diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 43987f4b2..7258382c4 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -23,71 +23,12 @@ #include "utils/Logger.h" #include "utils/Retranslator.h" -void -RequirementsModel::setRequirementsList( const Calamares::RequirementsList& requirements ) -{ - CALAMARES_RETRANSLATE_SLOT( &RequirementsModel::retranslate ) - - emit beginResetModel(); - m_requirements = requirements; - - auto isUnSatisfied = []( const Calamares::RequirementEntry& e ) { return !e.satisfied; }; - auto isMandatoryAndUnSatisfied = []( const Calamares::RequirementEntry& e ) { return e.mandatory && !e.satisfied; }; - - m_satisfiedRequirements = std::none_of( m_requirements.begin(), m_requirements.end(), isUnSatisfied ); - m_satisfiedMandatory = std::none_of( m_requirements.begin(), m_requirements.end(), isMandatoryAndUnSatisfied ); - - emit satisfiedRequirementsChanged( m_satisfiedRequirements ); - emit satisfiedMandatoryChanged(); - emit endResetModel(); -} - -int -RequirementsModel::rowCount( const QModelIndex& ) const -{ - return m_requirements.count(); -} - -QVariant -RequirementsModel::data( const QModelIndex& index, int role ) const -{ - const auto requirement = m_requirements.at( index.row() ); - - switch ( role ) - { - case Roles::Name: - return requirement.name; - case Roles::Details: - return requirement.enumerationText(); - case Roles::NegatedText: - return requirement.negatedText(); - case Roles::Satisfied: - return requirement.satisfied; - case Roles::Mandatory: - return requirement.mandatory; - default: - return QVariant(); - } -} - -QHash< int, QByteArray > -RequirementsModel::roleNames() const -{ - static QHash< int, QByteArray > roles; - roles[ Roles::Name ] = "name"; - roles[ Roles::Details ] = "details"; - roles[ Roles::NegatedText ] = "negatedText"; - roles[ Roles::Satisfied ] = "satisfied"; - roles[ Roles::Mandatory ] = "mandatory"; - return roles; -} - Config::Config( QObject* parent ) : QObject( parent ) - , m_requirementsModel( new RequirementsModel( this ) ) + , m_requirementsModel( new Calamares::RequirementsModel( this ) ) , m_languages( CalamaresUtils::Locale::availableTranslations() ) { - connect( m_requirementsModel, &RequirementsModel::satisfiedRequirementsChanged, this, &Config::setIsNextEnabled ); + connect( m_requirementsModel, &Calamares::RequirementsModel::satisfiedRequirementsChanged, this, &Config::setIsNextEnabled ); initLanguages(); @@ -100,7 +41,44 @@ Config::retranslate() m_genericWelcomeMessage = genericWelcomeMessage().arg( *Calamares::Branding::VersionedName ); emit genericWelcomeMessageChanged(); - m_requirementsModel->retranslate(); + if ( !m_requirementsModel->satisfiedRequirements() ) + { + QString message; + const bool setup = Calamares::Settings::instance()->isSetupMode(); + + if ( !m_requirementsModel->satisfiedMandatory() ) + { + message = setup ? tr( "This computer does not satisfy the minimum " + "requirements for setting up %1.
" + "Setup cannot continue. " + "Details..." ) + : tr( "This computer does not satisfy the minimum " + "requirements for installing %1.
" + "Installation cannot continue. " + "Details..." ); + } + else + { + message = setup ? tr( "This computer does not satisfy some of the " + "recommended requirements for setting up %1.
" + "Setup can continue, but some features " + "might be disabled." ) + : tr( "This computer does not satisfy some of the " + "recommended requirements for installing %1.
" + "Installation can continue, but some features " + "might be disabled." ); + } + + m_warningMessage = message.arg( *Calamares::Branding::ShortVersionedName ); + } + else + { + m_warningMessage = tr( "This program will ask you some questions and " + "set up %2 on your computer." ) + .arg( *Calamares::Branding::ProductName ); + } + + emit warningMessageChanged(); } CalamaresUtils::Locale::LabelModel* @@ -197,7 +175,7 @@ Config::setLocaleIndex( const int& index ) emit localeIndexChanged( m_localeIndex ); } -RequirementsModel& +Calamares::RequirementsModel& Config::requirementsModel() const { return *m_requirementsModel; @@ -262,51 +240,8 @@ Config::setSupportUrl( const QString& url ) emit supportUrlChanged(); } -void -RequirementsModel::retranslate() -{ - if ( !m_satisfiedRequirements ) - { - QString message; - const bool setup = Calamares::Settings::instance()->isSetupMode(); - - if ( !m_satisfiedMandatory ) - { - message = setup ? tr( "This computer does not satisfy the minimum " - "requirements for setting up %1.
" - "Setup cannot continue. " - "Details..." ) - : tr( "This computer does not satisfy the minimum " - "requirements for installing %1.
" - "Installation cannot continue. " - "Details..." ); - } - else - { - message = setup ? tr( "This computer does not satisfy some of the " - "recommended requirements for setting up %1.
" - "Setup can continue, but some features " - "might be disabled." ) - : tr( "This computer does not satisfy some of the " - "recommended requirements for installing %1.
" - "Installation can continue, but some features " - "might be disabled." ); - } - - m_warningMessage = message.arg( *Calamares::Branding::ShortVersionedName ); - } - else - { - m_warningMessage = tr( "This program will ask you some questions and " - "set up %2 on your computer." ) - .arg( *Calamares::Branding::ProductName ); - } - - emit warningMessageChanged(); -} - QString -Config::genericWelcomeMessage() +Config::genericWelcomeMessage() const { QString message; @@ -325,3 +260,8 @@ Config::genericWelcomeMessage() return message; } + +QString Config::warningMessage() const +{ + return m_warningMessage; +} diff --git a/src/modules/welcome/Config.h b/src/modules/welcome/Config.h index 389a45eec..e8cb35e52 100644 --- a/src/modules/welcome/Config.h +++ b/src/modules/welcome/Config.h @@ -19,79 +19,18 @@ #ifndef WELCOME_CONFIG_H #define WELCOME_CONFIG_H -#include "modulesystem/Requirement.h" #include "locale/LabelModel.h" +#include "modulesystem/Requirement.h" +#include "modulesystem/RequirementsModel.h" #include #include -// TODO: move this (and modulesystem/Requirement) to libcalamares -class RequirementsModel : public QAbstractListModel -{ - Q_OBJECT - Q_PROPERTY( bool satisfiedRequirements READ satisfiedRequirements NOTIFY satisfiedRequirementsChanged FINAL ) - Q_PROPERTY( bool satisfiedMandatory READ satisfiedMandatory NOTIFY satisfiedMandatoryChanged FINAL ) - Q_PROPERTY( QString warningMessage READ warningMessage NOTIFY warningMessageChanged FINAL ) - -public: - using QAbstractListModel::QAbstractListModel; - - enum Roles : short - { - Name, - Satisfied, - Mandatory, - Details, - NegatedText, - HasDetails - }; - - bool satisfiedRequirements() const { return m_satisfiedRequirements; } - - bool satisfiedMandatory() const { return m_satisfiedMandatory; } - - const Calamares::RequirementEntry& getEntry( const int& index ) const - { - if ( index > count() || index < 0 ) - { - return *( new Calamares::RequirementEntry() ); - } - - return m_requirements.at( index ); - } - - void setRequirementsList( const Calamares::RequirementsList& requirements ); - int rowCount( const QModelIndex& ) const override; - int count() const { return m_requirements.count(); } - - QString warningMessage() const { return m_warningMessage; } - - void retranslate(); - - QVariant data( const QModelIndex& index, int role ) const override; - -protected: - QHash< int, QByteArray > roleNames() const override; - -private: - Calamares::RequirementsList m_requirements; - bool m_satisfiedRequirements = false; - bool m_satisfiedMandatory = false; - - QString m_warningMessage; - -signals: - void satisfiedRequirementsChanged( bool value ); - void satisfiedMandatoryChanged(); - void warningMessageChanged(); -}; - - class Config : public QObject { Q_OBJECT Q_PROPERTY( CalamaresUtils::Locale::LabelModel* languagesModel READ languagesModel CONSTANT FINAL ) - Q_PROPERTY( RequirementsModel* requirementsModel MEMBER m_requirementsModel CONSTANT FINAL ) + Q_PROPERTY( Calamares::RequirementsModel* requirementsModel MEMBER m_requirementsModel CONSTANT FINAL ) Q_PROPERTY( QString languageIcon READ languageIcon CONSTANT FINAL ) @@ -99,6 +38,7 @@ class Config : public QObject Q_PROPERTY( int localeIndex READ localeIndex WRITE setLocaleIndex NOTIFY localeIndexChanged ) Q_PROPERTY( QString genericWelcomeMessage MEMBER m_genericWelcomeMessage NOTIFY genericWelcomeMessageChanged FINAL ) + Q_PROPERTY( QString warningMessage READ warningMessage NOTIFY warningMessageChanged FINAL ) Q_PROPERTY( QString supportUrl MEMBER m_supportUrl NOTIFY supportUrlChanged FINAL ) Q_PROPERTY( QString knownIssuesUrl MEMBER m_knownIssuesUrl NOTIFY knownIssuesUrlChanged FINAL ) @@ -111,7 +51,7 @@ public: Config( QObject* parent = nullptr ); void setCountryCode( const QString& countryCode ); void setLanguageIcon( const QString& languageIcon ); - RequirementsModel& requirementsModel() const; + Calamares::RequirementsModel& requirementsModel() const; void setIsNextEnabled( const bool& isNextEnabled ); @@ -130,8 +70,8 @@ public: QString donateUrl() const; void setDonateUrl( const QString& url ); - QString genericWelcomeMessage(); - + QString genericWelcomeMessage() const; + QString warningMessage() const; public slots: CalamaresUtils::Locale::LabelModel* languagesModel() const; @@ -141,7 +81,7 @@ public slots: private: void initLanguages(); QVariantMap m_configurationMap; - RequirementsModel* m_requirementsModel; + Calamares::RequirementsModel* m_requirementsModel; QString m_languageIcon; QString m_countryCode; int m_localeIndex = 0; @@ -149,6 +89,7 @@ private: CalamaresUtils::Locale::LabelModel* m_languages; QString m_genericWelcomeMessage; + QString m_warningMessage; QString m_supportUrl; QString m_knownIssuesUrl; @@ -159,7 +100,10 @@ signals: void countryCodeChanged( QString countryCode ); void localeIndexChanged( int localeIndex ); void isNextEnabledChanged( bool isNextEnabled ); + void genericWelcomeMessageChanged(); + void warningMessageChanged(); + void supportUrlChanged(); void knownIssuesUrlChanged(); void releaseNotesUrlChanged(); diff --git a/src/modules/welcome/checker/CheckerContainer.cpp b/src/modules/welcome/checker/CheckerContainer.cpp index 0e790fbb4..10da425ab 100644 --- a/src/modules/welcome/checker/CheckerContainer.cpp +++ b/src/modules/welcome/checker/CheckerContainer.cpp @@ -31,7 +31,7 @@ #include -CheckerContainer::CheckerContainer( const RequirementsModel &model, QWidget* parent ) +CheckerContainer::CheckerContainer( const Calamares::RequirementsModel &model, QWidget* parent ) : QWidget( parent ) , m_waitingWidget( new WaitingWidget( QString(), this ) ) , m_checkerWidget( nullptr ) diff --git a/src/modules/welcome/checker/CheckerContainer.h b/src/modules/welcome/checker/CheckerContainer.h index f38f198ea..5ebefa36e 100644 --- a/src/modules/welcome/checker/CheckerContainer.h +++ b/src/modules/welcome/checker/CheckerContainer.h @@ -40,7 +40,7 @@ class CheckerContainer : public QWidget { Q_OBJECT public: - explicit CheckerContainer(const RequirementsModel &model, QWidget* parent = nullptr ); + explicit CheckerContainer(const Calamares::RequirementsModel &model, QWidget* parent = nullptr ); virtual ~CheckerContainer(); bool verdict() const; @@ -58,7 +58,7 @@ protected: bool m_verdict; private: - const RequirementsModel &m_model; + const Calamares::RequirementsModel &m_model; } ; #endif diff --git a/src/modules/welcome/checker/ResultsListWidget.cpp b/src/modules/welcome/checker/ResultsListWidget.cpp index 275010b2f..c16cda4c4 100644 --- a/src/modules/welcome/checker/ResultsListWidget.cpp +++ b/src/modules/welcome/checker/ResultsListWidget.cpp @@ -47,7 +47,7 @@ static void createResultWidgets( QLayout* layout, QList< ResultWidget* >& resultWidgets, - const RequirementsModel &model, + const Calamares::RequirementsModel &model, std::function< bool( const Calamares::RequirementEntry& ) > predicate ) { @@ -94,18 +94,18 @@ public: * The list must continue to exist for the lifetime of the dialog, * or UB happens. */ - ResultsListDialog( const RequirementsModel& model, QWidget* parent ); + ResultsListDialog( const Calamares::RequirementsModel& model, QWidget* parent ); virtual ~ResultsListDialog(); private: QLabel* m_title; QList< ResultWidget* > m_resultWidgets; ///< One widget for each entry with details available - const RequirementsModel& m_model; + const Calamares::RequirementsModel& m_model; void retranslate(); }; -ResultsListDialog::ResultsListDialog( const RequirementsModel& model, QWidget* parent) +ResultsListDialog::ResultsListDialog( const Calamares::RequirementsModel& model, QWidget* parent) : QDialog( parent ) , m_model( model ) { @@ -151,7 +151,7 @@ ResultsListDialog::retranslate() } -ResultsListWidget::ResultsListWidget( const RequirementsModel &model, QWidget* parent ) +ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel &model, QWidget* parent ) : QWidget( parent ) , m_model( model ) { diff --git a/src/modules/welcome/checker/ResultsListWidget.h b/src/modules/welcome/checker/ResultsListWidget.h index eb1bdb611..05a8adfa4 100644 --- a/src/modules/welcome/checker/ResultsListWidget.h +++ b/src/modules/welcome/checker/ResultsListWidget.h @@ -30,7 +30,7 @@ class ResultsListWidget : public QWidget { Q_OBJECT public: - explicit ResultsListWidget(const RequirementsModel &model, QWidget* parent); + explicit ResultsListWidget(const Calamares::RequirementsModel &model, QWidget* parent); private: /// @brief A link in the explanatory text has been clicked @@ -38,7 +38,7 @@ private: void retranslate(); QLabel* m_explanation = nullptr; ///< Explanatory text above the list, with link - const RequirementsModel &m_model; + const Calamares::RequirementsModel &m_model; QList< ResultWidget* > m_resultWidgets; ///< One widget for each unsatisfied entry }; From 9d97972a342c85470cc635b6db6dd0c6756f24f9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 21:53:02 +0200 Subject: [PATCH 41/47] [welcome] Apply coding style --- src/modules/welcome/Config.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 7258382c4..316014a91 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -28,7 +28,10 @@ Config::Config( QObject* parent ) , m_requirementsModel( new Calamares::RequirementsModel( this ) ) , m_languages( CalamaresUtils::Locale::availableTranslations() ) { - connect( m_requirementsModel, &Calamares::RequirementsModel::satisfiedRequirementsChanged, this, &Config::setIsNextEnabled ); + connect( m_requirementsModel, + &Calamares::RequirementsModel::satisfiedRequirementsChanged, + this, + &Config::setIsNextEnabled ); initLanguages(); @@ -261,7 +264,8 @@ Config::genericWelcomeMessage() const return message; } -QString Config::warningMessage() const +QString +Config::warningMessage() const { return m_warningMessage; } From 39afbdb5709e5311eac9f578985de416942f663a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 21:55:36 +0200 Subject: [PATCH 42/47] [welcome] Shuffle signals to conventional location - signals after slots, before private - while here give the *MessageChanged signals a parameter (the changed message) --- src/modules/welcome/Config.cpp | 4 ++-- src/modules/welcome/Config.h | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 316014a91..0377bcf0c 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -42,7 +42,7 @@ void Config::retranslate() { m_genericWelcomeMessage = genericWelcomeMessage().arg( *Calamares::Branding::VersionedName ); - emit genericWelcomeMessageChanged(); + emit genericWelcomeMessageChanged( m_genericWelcomeMessage ); if ( !m_requirementsModel->satisfiedRequirements() ) { @@ -81,7 +81,7 @@ Config::retranslate() .arg( *Calamares::Branding::ProductName ); } - emit warningMessageChanged(); + emit warningMessageChanged( m_warningMessage ); } CalamaresUtils::Locale::LabelModel* diff --git a/src/modules/welcome/Config.h b/src/modules/welcome/Config.h index e8cb35e52..f447c7a10 100644 --- a/src/modules/welcome/Config.h +++ b/src/modules/welcome/Config.h @@ -78,6 +78,19 @@ public slots: void retranslate(); QString languageIcon() const; +signals: + void countryCodeChanged( QString countryCode ); + void localeIndexChanged( int localeIndex ); + void isNextEnabledChanged( bool isNextEnabled ); + + void genericWelcomeMessageChanged( QString message ); + void warningMessageChanged( QString message ); + + void supportUrlChanged(); + void knownIssuesUrlChanged(); + void releaseNotesUrlChanged(); + void donateUrlChanged(); + private: void initLanguages(); QVariantMap m_configurationMap; @@ -95,19 +108,6 @@ private: QString m_knownIssuesUrl; QString m_releaseNotesUrl; QString m_donateUrl; - -signals: - void countryCodeChanged( QString countryCode ); - void localeIndexChanged( int localeIndex ); - void isNextEnabledChanged( bool isNextEnabled ); - - void genericWelcomeMessageChanged(); - void warningMessageChanged(); - - void supportUrlChanged(); - void knownIssuesUrlChanged(); - void releaseNotesUrlChanged(); - void donateUrlChanged(); }; #endif From d2f5185d493800ef950273d07840c055c0e0494c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 22:00:43 +0200 Subject: [PATCH 43/47] [welcome] Remove unused m_configurationMap - the configuration is split into specific properties, not stored generically. --- src/modules/welcome/Config.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/welcome/Config.h b/src/modules/welcome/Config.h index f447c7a10..9c8fb12e5 100644 --- a/src/modules/welcome/Config.h +++ b/src/modules/welcome/Config.h @@ -93,13 +93,14 @@ signals: private: void initLanguages(); - QVariantMap m_configurationMap; + Calamares::RequirementsModel* m_requirementsModel; + CalamaresUtils::Locale::LabelModel* m_languages; + QString m_languageIcon; QString m_countryCode; int m_localeIndex = 0; bool m_isNextEnabled = false; - CalamaresUtils::Locale::LabelModel* m_languages; QString m_genericWelcomeMessage; QString m_warningMessage; From 4e7020d0303916c2a555c856a6ab06a0cf54c33f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 22:04:34 +0200 Subject: [PATCH 44/47] [libcalamares] Polish model - make signals consistent in carrying a parameter - explain why there's no Q_ENUM --- src/libcalamares/modulesystem/RequirementsModel.cpp | 2 +- src/libcalamares/modulesystem/RequirementsModel.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/modulesystem/RequirementsModel.cpp b/src/libcalamares/modulesystem/RequirementsModel.cpp index 4cd065dd7..4001d2d81 100644 --- a/src/libcalamares/modulesystem/RequirementsModel.cpp +++ b/src/libcalamares/modulesystem/RequirementsModel.cpp @@ -34,7 +34,7 @@ RequirementsModel::setRequirementsList( const Calamares::RequirementsList& requi m_satisfiedMandatory = std::none_of( m_requirements.begin(), m_requirements.end(), isMandatoryAndUnSatisfied ); emit satisfiedRequirementsChanged( m_satisfiedRequirements ); - emit satisfiedMandatoryChanged(); + emit satisfiedMandatoryChanged( m_satisfiedMandatory ); emit endResetModel(); } diff --git a/src/libcalamares/modulesystem/RequirementsModel.h b/src/libcalamares/modulesystem/RequirementsModel.h index 47f80e3ae..03e00bec5 100644 --- a/src/libcalamares/modulesystem/RequirementsModel.h +++ b/src/libcalamares/modulesystem/RequirementsModel.h @@ -46,6 +46,7 @@ public: NegatedText, HasDetails }; + // No Q_ENUM because these are exposed through roleNames() bool satisfiedRequirements() const { return m_satisfiedRequirements; } bool satisfiedMandatory() const { return m_satisfiedMandatory; } @@ -76,7 +77,7 @@ private: signals: void satisfiedRequirementsChanged( bool value ); - void satisfiedMandatoryChanged(); + void satisfiedMandatoryChanged( bool value ); void warningMessageChanged(); }; From e756cc8720d203b2e714f66ab7d5b86d46eaa1bb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 22:12:56 +0200 Subject: [PATCH 45/47] [libcalamares] Tidy RequirementsModel some more - put signals in conventional place - remove const int& parameter, that can just be int - drop oddly-guarded code (that leaks memory); if the index (row) being passed in, it's probably best to just crash - remove unused signal warningMessageChanged --- src/libcalamares/modulesystem/RequirementsModel.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/libcalamares/modulesystem/RequirementsModel.h b/src/libcalamares/modulesystem/RequirementsModel.h index 03e00bec5..2acf785e7 100644 --- a/src/libcalamares/modulesystem/RequirementsModel.h +++ b/src/libcalamares/modulesystem/RequirementsModel.h @@ -51,13 +51,8 @@ public: bool satisfiedRequirements() const { return m_satisfiedRequirements; } bool satisfiedMandatory() const { return m_satisfiedMandatory; } - const Calamares::RequirementEntry& getEntry( const int& index ) const + const Calamares::RequirementEntry& getEntry( int index ) const { - if ( index > count() || index < 0 ) - { - return *( new Calamares::RequirementEntry() ); - } - return m_requirements.at( index ); } @@ -67,6 +62,10 @@ public: int rowCount( const QModelIndex& ) const override; int count() const { return m_requirements.count(); } +signals: + void satisfiedRequirementsChanged( bool value ); + void satisfiedMandatoryChanged( bool value ); + protected: QHash< int, QByteArray > roleNames() const override; @@ -75,10 +74,6 @@ private: bool m_satisfiedRequirements = false; bool m_satisfiedMandatory = false; -signals: - void satisfiedRequirementsChanged( bool value ); - void satisfiedMandatoryChanged( bool value ); - void warningMessageChanged(); }; } // namespace Calamares From 5956c6678ef00a9ffca413d665a43af0f25e2f6c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 22:42:41 +0200 Subject: [PATCH 46/47] [welcome] Don't const& POD - simplify parameter types in some set-methods - while here, shuffle methods to bring things together --- src/modules/welcome/Config.cpp | 6 +++--- src/modules/welcome/Config.h | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 0377bcf0c..1c2b17c38 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -159,7 +159,7 @@ Config::setLanguageIcon( const QString& languageIcon ) } void -Config::setLocaleIndex( const int& index ) +Config::setLocaleIndex( int index ) { if ( index == m_localeIndex || index > CalamaresUtils::Locale::availableTranslations()->rowCount( QModelIndex() ) || index < 0 ) @@ -170,7 +170,7 @@ Config::setLocaleIndex( const int& index ) m_localeIndex = index; const auto& selectedLocale = m_languages->locale( m_localeIndex ).locale(); - cDebug() << "Selected locale" << selectedLocale; + cDebug() << "Index" << index << "Selected locale" << selectedLocale; QLocale::setDefault( selectedLocale ); CalamaresUtils::installTranslator( selectedLocale, Calamares::Branding::instance()->translationsDirectory() ); @@ -185,7 +185,7 @@ Config::requirementsModel() const } void -Config::setIsNextEnabled( const bool& isNextEnabled ) +Config::setIsNextEnabled( bool isNextEnabled ) { m_isNextEnabled = isNextEnabled; emit isNextEnabledChanged( m_isNextEnabled ); diff --git a/src/modules/welcome/Config.h b/src/modules/welcome/Config.h index 9c8fb12e5..80e4eeea9 100644 --- a/src/modules/welcome/Config.h +++ b/src/modules/welcome/Config.h @@ -49,13 +49,17 @@ class Config : public QObject public: Config( QObject* parent = nullptr ); - void setCountryCode( const QString& countryCode ); - void setLanguageIcon( const QString& languageIcon ); + Calamares::RequirementsModel& requirementsModel() const; - void setIsNextEnabled( const bool& isNextEnabled ); + void setCountryCode( const QString& countryCode ); - void setLocaleIndex( const int& index ); + QString languageIcon() const; + void setLanguageIcon( const QString& languageIcon ); + + void setIsNextEnabled( bool isNextEnabled ); + + void setLocaleIndex( int index ); int localeIndex() const { return m_localeIndex; } QString supportUrl() const; @@ -76,7 +80,6 @@ public: public slots: CalamaresUtils::Locale::LabelModel* languagesModel() const; void retranslate(); - QString languageIcon() const; signals: void countryCodeChanged( QString countryCode ); From fafc508d633b83bfe9ae3c25a8135ffe15b48e8e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 23:04:23 +0200 Subject: [PATCH 47/47] [welcome] Update the widget's notion of the locale - when the locale changes, tell the widget so that the drop-down displays the right language. FIXES #1361 --- src/modules/welcome/WelcomeViewStep.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/welcome/WelcomeViewStep.cpp b/src/modules/welcome/WelcomeViewStep.cpp index 848d319db..3a0bef18f 100644 --- a/src/modules/welcome/WelcomeViewStep.cpp +++ b/src/modules/welcome/WelcomeViewStep.cpp @@ -47,6 +47,7 @@ WelcomeViewStep::WelcomeViewStep( QObject* parent ) // the instance of the qqc2 or qwidgets page m_widget = new WelcomePage( m_conf ); + connect( m_conf, &Config::localeIndexChanged, m_widget, &WelcomePage::externallySelectedLanguage ); } WelcomeViewStep::~WelcomeViewStep()