1 /* === This file is part of Calamares - <https://calamares.io> ===
2  *
3  *   SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
4  *   SPDX-License-Identifier: GPL-3.0-or-later
5  *
6  *   Calamares is Free Software: see the License-Identifier above.
7  *
8  */
9 
10 #include "KeyboardViewStep.h"
11 
12 #include "Config.h"
13 #include "KeyboardPage.h"
14 
15 #include "GlobalStorage.h"
16 #include "JobQueue.h"
17 
CALAMARES_PLUGIN_FACTORY_DEFINITION(KeyboardViewStepFactory,registerPlugin<KeyboardViewStep> ();)18 CALAMARES_PLUGIN_FACTORY_DEFINITION( KeyboardViewStepFactory, registerPlugin< KeyboardViewStep >(); )
19 
20 KeyboardViewStep::KeyboardViewStep( QObject* parent )
21     : Calamares::ViewStep( parent )
22     , m_config( new Config( this ) )
23     , m_widget( new KeyboardPage( m_config ) )
24 {
25     m_config->detectCurrentKeyboardLayout();
26     emit nextStatusChanged( true );
27 }
28 
29 
~KeyboardViewStep()30 KeyboardViewStep::~KeyboardViewStep()
31 {
32     if ( m_widget && m_widget->parent() == nullptr )
33     {
34         m_widget->deleteLater();
35     }
36 }
37 
38 
39 QString
prettyName() const40 KeyboardViewStep::prettyName() const
41 {
42     return tr( "Keyboard" );
43 }
44 
45 
46 QString
prettyStatus() const47 KeyboardViewStep::prettyStatus() const
48 {
49     return m_config->prettyStatus();
50 }
51 
52 
53 QWidget*
widget()54 KeyboardViewStep::widget()
55 {
56     return m_widget;
57 }
58 
59 
60 bool
isNextEnabled() const61 KeyboardViewStep::isNextEnabled() const
62 {
63     return true;
64 }
65 
66 
67 bool
isBackEnabled() const68 KeyboardViewStep::isBackEnabled() const
69 {
70     return true;
71 }
72 
73 
74 bool
isAtBeginning() const75 KeyboardViewStep::isAtBeginning() const
76 {
77     return true;
78 }
79 
80 
81 bool
isAtEnd() const82 KeyboardViewStep::isAtEnd() const
83 {
84     return true;
85 }
86 
87 
88 QList< Calamares::job_ptr >
jobs() const89 KeyboardViewStep::jobs() const
90 {
91     return m_config->createJobs();
92 }
93 
94 
95 void
onActivate()96 KeyboardViewStep::onActivate()
97 {
98     m_config->guessLocaleKeyboardLayout();
99 }
100 
101 
102 void
onLeave()103 KeyboardViewStep::onLeave()
104 {
105     m_config->finalize();
106 }
107 
108 
109 void
setConfigurationMap(const QVariantMap & configurationMap)110 KeyboardViewStep::setConfigurationMap( const QVariantMap& configurationMap )
111 {
112     m_config->setConfigurationMap( configurationMap );
113 }
114