diff --git a/CHANGES b/CHANGES index 1f1d37f61..1322f0449 100644 --- a/CHANGES +++ b/CHANGES @@ -6,7 +6,7 @@ website will have to do for older versions. # 3.2.19 (unreleased) # This release contains contributions from (alphabetically by first name): - - No other contributors this time around. + - Anke Boersma ## Core ## - *Assamese* translation has been completed. @@ -17,10 +17,18 @@ This release contains contributions from (alphabetically by first name): translations without requiring a recompile: helpful for translators and possibly for distributions with their own translation style. See the translators and deployers wiki for details. + - A new `ViewStep` base class, `QmlViewStep`, has been added that loads + a configurable QML file and plays it. This is used by the new *notesqml* + module -- which is in itself a minimal wrapper around the same that + adds only a translatable module name. ## Modules ## - The *machineid* and *users* modules now prefer high-quality random data from `/dev/urandom` rather than pseudo-random data. #1254 + - A new *notesqml* module supports loading QML. This can be used for + "fancy" release notes as a QML application, rather than a webview + or text widget. Note that this does not replace the slideshow-during- + installation module. # 3.2.18 (2020-01-28) # diff --git a/README.md b/README.md index e2e87fddf..7b12532e5 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,11 @@ --------- [![GitHub release](https://img.shields.io/github/release/calamares/calamares.svg)](https://github.com/calamares/calamares/releases) -[![Build Status](https://calamares.io/ci/buildStatus/icon?job=calamares-post_commit)](https://calamares.io/ci/job/calamares-post_commit/) [![Travis Build Status](https://travis-ci.org/calamares/calamares.svg?branch=master)](https://travis-ci.org/calamares/calamares) [![Coverity Scan Build Status](https://scan.coverity.com/projects/5389/badge.svg)](https://scan.coverity.com/projects/5389) [![GitHub license](https://img.shields.io/github/license/calamares/calamares.svg)](https://github.com/calamares/calamares/blob/master/LICENSE) -| [Report a Bug](https://github.com/calamares/calamares/issues/new) | [Contribute](https://github.com/calamares/calamares/blob/master/ci/HACKING.md) | [Translate](https://www.transifex.com/projects/p/calamares/) | Freenode (IRC): #calamares | [Wiki](https://github.com/calamares/calamares/wiki) | +| [Report a Bug](https://github.com/calamares/calamares/issues/new) | [Translate](https://www.transifex.com/projects/p/calamares/) | [Contribute](https://github.com/calamares/calamares/wiki/Develop-Guide) | Freenode (IRC): #calamares | [Wiki](https://github.com/calamares/calamares/wiki) | |:-----------------------------------------:|:----------------------:|:-----------------------:|:--------------------------:|:--------------------------:| ### Dependencies diff --git a/ci/HACKING.md b/ci/HACKING.md index 02eb8fd17..f1c8b750b 100644 --- a/ci/HACKING.md +++ b/ci/HACKING.md @@ -1,211 +1 @@ -Hacking on Calamares -==================== - -These are the guidelines for hacking on Calamares. Except for the licensing, -which **must** be GPLv3+, these are guidelines and -- like PEP8 -- the most -important thing is to know when you can ignore them. - - -Licensing ---------- -Calamares is released under the terms of the GNU GPL, version 3 or later. -Every source file must have a license header, with a list of copyright holders and years. - -Example: -``` -/* === This file is part of Calamares - === - * - * Copyright 2013-2014, Random Person - * Copyright 2010, Someone Else - * - * 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 . - */ -``` -Copyright holders must be physical or legal personalities. A statement such as -`Copyright 2014, The FooBarQuux project` has no legal value if "The FooBarQuux -project" is not the legal name of a person, company, incorporated -organization, etc. - -Please add your name to files you touch when making any contribution (even if -it's just a typo-fix which might not be copyrightable in all jurisdictions). - - -Formatting C++ --------------- -This formatting guide applies to C++ code only; for Python modules, we use -[pycodestyle](https://github.com/PyCQA/pycodestyle) to apply a check of -some PEP8 guidelines. - -* Spaces, not tabs. -* Indentation is 4 spaces. -* Lines should be limited to 90 characters. -* Spaces between brackets and argument functions, including for template arguments -* No space before brackets, except for keywords, for example `function( argument )` but - `if ( condition )`. -* For pointer and reference variable declarations, put a space before the variable name - and no space between the type and the `*` or `&`, e.g. `int* p`. -* `for`, `if`, `else`, `while` and similar statements put the braces on the next line, - if the following block is more than one statement. Always use braces. -* Function and class definitions have their braces on separate lines. -* A function implementation's return type is on its own line. -* `CamelCase.{cpp,h}` style file names. -* Lambdas are preferrably indented to a 4-space tab, even when passed as an - argument to functions. - -Example: -``` -bool -MyClass::myMethod( QStringList list, const QString& name ) -{ - if ( list.isEmpty() ) - return false; - - cDebug() << "Items in list .."; - foreach ( const QString& string, list ) - cDebug() << " .." << string; - - switch ( m_enumValue ) - { - case Something: - return true; - case SomethingElse: - doSomething(); - break; - } -} -``` - -You can use `clang-format` (version 7) to have Calamares sources formatted -the right way. There is a `.clang-format` file that specifies the details. -In general: -``` - $ clang-format-7 -i -style=file -``` -` - -**NOTE:** An .editorconfig file is included to assist with formatting. In -order to take advantage of this functionality you will need to acquire the -[EditorConfig](http://editorconfig.org/#download) plug-in for your editor. - - -Naming ------- -* Use CamelCase for everything. -* Local variables should start out with a lowercase letter. -* Class names are capitalized -* Prefix class member variables with `m_`, e.g. `m_queue`. -* Prefix static member variables with `s_`, e.g. `s_instance`. -* Functions are named in the Qt style, like Java's, without the 'get' prefix. - * A getter is `variable()`. - * If it's a getter for a boolean, prefix with 'is', so `isCondition()`. - * A setter is `setVariable( arg )`. - - -Includes --------- -Header includes should be listed in the following order: - -* own header, -* Calamares includes, -* includes for Qt-based libraries, -* Qt includes, -* other includes. - -They should also be sorted alphabetically for ease of locating them. - -Includes in a header file should be kept to the absolute minimum, as to keep -compile times short. This can be achieved by using forward declarations -instead of includes, like `class QListView;`. - -Example: -``` -#include "Settings.h" - -#include "CalamaresApplication.h" -#include "utils/CalamaresUtils.h" -#include "utils/Logger.h" -#include "YamlUtils.h" - -#include -#include - -#include -``` - -Use include guards, not `#pragma once`. - - -C++ tips --------- -All C++11 features are acceptable, and the use of new C++11 features is encouraged when -it makes the code easier to understand and more maintainable. - -The use of `nullptr` is preferred over the use of `0` or `NULL`. - -For Qt containers it is better to use Qt's own `foreach`. For all other containers, the -range-based `for` syntax introduced with C++11 is preferred ([see this blog post][1]). - -When re-implementing a virtual method, always add the `override` keyword. - -Try to keep your code const correct. Declare methods const if they don't mutate the -object, and use const variables. It improves safety, and also makes it easier to -understand the code. - -For the Qt signal-slot system, the new (Qt5) syntax is to be preferred because it allows -the compiler to check for the existence of signals and slots. As an added benefit, the -new syntax can also be used with `tr1::bind` and C++11 lambdas. For more information, see -the [Qt wiki][2]. - -Example: -``` -connect( m_next, &QPushButton::clicked, this, &ViewManager::next ); - -connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded, [this] -{ - m_mainwindow->show(); -}); -``` - -[1]: http://blog.qt.digia.com/blog/2011/05/26/cpp0x-in-qt/ -[2]: http://qt-project.org/wiki/New_Signal_Slot_Syntax - - -Debugging ---------- -Use `cDebug()` from `utils/Logger.h`. You can pass a debug-level to the -macro (6 is debugging, higher is less important). Use `cWarning()` for warning -messages (equivalent to level 2) and `cError()` for errors (level 1). Warnings -and errors will add relevant text automatically. See `libcalamares/utils/Logger.h` -for details. - -For log messages that are continued across multiple calls to `cDebug()`, -in particular listing things, conventional formatting is as follows: -* End the first debug message with ` ..` -* Start the next debug message by outputting `Logger::SubEntry` - -For single-outputs that need to be split across multiplt lines, -output `Logger::Continuation`. - - -Commit Messages ---------------- -Keep commit messages short(-ish) and try to describe what is being changed -*as well as why*. Use the commit keywords for GitHub, especially *FIXES:* -to auto-close issues when they are resolved. - -For functional changes to Calamares modules or libraries, try to put -*[modulename]* in front of the first line of the commit message. - -For non-functional changes to infrastructure, try to label the change -with the kind of change, e.g. *CMake* or *i18n* or *Documentation*. +This has moved [to the wiki](https://github.com/calamares/calamares/wiki/Develop-Code). diff --git a/ci/RELEASE.md b/ci/RELEASE.md index 3198ee95d..5293abf6b 100644 --- a/ci/RELEASE.md +++ b/ci/RELEASE.md @@ -1,17 +1,16 @@ -The Calamares release process -============================= +# Calamares Release Process -> As releases from *master* are now rolling when-they-are-ready releases, -> some of these steps no longer are followed. In particular, -RC releases -> are not done anymore (although the RC variable is set in `CMakeLists.txt` -> to avoid accidents) and most things are automated through the release -> script [RELEASE.sh](RELEASE.sh) +> Calamares releases are now rolling when-they-are-ready releases. +> Releases are made from *master* and tagged there. When, in future, +> LTS releases resume, these steps may be edited again. +> +> Most things are automated through the release script [RELEASE.sh](RELEASE.sh) -#### (0) A week in advance +## (0) A week in advance -* (Only releases from master) - Run [Coverity scan][coverity], fix what's relevant. The Coverity scan runs - automatically once a week on master. +* Run [Coverity scan][coverity], fix what's relevant. The Coverity scan runs + automatically once a week on master. The badge is displayed on the + project front page and in the wiki. * Build with clang -Weverything, fix what's relevant. ``` rm -rf build ; mkdir build ; cd build @@ -26,34 +25,69 @@ The Calamares release process an additional environment variable to be set for some tests, which will destroy an attached disk. This is not always desirable. There are some sample config-files that are empty and which fail the config-tests. -* (Only releases from master) - Notify [translators][transifex]. In the dashboard there is an *Announcements* - link that you can use to send a translation announcement. +* Notify [translators][transifex]. In the dashboard there is an *Announcements* + link that you can use to send a translation announcement. Note that regular + use of `txpush.sh` will notify translators as well of any changes. [coverity]: https://scan.coverity.com/projects/calamares-calamares?tab=overview [transifex]: https://www.transifex.com/calamares/calamares/dashboard/ -#### (1) Preparation -* Bump version in `CMakeLists.txt`, *CALAMARES_VERSION* variables, and set - RC to a non-zero value (e.g. doing -rc1, -rc2, ...). Push that. -* Check `README.md` and everything `ci/HACKING.md`, make sure it's all still - relevant. Run `ci/calamaresstyle` to check the C++ code style. - Run pycodestyle on recently-modified Python modules, fix what makes sense. -* Check defaults in `settings.conf` and other configuration files. -* (Only releases from master) - Pull latest translations from Transifex. We only push / pull translations +## (1) Preparation + +* Pull latest translations from Transifex. We only push / pull translations from master, so longer-lived branches (e.g. 3.1.x) don't get translation - updates. This is to keep the translation workflow simple. + updates. This is to keep the translation workflow simple. The script + automatically commits changes to the translations. ``` sh ci/txpull.sh ``` -* (Only releases from master) - Update the list of enabled translation languages in `CMakeLists.txt`. +* Update the list of enabled translation languages in `CMakeLists.txt`. Check the [translation site][transifex] for the list of languages with - fairly complete translations. + fairly complete translations, or use `ci/txstats.py` for an automated + suggestion. If there are changes, commit them. +* Push the changes. +* Drop the RC variable to 0 in `CMakeLists.txt`, *CALAMARES_VERSION_RC*. +* Check `README.md` and the + [Coding Guide](https://github.com/calamares/calamares/wiki/Develop-Code), + make sure it's all still + relevant. Run `ci/calamaresstyle` to check the C++ code style. + Run pycodestyle on recently-modified Python modules, fix what makes sense. +* Check defaults in `settings.conf` and other configuration files. +* Edit `CHANGES` and set the date of the release. +* Commit both. This is usually done with commit-message + *Changes: pre-release housekeeping*. -#### (2) Tarball + +## (2) Release Day + +* Run the helper script `ci/RELEASE.sh` or follow steps below. + The script checks: + - for uncommitted local changes, + - if translations are up-to-date and translators + have had enough time to chase new strings, + - that the build is successful (with gcc and clang, if available), + - tests pass, + - tarball can be created, + - tarball can be signed. + On success, it prints out a suitable signature- and SHA256 blurb + for use in the release announcement. + +### (2.1) Buld and Test + +* Build with gcc. If available, build again with Clang and double-check + any warnings Clang produces. +* Run the tests; `make test` in the build directory should have no + failures (or if there are, know why they are there). + +### (2.2) Tag + +* `git tag -s v1.1.0` Make sure the signing key is known in GitHub, so that the + tag is shown as a verified tag. Do not sign -rc tags. + You can use `make show-version` in the build directory to get the right + version number -- this will fail if you didn't follow step (1). + +### (2.3) Tarball * Create tarball: `git-archive-all -v calamares-1.1-rc1.tar.gz` or without the helper script, @@ -64,21 +98,25 @@ The Calamares release process Double check that the tarball matches the version number. * Test tarball (e.g. unpack somewhere else and run the tests from step 0). -#### (3) Tag -* Set RC to zero in `CMakeLists.txt` if this is the actual release. -* `git tag -s v1.1.0` Make sure the signing key is known in GitHub, so that the - tag is shown as a verified tag. Do not sign -rc tags. +## (3) Housekeeping + * Generate MD5 and SHA256 checksums. * Upload tarball. * Announce on mailing list, notify packagers. * Write release article. - -#### (4) Release day - * Publish tarball. * Update download page. * Publish release article on `calamares.io`. * Publicize on social networks. * Close associated milestone on GitHub if this is the actual release. * Publish blog post. + +## (4) Post-Release + +* Bump the version number in `CMakeLists.txt` in the `project()` command. +* Set *CALAMARES_VERSION_RC* back to 1. +* Add a placeholder entry for the next release in `CHANGES` with date + text *not released yet*. +* Commit and push that, usually with the message + *Changes: post-release housekeeping*. diff --git a/src/libcalamares/GlobalStorage.cpp b/src/libcalamares/GlobalStorage.cpp index 5094ad2fd..428b01103 100644 --- a/src/libcalamares/GlobalStorage.cpp +++ b/src/libcalamares/GlobalStorage.cpp @@ -27,17 +27,6 @@ #include #include -#ifdef WITH_PYTHON -#include "PythonHelper.h" - - -#undef slots -#include -#include - -namespace bp = boost::python; -#endif - using CalamaresUtils::operator""_MiB; namespace Calamares @@ -167,75 +156,3 @@ GlobalStorage::loadYaml( const QString& filename ) } // namespace Calamares - -#ifdef WITH_PYTHON - -namespace CalamaresPython -{ - -Calamares::GlobalStorage* GlobalStoragePythonWrapper::s_gs_instance = nullptr; - -// The special handling for nullptr is only for the testing -// script for the python bindings, which passes in None; -// normal use will have a GlobalStorage from JobQueue::instance() -// passed in. Testing use will leak the allocated GlobalStorage -// object, but that's OK for testing. -GlobalStoragePythonWrapper::GlobalStoragePythonWrapper( Calamares::GlobalStorage* gs ) - : m_gs( gs ? gs : s_gs_instance ) -{ - if ( !m_gs ) - { - s_gs_instance = new Calamares::GlobalStorage; - m_gs = s_gs_instance; - } -} - -bool -GlobalStoragePythonWrapper::contains( const std::string& key ) const -{ - return m_gs->contains( QString::fromStdString( key ) ); -} - - -int -GlobalStoragePythonWrapper::count() const -{ - return m_gs->count(); -} - - -void -GlobalStoragePythonWrapper::insert( const std::string& key, const bp::object& value ) -{ - m_gs->insert( QString::fromStdString( key ), CalamaresPython::variantFromPyObject( value ) ); -} - -bp::list -GlobalStoragePythonWrapper::keys() const -{ - bp::list pyList; - const auto keys = m_gs->keys(); - for ( const QString& key : keys ) - { - pyList.append( key.toStdString() ); - } - return pyList; -} - - -int -GlobalStoragePythonWrapper::remove( const std::string& key ) -{ - return m_gs->remove( QString::fromStdString( key ) ); -} - - -bp::object -GlobalStoragePythonWrapper::value( const std::string& key ) const -{ - return CalamaresPython::variantToPyObject( m_gs->value( QString::fromStdString( key ) ) ); -} - -} // namespace CalamaresPython - -#endif // WITH_PYTHON diff --git a/src/libcalamares/GlobalStorage.h b/src/libcalamares/GlobalStorage.h index b070e23f6..bef9ec1cc 100644 --- a/src/libcalamares/GlobalStorage.h +++ b/src/libcalamares/GlobalStorage.h @@ -26,20 +26,6 @@ #include #include -#ifdef WITH_PYTHON -namespace boost -{ -namespace python -{ -namespace api -{ -class object; -} -class list; -} // namespace python -} // namespace boost -#endif - namespace Calamares { @@ -106,33 +92,4 @@ private: } // namespace Calamares -#ifdef WITH_PYTHON -namespace CalamaresPython -{ - -class GlobalStoragePythonWrapper -{ -public: - explicit GlobalStoragePythonWrapper( Calamares::GlobalStorage* gs ); - - bool contains( const std::string& key ) const; - int count() const; - void insert( const std::string& key, const boost::python::api::object& value ); - boost::python::list keys() const; - int remove( const std::string& key ); - boost::python::api::object value( const std::string& key ) const; - - // This is a helper for scripts that do not go through - // the JobQueue (i.e. the module testpython script), - // which allocate their own (singleton) GlobalStorage. - static Calamares::GlobalStorage* globalStorageInstance() { return s_gs_instance; } - -private: - Calamares::GlobalStorage* m_gs; - static Calamares::GlobalStorage* s_gs_instance; // See globalStorageInstance() -}; - -} // namespace CalamaresPython -#endif - #endif // CALAMARES_GLOBALSTORAGE_H diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index 6772671b7..2690769db 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -19,15 +19,11 @@ #include "JobQueue.h" +#include "CalamaresConfig.h" #include "GlobalStorage.h" #include "Job.h" #include "utils/Logger.h" -#include "CalamaresConfig.h" -#ifdef WITH_PYTHON -#include "PythonHelper.h" -#endif - #include namespace Calamares diff --git a/src/libcalamares/PythonHelper.cpp b/src/libcalamares/PythonHelper.cpp index 26a57ec14..d9db8581e 100644 --- a/src/libcalamares/PythonHelper.cpp +++ b/src/libcalamares/PythonHelper.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, 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 @@ -19,20 +19,13 @@ #include "PythonHelper.h" +#include "GlobalStorage.h" #include "utils/Dirs.h" #include "utils/Logger.h" #include #include -#undef slots -#include "utils/boost-warnings.h" -#include - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - namespace bp = boost::python; namespace CalamaresPython @@ -398,5 +391,67 @@ Helper::handleLastError() return QString( "
%1
" ).arg( msgList.join( "
" ) ); } +Calamares::GlobalStorage* GlobalStoragePythonWrapper::s_gs_instance = nullptr; + +// The special handling for nullptr is only for the testing +// script for the python bindings, which passes in None; +// normal use will have a GlobalStorage from JobQueue::instance() +// passed in. Testing use will leak the allocated GlobalStorage +// object, but that's OK for testing. +GlobalStoragePythonWrapper::GlobalStoragePythonWrapper( Calamares::GlobalStorage* gs ) + : m_gs( gs ? gs : s_gs_instance ) +{ + if ( !m_gs ) + { + s_gs_instance = new Calamares::GlobalStorage; + m_gs = s_gs_instance; + } +} + +bool +GlobalStoragePythonWrapper::contains( const std::string& key ) const +{ + return m_gs->contains( QString::fromStdString( key ) ); +} + + +int +GlobalStoragePythonWrapper::count() const +{ + return m_gs->count(); +} + + +void +GlobalStoragePythonWrapper::insert( const std::string& key, const bp::object& value ) +{ + m_gs->insert( QString::fromStdString( key ), CalamaresPython::variantFromPyObject( value ) ); +} + +bp::list +GlobalStoragePythonWrapper::keys() const +{ + bp::list pyList; + const auto keys = m_gs->keys(); + for ( const QString& key : keys ) + { + pyList.append( key.toStdString() ); + } + return pyList; +} + + +int +GlobalStoragePythonWrapper::remove( const std::string& key ) +{ + return m_gs->remove( QString::fromStdString( key ) ); +} + + +bp::object +GlobalStoragePythonWrapper::value( const std::string& key ) const +{ + return CalamaresPython::variantToPyObject( m_gs->value( QString::fromStdString( key ) ) ); +} } // namespace CalamaresPython diff --git a/src/libcalamares/PythonHelper.h b/src/libcalamares/PythonHelper.h index 9035ba6d4..418c75e5f 100644 --- a/src/libcalamares/PythonHelper.h +++ b/src/libcalamares/PythonHelper.h @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac - * Copyright 2018, Adriaan de Groot + * Copyright 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 @@ -21,19 +21,14 @@ #define CALAMARES_PYTHONJOBHELPER_H #include "PythonJob.h" +#include "utils/BoostPython.h" #include -#undef slots -#include "utils/boost-warnings.h" - -#include -#include -#include - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif +namespace Calamares +{ +class GlobalStorage; +} namespace CalamaresPython { @@ -72,6 +67,28 @@ private: QStringList m_pythonPaths; }; +class GlobalStoragePythonWrapper +{ +public: + explicit GlobalStoragePythonWrapper( Calamares::GlobalStorage* gs ); + + bool contains( const std::string& key ) const; + int count() const; + void insert( const std::string& key, const boost::python::api::object& value ); + boost::python::list keys() const; + int remove( const std::string& key ); + boost::python::api::object value( const std::string& key ) const; + + // This is a helper for scripts that do not go through + // the JobQueue (i.e. the module testpython script), + // which allocate their own (singleton) GlobalStorage. + static Calamares::GlobalStorage* globalStorageInstance() { return s_gs_instance; } + +private: + Calamares::GlobalStorage* m_gs; + static Calamares::GlobalStorage* s_gs_instance; // See globalStorageInstance() +}; + } // namespace CalamaresPython #endif // CALAMARES_PYTHONJOBHELPER_H diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index c18371881..d94a20981 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2016, Teo Mrnjavac - * Copyright 2018, Adriaan de Groot + * Copyright 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 @@ -19,20 +19,16 @@ #include "PythonJob.h" +#include "CalamaresVersion.h" #include "GlobalStorage.h" #include "JobQueue.h" #include "PythonHelper.h" +#include "PythonJobApi.h" +#include "utils/BoostPython.h" #include "utils/Logger.h" #include -#undef slots -#include -#include - -#include "PythonJobApi.h" - - namespace bp = boost::python; BOOST_PYTHON_FUNCTION_OVERLOADS( mount_overloads, CalamaresPython::mount, 2, 4 ); @@ -180,7 +176,7 @@ PythonJob::PythonJob( const ModuleSystem::InstanceKey& instance, , m_workingPath( workingPath ) , m_description() , m_configurationMap( moduleConfiguration ) - , m_weight( (instance.module() == QStringLiteral( "unpackfs" )) ? 12.0 : 1.0 ) + , m_weight( ( instance.module() == QStringLiteral( "unpackfs" ) ) ? 12.0 : 1.0 ) { } diff --git a/src/libcalamares/PythonJob.h b/src/libcalamares/PythonJob.h index c63daacdc..7cd1b7165 100644 --- a/src/libcalamares/PythonJob.h +++ b/src/libcalamares/PythonJob.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * 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 @@ -23,7 +24,7 @@ #include "modulesystem/InstanceKey.h" -#include +#include namespace CalamaresPython { diff --git a/src/libcalamares/PythonJobApi.cpp b/src/libcalamares/PythonJobApi.cpp index 7b65e979c..132a9dcf5 100644 --- a/src/libcalamares/PythonJobApi.cpp +++ b/src/libcalamares/PythonJobApi.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2016, Teo Mrnjavac - * Copyright 2017-2019, Adriaan de Groot + * Copyright 2017-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,26 +19,17 @@ #include "PythonJobApi.h" +#include "GlobalStorage.h" +#include "JobQueue.h" #include "PythonHelper.h" #include "utils/CalamaresUtilsSystem.h" #include "utils/Logger.h" #include "utils/String.h" -#include "GlobalStorage.h" -#include "JobQueue.h" - #include #include #include -#undef slots -#include "utils/boost-warnings.h" -#include - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - namespace bp = boost::python; static int diff --git a/src/libcalamares/PythonJobApi.h b/src/libcalamares/PythonJobApi.h index 3d3783f5f..6fb27cd62 100644 --- a/src/libcalamares/PythonJobApi.h +++ b/src/libcalamares/PythonJobApi.h @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2016, 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 @@ -20,12 +20,14 @@ #ifndef PYTHONJOBAPI_H #define PYTHONJOBAPI_H -#include "CalamaresVersion.h" +#include "qglobal.h" // For qreal -#include "PythonJob.h" +#include "utils/BoostPython.h" -#undef slots -#include +namespace Calamares +{ +class PythonJob; +} namespace CalamaresPython { diff --git a/src/libcalamares/utils/BoostPython.h b/src/libcalamares/utils/BoostPython.h new file mode 100644 index 000000000..7bd8865da --- /dev/null +++ b/src/libcalamares/utils/BoostPython.h @@ -0,0 +1,73 @@ +/* === 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 . + */ + +/* + * The Python and Boost::Python headers are not C++14 warning-proof, especially + * with picky compilers like Clang 8 and 9. Since we use Clang for the + * find-all-the-warnings case, switch those warnings off for + * the we-can't-change-them system headers. + * + * This convenience header handles including all the bits we need for + * Python support, while silencing warnings. + */ +#ifndef UTILS_BOOSTPYTHON_H +#define UTILS_BOOSTPYTHON_H + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreserved-id-macro" +#pragma clang diagnostic ignored "-Wold-style-cast" +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +#pragma clang diagnostic ignored "-Wextra-semi-stmt" +#pragma clang diagnostic ignored "-Wall" +#pragma clang diagnostic ignored "-Wimplicit-float-conversion" +#pragma clang diagnostic ignored "-Wundef" +#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" +#pragma clang diagnostic ignored "-Wshadow-field-in-constructor" +#pragma clang diagnostic ignored "-Wshadow" +#pragma clang diagnostic ignored "-Wmissing-noreturn" +#pragma clang diagnostic ignored "-Wcast-qual" +#pragma clang diagnostic ignored "-Wcast-align" +#pragma clang diagnostic ignored "-Wsign-conversion" +#pragma clang diagnostic ignored "-Wdouble-promotion" +#pragma clang diagnostic ignored "-Wredundant-parens" +#pragma clang diagnostic ignored "-Wweak-vtables" +#pragma clang diagnostic ignored "-Wdeprecated" +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wdisabled-macro-expansion" +#pragma clang diagnostic ignored "-Wdocumentation" +#pragma clang diagnostic ignored "-Wcomma" +#pragma clang diagnostic ignored "-Wunused-parameter" +#pragma clang diagnostic ignored "-Wunused-template" + +// Actually for Python headers +#pragma clang diagnostic ignored "-Wreserved-id-macro" +#endif + +#undef slots +#include +#include +#include +#include +#include + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif diff --git a/src/libcalamares/utils/Entropy.cpp b/src/libcalamares/utils/Entropy.cpp index 643346855..ce1f6ba9d 100644 --- a/src/libcalamares/utils/Entropy.cpp +++ b/src/libcalamares/utils/Entropy.cpp @@ -35,7 +35,7 @@ CalamaresUtils::getEntropy( int size, QByteArray& b ) char* buffer = b.data(); std::fill( buffer, buffer + size, 0xcb ); - int readSize = 0; + qint64 readSize = 0; QFile urandom( "/dev/urandom" ); if ( urandom.exists() && urandom.open( QIODevice::ReadOnly ) ) { @@ -62,7 +62,7 @@ CalamaresUtils::getEntropy( int size, QByteArray& b ) #define GET_ONE_BYTE \ if ( readSize < size ) \ { \ - buffer[ readSize++ ] = next & 0xff; \ + buffer[ readSize++ ] = char( next & 0xffU ); \ next = next >> 8; \ } GET_ONE_BYTE diff --git a/src/libcalamares/utils/TestPaths.cpp b/src/libcalamares/utils/TestPaths.cpp index 2f9f4e657..da67f9dd2 100644 --- a/src/libcalamares/utils/TestPaths.cpp +++ b/src/libcalamares/utils/TestPaths.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2018, Adriaan de Groot + * Copyright 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 @@ -38,8 +38,8 @@ class TestPaths : public QObject { Q_OBJECT public: - TestPaths() {}; - virtual ~TestPaths() {}; + TestPaths() {} + virtual ~TestPaths() {} private Q_SLOTS: void initTestCase(); diff --git a/src/libcalamares/utils/Tests.cpp b/src/libcalamares/utils/Tests.cpp index e39d182ea..34701a940 100644 --- a/src/libcalamares/utils/Tests.cpp +++ b/src/libcalamares/utils/Tests.cpp @@ -224,3 +224,30 @@ LibCalamaresTests::testPrintableEntropy() QVERIFY( c.cell() < 127 ); } } + +void +LibCalamaresTests::testOddSizedPrintable() +{ + QString s; + for ( int l = 0; l <= 37; ++l ) + { + auto r = CalamaresUtils::getPrintableEntropy( l, s ); + if ( l == 0 ) + { + QCOMPARE( r, CalamaresUtils::EntropySource::None ); + } + else + { + QVERIFY( r != CalamaresUtils::EntropySource::None ); + } + QCOMPARE( s.length(), l ); + + for ( QChar c : s ) + { + QVERIFY( c.isPrint() ); + QCOMPARE( c.row(), 0 ); + QVERIFY( c.cell() > 32 ); // ASCII SPACE + QVERIFY( c.cell() < 127 ); + } + } +} diff --git a/src/libcalamares/utils/Tests.h b/src/libcalamares/utils/Tests.h index d369ed4cb..f9908c74c 100644 --- a/src/libcalamares/utils/Tests.h +++ b/src/libcalamares/utils/Tests.h @@ -43,6 +43,7 @@ private Q_SLOTS: /** @brief Tests the entropy functions. */ void testEntropy(); void testPrintableEntropy(); + void testOddSizedPrintable(); }; #endif diff --git a/src/libcalamares/utils/boost-warnings.h b/src/libcalamares/utils/boost-warnings.h deleted file mode 100644 index 65a66b0f6..000000000 --- a/src/libcalamares/utils/boost-warnings.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreserved-id-macro" -#pragma clang diagnostic ignored "-Wold-style-cast" -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" -#pragma clang diagnostic ignored "-Wextra-semi-stmt" -#pragma clang diagnostic ignored "-Wall" -#endif diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index 061a401bb..c603ca22d 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -16,6 +16,7 @@ set( calamaresui_SOURCES utils/CalamaresUtilsGui.cpp utils/ImageRegistry.cpp utils/Paste.cpp + utils/Qml.cpp viewpages/BlankViewStep.cpp viewpages/ExecutionViewStep.cpp diff --git a/src/libcalamaresui/utils/Qml.cpp b/src/libcalamaresui/utils/Qml.cpp new file mode 100644 index 000000000..1ea72e674 --- /dev/null +++ b/src/libcalamaresui/utils/Qml.cpp @@ -0,0 +1,52 @@ +/* === 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 . + */ + +#include "Qml.h" + +#include "utils/Logger.h" + +#include +#include +#include +#include + +namespace CalamaresUtils +{ + +void +callQMLFunction( QQuickItem* qmlObject, const char* method ) +{ + QByteArray methodSignature( method ); + methodSignature.append( "()" ); + + if ( qmlObject && qmlObject->metaObject()->indexOfMethod( methodSignature ) >= 0 ) + { + QVariant returnValue; + QMetaObject::invokeMethod( qmlObject, method, Q_RETURN_ARG( QVariant, returnValue ) ); + if ( !returnValue.isNull() ) + { + cDebug() << "QML" << methodSignature << "returned" << returnValue; + } + } + else if ( qmlObject ) + { + cDebug() << "QML" << methodSignature << "is missing."; + } +} + +} // namespace CalamaresUtils diff --git a/src/libcalamaresui/utils/Qml.h b/src/libcalamaresui/utils/Qml.h new file mode 100644 index 000000000..70f59e7ec --- /dev/null +++ b/src/libcalamaresui/utils/Qml.h @@ -0,0 +1,42 @@ +/* === 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_QML_H +#define UTILS_QML_H + +#include "DllMacro.h" + +class QQuickItem; + +namespace CalamaresUtils +{ + +/** @brief Calls the QML method @p method on @p qmlObject + * + * Pass in only the name of the method (e.g. onActivate). This function + * checks if the method exists (with no arguments) before trying to + * call it, so that no warnings are printed due to missing methods. + * + * If there is a return value from the QML method, it is logged (but not otherwise used). + */ +DLLEXPORT void +callQMLFunction( QQuickItem* qmlObject, const char* method ); + +} // namespace CalamaresUtils + +#endif diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp index e0921910d..8ea918690 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp @@ -31,6 +31,7 @@ #include "utils/CalamaresUtilsGui.h" #include "utils/Dirs.h" #include "utils/Logger.h" +#include "utils/Qml.h" #include "utils/Retranslator.h" #include @@ -42,35 +43,6 @@ #include #include -/** @brief Calls the QML method @p method() - * - * Pass in only the name of the method (e.g. onActivate). This function - * checks if the method exists (with no arguments) before trying to - * call it, so that no warnings are printed due to missing methods. - * - * If there is a return value from the QML method, it is logged (but not otherwise used). - */ -static void -callQMLFunction( QQuickItem* qmlObject, const char* method ) -{ - QByteArray methodSignature( method ); - methodSignature.append( "()" ); - - if ( qmlObject && qmlObject->metaObject()->indexOfMethod( methodSignature ) >= 0 ) - { - QVariant returnValue; - QMetaObject::invokeMethod( qmlObject, method, Q_RETURN_ARG( QVariant, returnValue ) ); - if ( !returnValue.isNull() ) - { - cDebug() << "QML" << methodSignature << "returned" << returnValue; - } - } - else if ( qmlObject ) - { - cDebug() << "QML" << methodSignature << "is missing."; - } -} - namespace Calamares { @@ -205,7 +177,7 @@ changeSlideShowState( Slideshow state, QQuickItem* slideshow, QQuickWidget* widg if ( Branding::instance()->slideshowAPI() == 2 ) { // The QML was already loaded in the constructor, need to start it - callQMLFunction( slideshow, activate ? "onActivate" : "onLeave" ); + CalamaresUtils::callQMLFunction( slideshow, activate ? "onActivate" : "onLeave" ); } else if ( !Calamares::Branding::instance()->slideshowPath().isEmpty() ) { diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index b009d1626..2bfc72757 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -19,10 +19,12 @@ #include "QmlViewStep.h" #include "Branding.h" +#include "ViewManager.h" #include "utils/Dirs.h" #include "utils/Logger.h" #include "utils/NamedEnum.h" +#include "utils/Qml.h" #include "utils/Variant.h" #include "widgets/WaitingWidget.h" @@ -50,6 +52,36 @@ searchNames() return names; } +/// @brief State-change of the QML, for changeQMLState() +enum class QMLAction +{ + Start, + Stop +}; + +/** @brief Tells the QML we activated or left it. + * + * If @p action is @c QMLAction::Start, calls onActivate in the QML. + * If @p action is @c QMLAction::Stop, calls onLeave in the QML. + * + * Sets *activatedInCalamares* property on the QML as well (to true + * if @p action is @c QMLAction::Start, false otherwise). + */ +static void +changeQMLState( QMLAction action, QQuickItem* item ) +{ + static const char propertyName[] = "activatedInCalamares"; + + bool activate = action == QMLAction::Start; + CalamaresUtils::callQMLFunction( item, activate ? "onActivate" : "onLeave" ); + + auto property = item->property( propertyName ); + if ( property.isValid() && ( property.type() == QVariant::Bool ) && ( property.toBool() != activate ) ) + { + item->setProperty( propertyName, activate ); + } +} + namespace Calamares { @@ -80,57 +112,61 @@ QmlViewStep::prettyName() const } -} // namespace Calamares - bool -Calamares::QmlViewStep::isAtBeginning() const +QmlViewStep::isAtBeginning() const { return true; } bool -Calamares::QmlViewStep::isAtEnd() const +QmlViewStep::isAtEnd() const { return true; } bool -Calamares::QmlViewStep::isBackEnabled() const +QmlViewStep::isBackEnabled() const { return true; } bool -Calamares::QmlViewStep::isNextEnabled() const +QmlViewStep::isNextEnabled() const { return true; } Calamares::JobList -Calamares::QmlViewStep::jobs() const +QmlViewStep::jobs() const { return JobList(); } void -Calamares::QmlViewStep::onActivate() +QmlViewStep::onActivate() { - // TODO: call into QML + if ( m_qmlObject ) + { + changeQMLState( QMLAction::Start, m_qmlObject ); + } } void -Calamares::QmlViewStep::onLeave() +QmlViewStep::onLeave() { - // TODO: call into QML + if ( m_qmlObject ) + { + changeQMLState( QMLAction::Stop, m_qmlObject ); + } } QWidget* -Calamares::QmlViewStep::widget() +QmlViewStep::widget() { return m_widget; } void -Calamares::QmlViewStep::loadComplete() +QmlViewStep::loadComplete() { cDebug() << "QML component" << m_qmlFileName << m_qmlComponent->status(); if ( m_qmlComponent->status() == QQmlComponent::Error ) @@ -163,7 +199,7 @@ Calamares::QmlViewStep::loadComplete() } void -Calamares::QmlViewStep::showQml() +QmlViewStep::showQml() { if ( !m_qmlWidget || !m_qmlObject ) { @@ -181,6 +217,13 @@ Calamares::QmlViewStep::showQml() { cDebug() << "showQml() called twice"; } + + if ( ViewManager::instance()->currentStep() == this ) + { + // We're alreay visible! Must have been slow QML loading, and we + // passed onActivate already. + changeQMLState( QMLAction::Start, m_qmlObject ); + } } @@ -190,7 +233,7 @@ Calamares::QmlViewStep::showQml() * is badly configured). */ QString -searchQmlFile( Calamares::QmlViewStep::QmlSearch method, const QString& configuredName, const QString& moduleName ) +searchQmlFile( QmlViewStep::QmlSearch method, const QString& configuredName, const QString& moduleName ) { using QmlSearch = Calamares::QmlViewStep::QmlSearch; @@ -235,7 +278,7 @@ searchQmlFile( Calamares::QmlViewStep::QmlSearch method, const QString& configur } void -Calamares::QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { bool ok = false; m_searchMethod = searchNames().find( CalamaresUtils::getString( configurationMap, "search" ), ok ); @@ -270,8 +313,10 @@ Calamares::QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap } void -Calamares::QmlViewStep::showFailedQml() +QmlViewStep::showFailedQml() { cWarning() << "QmlViewStep" << moduleInstanceKey() << "loading failed."; m_spinner->setText( prettyName() + ' ' + tr( "Loading failed." ) ); } + +} // namespace Calamares diff --git a/src/modules/hostinfo/HostInfoJob.cpp b/src/modules/hostinfo/HostInfoJob.cpp index 3e0e4258c..c2959fb6b 100644 --- a/src/modules/hostinfo/HostInfoJob.cpp +++ b/src/modules/hostinfo/HostInfoJob.cpp @@ -156,7 +156,8 @@ HostInfoJob::exec() gs->insert( "hostOSName", hostOSName() ); gs->insert( "hostCPU", hostCPU() ); - auto ram = CalamaresUtils::BytesToMiB( CalamaresUtils::System::instance()->getTotalMemoryB().first ); + // Memory can't be negative, so it's reported as unsigned long. + auto ram = CalamaresUtils::BytesToMiB( qint64( CalamaresUtils::System::instance()->getTotalMemoryB().first ) ); if ( ram ) { gs->insert( "hostRAMMiB", ram ); diff --git a/src/modules/dummyqml/CMakeLists.txt b/src/modules/notesqml/CMakeLists.txt similarity index 64% rename from src/modules/dummyqml/CMakeLists.txt rename to src/modules/notesqml/CMakeLists.txt index 9a7532e9e..6aedab5aa 100644 --- a/src/modules/dummyqml/CMakeLists.txt +++ b/src/modules/notesqml/CMakeLists.txt @@ -1,10 +1,10 @@ -calamares_add_plugin( dummyqml +calamares_add_plugin( notesqml TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES - DummyQmlViewStep.cpp + NotesQmlViewStep.cpp RESOURCES - dummyqml.qrc + notesqml.qrc LINK_PRIVATE_LIBRARIES calamaresui SHARED_LIB diff --git a/src/modules/dummyqml/DummyQmlViewStep.cpp b/src/modules/notesqml/NotesQmlViewStep.cpp similarity index 78% rename from src/modules/dummyqml/DummyQmlViewStep.cpp rename to src/modules/notesqml/NotesQmlViewStep.cpp index 030779f7f..e729c2df7 100644 --- a/src/modules/dummyqml/DummyQmlViewStep.cpp +++ b/src/modules/notesqml/NotesQmlViewStep.cpp @@ -17,36 +17,36 @@ * along with Calamares. If not, see . */ -#include "DummyQmlViewStep.h" +#include "NotesQmlViewStep.h" #include -DummyQmlViewStep::DummyQmlViewStep( QObject* parent ) - : Calamares::QmlViewStep( "dummyqml", parent ) +NotesQmlViewStep::NotesQmlViewStep( QObject* parent ) + : Calamares::QmlViewStep( "notesqml", parent ) { } -DummyQmlViewStep::~DummyQmlViewStep() {} +NotesQmlViewStep::~NotesQmlViewStep() {} QString -DummyQmlViewStep::prettyName() const +NotesQmlViewStep::prettyName() const { return m_notesName ? m_notesName->get() : tr( "Notes" ); } void -DummyQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +NotesQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation bool qmlLabel_ok = false; auto qmlLabel = CalamaresUtils::getSubMap( configurationMap, "qmlLabel", qmlLabel_ok ); - + if ( qmlLabel.contains( "notes" ) ) { m_notesName = new CalamaresUtils::Locale::TranslatedString( qmlLabel, "notes" ); } - + } -CALAMARES_PLUGIN_FACTORY_DEFINITION( DummyQmlViewStepFactory, registerPlugin< DummyQmlViewStep >(); ) +CALAMARES_PLUGIN_FACTORY_DEFINITION( NotesQmlViewStepFactory, registerPlugin< NotesQmlViewStep >(); ) diff --git a/src/modules/dummyqml/DummyQmlViewStep.h b/src/modules/notesqml/NotesQmlViewStep.h similarity index 82% rename from src/modules/dummyqml/DummyQmlViewStep.h rename to src/modules/notesqml/NotesQmlViewStep.h index cf49436b0..445b34c81 100644 --- a/src/modules/dummyqml/DummyQmlViewStep.h +++ b/src/modules/notesqml/NotesQmlViewStep.h @@ -17,8 +17,8 @@ * along with Calamares. If not, see . */ -#ifndef DUMMYQMLVIEWSTEP_H -#define DUMMYQMLVIEWSTEP_H +#ifndef NOTESQMLVIEWSTEP_H +#define NOTESQMLVIEWSTEP_H #include "PluginDllMacro.h" #include "locale/TranslatableConfiguration.h" @@ -27,13 +27,13 @@ #include "utils/PluginFactory.h" #include "viewpages/QmlViewStep.h" -class PLUGINDLLEXPORT DummyQmlViewStep : public Calamares::QmlViewStep +class PLUGINDLLEXPORT NotesQmlViewStep : public Calamares::QmlViewStep { Q_OBJECT public: - DummyQmlViewStep( QObject* parent = nullptr ); - virtual ~DummyQmlViewStep() override; + NotesQmlViewStep( QObject* parent = nullptr ); + virtual ~NotesQmlViewStep() override; QString prettyName() const override; @@ -43,6 +43,6 @@ private: CalamaresUtils::Locale::TranslatedString* m_notesName; // As it appears in the sidebar }; -CALAMARES_PLUGIN_FACTORY_DECLARATION( DummyQmlViewStepFactory ) +CALAMARES_PLUGIN_FACTORY_DECLARATION( NotesQmlViewStepFactory ) #endif diff --git a/src/modules/dummyqml/dummyqml.qml b/src/modules/notesqml/examples/dummyqml.qml similarity index 100% rename from src/modules/dummyqml/dummyqml.qml rename to src/modules/notesqml/examples/dummyqml.qml diff --git a/src/modules/dummyqml/dummyqml.conf b/src/modules/notesqml/notesqml.conf similarity index 53% rename from src/modules/dummyqml/dummyqml.conf rename to src/modules/notesqml/notesqml.conf index 9e7a83fdd..1afd9e682 100644 --- a/src/modules/dummyqml/dummyqml.conf +++ b/src/modules/notesqml/notesqml.conf @@ -1,6 +1,14 @@ -# The dummy QML module just displays a QML page. It doesn't -# have much in the way of own configuration, only where -# the QML file is searched. +# The *notesqml* module can be used to display a QML file +# as an installer step. This is most useful for release-notes +# and similar somewhat-static content, but if you want to you +# can put SameGame in there as well. +# +# While the module compiles a QML file into a QRC for inclusion +# into the shared library, normal use will configure it with +# an external file, either from Calamares AppData directory or +# from the branding directory. +# +# --- # # QML modules can search for the QML inside the Qt resources # (QRC) which are compiled into the module, or in the branding @@ -13,7 +21,7 @@ # QML file for it. # # To support instanced QML modules, searches in the branding -# directory look for the full module@instanceid name as well. +# directory look for the full notesqml@instanceid name as well. --- # Search mode. Valid values are "both", "qrc" and "branding" search: both @@ -21,9 +29,12 @@ search: both # Name of the QML file. If not set, uses the name of the instance # of the module (e.g. if you list this module in `settings.conf` # in the *instances* section, you get *id*, otherwise it would -# normally be "dummyqml"). -# filename: dummyqml +# normally be "notesqml"). +#filename: notesqml +# This is the name of the module in the progress-tree / sidebar +# in Calamares. To support multiple instances of the QML module, +# the name is configurable and translatable here. qmlLabel: notes: "Release Notes" notes[nl]: "Opmerkingen" diff --git a/src/modules/notesqml/notesqml.qml b/src/modules/notesqml/notesqml.qml new file mode 100644 index 000000000..d1ff4f1b5 --- /dev/null +++ b/src/modules/notesqml/notesqml.qml @@ -0,0 +1,75 @@ +/* === 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 QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Window 2.2 +import QtQuick.Layouts 1.3 +import QtQuick.Controls.Material 2.1 + +Item { + width: 740 + height: 420 + + Flickable { + id: flick + anchors.fill: parent + contentHeight: 800 + + ScrollBar.vertical: ScrollBar { + id: fscrollbar + width: 10 + policy: ScrollBar.AlwaysOn + } + + TextArea { + id: intro + x: 1 + y: 0 + width: parent.width - fscrollbar.width + font.pointSize: 14 + textFormat: Text.RichText + antialiasing: true + activeFocusOnPress: false + wrapMode: Text.WordWrap + + text: qsTr("

Generic GNU/Linux 2020.2 LTS Turgid Tuba

+

This an example QML file, showing options in RichText with Flickable content.

+ +

QML with RichText can use HTML tags, Flickable content is useful for touchscreens.

+ +

This is bold text

+

This is italic text

+

This is underlined text

+

This text will be center-aligned.

+

This is strikethrough

+ +

Code example: + ls -l /home

+ +

Lists:

+
    +
  • Intel CPU systems
  • +
  • AMD CPU systems
  • +
+ +

The vertical scrollbar is adjustable, current width set to 10.

") + + } + } +} diff --git a/src/modules/dummyqml/dummyqml.qrc b/src/modules/notesqml/notesqml.qrc similarity index 57% rename from src/modules/dummyqml/dummyqml.qrc rename to src/modules/notesqml/notesqml.qrc index 85b1da5ca..a4aa1909f 100644 --- a/src/modules/dummyqml/dummyqml.qrc +++ b/src/modules/notesqml/notesqml.qrc @@ -1,5 +1,5 @@ - dummyqml.qml + notesqml.qml