From 4ddd1ecceb83b760fb5d680ce17cb8c0dbe1e485 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Mar 2020 22:13:30 +0200 Subject: [PATCH 01/14] [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 02/14] [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 03/14] [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 04/14] [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 05/14] [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 e5562a50694a553206433ea4008285561da9f61c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 21:33:07 +0200 Subject: [PATCH 06/14] [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 ca7733c8e43f71c8f85216012d250ae0a2ce21c2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 Apr 2020 21:52:05 +0200 Subject: [PATCH 07/14] [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 08/14] [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 09/14] [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 10/14] [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 11/14] [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 12/14] [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 13/14] [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 14/14] [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()