source: calamares/trunk/fuentes/src/libcalamaresui/viewpages/ViewStep.h @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 3.8 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
4 *   Copyright 2017, Adriaan de Groot <groot@kde.org>
5 *
6 *   Calamares is free software: you can redistribute it and/or modify
7 *   it under the terms of the GNU General Public License as published by
8 *   the Free Software Foundation, either version 3 of the License, or
9 *   (at your option) any later version.
10 *
11 *   Calamares is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef VIEWSTEP_H
21#define VIEWSTEP_H
22
23#include <QObject>
24
25#include "../UiDllMacro.h"
26#include "Typedefs.h"
27
28namespace Calamares
29{
30
31/**
32 * @brief The ViewStep class is the base class for all view modules.
33 * A view module is a Calamares module which has at least one UI page (exposed as
34 * ViewStep::widget), and can optionally create Calamares jobs at runtime.
35 * As of early 2017, a view module can be implemented by deriving from ViewStep
36 * in C++ (as a Qt Plugin) or in Python with the PythonQt interface (which also
37 * mimics the ViewStep class).
38 *
39 * A ViewStep can describe itself in human-readable format for the SummaryPage
40 * (which shows all of the things which have been collected to be done in the
41 * next exec-step) through prettyStatus() and createSummaryWidget().
42 */
43class UIDLLEXPORT ViewStep : public QObject
44{
45    Q_OBJECT
46public:
47    explicit ViewStep( QObject* parent = nullptr );
48    virtual ~ViewStep() override;
49
50    virtual QString prettyName() const = 0;
51
52    /**
53     * Optional. May return a non-empty string describing what this
54     * step is going to do (should be translated). This is also used
55     * in the summary page to describe what is going to be done.
56     * Return an empty string to provide no description.
57     */
58    virtual QString prettyStatus() const;
59
60    /**
61     * Optional. May return a widget which will be inserted in the summary
62     * page. The caller takes ownership of the widget. Return nullptr to
63     * provide no widget. In general, this is only used for complicated
64     * steps where prettyStatus() is not sufficient.
65     */
66    virtual QWidget* createSummaryWidget() const;
67
68    //TODO: we might want to make this a QSharedPointer
69    virtual QWidget* widget() = 0;
70
71    virtual void next() = 0;
72    virtual void back() = 0;
73
74    virtual bool isNextEnabled() const = 0;
75    virtual bool isBackEnabled() const = 0;
76
77    virtual bool isAtBeginning() const = 0;
78    virtual bool isAtEnd() const = 0;
79
80    /**
81     * @brief onActivate called every time a ViewStep is shown, either by going forward
82     * or backward.
83     * The default implementation does nothing.
84     */
85    virtual void onActivate();
86
87    /**
88     * @brief onLeave called every time a ViewStep is hidden and control passes to
89     * another ViewStep, either by going forward or backward.
90     * The default implementation does nothing.
91     */
92    virtual void onLeave();
93
94    virtual JobList jobs() const = 0;
95
96    void setModuleInstanceKey( const QString& instanceKey );
97    QString moduleInstanceKey() const
98    {
99        return m_instanceKey;
100    }
101
102    virtual void setConfigurationMap( const QVariantMap& configurationMap );
103
104signals:
105    void nextStatusChanged( bool status );
106    void done();
107
108    /* Emitted when the viewstep thinks it needs more space than is currently
109     * available for display. @p enlarge is the requested additional space,
110     * e.g. 24px vertical. This request may be silently ignored.
111     */
112    void enlarge( QSize enlarge ) const;
113
114protected:
115    QString m_instanceKey;
116};
117
118}
119
120#endif // VIEWSTEP_H
Note: See TracBrowser for help on using the repository browser.