2020-01-10 12:13:40 +01:00
|
|
|
/* === 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 QMLVIEWSTEP_H
|
|
|
|
#define QMLVIEWSTEP_H
|
|
|
|
|
2020-03-11 17:12:02 +01:00
|
|
|
#include "utils/Qml.h"
|
2020-01-10 12:13:40 +01:00
|
|
|
#include "viewpages/ViewStep.h"
|
|
|
|
|
2020-01-10 13:10:55 +01:00
|
|
|
class QQmlComponent;
|
|
|
|
class QQuickItem;
|
|
|
|
class QQuickWidget;
|
|
|
|
class WaitingWidget;
|
|
|
|
|
2020-01-10 12:13:40 +01:00
|
|
|
namespace Calamares
|
|
|
|
{
|
|
|
|
|
|
|
|
/** @brief A viewstep that uses QML for the UI
|
|
|
|
*
|
|
|
|
* This is generally a **base** class for other view steps, but
|
|
|
|
* it can be used stand-alone for viewsteps that don't really have
|
|
|
|
* any functionality.
|
2020-06-25 14:04:49 +02:00
|
|
|
*
|
|
|
|
* Most subclasses will override the following methods:
|
|
|
|
* - prettyName() to provide a meaningful human-readable name
|
|
|
|
* - jobs() if there is real work to be done during installation
|
|
|
|
* - getConfig() to return a meaningful configuration object
|
|
|
|
*
|
|
|
|
* For details on the interaction between the config object and
|
|
|
|
* the QML in the module, see the Calamares wiki:
|
|
|
|
* https://github.com/calamares/calamares/wiki/Develop-Design
|
2020-01-10 12:13:40 +01:00
|
|
|
*/
|
|
|
|
class QmlViewStep : public Calamares::ViewStep
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-01-10 17:19:15 +01:00
|
|
|
/** @brief Creates a QML view step
|
|
|
|
*
|
2020-03-11 15:57:08 +01:00
|
|
|
* The search behavior for the actial QML depends on a QmlSearch value.
|
|
|
|
* This is set through common configuration key *qmlSearch*.
|
|
|
|
* The filename used comes from the module identifier, or can be
|
|
|
|
* set in the configuration file through *qmlFilename*.
|
2020-03-12 17:37:39 +01:00
|
|
|
*
|
|
|
|
* @see Qml.h for available Calamares internals.
|
2020-01-10 17:19:15 +01:00
|
|
|
*/
|
2020-03-11 15:57:08 +01:00
|
|
|
QmlViewStep( QObject* parent = nullptr );
|
2020-01-10 12:13:40 +01:00
|
|
|
virtual ~QmlViewStep() override;
|
|
|
|
|
|
|
|
virtual QString prettyName() const override;
|
|
|
|
|
|
|
|
virtual QWidget* widget() override;
|
2020-06-24 23:41:20 +02:00
|
|
|
virtual QSize widgetMargins( Qt::Orientations panelSides ) override;
|
2020-01-10 12:13:40 +01:00
|
|
|
|
|
|
|
virtual bool isNextEnabled() const override;
|
|
|
|
virtual bool isBackEnabled() const override;
|
|
|
|
|
|
|
|
virtual bool isAtBeginning() const override;
|
|
|
|
virtual bool isAtEnd() const override;
|
|
|
|
|
|
|
|
virtual void onActivate() override;
|
|
|
|
virtual void onLeave() override;
|
|
|
|
|
2020-01-10 17:19:15 +01:00
|
|
|
/// @brief QML widgets don't produce jobs by default
|
2020-01-10 12:13:40 +01:00
|
|
|
virtual JobList jobs() const override;
|
|
|
|
|
2020-02-12 22:33:49 +01:00
|
|
|
/// @brief Configure search paths; subclasses should call this at the **end** of their own implementation
|
2020-01-10 17:19:15 +01:00
|
|
|
virtual void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
|
|
|
|
2020-02-12 17:51:10 +01:00
|
|
|
protected:
|
|
|
|
/** @brief Gets a pointer to the Config of this view step
|
|
|
|
*
|
|
|
|
* Parts of the configuration of the viewstep can be passed to QML
|
|
|
|
* by placing them in a QObject (as properties). The default
|
|
|
|
* implementation returns nullptr, for no-config.
|
|
|
|
*
|
|
|
|
* Ownership of the config object remains with the ViewStep; it is possible
|
|
|
|
* to return a pointer to a member variable.
|
2020-03-12 17:37:39 +01:00
|
|
|
*
|
|
|
|
* This object is made available as a context-property *config* in QML.
|
2020-02-12 17:51:10 +01:00
|
|
|
*/
|
|
|
|
virtual QObject* getConfig();
|
|
|
|
|
2020-03-18 11:02:16 +01:00
|
|
|
/** @brief Adds a context property for this QML file
|
|
|
|
*
|
|
|
|
* Does not take ownership.
|
|
|
|
*/
|
|
|
|
void setContextProperty( const char* name, QObject* property );
|
|
|
|
|
2020-01-10 13:39:03 +01:00
|
|
|
private Q_SLOTS:
|
|
|
|
void loadComplete();
|
|
|
|
|
2020-01-10 12:13:40 +01:00
|
|
|
private:
|
2020-01-10 13:39:03 +01:00
|
|
|
/// @brief Swap out the spinner for the QQuickWidget
|
|
|
|
void showQml();
|
2020-01-10 17:41:20 +01:00
|
|
|
/// @brief Show error message in spinner.
|
|
|
|
void showFailedQml();
|
2020-01-10 13:39:03 +01:00
|
|
|
|
2020-01-10 17:19:15 +01:00
|
|
|
/// @brief Controls where m_name is searched
|
2020-03-11 17:12:02 +01:00
|
|
|
CalamaresUtils::QmlSearch m_searchMethod;
|
2020-01-10 17:19:15 +01:00
|
|
|
|
2020-01-10 12:13:40 +01:00
|
|
|
QString m_name;
|
2020-01-10 13:39:03 +01:00
|
|
|
QString m_qmlFileName;
|
2020-01-10 13:10:55 +01:00
|
|
|
|
|
|
|
QWidget* m_widget = nullptr;
|
|
|
|
WaitingWidget* m_spinner = nullptr;
|
2020-01-10 13:39:03 +01:00
|
|
|
QQuickWidget* m_qmlWidget = nullptr;
|
2020-01-10 13:10:55 +01:00
|
|
|
QQmlComponent* m_qmlComponent = nullptr;
|
|
|
|
QQuickItem* m_qmlObject = nullptr;
|
2020-01-10 12:13:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Calamares
|
|
|
|
#endif
|