[keyboard] Move configuration to the Config object
- information from the configuration file -> Config object - job creation -> Config object Ignore keyboardq for now.
This commit is contained in:
parent
0f6602cad7
commit
c7c7e6a6c1
@ -7,6 +7,7 @@ calamares_add_plugin( keyboard
|
||||
TYPE viewmodule
|
||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||
SOURCES
|
||||
Config.cpp
|
||||
KeyboardViewStep.cpp
|
||||
KeyboardPage.cpp
|
||||
KeyboardLayoutModel.cpp
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Retranslator.h"
|
||||
#include "utils/String.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QProcess>
|
||||
@ -214,16 +215,16 @@ Config::prettyStatus() const
|
||||
}
|
||||
|
||||
Calamares::JobList
|
||||
Config::createJobs( const QString& xOrgConfFileName, const QString& convertedKeymapPath, bool writeEtcDefaultKeyboard )
|
||||
Config::createJobs()
|
||||
{
|
||||
QList< Calamares::job_ptr > list;
|
||||
|
||||
Calamares::Job* j = new SetKeyboardLayoutJob( m_selectedModel,
|
||||
m_selectedLayout,
|
||||
m_selectedVariant,
|
||||
xOrgConfFileName,
|
||||
convertedKeymapPath,
|
||||
writeEtcDefaultKeyboard );
|
||||
m_xOrgConfFileName,
|
||||
m_convertedKeymapPath,
|
||||
m_writeEtcDefaultKeyboard );
|
||||
list.append( Calamares::job_ptr( j ) );
|
||||
|
||||
return list;
|
||||
@ -393,3 +394,41 @@ Config::updateVariants( const QPersistentModelIndex& currentItem, QString curren
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
using namespace CalamaresUtils;
|
||||
|
||||
if ( configurationMap.contains( "xOrgConfFileName" )
|
||||
&& configurationMap.value( "xOrgConfFileName" ).type() == QVariant::String
|
||||
&& !getString( configurationMap, "xOrgConfFileName" ).isEmpty() )
|
||||
{
|
||||
m_xOrgConfFileName = getString( configurationMap, "xOrgConfFileName" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xOrgConfFileName = "00-keyboard.conf";
|
||||
}
|
||||
|
||||
if ( configurationMap.contains( "convertedKeymapPath" )
|
||||
&& configurationMap.value( "convertedKeymapPath" ).type() == QVariant::String
|
||||
&& !getString( configurationMap, "convertedKeymapPath" ).isEmpty() )
|
||||
{
|
||||
m_convertedKeymapPath = getString( configurationMap, "convertedKeymapPath" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_convertedKeymapPath = QString();
|
||||
}
|
||||
|
||||
if ( configurationMap.contains( "writeEtcDefaultKeyboard" )
|
||||
&& configurationMap.value( "writeEtcDefaultKeyboard" ).type() == QVariant::Bool )
|
||||
{
|
||||
m_writeEtcDefaultKeyboard = getBool( configurationMap, "writeEtcDefaultKeyboard", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_writeEtcDefaultKeyboard = true;
|
||||
}
|
||||
}
|
||||
|
@ -33,13 +33,14 @@ public:
|
||||
|
||||
void init();
|
||||
|
||||
Calamares::JobList
|
||||
createJobs( const QString& xOrgConfFileName, const QString& convertedKeymapPath, bool writeEtcDefaultKeyboard );
|
||||
Calamares::JobList createJobs();
|
||||
QString prettyStatus() const;
|
||||
|
||||
void onActivate();
|
||||
void finalize();
|
||||
|
||||
void setConfigurationMap( const QVariantMap& configurationMap );
|
||||
|
||||
private:
|
||||
void guessLayout( const QStringList& langParts );
|
||||
void updateVariants( const QPersistentModelIndex& currentItem, QString currentVariant = QString() );
|
||||
@ -53,6 +54,12 @@ private:
|
||||
QString m_selectedVariant;
|
||||
QTimer m_setxkbmapTimer;
|
||||
|
||||
// From configuration
|
||||
QString m_xOrgConfFileName;
|
||||
QString m_convertedKeymapPath;
|
||||
bool m_writeEtcDefaultKeyboard = true;
|
||||
|
||||
|
||||
protected:
|
||||
KeyboardModelsModel* keyboardModels() const;
|
||||
KeyboardLayoutModel* keyboardLayouts() const;
|
||||
|
@ -9,20 +9,19 @@
|
||||
|
||||
#include "KeyboardViewStep.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include "KeyboardPage.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
|
||||
#include "utils/Variant.h"
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( KeyboardViewStepFactory, registerPlugin< KeyboardViewStep >(); )
|
||||
|
||||
KeyboardViewStep::KeyboardViewStep( QObject* parent )
|
||||
: Calamares::ViewStep( parent )
|
||||
, m_config( new Config(this) )
|
||||
, m_widget( new KeyboardPage() )
|
||||
, m_nextEnabled( false )
|
||||
, m_writeEtcDefaultKeyboard( true )
|
||||
{
|
||||
m_widget->init();
|
||||
m_nextEnabled = true;
|
||||
@ -91,7 +90,7 @@ KeyboardViewStep::isAtEnd() const
|
||||
QList< Calamares::job_ptr >
|
||||
KeyboardViewStep::jobs() const
|
||||
{
|
||||
return m_jobs;
|
||||
return m_config->createJobs();
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +105,6 @@ void
|
||||
KeyboardViewStep::onLeave()
|
||||
{
|
||||
m_widget->finalize();
|
||||
m_jobs = m_widget->createJobs( m_xOrgConfFileName, m_convertedKeymapPath, m_writeEtcDefaultKeyboard );
|
||||
m_prettyStatus = m_widget->prettyStatus();
|
||||
}
|
||||
|
||||
@ -114,37 +112,5 @@ KeyboardViewStep::onLeave()
|
||||
void
|
||||
KeyboardViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
using namespace CalamaresUtils;
|
||||
|
||||
if ( configurationMap.contains( "xOrgConfFileName" )
|
||||
&& configurationMap.value( "xOrgConfFileName" ).type() == QVariant::String
|
||||
&& !getString( configurationMap, "xOrgConfFileName" ).isEmpty() )
|
||||
{
|
||||
m_xOrgConfFileName = getString( configurationMap, "xOrgConfFileName" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xOrgConfFileName = "00-keyboard.conf";
|
||||
}
|
||||
|
||||
if ( configurationMap.contains( "convertedKeymapPath" )
|
||||
&& configurationMap.value( "convertedKeymapPath" ).type() == QVariant::String
|
||||
&& !getString( configurationMap, "convertedKeymapPath" ).isEmpty() )
|
||||
{
|
||||
m_convertedKeymapPath = getString( configurationMap, "convertedKeymapPath" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_convertedKeymapPath = QString();
|
||||
}
|
||||
|
||||
if ( configurationMap.contains( "writeEtcDefaultKeyboard" )
|
||||
&& configurationMap.value( "writeEtcDefaultKeyboard" ).type() == QVariant::Bool )
|
||||
{
|
||||
m_writeEtcDefaultKeyboard = getBool( configurationMap, "writeEtcDefaultKeyboard", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_writeEtcDefaultKeyboard = true;
|
||||
}
|
||||
m_config->setConfigurationMap(configurationMap);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Config;
|
||||
class KeyboardPage;
|
||||
|
||||
class PLUGINDLLEXPORT KeyboardViewStep : public Calamares::ViewStep
|
||||
@ -46,15 +47,10 @@ public:
|
||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||
|
||||
private:
|
||||
Config* m_config;
|
||||
KeyboardPage* m_widget;
|
||||
bool m_nextEnabled;
|
||||
QString m_prettyStatus;
|
||||
|
||||
QString m_xOrgConfFileName;
|
||||
QString m_convertedKeymapPath;
|
||||
bool m_writeEtcDefaultKeyboard;
|
||||
|
||||
Calamares::JobList m_jobs;
|
||||
};
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( KeyboardViewStepFactory )
|
||||
|
@ -79,7 +79,7 @@ void
|
||||
KeyboardQmlViewStep::onLeave()
|
||||
{
|
||||
m_config->finalize();
|
||||
m_jobs = m_config->createJobs( m_xOrgConfFileName, m_convertedKeymapPath, m_writeEtcDefaultKeyboard );
|
||||
// m_jobs = m_config->createJobs( m_xOrgConfFileName, m_convertedKeymapPath, m_writeEtcDefaultKeyboard );
|
||||
m_prettyStatus = m_config->prettyStatus();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user