source: calamares/trunk/fuentes/src/modules/license/LicenseViewStep.cpp @ 7538

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

sync with github

File size: 3.9 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2015, Anke Boersma <demm@kaosx.us>
4 *   Copyright 2015, Teo Mrnjavac <teo@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#include "LicenseViewStep.h"
21
22#include "LicensePage.h"
23#include "JobQueue.h"
24#include "GlobalStorage.h"
25#include "utils/Logger.h"
26
27#include <QVariantMap>
28
29CALAMARES_PLUGIN_FACTORY_DEFINITION( LicenseViewStepFactory, registerPlugin<LicenseViewStep>(); )
30
31LicenseViewStep::LicenseViewStep( QObject* parent )
32    : Calamares::ViewStep( parent )
33    , m_widget( new LicensePage )
34{
35    emit nextStatusChanged( false );
36    connect( m_widget, &LicensePage::nextStatusChanged,
37             this, &LicenseViewStep::nextStatusChanged );
38}
39
40
41LicenseViewStep::~LicenseViewStep()
42{
43    if ( m_widget && m_widget->parent() == nullptr )
44        m_widget->deleteLater();
45}
46
47
48QString
49LicenseViewStep::prettyName() const
50{
51    return tr( "License" );
52}
53
54
55QWidget*
56LicenseViewStep::widget()
57{
58    return m_widget;
59}
60
61
62void
63LicenseViewStep::next()
64{
65    emit done();
66}
67
68
69void
70LicenseViewStep::back()
71{}
72
73
74bool
75LicenseViewStep::isNextEnabled() const
76{
77    return m_widget->isNextEnabled();
78}
79
80
81bool
82LicenseViewStep::isBackEnabled() const
83{
84    return true;
85}
86
87
88bool
89LicenseViewStep::isAtBeginning() const
90{
91    return true;
92}
93
94
95bool
96LicenseViewStep::isAtEnd() const
97{
98    return true;
99}
100
101
102QList< Calamares::job_ptr >
103LicenseViewStep::jobs() const
104{
105    return QList< Calamares::job_ptr >();
106}
107
108void
109LicenseViewStep::setConfigurationMap( const QVariantMap& configurationMap )
110{
111    QList< LicenseEntry > entriesList;
112    if ( configurationMap.contains( "entries" ) &&
113         configurationMap.value( "entries" ).type() == QVariant::List )
114    {
115        const auto entries = configurationMap.value( "entries" ).toList();
116        for ( const QVariant& entryV : entries )
117        {
118            if ( entryV.type() != QVariant::Map )
119                continue;
120
121            QVariantMap entryMap = entryV.toMap();
122            if ( !entryMap.contains( "id" ) ||
123                 !entryMap.contains( "name" ) ||
124                 !entryMap.contains( "url" ) )
125                continue;
126
127            LicenseEntry entry;
128            entry.id =          entryMap[ "id" ].toString();
129            entry.prettyName =  entryMap[ "name" ].toString();
130            entry.prettyVendor =entryMap.value( "vendor" ).toString();
131            entry.url =         QUrl( entryMap[ "url" ].toString() );
132            entry.required =    entryMap.value( "required", QVariant( false ) ).toBool();
133
134            QString entryType = entryMap.value( "type", "software" ).toString();
135            if ( entryType == "driver" )
136                entry.type =    LicenseEntry::Driver;
137            else if ( entryType == "gpudriver" )
138                entry.type =    LicenseEntry::GpuDriver;
139            else if ( entryType == "browserplugin" )
140                entry.type =    LicenseEntry::BrowserPlugin;
141            else if ( entryType == "codec" )
142                entry.type =    LicenseEntry::Codec;
143            else if ( entryType == "package" )
144                entry.type =    LicenseEntry::Package;
145            else
146                entry.type =    LicenseEntry::Software;
147
148            entriesList.append( entry );
149        }
150    }
151
152    m_widget->setEntries( entriesList );
153}
Note: See TracBrowser for help on using the repository browser.