mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-25 03:15:44 -05:00
[keyboardq] apply the style script
This commit is contained in:
parent
1a46e08cc2
commit
835850c02a
11 changed files with 411 additions and 342 deletions
|
@ -19,19 +19,20 @@
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
#include "keyboardwidget/keyboardpreview.h"
|
|
||||||
#include "SetKeyboardLayoutJob.h"
|
#include "SetKeyboardLayoutJob.h"
|
||||||
|
#include "keyboardwidget/keyboardpreview.h"
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QProcess>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
KeyboardModelsModel::KeyboardModelsModel(QObject* parent) : QAbstractListModel(parent)
|
KeyboardModelsModel::KeyboardModelsModel( QObject* parent )
|
||||||
|
: QAbstractListModel( parent )
|
||||||
{
|
{
|
||||||
detectModels();
|
detectModels();
|
||||||
}
|
}
|
||||||
|
@ -47,8 +48,9 @@ KeyboardModelsModel::detectModels()
|
||||||
index++;
|
index++;
|
||||||
m_list << QMap< QString, QString > { { "label", key }, { "key", models[ key ] } };
|
m_list << QMap< QString, QString > { { "label", key }, { "key", models[ key ] } };
|
||||||
if ( models[ key ] == "pc105" )
|
if ( models[ key ] == "pc105" )
|
||||||
|
{
|
||||||
this->setCurrentIndex( index );
|
this->setCurrentIndex( index );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +67,9 @@ QVariant
|
||||||
KeyboardModelsModel::data( const QModelIndex& index, int role ) const
|
KeyboardModelsModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
const auto item = m_list.at( index.row() );
|
const auto item = m_list.at( index.row() );
|
||||||
return role == Qt::DisplayRole ? item[ "label" ] : item[ "key" ];
|
return role == Qt::DisplayRole ? item[ "label" ] : item[ "key" ];
|
||||||
}
|
}
|
||||||
|
@ -92,7 +96,9 @@ const QMap<QString, QString>
|
||||||
KeyboardModelsModel::item( const int& index ) const
|
KeyboardModelsModel::item( const int& index ) const
|
||||||
{
|
{
|
||||||
if ( index >= m_list.count() || index < 0 )
|
if ( index >= m_list.count() || index < 0 )
|
||||||
|
{
|
||||||
return QMap< QString, QString >();
|
return QMap< QString, QString >();
|
||||||
|
}
|
||||||
|
|
||||||
return m_list.at( index );
|
return m_list.at( index );
|
||||||
}
|
}
|
||||||
|
@ -101,7 +107,9 @@ const QMap<QString, QString>
|
||||||
KeyboardVariantsModel::item( const int& index ) const
|
KeyboardVariantsModel::item( const int& index ) const
|
||||||
{
|
{
|
||||||
if ( index >= m_list.count() || index < 0 )
|
if ( index >= m_list.count() || index < 0 )
|
||||||
|
{
|
||||||
return QMap< QString, QString >();
|
return QMap< QString, QString >();
|
||||||
|
}
|
||||||
|
|
||||||
return m_list.at( index );
|
return m_list.at( index );
|
||||||
}
|
}
|
||||||
|
@ -110,14 +118,18 @@ void
|
||||||
KeyboardModelsModel::setCurrentIndex( const int& index )
|
KeyboardModelsModel::setCurrentIndex( const int& index )
|
||||||
{
|
{
|
||||||
if ( index >= m_list.count() || index < 0 )
|
if ( index >= m_list.count() || index < 0 )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
emit currentIndexChanged( m_currentIndex );
|
emit currentIndexChanged( m_currentIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardVariantsModel::KeyboardVariantsModel(QObject *parent) : QAbstractListModel(parent)
|
KeyboardVariantsModel::KeyboardVariantsModel( QObject* parent )
|
||||||
{}
|
: QAbstractListModel( parent )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
KeyboardVariantsModel::currentIndex() const
|
KeyboardVariantsModel::currentIndex() const
|
||||||
|
@ -129,7 +141,9 @@ void
|
||||||
KeyboardVariantsModel::setCurrentIndex( const int& index )
|
KeyboardVariantsModel::setCurrentIndex( const int& index )
|
||||||
{
|
{
|
||||||
if ( index >= m_list.count() || index < 0 )
|
if ( index >= m_list.count() || index < 0 )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
emit currentIndexChanged( m_currentIndex );
|
emit currentIndexChanged( m_currentIndex );
|
||||||
|
@ -139,7 +153,9 @@ QVariant
|
||||||
KeyboardVariantsModel::data( const QModelIndex& index, int role ) const
|
KeyboardVariantsModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
const auto item = m_list.at( index.row() );
|
const auto item = m_list.at( index.row() );
|
||||||
return role == Qt::DisplayRole ? item[ "label" ] : item[ "key" ];
|
return role == Qt::DisplayRole ? item[ "label" ] : item[ "key" ];
|
||||||
}
|
}
|
||||||
|
@ -172,15 +188,19 @@ KeyboardVariantsModel::setVariants(QMap< QString, QString > variants)
|
||||||
/* Returns stringlist with suitable setxkbmap command-line arguments
|
/* Returns stringlist with suitable setxkbmap command-line arguments
|
||||||
* to set the given @p layout and @p variant.
|
* to set the given @p layout and @p variant.
|
||||||
*/
|
*/
|
||||||
static inline QStringList xkbmap_args( const QString& layout, const QString& variant )
|
static inline QStringList
|
||||||
|
xkbmap_args( const QString& layout, const QString& variant )
|
||||||
{
|
{
|
||||||
QStringList r { "-layout", layout };
|
QStringList r { "-layout", layout };
|
||||||
if ( !variant.isEmpty() )
|
if ( !variant.isEmpty() )
|
||||||
|
{
|
||||||
r << "-variant" << variant;
|
r << "-variant" << variant;
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::Config(QObject *parent) : QObject(parent)
|
Config::Config( QObject* parent )
|
||||||
|
: QObject( parent )
|
||||||
, m_keyboardModelsModel( new KeyboardModelsModel( this ) )
|
, m_keyboardModelsModel( new KeyboardModelsModel( this ) )
|
||||||
, m_keyboardLayoutsModel( new KeyboardLayoutModel( this ) )
|
, m_keyboardLayoutsModel( new KeyboardLayoutModel( this ) )
|
||||||
, m_keyboardVariantsModel( new KeyboardVariantsModel( this ) )
|
, m_keyboardVariantsModel( new KeyboardVariantsModel( this ) )
|
||||||
|
@ -188,26 +208,20 @@ Config::Config(QObject *parent) : QObject(parent)
|
||||||
m_setxkbmapTimer.setSingleShot( true );
|
m_setxkbmapTimer.setSingleShot( true );
|
||||||
|
|
||||||
// Connect signals and slots
|
// Connect signals and slots
|
||||||
connect( m_keyboardModelsModel, &KeyboardModelsModel::currentIndexChanged,
|
connect( m_keyboardModelsModel, &KeyboardModelsModel::currentIndexChanged, [&]( int index ) {
|
||||||
[&](int index)
|
|
||||||
{
|
|
||||||
m_selectedModel = m_keyboardModelsModel->item( index ).value( "key", "pc105" );
|
m_selectedModel = m_keyboardModelsModel->item( index ).value( "key", "pc105" );
|
||||||
// Set Xorg keyboard model
|
// Set Xorg keyboard model
|
||||||
QProcess::execute( "setxkbmap", QStringList { "-model", m_selectedModel } );
|
QProcess::execute( "setxkbmap", QStringList { "-model", m_selectedModel } );
|
||||||
emit prettyStatusChanged();
|
emit prettyStatusChanged();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
connect( m_keyboardLayoutsModel, &KeyboardLayoutModel::currentIndexChanged,
|
connect( m_keyboardLayoutsModel, &KeyboardLayoutModel::currentIndexChanged, [&]( int index ) {
|
||||||
[&](int index)
|
|
||||||
{
|
|
||||||
m_selectedLayout = m_keyboardLayoutsModel->item( index ).first;
|
m_selectedLayout = m_keyboardLayoutsModel->item( index ).first;
|
||||||
updateVariants( QPersistentModelIndex( m_keyboardLayoutsModel->index( index ) ) );
|
updateVariants( QPersistentModelIndex( m_keyboardLayoutsModel->index( index ) ) );
|
||||||
emit prettyStatusChanged();
|
emit prettyStatusChanged();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
connect( m_keyboardVariantsModel, &KeyboardVariantsModel::currentIndexChanged,
|
connect( m_keyboardVariantsModel, &KeyboardVariantsModel::currentIndexChanged, [&]( int index ) {
|
||||||
[&](int index)
|
|
||||||
{
|
|
||||||
m_selectedVariant = m_keyboardVariantsModel->item( index )[ "key" ];
|
m_selectedVariant = m_keyboardVariantsModel->item( index )[ "key" ];
|
||||||
|
|
||||||
// Set Xorg keyboard layout
|
// Set Xorg keyboard layout
|
||||||
|
@ -217,9 +231,7 @@ Config::Config(QObject *parent) : QObject(parent)
|
||||||
m_setxkbmapTimer.disconnect( this );
|
m_setxkbmapTimer.disconnect( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
connect( &m_setxkbmapTimer, &QTimer::timeout,
|
connect( &m_setxkbmapTimer, &QTimer::timeout, this, [=] {
|
||||||
this, [=]
|
|
||||||
{
|
|
||||||
QProcess::execute( "setxkbmap", xkbmap_args( m_selectedLayout, m_selectedVariant ) );
|
QProcess::execute( "setxkbmap", xkbmap_args( m_selectedLayout, m_selectedVariant ) );
|
||||||
cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant;
|
cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant;
|
||||||
m_setxkbmapTimer.disconnect( this );
|
m_setxkbmapTimer.disconnect( this );
|
||||||
|
@ -255,10 +267,11 @@ findLayout( const KeyboardLayoutModel* klm, const QString& currentLayout )
|
||||||
for ( int i = 0; i < klm->rowCount(); ++i )
|
for ( int i = 0; i < klm->rowCount(); ++i )
|
||||||
{
|
{
|
||||||
QModelIndex idx = klm->index( i );
|
QModelIndex idx = klm->index( i );
|
||||||
if ( idx.isValid() &&
|
if ( idx.isValid() && idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() == currentLayout )
|
||||||
idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() == currentLayout )
|
{
|
||||||
currentLayoutItem = idx;
|
currentLayoutItem = idx;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return currentLayoutItem;
|
return currentLayoutItem;
|
||||||
}
|
}
|
||||||
|
@ -274,18 +287,17 @@ Config::init()
|
||||||
|
|
||||||
if ( process.waitForFinished() )
|
if ( process.waitForFinished() )
|
||||||
{
|
{
|
||||||
const QStringList list = QString( process.readAll() )
|
const QStringList list = QString( process.readAll() ).split( "\n", QString::SkipEmptyParts );
|
||||||
.split( "\n", QString::SkipEmptyParts );
|
|
||||||
|
|
||||||
for ( QString line : list )
|
for ( QString line : list )
|
||||||
{
|
{
|
||||||
line = line.trimmed();
|
line = line.trimmed();
|
||||||
if ( !line.startsWith( "xkb_symbols" ) )
|
if ( !line.startsWith( "xkb_symbols" ) )
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
line = line.remove( "}" )
|
line = line.remove( "}" ).remove( "{" ).remove( ";" );
|
||||||
.remove( "{" )
|
|
||||||
.remove( ";" );
|
|
||||||
line = line.mid( line.indexOf( "\"" ) + 1 );
|
line = line.mid( line.indexOf( "\"" ) + 1 );
|
||||||
|
|
||||||
QStringList split = line.split( "+", QString::SkipEmptyParts );
|
QStringList split = line.split( "+", QString::SkipEmptyParts );
|
||||||
|
@ -296,12 +308,9 @@ Config::init()
|
||||||
if ( currentLayout.contains( "(" ) )
|
if ( currentLayout.contains( "(" ) )
|
||||||
{
|
{
|
||||||
int parenthesisIndex = currentLayout.indexOf( "(" );
|
int parenthesisIndex = currentLayout.indexOf( "(" );
|
||||||
currentVariant = currentLayout.mid( parenthesisIndex + 1 )
|
currentVariant = currentLayout.mid( parenthesisIndex + 1 ).trimmed();
|
||||||
.trimmed();
|
|
||||||
currentVariant.chop( 1 );
|
currentVariant.chop( 1 );
|
||||||
currentLayout = currentLayout
|
currentLayout = currentLayout.mid( 0, parenthesisIndex ).trimmed();
|
||||||
.mid( 0, parenthesisIndex )
|
|
||||||
.trimmed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -311,9 +320,7 @@ Config::init()
|
||||||
|
|
||||||
//### Layouts and Variants
|
//### Layouts and Variants
|
||||||
QPersistentModelIndex currentLayoutItem = findLayout( m_keyboardLayoutsModel, currentLayout );
|
QPersistentModelIndex currentLayoutItem = findLayout( m_keyboardLayoutsModel, currentLayout );
|
||||||
if ( !currentLayoutItem.isValid() && (
|
if ( !currentLayoutItem.isValid() && ( ( currentLayout == "latin" ) || ( currentLayout == "pc" ) ) )
|
||||||
( currentLayout == "latin" )
|
|
||||||
|| ( currentLayout == "pc" ) ) )
|
|
||||||
{
|
{
|
||||||
currentLayout = "us";
|
currentLayout = "us";
|
||||||
currentLayoutItem = findLayout( m_keyboardLayoutsModel, currentLayout );
|
currentLayoutItem = findLayout( m_keyboardLayoutsModel, currentLayout );
|
||||||
|
@ -329,17 +336,22 @@ Config::init()
|
||||||
// Default to the first available layout if none was set
|
// Default to the first available layout if none was set
|
||||||
// Do this after unblocking signals so we get the default variant handling.
|
// Do this after unblocking signals so we get the default variant handling.
|
||||||
if ( !currentLayoutItem.isValid() && m_keyboardLayoutsModel->rowCount() > 0 )
|
if ( !currentLayoutItem.isValid() && m_keyboardLayoutsModel->rowCount() > 0 )
|
||||||
|
{
|
||||||
m_keyboardLayoutsModel->setCurrentIndex( m_keyboardLayoutsModel->index( 0 ).row() );
|
m_keyboardLayoutsModel->setCurrentIndex( m_keyboardLayoutsModel->index( 0 ).row() );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
Config::prettyStatus() const
|
Config::prettyStatus() const
|
||||||
{
|
{
|
||||||
QString status;
|
QString status;
|
||||||
status += tr( "Set keyboard model to %1.<br/>" ).arg( m_keyboardModelsModel->item(m_keyboardModelsModel->currentIndex())["label"] );
|
status += tr( "Set keyboard model to %1.<br/>" )
|
||||||
|
.arg( m_keyboardModelsModel->item( m_keyboardModelsModel->currentIndex() )[ "label" ] );
|
||||||
|
|
||||||
QString layout = m_keyboardLayoutsModel->item( m_keyboardLayoutsModel->currentIndex() ).second.description;
|
QString layout = m_keyboardLayoutsModel->item( m_keyboardLayoutsModel->currentIndex() ).second.description;
|
||||||
QString variant = m_keyboardVariantsModel->currentIndex() >= 0 ? m_keyboardVariantsModel->item(m_keyboardVariantsModel->currentIndex())["label"] : QString( "<default>" );
|
QString variant = m_keyboardVariantsModel->currentIndex() >= 0
|
||||||
|
? m_keyboardVariantsModel->item( m_keyboardVariantsModel->currentIndex() )[ "label" ]
|
||||||
|
: QString( "<default>" );
|
||||||
status += tr( "Set keyboard layout to %1/%2." ).arg( layout, variant );
|
status += tr( "Set keyboard layout to %1/%2." ).arg( layout, variant );
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
@ -371,7 +383,8 @@ Config::guessLayout(const QStringList& langParts)
|
||||||
for ( int i = 0; i < m_keyboardLayoutsModel->rowCount(); ++i )
|
for ( int i = 0; i < m_keyboardLayoutsModel->rowCount(); ++i )
|
||||||
{
|
{
|
||||||
QModelIndex idx = m_keyboardLayoutsModel->index( i );
|
QModelIndex idx = m_keyboardLayoutsModel->index( i );
|
||||||
QString name = idx.isValid() ? idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() : QString();
|
QString name
|
||||||
|
= idx.isValid() ? idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() : QString();
|
||||||
if ( idx.isValid() && ( name.compare( *countryPart, Qt::CaseInsensitive ) == 0 ) )
|
if ( idx.isValid() && ( name.compare( *countryPart, Qt::CaseInsensitive ) == 0 ) )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "matched" << name;
|
cDebug() << Logger::SubEntry << "matched" << name;
|
||||||
|
@ -388,10 +401,13 @@ Config::guessLayout(const QStringList& langParts)
|
||||||
cDebug() << "Next level:" << *countryPart;
|
cDebug() << "Next level:" << *countryPart;
|
||||||
for ( int variantnumber = 0; variantnumber < m_keyboardVariantsModel->rowCount(); ++variantnumber )
|
for ( int variantnumber = 0; variantnumber < m_keyboardVariantsModel->rowCount(); ++variantnumber )
|
||||||
{
|
{
|
||||||
if ( m_keyboardVariantsModel->item(variantnumber)["key"].compare( *countryPart, Qt::CaseInsensitive ) )
|
if ( m_keyboardVariantsModel->item( variantnumber )[ "key" ].compare( *countryPart,
|
||||||
|
Qt::CaseInsensitive ) )
|
||||||
{
|
{
|
||||||
m_keyboardVariantsModel->setCurrentIndex( variantnumber );
|
m_keyboardVariantsModel->setCurrentIndex( variantnumber );
|
||||||
cDebug() << Logger::SubEntry << "matched variant" << m_keyboardVariantsModel->item(variantnumber)["key"] << ' ' <<m_keyboardVariantsModel->item(variantnumber)["key"];
|
cDebug() << Logger::SubEntry << "matched variant"
|
||||||
|
<< m_keyboardVariantsModel->item( variantnumber )[ "key" ] << ' '
|
||||||
|
<< m_keyboardVariantsModel->item( variantnumber )[ "key" ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,10 +473,14 @@ Config::onActivate()
|
||||||
// Chop off .codeset and @modifier
|
// Chop off .codeset and @modifier
|
||||||
int index = lang.indexOf( '.' );
|
int index = lang.indexOf( '.' );
|
||||||
if ( index >= 0 )
|
if ( index >= 0 )
|
||||||
|
{
|
||||||
lang.truncate( index );
|
lang.truncate( index );
|
||||||
|
}
|
||||||
index = lang.indexOf( '@' );
|
index = lang.indexOf( '@' );
|
||||||
if ( index >= 0 )
|
if ( index >= 0 )
|
||||||
|
{
|
||||||
lang.truncate( index );
|
lang.truncate( index );
|
||||||
|
}
|
||||||
|
|
||||||
lang.replace( '-', '_' ); // Normalize separators
|
lang.replace( '-', '_' ); // Normalize separators
|
||||||
}
|
}
|
||||||
|
@ -517,4 +537,3 @@ Config::updateVariants(const QPersistentModelIndex& currentItem, QString current
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,11 @@
|
||||||
#include "Job.h"
|
#include "Job.h"
|
||||||
#include "KeyboardLayoutModel.h"
|
#include "KeyboardLayoutModel.h"
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
class KeyboardModelsModel : public QAbstractListModel
|
class KeyboardModelsModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
|
@ -99,9 +99,8 @@ public:
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
Calamares::JobList createJobs( const QString& xOrgConfFileName,
|
Calamares::JobList
|
||||||
const QString& convertedKeymapPath,
|
createJobs( const QString& xOrgConfFileName, const QString& convertedKeymapPath, bool writeEtcDefaultKeyboard );
|
||||||
bool writeEtcDefaultKeyboard );
|
|
||||||
QString prettyStatus() const;
|
QString prettyStatus() const;
|
||||||
|
|
||||||
void onActivate();
|
void onActivate();
|
||||||
|
@ -109,8 +108,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void guessLayout( const QStringList& langParts );
|
void guessLayout( const QStringList& langParts );
|
||||||
void updateVariants( const QPersistentModelIndex& currentItem,
|
void updateVariants( const QPersistentModelIndex& currentItem, QString currentVariant = QString() );
|
||||||
QString currentVariant = QString() );
|
|
||||||
|
|
||||||
KeyboardModelsModel* m_keyboardModelsModel;
|
KeyboardModelsModel* m_keyboardModelsModel;
|
||||||
KeyboardLayoutModel* m_keyboardLayoutsModel;
|
KeyboardLayoutModel* m_keyboardLayoutsModel;
|
||||||
|
|
|
@ -40,7 +40,9 @@ QVariant
|
||||||
KeyboardLayoutModel::data( const QModelIndex& index, int role ) const
|
KeyboardLayoutModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
switch ( role )
|
switch ( role )
|
||||||
{
|
{
|
||||||
|
@ -59,7 +61,9 @@ const QPair< QString, KeyboardGlobal::KeyboardInfo >
|
||||||
KeyboardLayoutModel::item( const int& index ) const
|
KeyboardLayoutModel::item( const int& index ) const
|
||||||
{
|
{
|
||||||
if ( index >= m_layouts.count() || index < 0 )
|
if ( index >= m_layouts.count() || index < 0 )
|
||||||
|
{
|
||||||
return QPair< QString, KeyboardGlobal::KeyboardInfo >();
|
return QPair< QString, KeyboardGlobal::KeyboardInfo >();
|
||||||
|
}
|
||||||
|
|
||||||
return m_layouts.at( index );
|
return m_layouts.at( index );
|
||||||
}
|
}
|
||||||
|
@ -67,15 +71,16 @@ KeyboardLayoutModel::item(const int &index) const
|
||||||
void
|
void
|
||||||
KeyboardLayoutModel::init()
|
KeyboardLayoutModel::init()
|
||||||
{
|
{
|
||||||
KeyboardGlobal::LayoutsMap layouts =
|
KeyboardGlobal::LayoutsMap layouts = KeyboardGlobal::getKeyboardLayouts();
|
||||||
KeyboardGlobal::getKeyboardLayouts();
|
for ( KeyboardGlobal::LayoutsMap::const_iterator it = layouts.constBegin(); it != layouts.constEnd(); ++it )
|
||||||
for ( KeyboardGlobal::LayoutsMap::const_iterator it = layouts.constBegin();
|
|
||||||
it != layouts.constEnd(); ++it )
|
|
||||||
m_layouts.append( qMakePair( it.key(), it.value() ) );
|
|
||||||
|
|
||||||
std::stable_sort( m_layouts.begin(), m_layouts.end(), []( const QPair< QString, KeyboardGlobal::KeyboardInfo >& a,
|
|
||||||
const QPair< QString, KeyboardGlobal::KeyboardInfo >& b )
|
|
||||||
{
|
{
|
||||||
|
m_layouts.append( qMakePair( it.key(), it.value() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
std::stable_sort( m_layouts.begin(),
|
||||||
|
m_layouts.end(),
|
||||||
|
[]( const QPair< QString, KeyboardGlobal::KeyboardInfo >& a,
|
||||||
|
const QPair< QString, KeyboardGlobal::KeyboardInfo >& b ) {
|
||||||
return a.second.description < b.second.description;
|
return a.second.description < b.second.description;
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -90,7 +95,9 @@ void
|
||||||
KeyboardLayoutModel::setCurrentIndex( const int& index )
|
KeyboardLayoutModel::setCurrentIndex( const int& index )
|
||||||
{
|
{
|
||||||
if ( index >= m_layouts.count() || index < 0 )
|
if ( index >= m_layouts.count() || index < 0 )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
emit currentIndexChanged( m_currentIndex );
|
emit currentIndexChanged( m_currentIndex );
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
|
|
||||||
#include "KeyboardPage.h"
|
#include "KeyboardPage.h"
|
||||||
|
|
||||||
#include "ui_KeyboardPage.h"
|
|
||||||
#include "keyboardwidget/keyboardpreview.h"
|
|
||||||
#include "SetKeyboardLayoutJob.h"
|
|
||||||
#include "KeyboardLayoutModel.h"
|
#include "KeyboardLayoutModel.h"
|
||||||
|
#include "SetKeyboardLayoutJob.h"
|
||||||
|
#include "keyboardwidget/keyboardpreview.h"
|
||||||
|
#include "ui_KeyboardPage.h"
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
@ -45,9 +45,7 @@ public:
|
||||||
virtual ~LayoutItem();
|
virtual ~LayoutItem();
|
||||||
};
|
};
|
||||||
|
|
||||||
LayoutItem::~LayoutItem()
|
LayoutItem::~LayoutItem() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static QPersistentModelIndex
|
static QPersistentModelIndex
|
||||||
findLayout( const KeyboardLayoutModel* klm, const QString& currentLayout )
|
findLayout( const KeyboardLayoutModel* klm, const QString& currentLayout )
|
||||||
|
@ -57,10 +55,11 @@ findLayout( const KeyboardLayoutModel* klm, const QString& currentLayout )
|
||||||
for ( int i = 0; i < klm->rowCount(); ++i )
|
for ( int i = 0; i < klm->rowCount(); ++i )
|
||||||
{
|
{
|
||||||
QModelIndex idx = klm->index( i );
|
QModelIndex idx = klm->index( i );
|
||||||
if ( idx.isValid() &&
|
if ( idx.isValid() && idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() == currentLayout )
|
||||||
idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() == currentLayout )
|
{
|
||||||
currentLayoutItem = idx;
|
currentLayoutItem = idx;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return currentLayoutItem;
|
return currentLayoutItem;
|
||||||
}
|
}
|
||||||
|
@ -79,19 +78,14 @@ KeyboardPage::KeyboardPage( QWidget* parent )
|
||||||
m_setxkbmapTimer.setSingleShot( true );
|
m_setxkbmapTimer.setSingleShot( true );
|
||||||
|
|
||||||
// Connect signals and slots
|
// Connect signals and slots
|
||||||
connect( ui->listVariant, &QListWidget::currentItemChanged,
|
connect( ui->listVariant, &QListWidget::currentItemChanged, this, &KeyboardPage::onListVariantCurrentItemChanged );
|
||||||
this, &KeyboardPage::onListVariantCurrentItemChanged );
|
|
||||||
|
|
||||||
connect( ui->buttonRestore, &QPushButton::clicked,
|
connect(
|
||||||
[this]
|
ui->buttonRestore, &QPushButton::clicked, [this] { ui->comboBoxModel->setCurrentIndex( m_defaultIndex ); } );
|
||||||
{
|
|
||||||
ui->comboBoxModel->setCurrentIndex( m_defaultIndex );
|
|
||||||
} );
|
|
||||||
|
|
||||||
connect( ui->comboBoxModel,
|
connect( ui->comboBoxModel,
|
||||||
static_cast< void ( QComboBox::* )( const QString& ) >( &QComboBox::currentIndexChanged ),
|
static_cast< void ( QComboBox::* )( const QString& ) >( &QComboBox::currentIndexChanged ),
|
||||||
[this]( const QString& text )
|
[this]( const QString& text ) {
|
||||||
{
|
|
||||||
QString model = m_models.value( text, "pc105" );
|
QString model = m_models.value( text, "pc105" );
|
||||||
|
|
||||||
// Set Xorg keyboard model
|
// Set Xorg keyboard model
|
||||||
|
@ -119,18 +113,17 @@ KeyboardPage::init()
|
||||||
|
|
||||||
if ( process.waitForFinished() )
|
if ( process.waitForFinished() )
|
||||||
{
|
{
|
||||||
const QStringList list = QString( process.readAll() )
|
const QStringList list = QString( process.readAll() ).split( "\n", QString::SkipEmptyParts );
|
||||||
.split( "\n", QString::SkipEmptyParts );
|
|
||||||
|
|
||||||
for ( QString line : list )
|
for ( QString line : list )
|
||||||
{
|
{
|
||||||
line = line.trimmed();
|
line = line.trimmed();
|
||||||
if ( !line.startsWith( "xkb_symbols" ) )
|
if ( !line.startsWith( "xkb_symbols" ) )
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
line = line.remove( "}" )
|
line = line.remove( "}" ).remove( "{" ).remove( ";" );
|
||||||
.remove( "{" )
|
|
||||||
.remove( ";" );
|
|
||||||
line = line.mid( line.indexOf( "\"" ) + 1 );
|
line = line.mid( line.indexOf( "\"" ) + 1 );
|
||||||
|
|
||||||
QStringList split = line.split( "+", QString::SkipEmptyParts );
|
QStringList split = line.split( "+", QString::SkipEmptyParts );
|
||||||
|
@ -141,12 +134,9 @@ KeyboardPage::init()
|
||||||
if ( currentLayout.contains( "(" ) )
|
if ( currentLayout.contains( "(" ) )
|
||||||
{
|
{
|
||||||
int parenthesisIndex = currentLayout.indexOf( "(" );
|
int parenthesisIndex = currentLayout.indexOf( "(" );
|
||||||
currentVariant = currentLayout.mid( parenthesisIndex + 1 )
|
currentVariant = currentLayout.mid( parenthesisIndex + 1 ).trimmed();
|
||||||
.trimmed();
|
|
||||||
currentVariant.chop( 1 );
|
currentVariant.chop( 1 );
|
||||||
currentLayout = currentLayout
|
currentLayout = currentLayout.mid( 0, parenthesisIndex ).trimmed();
|
||||||
.mid( 0, parenthesisIndex )
|
|
||||||
.trimmed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -165,7 +155,9 @@ KeyboardPage::init()
|
||||||
mi.next();
|
mi.next();
|
||||||
|
|
||||||
if ( mi.value() == "pc105" )
|
if ( mi.value() == "pc105" )
|
||||||
|
{
|
||||||
m_defaultIndex = ui->comboBoxModel->count();
|
m_defaultIndex = ui->comboBoxModel->count();
|
||||||
|
}
|
||||||
|
|
||||||
ui->comboBoxModel->addItem( mi.key() );
|
ui->comboBoxModel->addItem( mi.key() );
|
||||||
}
|
}
|
||||||
|
@ -180,16 +172,16 @@ KeyboardPage::init()
|
||||||
|
|
||||||
KeyboardLayoutModel* klm = new KeyboardLayoutModel( this );
|
KeyboardLayoutModel* klm = new KeyboardLayoutModel( this );
|
||||||
ui->listLayout->setModel( klm );
|
ui->listLayout->setModel( klm );
|
||||||
connect( ui->listLayout->selectionModel(), &QItemSelectionModel::currentChanged,
|
connect( ui->listLayout->selectionModel(),
|
||||||
this, &KeyboardPage::onListLayoutCurrentItemChanged );
|
&QItemSelectionModel::currentChanged,
|
||||||
|
this,
|
||||||
|
&KeyboardPage::onListLayoutCurrentItemChanged );
|
||||||
|
|
||||||
// Block signals
|
// Block signals
|
||||||
ui->listLayout->blockSignals( true );
|
ui->listLayout->blockSignals( true );
|
||||||
|
|
||||||
QPersistentModelIndex currentLayoutItem = findLayout( klm, currentLayout );
|
QPersistentModelIndex currentLayoutItem = findLayout( klm, currentLayout );
|
||||||
if ( !currentLayoutItem.isValid() && (
|
if ( !currentLayoutItem.isValid() && ( ( currentLayout == "latin" ) || ( currentLayout == "pc" ) ) )
|
||||||
( currentLayout == "latin" )
|
|
||||||
|| ( currentLayout == "pc" ) ) )
|
|
||||||
{
|
{
|
||||||
currentLayout = "us";
|
currentLayout = "us";
|
||||||
currentLayoutItem = findLayout( klm, currentLayout );
|
currentLayoutItem = findLayout( klm, currentLayout );
|
||||||
|
@ -208,8 +200,10 @@ KeyboardPage::init()
|
||||||
// Default to the first available layout if none was set
|
// Default to the first available layout if none was set
|
||||||
// Do this after unblocking signals so we get the default variant handling.
|
// Do this after unblocking signals so we get the default variant handling.
|
||||||
if ( !currentLayoutItem.isValid() && klm->rowCount() > 0 )
|
if ( !currentLayoutItem.isValid() && klm->rowCount() > 0 )
|
||||||
|
{
|
||||||
ui->listLayout->setCurrentIndex( klm->index( 0 ) );
|
ui->listLayout->setCurrentIndex( klm->index( 0 ) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
|
@ -232,8 +226,7 @@ KeyboardPage::createJobs( const QString& xOrgConfFileName,
|
||||||
bool writeEtcDefaultKeyboard )
|
bool writeEtcDefaultKeyboard )
|
||||||
{
|
{
|
||||||
QList< Calamares::job_ptr > list;
|
QList< Calamares::job_ptr > list;
|
||||||
QString selectedModel = m_models.value( ui->comboBoxModel->currentText(),
|
QString selectedModel = m_models.value( ui->comboBoxModel->currentText(), "pc105" );
|
||||||
"pc105" );
|
|
||||||
|
|
||||||
Calamares::Job* j = new SetKeyboardLayoutJob( selectedModel,
|
Calamares::Job* j = new SetKeyboardLayoutJob( selectedModel,
|
||||||
m_selectedLayout,
|
m_selectedLayout,
|
||||||
|
@ -258,7 +251,8 @@ KeyboardPage::guessLayout( const QStringList& langParts )
|
||||||
for ( int i = 0; i < klm->rowCount(); ++i )
|
for ( int i = 0; i < klm->rowCount(); ++i )
|
||||||
{
|
{
|
||||||
QModelIndex idx = klm->index( i );
|
QModelIndex idx = klm->index( i );
|
||||||
QString name = idx.isValid() ? idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() : QString();
|
QString name
|
||||||
|
= idx.isValid() ? idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() : QString();
|
||||||
if ( idx.isValid() && ( name.compare( *countryPart, Qt::CaseInsensitive ) == 0 ) )
|
if ( idx.isValid() && ( name.compare( *countryPart, Qt::CaseInsensitive ) == 0 ) )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "matched" << name;
|
cDebug() << Logger::SubEntry << "matched" << name;
|
||||||
|
@ -279,7 +273,8 @@ KeyboardPage::guessLayout( const QStringList& langParts )
|
||||||
if ( variantdata && ( variantdata->data.compare( *countryPart, Qt::CaseInsensitive ) == 0 ) )
|
if ( variantdata && ( variantdata->data.compare( *countryPart, Qt::CaseInsensitive ) == 0 ) )
|
||||||
{
|
{
|
||||||
ui->listVariant->setCurrentItem( variantdata );
|
ui->listVariant->setCurrentItem( variantdata );
|
||||||
cDebug() << Logger::SubEntry << "matched variant" << variantdata->data << ' ' << variantdata->text();
|
cDebug() << Logger::SubEntry << "matched variant" << variantdata->data << ' '
|
||||||
|
<< variantdata->text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,10 +343,14 @@ KeyboardPage::onActivate()
|
||||||
// Chop off .codeset and @modifier
|
// Chop off .codeset and @modifier
|
||||||
int index = lang.indexOf( '.' );
|
int index = lang.indexOf( '.' );
|
||||||
if ( index >= 0 )
|
if ( index >= 0 )
|
||||||
|
{
|
||||||
lang.truncate( index );
|
lang.truncate( index );
|
||||||
|
}
|
||||||
index = lang.indexOf( '@' );
|
index = lang.indexOf( '@' );
|
||||||
if ( index >= 0 )
|
if ( index >= 0 )
|
||||||
|
{
|
||||||
lang.truncate( index );
|
lang.truncate( index );
|
||||||
|
}
|
||||||
|
|
||||||
lang.replace( '-', '_' ); // Normalize separators
|
lang.replace( '-', '_' ); // Normalize separators
|
||||||
}
|
}
|
||||||
|
@ -394,15 +393,13 @@ KeyboardPage::finalize()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
KeyboardPage::updateVariants( const QPersistentModelIndex& currentItem,
|
KeyboardPage::updateVariants( const QPersistentModelIndex& currentItem, QString currentVariant )
|
||||||
QString currentVariant )
|
|
||||||
{
|
{
|
||||||
// Block signals
|
// Block signals
|
||||||
ui->listVariant->blockSignals( true );
|
ui->listVariant->blockSignals( true );
|
||||||
|
|
||||||
QMap< QString, QString > variants =
|
QMap< QString, QString > variants
|
||||||
currentItem.data( KeyboardLayoutModel::KeyboardVariantsRole )
|
= currentItem.data( KeyboardLayoutModel::KeyboardVariantsRole ).value< QMap< QString, QString > >();
|
||||||
.value< QMap< QString, QString > >();
|
|
||||||
QMapIterator< QString, QString > li( variants );
|
QMapIterator< QString, QString > li( variants );
|
||||||
LayoutItem* defaultItem = nullptr;
|
LayoutItem* defaultItem = nullptr;
|
||||||
|
|
||||||
|
@ -420,25 +417,30 @@ KeyboardPage::updateVariants( const QPersistentModelIndex& currentItem,
|
||||||
// currentVariant defaults to QString(). It is only non-empty during the
|
// currentVariant defaults to QString(). It is only non-empty during the
|
||||||
// initial setup.
|
// initial setup.
|
||||||
if ( li.value() == currentVariant )
|
if ( li.value() == currentVariant )
|
||||||
|
{
|
||||||
defaultItem = item;
|
defaultItem = item;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Unblock signals
|
// Unblock signals
|
||||||
ui->listVariant->blockSignals( false );
|
ui->listVariant->blockSignals( false );
|
||||||
|
|
||||||
// Set to default value
|
// Set to default value
|
||||||
if ( defaultItem )
|
if ( defaultItem )
|
||||||
|
{
|
||||||
ui->listVariant->setCurrentItem( defaultItem );
|
ui->listVariant->setCurrentItem( defaultItem );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current,
|
KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current, const QModelIndex& previous )
|
||||||
const QModelIndex& previous )
|
|
||||||
{
|
{
|
||||||
Q_UNUSED( previous )
|
Q_UNUSED( previous )
|
||||||
if ( !current.isValid() )
|
if ( !current.isValid() )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
updateVariants( QPersistentModelIndex( current ) );
|
updateVariants( QPersistentModelIndex( current ) );
|
||||||
}
|
}
|
||||||
|
@ -446,11 +448,14 @@ KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current,
|
||||||
/* Returns stringlist with suitable setxkbmap command-line arguments
|
/* Returns stringlist with suitable setxkbmap command-line arguments
|
||||||
* to set the given @p layout and @p variant.
|
* to set the given @p layout and @p variant.
|
||||||
*/
|
*/
|
||||||
static inline QStringList xkbmap_args( const QString& layout, const QString& variant )
|
static inline QStringList
|
||||||
|
xkbmap_args( const QString& layout, const QString& variant )
|
||||||
{
|
{
|
||||||
QStringList r { "-layout", layout };
|
QStringList r { "-layout", layout };
|
||||||
if ( !variant.isEmpty() )
|
if ( !variant.isEmpty() )
|
||||||
|
{
|
||||||
r << "-variant" << variant;
|
r << "-variant" << variant;
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +468,9 @@ KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWi
|
||||||
LayoutItem* variantItem = dynamic_cast< LayoutItem* >( current );
|
LayoutItem* variantItem = dynamic_cast< LayoutItem* >( current );
|
||||||
|
|
||||||
if ( !layoutIndex.isValid() || !variantItem )
|
if ( !layoutIndex.isValid() || !variantItem )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString layout = layoutIndex.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString();
|
QString layout = layoutIndex.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString();
|
||||||
QString variant = variantItem->data;
|
QString variant = variantItem->data;
|
||||||
|
@ -480,9 +487,7 @@ KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWi
|
||||||
m_setxkbmapTimer.disconnect( this );
|
m_setxkbmapTimer.disconnect( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
connect( &m_setxkbmapTimer, &QTimer::timeout,
|
connect( &m_setxkbmapTimer, &QTimer::timeout, this, [=] {
|
||||||
this, [=]
|
|
||||||
{
|
|
||||||
QProcess::execute( "setxkbmap", xkbmap_args( layout, variant ) );
|
QProcess::execute( "setxkbmap", xkbmap_args( layout, variant ) );
|
||||||
cDebug() << "xkbmap selection changed to: " << layout << '-' << variant;
|
cDebug() << "xkbmap selection changed to: " << layout << '-' << variant;
|
||||||
m_setxkbmapTimer.disconnect( this );
|
m_setxkbmapTimer.disconnect( this );
|
||||||
|
|
|
@ -48,24 +48,20 @@ public:
|
||||||
|
|
||||||
QString prettyStatus() const;
|
QString prettyStatus() const;
|
||||||
|
|
||||||
Calamares::JobList createJobs( const QString& xOrgConfFileName,
|
Calamares::JobList
|
||||||
const QString& convertedKeymapPath,
|
createJobs( const QString& xOrgConfFileName, const QString& convertedKeymapPath, bool writeEtcDefaultKeyboard );
|
||||||
bool writeEtcDefaultKeyboard );
|
|
||||||
|
|
||||||
void onActivate();
|
void onActivate();
|
||||||
void finalize();
|
void finalize();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void onListLayoutCurrentItemChanged( const QModelIndex& current,
|
void onListLayoutCurrentItemChanged( const QModelIndex& current, const QModelIndex& previous );
|
||||||
const QModelIndex& previous );
|
void onListVariantCurrentItemChanged( QListWidgetItem* current, QListWidgetItem* previous );
|
||||||
void onListVariantCurrentItemChanged( QListWidgetItem* current,
|
|
||||||
QListWidgetItem* previous );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Guess a layout based on the split-apart locale
|
/// Guess a layout based on the split-apart locale
|
||||||
void guessLayout( const QStringList& langParts );
|
void guessLayout( const QStringList& langParts );
|
||||||
void updateVariants( const QPersistentModelIndex& currentItem,
|
void updateVariants( const QPersistentModelIndex& currentItem, QString currentVariant = QString() );
|
||||||
QString currentVariant = QString() );
|
|
||||||
|
|
||||||
Ui::Page_Keyboard* ui;
|
Ui::Page_Keyboard* ui;
|
||||||
KeyBoardPreview* m_keyboardPreview;
|
KeyBoardPreview* m_keyboardPreview;
|
||||||
|
|
|
@ -125,27 +125,35 @@ KeyboardViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils;
|
using namespace CalamaresUtils;
|
||||||
|
|
||||||
if ( configurationMap.contains( "xOrgConfFileName" ) &&
|
if ( configurationMap.contains( "xOrgConfFileName" )
|
||||||
configurationMap.value( "xOrgConfFileName" ).type() == QVariant::String &&
|
&& configurationMap.value( "xOrgConfFileName" ).type() == QVariant::String
|
||||||
!getString( configurationMap, "xOrgConfFileName" ).isEmpty() )
|
&& !getString( configurationMap, "xOrgConfFileName" ).isEmpty() )
|
||||||
{
|
{
|
||||||
m_xOrgConfFileName = getString( configurationMap, "xOrgConfFileName" );
|
m_xOrgConfFileName = getString( configurationMap, "xOrgConfFileName" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_xOrgConfFileName = "00-keyboard.conf";
|
m_xOrgConfFileName = "00-keyboard.conf";
|
||||||
|
}
|
||||||
|
|
||||||
if ( configurationMap.contains( "convertedKeymapPath" ) &&
|
if ( configurationMap.contains( "convertedKeymapPath" )
|
||||||
configurationMap.value( "convertedKeymapPath" ).type() == QVariant::String &&
|
&& configurationMap.value( "convertedKeymapPath" ).type() == QVariant::String
|
||||||
!getString( configurationMap, "convertedKeymapPath" ).isEmpty() )
|
&& !getString( configurationMap, "convertedKeymapPath" ).isEmpty() )
|
||||||
{
|
{
|
||||||
m_convertedKeymapPath = getString( configurationMap, "convertedKeymapPath" );
|
m_convertedKeymapPath = getString( configurationMap, "convertedKeymapPath" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_convertedKeymapPath = QString();
|
m_convertedKeymapPath = QString();
|
||||||
|
}
|
||||||
|
|
||||||
if ( configurationMap.contains( "writeEtcDefaultKeyboard" ) &&
|
if ( configurationMap.contains( "writeEtcDefaultKeyboard" )
|
||||||
configurationMap.value( "writeEtcDefaultKeyboard" ).type() == QVariant::Bool )
|
&& configurationMap.value( "writeEtcDefaultKeyboard" ).type() == QVariant::Bool )
|
||||||
|
{
|
||||||
m_writeEtcDefaultKeyboard = getBool( configurationMap, "writeEtcDefaultKeyboard", true );
|
m_writeEtcDefaultKeyboard = getBool( configurationMap, "writeEtcDefaultKeyboard", true );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_writeEtcDefaultKeyboard = true;
|
m_writeEtcDefaultKeyboard = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,16 +24,16 @@
|
||||||
|
|
||||||
#include "SetKeyboardLayoutJob.h"
|
#include "SetKeyboardLayoutJob.h"
|
||||||
|
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "utils/Logger.h"
|
#include "JobQueue.h"
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QFileInfo>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
|
|
||||||
SetKeyboardLayoutJob::SetKeyboardLayoutJob( const QString& model,
|
SetKeyboardLayoutJob::SetKeyboardLayoutJob( const QString& model,
|
||||||
|
@ -56,9 +56,7 @@ SetKeyboardLayoutJob::SetKeyboardLayoutJob( const QString& model,
|
||||||
QString
|
QString
|
||||||
SetKeyboardLayoutJob::prettyName() const
|
SetKeyboardLayoutJob::prettyName() const
|
||||||
{
|
{
|
||||||
return tr( "Set keyboard model to %1, layout to %2-%3" ).arg( m_model )
|
return tr( "Set keyboard model to %1, layout to %2-%3" ).arg( m_model ).arg( m_layout ).arg( m_variant );
|
||||||
.arg( m_layout )
|
|
||||||
.arg( m_variant );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,13 +68,14 @@ SetKeyboardLayoutJob::findConvertedKeymap( const QString& convertedKeymapPath )
|
||||||
// No search path supplied, assume the distribution does not provide
|
// No search path supplied, assume the distribution does not provide
|
||||||
// converted keymaps
|
// converted keymaps
|
||||||
if ( convertedKeymapPath.isEmpty() )
|
if ( convertedKeymapPath.isEmpty() )
|
||||||
|
{
|
||||||
return QString();
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
QDir convertedKeymapDir( convertedKeymapPath );
|
QDir convertedKeymapDir( convertedKeymapPath );
|
||||||
QString name = m_variant.isEmpty() ? m_layout : ( m_layout + '-' + m_variant );
|
QString name = m_variant.isEmpty() ? m_layout : ( m_layout + '-' + m_variant );
|
||||||
|
|
||||||
if ( convertedKeymapDir.exists( name + ".map" )
|
if ( convertedKeymapDir.exists( name + ".map" ) || convertedKeymapDir.exists( name + ".map.gz" ) )
|
||||||
|| convertedKeymapDir.exists( name + ".map.gz" ) )
|
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "Found converted keymap" << name;
|
cDebug() << Logger::SubEntry << "Found converted keymap" << name;
|
||||||
return name;
|
return name;
|
||||||
|
@ -101,11 +100,15 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
|
||||||
{
|
{
|
||||||
QString line = stream.readLine().trimmed();
|
QString line = stream.readLine().trimmed();
|
||||||
if ( line.isEmpty() || line.startsWith( '#' ) )
|
if ( line.isEmpty() || line.startsWith( '#' ) )
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList mapping = line.split( '\t', QString::SkipEmptyParts );
|
QStringList mapping = line.split( '\t', QString::SkipEmptyParts );
|
||||||
if ( mapping.size() < 5 )
|
if ( mapping.size() < 5 )
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int matching = 0;
|
int matching = 0;
|
||||||
|
|
||||||
|
@ -114,24 +117,36 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
|
||||||
// allow more than one layout, this should change too.
|
// allow more than one layout, this should change too.
|
||||||
if ( m_layout == mapping[ 1 ] )
|
if ( m_layout == mapping[ 1 ] )
|
||||||
// If we got an exact match, this is best
|
// If we got an exact match, this is best
|
||||||
|
{
|
||||||
matching = 10;
|
matching = 10;
|
||||||
|
}
|
||||||
// Look for an entry whose first layout matches ours
|
// Look for an entry whose first layout matches ours
|
||||||
else if ( mapping[ 1 ].startsWith( m_layout + ',' ) )
|
else if ( mapping[ 1 ].startsWith( m_layout + ',' ) )
|
||||||
|
{
|
||||||
matching = 5;
|
matching = 5;
|
||||||
|
}
|
||||||
|
|
||||||
if ( matching > 0 )
|
if ( matching > 0 )
|
||||||
{
|
{
|
||||||
if ( m_model.isEmpty() || m_model == mapping[ 2 ] )
|
if ( m_model.isEmpty() || m_model == mapping[ 2 ] )
|
||||||
|
{
|
||||||
matching++;
|
matching++;
|
||||||
|
}
|
||||||
|
|
||||||
QString mappingVariant = mapping[ 3 ];
|
QString mappingVariant = mapping[ 3 ];
|
||||||
if ( mappingVariant == "-" )
|
if ( mappingVariant == "-" )
|
||||||
|
{
|
||||||
mappingVariant = QString();
|
mappingVariant = QString();
|
||||||
|
}
|
||||||
else if ( mappingVariant.startsWith( ',' ) )
|
else if ( mappingVariant.startsWith( ',' ) )
|
||||||
|
{
|
||||||
mappingVariant.remove( 1, 0 );
|
mappingVariant.remove( 1, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
if ( m_variant == mappingVariant )
|
if ( m_variant == mappingVariant )
|
||||||
|
{
|
||||||
matching++;
|
matching++;
|
||||||
|
}
|
||||||
|
|
||||||
// We ignore mapping[4], the xkb options, for now. If we ever
|
// We ignore mapping[4], the xkb options, for now. If we ever
|
||||||
// allow setting options in the UI, we should match them here.
|
// allow setting options in the UI, we should match them here.
|
||||||
|
@ -140,8 +155,7 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
|
||||||
// The best matching entry so far, then let's save that
|
// The best matching entry so far, then let's save that
|
||||||
if ( matching >= qMax( bestMatching, 1 ) )
|
if ( matching >= qMax( bestMatching, 1 ) )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "Found legacy keymap" << mapping[0]
|
cDebug() << Logger::SubEntry << "Found legacy keymap" << mapping[ 0 ] << "with score" << matching;
|
||||||
<< "with score" << matching;
|
|
||||||
|
|
||||||
if ( matching > bestMatching )
|
if ( matching > bestMatching )
|
||||||
{
|
{
|
||||||
|
@ -156,16 +170,16 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SetKeyboardLayoutJob::writeVConsoleData( const QString& vconsoleConfPath,
|
SetKeyboardLayoutJob::writeVConsoleData( const QString& vconsoleConfPath, const QString& convertedKeymapPath ) const
|
||||||
const QString& convertedKeymapPath ) const
|
|
||||||
{
|
{
|
||||||
QString keymap = findConvertedKeymap( convertedKeymapPath );
|
QString keymap = findConvertedKeymap( convertedKeymapPath );
|
||||||
if ( keymap.isEmpty() )
|
if ( keymap.isEmpty() )
|
||||||
|
{
|
||||||
keymap = findLegacyKeymap();
|
keymap = findLegacyKeymap();
|
||||||
|
}
|
||||||
if ( keymap.isEmpty() )
|
if ( keymap.isEmpty() )
|
||||||
{
|
{
|
||||||
cDebug() << "Trying to use X11 layout" << m_layout
|
cDebug() << "Trying to use X11 layout" << m_layout << "as the virtual console layout";
|
||||||
<< "as the virtual console layout";
|
|
||||||
keymap = m_layout;
|
keymap = m_layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,11 +192,15 @@ SetKeyboardLayoutJob::writeVConsoleData( const QString& vconsoleConfPath,
|
||||||
file.open( QIODevice::ReadOnly | QIODevice::Text );
|
file.open( QIODevice::ReadOnly | QIODevice::Text );
|
||||||
QTextStream stream( &file );
|
QTextStream stream( &file );
|
||||||
while ( !stream.atEnd() )
|
while ( !stream.atEnd() )
|
||||||
|
{
|
||||||
existingLines << stream.readLine();
|
existingLines << stream.readLine();
|
||||||
|
}
|
||||||
file.close();
|
file.close();
|
||||||
if ( stream.status() != QTextStream::Ok )
|
if ( stream.status() != QTextStream::Ok )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Write out the existing lines and replace the KEYMAP= line
|
// Write out the existing lines and replace the KEYMAP= line
|
||||||
file.open( QIODevice::WriteOnly | QIODevice::Text );
|
file.open( QIODevice::WriteOnly | QIODevice::Text );
|
||||||
|
@ -196,11 +214,15 @@ SetKeyboardLayoutJob::writeVConsoleData( const QString& vconsoleConfPath,
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
stream << existingLine << '\n';
|
stream << existingLine << '\n';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Add a KEYMAP= line if there wasn't any
|
// Add a KEYMAP= line if there wasn't any
|
||||||
if ( !found )
|
if ( !found )
|
||||||
|
{
|
||||||
stream << "KEYMAP=" << keymap << '\n';
|
stream << "KEYMAP=" << keymap << '\n';
|
||||||
|
}
|
||||||
stream.flush();
|
stream.flush();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
@ -224,22 +246,27 @@ SetKeyboardLayoutJob::writeX11Data( const QString& keyboardConfPath ) const
|
||||||
" MatchIsKeyboard \"on\"\n";
|
" MatchIsKeyboard \"on\"\n";
|
||||||
|
|
||||||
if ( !m_layout.isEmpty() )
|
if ( !m_layout.isEmpty() )
|
||||||
|
{
|
||||||
stream << " Option \"XkbLayout\" \"" << m_layout << "\"\n";
|
stream << " Option \"XkbLayout\" \"" << m_layout << "\"\n";
|
||||||
|
}
|
||||||
|
|
||||||
if ( !m_model.isEmpty() )
|
if ( !m_model.isEmpty() )
|
||||||
|
{
|
||||||
stream << " Option \"XkbModel\" \"" << m_model << "\"\n";
|
stream << " Option \"XkbModel\" \"" << m_model << "\"\n";
|
||||||
|
}
|
||||||
|
|
||||||
if ( !m_variant.isEmpty() )
|
if ( !m_variant.isEmpty() )
|
||||||
|
{
|
||||||
stream << " Option \"XkbVariant\" \"" << m_variant << "\"\n";
|
stream << " Option \"XkbVariant\" \"" << m_variant << "\"\n";
|
||||||
|
}
|
||||||
|
|
||||||
stream << "EndSection\n";
|
stream << "EndSection\n";
|
||||||
stream.flush();
|
stream.flush();
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
cDebug() << "Written XkbLayout" << m_layout <<
|
cDebug() << "Written XkbLayout" << m_layout << "; XkbModel" << m_model << "; XkbVariant" << m_variant
|
||||||
"; XkbModel" << m_model <<
|
<< "to X.org file" << keyboardConfPath;
|
||||||
"; XkbVariant" << m_variant << "to X.org file" << keyboardConfPath;
|
|
||||||
|
|
||||||
return ( stream.status() == QTextStream::Ok );
|
return ( stream.status() == QTextStream::Ok );
|
||||||
}
|
}
|
||||||
|
@ -264,10 +291,8 @@ SetKeyboardLayoutJob::writeDefaultKeyboardData( const QString& defaultKeyboardPa
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
cDebug() << "Written XKBMODEL" << m_model <<
|
cDebug() << "Written XKBMODEL" << m_model << "; XKBLAYOUT" << m_layout << "; XKBVARIANT" << m_variant
|
||||||
"; XKBLAYOUT" << m_layout <<
|
<< "to /etc/default/keyboard file" << defaultKeyboardPath;
|
||||||
"; XKBVARIANT" << m_variant <<
|
|
||||||
"to /etc/default/keyboard file" << defaultKeyboardPath;
|
|
||||||
|
|
||||||
return ( stream.status() == QTextStream::Ok );
|
return ( stream.status() == QTextStream::Ok );
|
||||||
}
|
}
|
||||||
|
@ -292,28 +317,33 @@ SetKeyboardLayoutJob::exec()
|
||||||
{
|
{
|
||||||
keyboardConfPath = m_xOrgConfFileName;
|
keyboardConfPath = m_xOrgConfFileName;
|
||||||
while ( keyboardConfPath.startsWith( '/' ) )
|
while ( keyboardConfPath.startsWith( '/' ) )
|
||||||
|
{
|
||||||
keyboardConfPath.remove( 0, 1 );
|
keyboardConfPath.remove( 0, 1 );
|
||||||
|
}
|
||||||
keyboardConfPath = destDir.absoluteFilePath( keyboardConfPath );
|
keyboardConfPath = destDir.absoluteFilePath( keyboardConfPath );
|
||||||
xorgConfDPath = QFileInfo( keyboardConfPath ).path();
|
xorgConfDPath = QFileInfo( keyboardConfPath ).path();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xorgConfDPath = destDir.absoluteFilePath( "etc/X11/xorg.conf.d" );
|
xorgConfDPath = destDir.absoluteFilePath( "etc/X11/xorg.conf.d" );
|
||||||
keyboardConfPath = QDir( xorgConfDPath )
|
keyboardConfPath = QDir( xorgConfDPath ).absoluteFilePath( m_xOrgConfFileName );
|
||||||
.absoluteFilePath( m_xOrgConfFileName );
|
|
||||||
}
|
}
|
||||||
destDir.mkpath( xorgConfDPath );
|
destDir.mkpath( xorgConfDPath );
|
||||||
|
|
||||||
QString defaultKeyboardPath;
|
QString defaultKeyboardPath;
|
||||||
if ( QDir( destDir.absoluteFilePath( "etc/default" ) ).exists() )
|
if ( QDir( destDir.absoluteFilePath( "etc/default" ) ).exists() )
|
||||||
|
{
|
||||||
defaultKeyboardPath = destDir.absoluteFilePath( "etc/default/keyboard" );
|
defaultKeyboardPath = destDir.absoluteFilePath( "etc/default/keyboard" );
|
||||||
|
}
|
||||||
|
|
||||||
// Get the path to the destination's path to the converted key mappings
|
// Get the path to the destination's path to the converted key mappings
|
||||||
QString convertedKeymapPath = m_convertedKeymapPath;
|
QString convertedKeymapPath = m_convertedKeymapPath;
|
||||||
if ( !convertedKeymapPath.isEmpty() )
|
if ( !convertedKeymapPath.isEmpty() )
|
||||||
{
|
{
|
||||||
while ( convertedKeymapPath.startsWith( '/' ) )
|
while ( convertedKeymapPath.startsWith( '/' ) )
|
||||||
|
{
|
||||||
convertedKeymapPath.remove( 0, 1 );
|
convertedKeymapPath.remove( 0, 1 );
|
||||||
|
}
|
||||||
convertedKeymapPath = destDir.absoluteFilePath( convertedKeymapPath );
|
convertedKeymapPath = destDir.absoluteFilePath( convertedKeymapPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +358,8 @@ SetKeyboardLayoutJob::exec()
|
||||||
if ( !defaultKeyboardPath.isEmpty() && m_writeEtcDefaultKeyboard )
|
if ( !defaultKeyboardPath.isEmpty() && m_writeEtcDefaultKeyboard )
|
||||||
{
|
{
|
||||||
if ( !writeDefaultKeyboardData( defaultKeyboardPath ) )
|
if ( !writeDefaultKeyboardData( defaultKeyboardPath ) )
|
||||||
return Calamares::JobResult::error( tr( "Failed to write keyboard configuration to existing /etc/default directory." ),
|
return Calamares::JobResult::error(
|
||||||
|
tr( "Failed to write keyboard configuration to existing /etc/default directory." ),
|
||||||
tr( "Failed to write to %1" ).arg( keyboardConfPath ) );
|
tr( "Failed to write to %1" ).arg( keyboardConfPath ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,7 @@ public:
|
||||||
private:
|
private:
|
||||||
QString findConvertedKeymap( const QString& convertedKeymapPath ) const;
|
QString findConvertedKeymap( const QString& convertedKeymapPath ) const;
|
||||||
QString findLegacyKeymap() const;
|
QString findLegacyKeymap() const;
|
||||||
bool writeVConsoleData( const QString& vconsoleConfPath,
|
bool writeVConsoleData( const QString& vconsoleConfPath, const QString& convertedKeymapPath ) const;
|
||||||
const QString& convertedKeymapPath ) const;
|
|
||||||
bool writeX11Data( const QString& keyboardConfPath ) const;
|
bool writeX11Data( const QString& keyboardConfPath ) const;
|
||||||
bool writeDefaultKeyboardData( const QString& defaultKeyboardPath ) const;
|
bool writeDefaultKeyboardData( const QString& defaultKeyboardPath ) const;
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
#include "KeyboardQmlViewStep.h"
|
#include "KeyboardQmlViewStep.h"
|
||||||
|
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( KeyboardQmlViewStepFactory, registerPlugin< KeyboardQmlViewStep >(); )
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( KeyboardQmlViewStepFactory, registerPlugin< KeyboardQmlViewStep >(); )
|
||||||
|
@ -88,9 +88,7 @@ void
|
||||||
KeyboardQmlViewStep::onLeave()
|
KeyboardQmlViewStep::onLeave()
|
||||||
{
|
{
|
||||||
m_config->finalize();
|
m_config->finalize();
|
||||||
m_jobs = m_config->createJobs( m_xOrgConfFileName,
|
m_jobs = m_config->createJobs( m_xOrgConfFileName, m_convertedKeymapPath, m_writeEtcDefaultKeyboard );
|
||||||
m_convertedKeymapPath,
|
|
||||||
m_writeEtcDefaultKeyboard );
|
|
||||||
m_prettyStatus = m_config->prettyStatus();
|
m_prettyStatus = m_config->prettyStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,29 +103,37 @@ KeyboardQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils;
|
using namespace CalamaresUtils;
|
||||||
|
|
||||||
if ( configurationMap.contains( "xOrgConfFileName" ) &&
|
if ( configurationMap.contains( "xOrgConfFileName" )
|
||||||
configurationMap.value( "xOrgConfFileName" ).type() == QVariant::String &&
|
&& configurationMap.value( "xOrgConfFileName" ).type() == QVariant::String
|
||||||
!getString( configurationMap, "xOrgConfFileName" ).isEmpty() )
|
&& !getString( configurationMap, "xOrgConfFileName" ).isEmpty() )
|
||||||
{
|
{
|
||||||
m_xOrgConfFileName = getString( configurationMap, "xOrgConfFileName" );
|
m_xOrgConfFileName = getString( configurationMap, "xOrgConfFileName" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_xOrgConfFileName = "00-keyboard.conf";
|
m_xOrgConfFileName = "00-keyboard.conf";
|
||||||
|
}
|
||||||
|
|
||||||
if ( configurationMap.contains( "convertedKeymapPath" ) &&
|
if ( configurationMap.contains( "convertedKeymapPath" )
|
||||||
configurationMap.value( "convertedKeymapPath" ).type() == QVariant::String &&
|
&& configurationMap.value( "convertedKeymapPath" ).type() == QVariant::String
|
||||||
!getString( configurationMap, "convertedKeymapPath" ).isEmpty() )
|
&& !getString( configurationMap, "convertedKeymapPath" ).isEmpty() )
|
||||||
{
|
{
|
||||||
m_convertedKeymapPath = getString( configurationMap, "convertedKeymapPath" );
|
m_convertedKeymapPath = getString( configurationMap, "convertedKeymapPath" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_convertedKeymapPath = QString();
|
m_convertedKeymapPath = QString();
|
||||||
|
}
|
||||||
|
|
||||||
if ( configurationMap.contains( "writeEtcDefaultKeyboard" ) &&
|
if ( configurationMap.contains( "writeEtcDefaultKeyboard" )
|
||||||
configurationMap.value( "writeEtcDefaultKeyboard" ).type() == QVariant::Bool )
|
&& configurationMap.value( "writeEtcDefaultKeyboard" ).type() == QVariant::Bool )
|
||||||
|
{
|
||||||
m_writeEtcDefaultKeyboard = getBool( configurationMap, "writeEtcDefaultKeyboard", true );
|
m_writeEtcDefaultKeyboard = getBool( configurationMap, "writeEtcDefaultKeyboard", true );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_writeEtcDefaultKeyboard = true;
|
m_writeEtcDefaultKeyboard = true;
|
||||||
|
}
|
||||||
|
|
||||||
Calamares::QmlViewStep::setConfigurationMap( configurationMap );
|
Calamares::QmlViewStep::setConfigurationMap( configurationMap );
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#include <DllMacro.h>
|
||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/QmlViewStep.h>
|
#include <viewpages/QmlViewStep.h>
|
||||||
#include <DllMacro.h>
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue