source: calamares/trunk/fuentes/src/libcalamaresui/ExecutionViewStep.cpp @ 7538

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

sync with github

File size: 4.0 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014, Aurélien Gâteau <agateau@kde.org>
4 *   Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
5 *   Copyright 2018, Adriaan de Groot <groot@kde.org>
6 *
7 *   Calamares is free software: you can redistribute it and/or modify
8 *   it under the terms of the GNU General Public License as published by
9 *   the Free Software Foundation, either version 3 of the License, or
10 *   (at your option) any later version.
11 *
12 *   Calamares is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <ExecutionViewStep.h>
22
23#include "Branding.h"
24#include "JobQueue.h"
25#include "modulesystem/Module.h"
26#include "modulesystem/ModuleManager.h"
27#include "Settings.h"
28#include "utils/CalamaresUtilsGui.h"
29#include "utils/Logger.h"
30#include "utils/Retranslator.h"
31#include "ViewManager.h"
32
33#include <QDir>
34#include <QLabel>
35#include <QProgressBar>
36#include <QVBoxLayout>
37#include <QtQuickWidgets/QQuickWidget>
38#include <QQmlEngine>
39
40
41namespace Calamares
42{
43
44ExecutionViewStep::ExecutionViewStep( QObject* parent )
45    : ViewStep( parent )
46    , m_widget( new QWidget )
47{
48    m_progressBar = new QProgressBar;
49    m_progressBar->setMaximum( 10000 );
50    m_label = new QLabel;
51    QVBoxLayout* layout = new QVBoxLayout( m_widget );
52    QVBoxLayout* innerLayout = new QVBoxLayout;
53
54    m_slideShow = new QQuickWidget;
55    layout->addWidget( m_slideShow );
56    CalamaresUtils::unmarginLayout( layout );
57
58    layout->addLayout( innerLayout );
59    m_slideShow->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
60    m_slideShow->setResizeMode( QQuickWidget::SizeRootObjectToView );
61
62    m_slideShow->engine()->addImportPath( CalamaresUtils::qmlModulesDir().absolutePath() );
63
64    innerLayout->addSpacing( CalamaresUtils::defaultFontHeight() / 2 );
65    innerLayout->addWidget( m_progressBar );
66    innerLayout->addWidget( m_label );
67
68    cDebug() << "QML import paths:" << Logger::DebugList( m_slideShow->engine()->importPathList() );
69
70    connect( JobQueue::instance(), &JobQueue::progress,
71             this, &ExecutionViewStep::updateFromJobQueue );
72}
73
74
75QString
76ExecutionViewStep::prettyName() const
77{
78    return tr( "Install" );
79}
80
81
82QWidget*
83ExecutionViewStep::widget()
84{
85    return m_widget;
86}
87
88
89void
90ExecutionViewStep::next()
91{
92}
93
94
95void
96ExecutionViewStep::back()
97{
98}
99
100
101bool
102ExecutionViewStep::isNextEnabled() const
103{
104    return false;
105}
106
107
108bool
109ExecutionViewStep::isBackEnabled() const
110{
111    return false;
112}
113
114
115bool
116ExecutionViewStep::isAtBeginning() const
117{
118    return true;
119}
120
121
122bool
123ExecutionViewStep::isAtEnd() const
124{
125    return true;
126}
127
128
129void
130ExecutionViewStep::onActivate()
131{
132    CALAMARES_RETRANSLATE_WIDGET( m_widget,
133        if ( !Calamares::Branding::instance()->slideshowPath().isEmpty() )
134            m_slideShow->setSource( QUrl::fromLocalFile( Calamares::Branding::instance()
135                                                         ->slideshowPath() ) );
136    )
137
138
139    JobQueue* queue = JobQueue::instance();
140    foreach ( const QString& instanceKey, m_jobInstanceKeys )
141    {
142        Calamares::Module* module = Calamares::ModuleManager::instance()
143                                    ->moduleInstance( instanceKey );
144        if ( module )
145            queue->enqueue( module->jobs() );
146    }
147
148    queue->start();
149}
150
151
152JobList
153ExecutionViewStep::jobs() const
154{
155    return JobList();
156}
157
158
159void
160ExecutionViewStep::appendJobModuleInstanceKey( const QString& instanceKey )
161{
162    m_jobInstanceKeys.append( instanceKey );
163}
164
165
166void
167ExecutionViewStep::updateFromJobQueue( qreal percent, const QString& message )
168{
169    m_progressBar->setValue( int( percent * m_progressBar->maximum() ) );
170    m_label->setText( message );
171}
172
173} // namespace
Note: See TracBrowser for help on using the repository browser.