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

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

sync with github

File size: 4.5 KB
RevLine 
[7538]1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
4 *   Copyright 2017-2018, 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 VIEWMANAGER_H
21#define VIEWMANAGER_H
22
23#include "UiDllMacro.h"
24#include "Typedefs.h"
25
26#include <QList>
27#include <QPushButton>
28#include <QStackedWidget>
29
30
31namespace Calamares
32{
33
34class ViewStep;
35class ExecutionViewStep;
36
37/**
38 * @brief The ViewManager class handles progression through view pages.
39 * @note Singleton object, only use through ViewManager::instance().
40 */
41class UIDLLEXPORT ViewManager : public QObject
42{
43    Q_OBJECT
44public:
45    /**
46     * @brief instance access to the ViewManager singleton.
47     * @return pointer to the singleton instance.
48     */
49    static ViewManager* instance();
50    static ViewManager* instance( QObject* parent );
51
52    /**
53     * @brief centralWidget always returns the central widget in the Calamares main
54     * window.
55     * @return a pointer to the active QWidget (usually a wizard page provided by a
56     * view module).
57     */
58    QWidget* centralWidget();
59
60    /**
61     * @brief addViewStep appends a view step to the roster.
62     * @param step a pointer to the ViewStep object to add.
63     * @note a ViewStep is the active instance of a view module, it aggregates one
64     * or more view pages, plus zero or more jobs which may be created at runtime.
65     */
66    void addViewStep( ViewStep* step );
67
68    /**
69     * @brief viewSteps returns the list of currently present view steps.
70     * @return the ViewStepList.
71     * This should only return an empty list before startup is complete.
72     */
73    ViewStepList viewSteps() const;
74
75    /**
76     * @brief currentStep returns the currently active ViewStep, i.e. the ViewStep
77     * which owns the currently visible view page.
78     * @return the active ViewStep. Do not confuse this with centralWidget().
79     * @see ViewStep::centralWidget
80     */
81    ViewStep* currentStep() const;
82
83    /**
84     * @brief currentStepIndex returns the index of the currently active ViewStep.
85     * @return the index.
86     */
87    int currentStepIndex() const;
88
89    /**
90     * @ brief Called when "Cancel" is clicked; asks for confirmation.
91     * Other means of closing Calamares also call this method, e.g. alt-F4.
92     * At the end of installation, no confirmation is asked. Returns true
93     * if the user confirms closing the window.
94     */
95    bool confirmCancelInstallation();
96
97public slots:
98    /**
99     * @brief next moves forward to the next page of the current ViewStep (if any),
100     * or to the first page of the next ViewStep if the current ViewStep doesn't
101     * have any more pages.
102     */
103    void next();
104
105    /**
106     * @brief back moves backward to the previous page of the current ViewStep (if any),
107     * or to the last page of the previous ViewStep if the current ViewStep doesn't
108     * have any pages before the current one.
109     */
110    void back();
111
112    /**
113     * @brief onInstallationFailed displays an error message when a fatal failure
114     * happens in a ViewStep.
115     * @param message the error string.
116     * @param details the details string.
117     */
118    void onInstallationFailed( const QString& message, const QString& details );
119
120    /** @brief Replaces the stack with a view step stating that initialization failed.
121     *
122     * @param modules a list of failed modules.
123     */
124    void onInitFailed( const QStringList& modules );
125
126signals:
127    void currentStepChanged();
128    void enlarge( QSize enlarge ) const;  // See ViewStep::enlarge()
129
130private:
131    explicit ViewManager( QObject* parent = nullptr );
132    virtual ~ViewManager() override;
133
134    void insertViewStep( int before, ViewStep* step );
135    void updateButtonLabels();
136
137    static ViewManager* s_instance;
138
139    ViewStepList m_steps;
140    int m_currentStep;
141
142    QWidget* m_widget;
143    QStackedWidget* m_stack;
144    QPushButton* m_back;
145    QPushButton* m_next;
146    QPushButton* m_quit;
147};
148
149}
150
151#endif // VIEWMANAGER_H
Note: See TracBrowser for help on using the repository browser.