source: calamares/trunk/fuentes/src/modules/keyboard/KeyboardViewStep.cpp @ 7538

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

sync with github

File size: 3.7 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
4 *
5 *   Calamares is free software: you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation, either version 3 of the License, or
8 *   (at your option) any later version.
9 *
10 *   Calamares is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "KeyboardViewStep.h"
20
21#include "JobQueue.h"
22#include "GlobalStorage.h"
23
24#include "KeyboardPage.h"
25
26CALAMARES_PLUGIN_FACTORY_DEFINITION( KeyboardViewStepFactory, registerPlugin<KeyboardViewStep>(); )
27
28KeyboardViewStep::KeyboardViewStep( QObject* parent )
29    : Calamares::ViewStep( parent )
30    , m_widget( new KeyboardPage() )
31    , m_nextEnabled( false )
32    , m_writeEtcDefaultKeyboard( true )
33{
34    m_widget->init();
35    m_nextEnabled = true;
36    emit nextStatusChanged( m_nextEnabled );
37}
38
39
40KeyboardViewStep::~KeyboardViewStep()
41{
42    if ( m_widget && m_widget->parent() == nullptr )
43        m_widget->deleteLater();
44}
45
46
47QString
48KeyboardViewStep::prettyName() const
49{
50    return tr( "Keyboard" );
51}
52
53
54QString
55KeyboardViewStep::prettyStatus() const
56{
57    return m_prettyStatus;
58}
59
60
61QWidget*
62KeyboardViewStep::widget()
63{
64    return m_widget;
65}
66
67
68void
69KeyboardViewStep::next()
70{
71    //TODO: actually save those settings somewhere
72    emit done();
73}
74
75
76void
77KeyboardViewStep::back()
78{}
79
80
81bool
82KeyboardViewStep::isNextEnabled() const
83{
84    return m_nextEnabled;
85}
86
87
88bool
89KeyboardViewStep::isBackEnabled() const
90{
91    return true;
92}
93
94
95bool
96KeyboardViewStep::isAtBeginning() const
97{
98    return true;
99}
100
101
102bool
103KeyboardViewStep::isAtEnd() const
104{
105    return true;
106}
107
108
109QList< Calamares::job_ptr >
110KeyboardViewStep::jobs() const
111{
112    return m_jobs;
113}
114
115
116void
117KeyboardViewStep::onActivate()
118{
119    m_widget->onActivate();
120}
121
122
123void
124KeyboardViewStep::onLeave()
125{
126    m_widget->finalize();
127    m_jobs = m_widget->createJobs( m_xOrgConfFileName,
128                                   m_convertedKeymapPath,
129                                   m_writeEtcDefaultKeyboard );
130    m_prettyStatus = m_widget->prettyStatus();
131}
132
133
134void
135KeyboardViewStep::setConfigurationMap( const QVariantMap& configurationMap )
136{
137    if ( configurationMap.contains( "xOrgConfFileName" ) &&
138            configurationMap.value( "xOrgConfFileName" ).type() == QVariant::String &&
139            !configurationMap.value( "xOrgConfFileName" ).toString().isEmpty() )
140    {
141        m_xOrgConfFileName = configurationMap.value( "xOrgConfFileName" )
142                             .toString();
143    }
144    else
145        m_xOrgConfFileName = "00-keyboard.conf";
146
147    if ( configurationMap.contains( "convertedKeymapPath" ) &&
148            configurationMap.value( "convertedKeymapPath" ).type() == QVariant::String &&
149            !configurationMap.value( "convertedKeymapPath" ).toString().isEmpty() )
150    {
151        m_convertedKeymapPath = configurationMap.value( "convertedKeymapPath" )
152                                .toString();
153    }
154    else
155        m_convertedKeymapPath = QString();
156
157    if ( configurationMap.contains( "writeEtcDefaultKeyboard" ) &&
158            configurationMap.value( "writeEtcDefaultKeyboard" ).type() == QVariant::Bool )
159        m_writeEtcDefaultKeyboard = configurationMap.value( "writeEtcDefaultKeyboard" ).toBool();
160    else
161        m_writeEtcDefaultKeyboard = true;
162}
Note: See TracBrowser for help on using the repository browser.