[merge] with upstream

This commit is contained in:
Philip Müller 2020-02-12 15:53:13 +01:00
commit f0ab3a46de
32 changed files with 572 additions and 513 deletions

10
CHANGES
View File

@ -6,7 +6,7 @@ website will have to do for older versions.
# 3.2.19 (unreleased) # # 3.2.19 (unreleased) #
This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name):
- No other contributors this time around. - Anke Boersma
## Core ## ## Core ##
- *Assamese* translation has been completed. - *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 translations without requiring a recompile: helpful for translators
and possibly for distributions with their own translation style. and possibly for distributions with their own translation style.
See the translators and deployers wiki for details. 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 ## ## Modules ##
- The *machineid* and *users* modules now prefer high-quality random - The *machineid* and *users* modules now prefer high-quality random
data from `/dev/urandom` rather than pseudo-random data. #1254 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) # # 3.2.18 (2020-01-28) #

View File

@ -2,12 +2,11 @@
--------- ---------
[![GitHub release](https://img.shields.io/github/release/calamares/calamares.svg)](https://github.com/calamares/calamares/releases) [![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) [![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) [![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) [![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 ### Dependencies

View File

@ -1,211 +1 @@
Hacking on Calamares This has moved [to the wiki](https://github.com/calamares/calamares/wiki/Develop-Code).
====================
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 - <https://github.com/calamares> ===
*
* Copyright 2013-2014, Random Person <name@example.com>
* Copyright 2010, Someone Else <someone@example.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
```
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 <files>
```
`
**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 <QDir>
#include <QFile>
#include <yaml-cpp/yaml.h>
```
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*.

View File

@ -1,17 +1,16 @@
The Calamares release process # Calamares Release Process
=============================
> As releases from *master* are now rolling when-they-are-ready releases, > Calamares releases are now rolling when-they-are-ready releases.
> some of these steps no longer are followed. In particular, -RC releases > Releases are made from *master* and tagged there. When, in future,
> are not done anymore (although the RC variable is set in `CMakeLists.txt` > LTS releases resume, these steps may be edited again.
> to avoid accidents) and most things are automated through the release >
> script [RELEASE.sh](RELEASE.sh) > 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
Run [Coverity scan][coverity], fix what's relevant. The Coverity scan runs automatically once a week on master. The badge is displayed on the
automatically once a week on master. project front page and in the wiki.
* Build with clang -Weverything, fix what's relevant. * Build with clang -Weverything, fix what's relevant.
``` ```
rm -rf build ; mkdir build ; cd build 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 an additional environment variable to be set for some tests, which will
destroy an attached disk. This is not always desirable. There are some destroy an attached disk. This is not always desirable. There are some
sample config-files that are empty and which fail the config-tests. 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*
Notify [translators][transifex]. In the dashboard there is an *Announcements* link that you can use to send a translation announcement. Note that regular
link that you can use to send a translation announcement. use of `txpush.sh` will notify translators as well of any changes.
[coverity]: https://scan.coverity.com/projects/calamares-calamares?tab=overview [coverity]: https://scan.coverity.com/projects/calamares-calamares?tab=overview
[transifex]: https://www.transifex.com/calamares/calamares/dashboard/ [transifex]: https://www.transifex.com/calamares/calamares/dashboard/
#### (1) Preparation
* Bump version in `CMakeLists.txt`, *CALAMARES_VERSION* variables, and set ## (1) Preparation
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 * Pull latest translations from Transifex. We only push / pull translations
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
from master, so longer-lived branches (e.g. 3.1.x) don't get translation 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 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 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 * Create tarball: `git-archive-all -v calamares-1.1-rc1.tar.gz` or without
the helper script, the helper script,
@ -64,21 +98,25 @@ The Calamares release process
Double check that the tarball matches the version number. Double check that the tarball matches the version number.
* Test tarball (e.g. unpack somewhere else and run the tests from step 0). * 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. ## (3) Housekeeping
* `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.
* Generate MD5 and SHA256 checksums. * Generate MD5 and SHA256 checksums.
* Upload tarball. * Upload tarball.
* Announce on mailing list, notify packagers. * Announce on mailing list, notify packagers.
* Write release article. * Write release article.
#### (4) Release day
* Publish tarball. * Publish tarball.
* Update download page. * Update download page.
* Publish release article on `calamares.io`. * Publish release article on `calamares.io`.
* Publicize on social networks. * Publicize on social networks.
* Close associated milestone on GitHub if this is the actual release. * Close associated milestone on GitHub if this is the actual release.
* Publish blog post. * 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*.

View File

@ -27,17 +27,6 @@
#include <QFile> #include <QFile>
#include <QJsonDocument> #include <QJsonDocument>
#ifdef WITH_PYTHON
#include "PythonHelper.h"
#undef slots
#include <boost/python/list.hpp>
#include <boost/python/str.hpp>
namespace bp = boost::python;
#endif
using CalamaresUtils::operator""_MiB; using CalamaresUtils::operator""_MiB;
namespace Calamares namespace Calamares
@ -167,75 +156,3 @@ GlobalStorage::loadYaml( const QString& filename )
} // namespace Calamares } // 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

View File

@ -26,20 +26,6 @@
#include <QString> #include <QString>
#include <QVariantMap> #include <QVariantMap>
#ifdef WITH_PYTHON
namespace boost
{
namespace python
{
namespace api
{
class object;
}
class list;
} // namespace python
} // namespace boost
#endif
namespace Calamares namespace Calamares
{ {
@ -106,33 +92,4 @@ private:
} // namespace Calamares } // 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 #endif // CALAMARES_GLOBALSTORAGE_H

View File

@ -19,15 +19,11 @@
#include "JobQueue.h" #include "JobQueue.h"
#include "CalamaresConfig.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "Job.h" #include "Job.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "CalamaresConfig.h"
#ifdef WITH_PYTHON
#include "PythonHelper.h"
#endif
#include <QThread> #include <QThread>
namespace Calamares namespace Calamares

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014, Teo Mrnjavac <teo@kde.org> * Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, 2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,20 +19,13 @@
#include "PythonHelper.h" #include "PythonHelper.h"
#include "GlobalStorage.h"
#include "utils/Dirs.h" #include "utils/Dirs.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#undef slots
#include "utils/boost-warnings.h"
#include <boost/python.hpp>
#ifdef __clang__
#pragma clang diagnostic pop
#endif
namespace bp = boost::python; namespace bp = boost::python;
namespace CalamaresPython namespace CalamaresPython
@ -398,5 +391,67 @@ Helper::handleLastError()
return QString( "<div>%1</div>" ).arg( msgList.join( "</div><div>" ) ); return QString( "<div>%1</div>" ).arg( msgList.join( "</div><div>" ) );
} }
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 } // namespace CalamaresPython

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014, Teo Mrnjavac <teo@kde.org> * Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org> * Copyright 2018, 2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,19 +21,14 @@
#define CALAMARES_PYTHONJOBHELPER_H #define CALAMARES_PYTHONJOBHELPER_H
#include "PythonJob.h" #include "PythonJob.h"
#include "utils/BoostPython.h"
#include <QStringList> #include <QStringList>
#undef slots namespace Calamares
#include "utils/boost-warnings.h" {
class GlobalStorage;
#include <boost/python/dict.hpp> }
#include <boost/python/list.hpp>
#include <boost/python/object.hpp>
#ifdef __clang__
#pragma clang diagnostic pop
#endif
namespace CalamaresPython namespace CalamaresPython
{ {
@ -72,6 +67,28 @@ private:
QStringList m_pythonPaths; 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 } // namespace CalamaresPython
#endif // CALAMARES_PYTHONJOBHELPER_H #endif // CALAMARES_PYTHONJOBHELPER_H

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org> * Copyright 2018, 2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,20 +19,16 @@
#include "PythonJob.h" #include "PythonJob.h"
#include "CalamaresVersion.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "PythonHelper.h" #include "PythonHelper.h"
#include "PythonJobApi.h"
#include "utils/BoostPython.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include <QDir> #include <QDir>
#undef slots
#include <boost/python.hpp>
#include <boost/python/args.hpp>
#include "PythonJobApi.h"
namespace bp = boost::python; namespace bp = boost::python;
BOOST_PYTHON_FUNCTION_OVERLOADS( mount_overloads, CalamaresPython::mount, 2, 4 ); BOOST_PYTHON_FUNCTION_OVERLOADS( mount_overloads, CalamaresPython::mount, 2, 4 );
@ -180,7 +176,7 @@ PythonJob::PythonJob( const ModuleSystem::InstanceKey& instance,
, m_workingPath( workingPath ) , m_workingPath( workingPath )
, m_description() , m_description()
, m_configurationMap( moduleConfiguration ) , m_configurationMap( moduleConfiguration )
, m_weight( (instance.module() == QStringLiteral( "unpackfs" )) ? 12.0 : 1.0 ) , m_weight( ( instance.module() == QStringLiteral( "unpackfs" ) ) ? 12.0 : 1.0 )
{ {
} }

View File

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014, Teo Mrnjavac <teo@kde.org> * Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -23,7 +24,7 @@
#include "modulesystem/InstanceKey.h" #include "modulesystem/InstanceKey.h"
#include <QVariant> #include <QVariantMap>
namespace CalamaresPython namespace CalamaresPython
{ {

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2019, Adriaan de Groot <groot@kde.org> * Copyright 2017-2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,26 +19,17 @@
#include "PythonJobApi.h" #include "PythonJobApi.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "PythonHelper.h" #include "PythonHelper.h"
#include "utils/CalamaresUtilsSystem.h" #include "utils/CalamaresUtilsSystem.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/String.h" #include "utils/String.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir> #include <QDir>
#include <QStandardPaths> #include <QStandardPaths>
#undef slots
#include "utils/boost-warnings.h"
#include <boost/python.hpp>
#ifdef __clang__
#pragma clang diagnostic pop
#endif
namespace bp = boost::python; namespace bp = boost::python;
static int static int

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, 2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -20,12 +20,14 @@
#ifndef PYTHONJOBAPI_H #ifndef PYTHONJOBAPI_H
#define PYTHONJOBAPI_H #define PYTHONJOBAPI_H
#include "CalamaresVersion.h" #include "qglobal.h" // For qreal
#include "PythonJob.h" #include "utils/BoostPython.h"
#undef slots namespace Calamares
#include <boost/python/dict.hpp> {
class PythonJob;
}
namespace CalamaresPython namespace CalamaresPython
{ {

View File

@ -0,0 +1,73 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2019-2020, Adriaan de Groot <groot@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/*
* 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 <boost/python.hpp>
#include <boost/python/args.hpp>
#include <boost/python/dict.hpp>
#include <boost/python/list.hpp>
#include <boost/python/object.hpp>
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif

View File

@ -35,7 +35,7 @@ CalamaresUtils::getEntropy( int size, QByteArray& b )
char* buffer = b.data(); char* buffer = b.data();
std::fill( buffer, buffer + size, 0xcb ); std::fill( buffer, buffer + size, 0xcb );
int readSize = 0; qint64 readSize = 0;
QFile urandom( "/dev/urandom" ); QFile urandom( "/dev/urandom" );
if ( urandom.exists() && urandom.open( QIODevice::ReadOnly ) ) if ( urandom.exists() && urandom.open( QIODevice::ReadOnly ) )
{ {
@ -62,7 +62,7 @@ CalamaresUtils::getEntropy( int size, QByteArray& b )
#define GET_ONE_BYTE \ #define GET_ONE_BYTE \
if ( readSize < size ) \ if ( readSize < size ) \
{ \ { \
buffer[ readSize++ ] = next & 0xff; \ buffer[ readSize++ ] = char( next & 0xffU ); \
next = next >> 8; \ next = next >> 8; \
} }
GET_ONE_BYTE GET_ONE_BYTE

View File

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2018, Adriaan de Groot <groot@kde.org> * Copyright 2018, 2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -38,8 +38,8 @@ class TestPaths : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
TestPaths() {}; TestPaths() {}
virtual ~TestPaths() {}; virtual ~TestPaths() {}
private Q_SLOTS: private Q_SLOTS:
void initTestCase(); void initTestCase();

View File

@ -224,3 +224,30 @@ LibCalamaresTests::testPrintableEntropy()
QVERIFY( c.cell() < 127 ); 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 );
}
}
}

View File

@ -43,6 +43,7 @@ private Q_SLOTS:
/** @brief Tests the entropy functions. */ /** @brief Tests the entropy functions. */
void testEntropy(); void testEntropy();
void testPrintableEntropy(); void testPrintableEntropy();
void testOddSizedPrintable();
}; };
#endif #endif

View File

@ -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

View File

@ -16,6 +16,7 @@ set( calamaresui_SOURCES
utils/CalamaresUtilsGui.cpp utils/CalamaresUtilsGui.cpp
utils/ImageRegistry.cpp utils/ImageRegistry.cpp
utils/Paste.cpp utils/Paste.cpp
utils/Qml.cpp
viewpages/BlankViewStep.cpp viewpages/BlankViewStep.cpp
viewpages/ExecutionViewStep.cpp viewpages/ExecutionViewStep.cpp

View File

@ -0,0 +1,52 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2020, Adriaan de Groot <groot@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "Qml.h"
#include "utils/Logger.h"
#include <QByteArray>
#include <QObject>
#include <QQuickItem>
#include <QVariant>
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

View File

@ -0,0 +1,42 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2020, Adriaan de Groot <groot@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -31,6 +31,7 @@
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
#include "utils/Dirs.h" #include "utils/Dirs.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Qml.h"
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
#include <QDir> #include <QDir>
@ -42,35 +43,6 @@
#include <QQuickWidget> #include <QQuickWidget>
#include <QVBoxLayout> #include <QVBoxLayout>
/** @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 namespace Calamares
{ {
@ -205,7 +177,7 @@ changeSlideShowState( Slideshow state, QQuickItem* slideshow, QQuickWidget* widg
if ( Branding::instance()->slideshowAPI() == 2 ) if ( Branding::instance()->slideshowAPI() == 2 )
{ {
// The QML was already loaded in the constructor, need to start it // 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() ) else if ( !Calamares::Branding::instance()->slideshowPath().isEmpty() )
{ {

View File

@ -19,10 +19,12 @@
#include "QmlViewStep.h" #include "QmlViewStep.h"
#include "Branding.h" #include "Branding.h"
#include "ViewManager.h"
#include "utils/Dirs.h" #include "utils/Dirs.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/NamedEnum.h" #include "utils/NamedEnum.h"
#include "utils/Qml.h"
#include "utils/Variant.h" #include "utils/Variant.h"
#include "widgets/WaitingWidget.h" #include "widgets/WaitingWidget.h"
@ -50,6 +52,36 @@ searchNames()
return names; 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 namespace Calamares
{ {
@ -80,57 +112,61 @@ QmlViewStep::prettyName() const
} }
} // namespace Calamares
bool bool
Calamares::QmlViewStep::isAtBeginning() const QmlViewStep::isAtBeginning() const
{ {
return true; return true;
} }
bool bool
Calamares::QmlViewStep::isAtEnd() const QmlViewStep::isAtEnd() const
{ {
return true; return true;
} }
bool bool
Calamares::QmlViewStep::isBackEnabled() const QmlViewStep::isBackEnabled() const
{ {
return true; return true;
} }
bool bool
Calamares::QmlViewStep::isNextEnabled() const QmlViewStep::isNextEnabled() const
{ {
return true; return true;
} }
Calamares::JobList Calamares::JobList
Calamares::QmlViewStep::jobs() const QmlViewStep::jobs() const
{ {
return JobList(); return JobList();
} }
void void
Calamares::QmlViewStep::onActivate() QmlViewStep::onActivate()
{ {
// TODO: call into QML if ( m_qmlObject )
{
changeQMLState( QMLAction::Start, m_qmlObject );
}
} }
void void
Calamares::QmlViewStep::onLeave() QmlViewStep::onLeave()
{ {
// TODO: call into QML if ( m_qmlObject )
{
changeQMLState( QMLAction::Stop, m_qmlObject );
}
} }
QWidget* QWidget*
Calamares::QmlViewStep::widget() QmlViewStep::widget()
{ {
return m_widget; return m_widget;
} }
void void
Calamares::QmlViewStep::loadComplete() QmlViewStep::loadComplete()
{ {
cDebug() << "QML component" << m_qmlFileName << m_qmlComponent->status(); cDebug() << "QML component" << m_qmlFileName << m_qmlComponent->status();
if ( m_qmlComponent->status() == QQmlComponent::Error ) if ( m_qmlComponent->status() == QQmlComponent::Error )
@ -163,7 +199,7 @@ Calamares::QmlViewStep::loadComplete()
} }
void void
Calamares::QmlViewStep::showQml() QmlViewStep::showQml()
{ {
if ( !m_qmlWidget || !m_qmlObject ) if ( !m_qmlWidget || !m_qmlObject )
{ {
@ -181,6 +217,13 @@ Calamares::QmlViewStep::showQml()
{ {
cDebug() << "showQml() called twice"; 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). * is badly configured).
*/ */
QString 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; using QmlSearch = Calamares::QmlViewStep::QmlSearch;
@ -235,7 +278,7 @@ searchQmlFile( Calamares::QmlViewStep::QmlSearch method, const QString& configur
} }
void void
Calamares::QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
bool ok = false; bool ok = false;
m_searchMethod = searchNames().find( CalamaresUtils::getString( configurationMap, "search" ), ok ); m_searchMethod = searchNames().find( CalamaresUtils::getString( configurationMap, "search" ), ok );
@ -270,8 +313,10 @@ Calamares::QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap
} }
void void
Calamares::QmlViewStep::showFailedQml() QmlViewStep::showFailedQml()
{ {
cWarning() << "QmlViewStep" << moduleInstanceKey() << "loading failed."; cWarning() << "QmlViewStep" << moduleInstanceKey() << "loading failed.";
m_spinner->setText( prettyName() + ' ' + tr( "Loading failed." ) ); m_spinner->setText( prettyName() + ' ' + tr( "Loading failed." ) );
} }
} // namespace Calamares

View File

@ -156,7 +156,8 @@ HostInfoJob::exec()
gs->insert( "hostOSName", hostOSName() ); gs->insert( "hostOSName", hostOSName() );
gs->insert( "hostCPU", hostCPU() ); 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 ) if ( ram )
{ {
gs->insert( "hostRAMMiB", ram ); gs->insert( "hostRAMMiB", ram );

View File

@ -1,10 +1,10 @@
calamares_add_plugin( dummyqml calamares_add_plugin( notesqml
TYPE viewmodule TYPE viewmodule
EXPORT_MACRO PLUGINDLLEXPORT_PRO EXPORT_MACRO PLUGINDLLEXPORT_PRO
SOURCES SOURCES
DummyQmlViewStep.cpp NotesQmlViewStep.cpp
RESOURCES RESOURCES
dummyqml.qrc notesqml.qrc
LINK_PRIVATE_LIBRARIES LINK_PRIVATE_LIBRARIES
calamaresui calamaresui
SHARED_LIB SHARED_LIB

View File

@ -17,36 +17,36 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "DummyQmlViewStep.h" #include "NotesQmlViewStep.h"
#include <QVariant> #include <QVariant>
DummyQmlViewStep::DummyQmlViewStep( QObject* parent ) NotesQmlViewStep::NotesQmlViewStep( QObject* parent )
: Calamares::QmlViewStep( "dummyqml", parent ) : Calamares::QmlViewStep( "notesqml", parent )
{ {
} }
DummyQmlViewStep::~DummyQmlViewStep() {} NotesQmlViewStep::~NotesQmlViewStep() {}
QString QString
DummyQmlViewStep::prettyName() const NotesQmlViewStep::prettyName() const
{ {
return m_notesName ? m_notesName->get() : tr( "Notes" ); return m_notesName ? m_notesName->get() : tr( "Notes" );
} }
void void
DummyQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) NotesQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation
bool qmlLabel_ok = false; bool qmlLabel_ok = false;
auto qmlLabel = CalamaresUtils::getSubMap( configurationMap, "qmlLabel", qmlLabel_ok ); auto qmlLabel = CalamaresUtils::getSubMap( configurationMap, "qmlLabel", qmlLabel_ok );
if ( qmlLabel.contains( "notes" ) ) if ( qmlLabel.contains( "notes" ) )
{ {
m_notesName = new CalamaresUtils::Locale::TranslatedString( qmlLabel, "notes" ); m_notesName = new CalamaresUtils::Locale::TranslatedString( qmlLabel, "notes" );
} }
} }
CALAMARES_PLUGIN_FACTORY_DEFINITION( DummyQmlViewStepFactory, registerPlugin< DummyQmlViewStep >(); ) CALAMARES_PLUGIN_FACTORY_DEFINITION( NotesQmlViewStepFactory, registerPlugin< NotesQmlViewStep >(); )

View File

@ -17,8 +17,8 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef DUMMYQMLVIEWSTEP_H #ifndef NOTESQMLVIEWSTEP_H
#define DUMMYQMLVIEWSTEP_H #define NOTESQMLVIEWSTEP_H
#include "PluginDllMacro.h" #include "PluginDllMacro.h"
#include "locale/TranslatableConfiguration.h" #include "locale/TranslatableConfiguration.h"
@ -27,13 +27,13 @@
#include "utils/PluginFactory.h" #include "utils/PluginFactory.h"
#include "viewpages/QmlViewStep.h" #include "viewpages/QmlViewStep.h"
class PLUGINDLLEXPORT DummyQmlViewStep : public Calamares::QmlViewStep class PLUGINDLLEXPORT NotesQmlViewStep : public Calamares::QmlViewStep
{ {
Q_OBJECT Q_OBJECT
public: public:
DummyQmlViewStep( QObject* parent = nullptr ); NotesQmlViewStep( QObject* parent = nullptr );
virtual ~DummyQmlViewStep() override; virtual ~NotesQmlViewStep() override;
QString prettyName() const override; QString prettyName() const override;
@ -43,6 +43,6 @@ private:
CalamaresUtils::Locale::TranslatedString* m_notesName; // As it appears in the sidebar CalamaresUtils::Locale::TranslatedString* m_notesName; // As it appears in the sidebar
}; };
CALAMARES_PLUGIN_FACTORY_DECLARATION( DummyQmlViewStepFactory ) CALAMARES_PLUGIN_FACTORY_DECLARATION( NotesQmlViewStepFactory )
#endif #endif

View File

@ -1,6 +1,14 @@
# The dummy QML module just displays a QML page. It doesn't # The *notesqml* module can be used to display a QML file
# have much in the way of own configuration, only where # as an installer step. This is most useful for release-notes
# the QML file is searched. # 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 # QML modules can search for the QML inside the Qt resources
# (QRC) which are compiled into the module, or in the branding # (QRC) which are compiled into the module, or in the branding
@ -13,7 +21,7 @@
# QML file for it. # QML file for it.
# #
# To support instanced QML modules, searches in the branding # 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 mode. Valid values are "both", "qrc" and "branding"
search: both search: both
@ -21,9 +29,12 @@ search: both
# Name of the QML file. If not set, uses the name of the instance # 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` # of the module (e.g. if you list this module in `settings.conf`
# in the *instances* section, you get *id*, otherwise it would # in the *instances* section, you get *id*, otherwise it would
# normally be "dummyqml"). # normally be "notesqml").
# filename: dummyqml #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: qmlLabel:
notes: "Release Notes" notes: "Release Notes"
notes[nl]: "Opmerkingen" notes[nl]: "Opmerkingen"

View File

@ -0,0 +1,75 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2020, Anke Boersma <demm@kaosx.us>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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("<h3>Generic GNU/Linux 2020.2 LTS <quote>Turgid Tuba</quote></h3>
<p>This an example QML file, showing options in RichText with Flickable content.</p>
<p>QML with RichText can use HTML tags, Flickable content is useful for touchscreens.</p>
<p><b>This is bold text</b></p>
<p><i>This is italic text</i></p>
<p><u>This is underlined text</u></p>
<p><center>This text will be center-aligned.</center></p>
<p><s>This is strikethrough</s></p>
<p>Code example:
<code>ls -l /home</code></p>
<p><b>Lists:</b></p>
<ul>
<li>Intel CPU systems</li>
<li>AMD CPU systems</li>
</ul>
<p>The vertical scrollbar is adjustable, current width set to 10.</p>")
}
}
}

View File

@ -1,5 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0"> <!DOCTYPE RCC><RCC version="1.0">
<qresource> <qresource>
<file alias="dummyqml.qml">dummyqml.qml</file> <file alias="notesqml.qml">notesqml.qml</file>
</qresource> </qresource>
</RCC> </RCC>