Code-style: format the keyboard module

This commit is contained in:
Adriaan de Groot 2017-09-26 11:22:51 +02:00
parent ea07d9e1d8
commit 9b9801d48d
4 changed files with 63 additions and 75 deletions

View File

@ -64,9 +64,7 @@ KeyboardLayoutModel::init()
KeyboardGlobal::getKeyboardLayouts();
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 )

View File

@ -86,7 +86,7 @@ KeyboardPage::KeyboardPage( QWidget* parent )
[this]
{
ui->comboBoxModel->setCurrentIndex( m_defaultIndex );
});
} );
connect( ui->comboBoxModel,
static_cast< void ( QComboBox::* )( const QString& ) >( &QComboBox::currentIndexChanged ),
@ -97,7 +97,7 @@ KeyboardPage::KeyboardPage( QWidget* parent )
// Set Xorg keyboard model
QProcess::execute( QLatin1Literal( "setxkbmap" ),
QStringList() << "-model" << model );
});
} );
CALAMARES_RETRANSLATE( ui->retranslateUi( this ); )
}
@ -253,7 +253,7 @@ KeyboardPage::guessLayout( const QStringList& langParts )
{
const KeyboardLayoutModel* klm = dynamic_cast< KeyboardLayoutModel* >( ui->listLayout->model() );
bool foundCountryPart = false;
for ( auto countryPart = langParts.rbegin(); !foundCountryPart && countryPart != langParts.rend(); ++countryPart)
for ( auto countryPart = langParts.rbegin(); !foundCountryPart && countryPart != langParts.rend(); ++countryPart )
{
cDebug() << " .. looking for locale part" << *countryPart;
for ( int i = 0; i < klm->rowCount(); ++i )
@ -285,15 +285,15 @@ KeyboardPage::onActivate()
if ( !lang.isEmpty() )
{
// Chop off .codeset and @modifier
int index = lang.indexOf('.');
int index = lang.indexOf( '.' );
if ( index >= 0 )
lang.truncate( index );
index = lang.indexOf('@');
index = lang.indexOf( '@' );
if ( index >= 0 )
lang.truncate( index );
lang.replace( '-', '_' ); // Normalize separators
const auto langParts = lang.split( '_' , QString::SkipEmptyParts );
const auto langParts = lang.split( '_', QString::SkipEmptyParts );
QString country = QLocale::countryToString( QLocale( lang ).country() );
cDebug() << " .. extracted country" << country << "::" << langParts;
@ -370,7 +370,7 @@ KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current,
/* Returns stringlist with suitable setxkbmap command-line arguments
* to set the given @p layout and @p variant.
*/
static inline QStringList xkbmap_args( QStringList&& r, const QString& layout, const QString& variant)
static inline QStringList xkbmap_args( QStringList&& r, const QString& layout, const QString& variant )
{
r << "-layout" << layout;
if ( !variant.isEmpty() )

View File

@ -142,9 +142,7 @@ KeyboardViewStep::setConfigurationMap( const QVariantMap& configurationMap )
.toString();
}
else
{
m_xOrgConfFileName = "00-keyboard.conf";
}
if ( configurationMap.contains( "convertedKeymapPath" ) &&
configurationMap.value( "convertedKeymapPath" ).type() == QVariant::String &&
@ -154,17 +152,11 @@ KeyboardViewStep::setConfigurationMap( const QVariantMap& configurationMap )
.toString();
}
else
{
m_convertedKeymapPath = QString();
}
if ( configurationMap.contains( "writeEtcDefaultKeyboard" ) &&
configurationMap.value( "writeEtcDefaultKeyboard" ).type() == QVariant::Bool )
{
m_writeEtcDefaultKeyboard = configurationMap.value( "writeEtcDefaultKeyboard" ).toBool();
}
else
{
m_writeEtcDefaultKeyboard = true;
}
}

View File

@ -41,7 +41,7 @@ SetKeyboardLayoutJob::SetKeyboardLayoutJob( const QString& model,
const QString& variant,
const QString& xOrgConfFileName,
const QString& convertedKeymapPath,
bool writeEtcDefaultKeyboard)
bool writeEtcDefaultKeyboard )
: Calamares::Job()
, m_model( model )
, m_layout( layout )
@ -303,9 +303,7 @@ SetKeyboardLayoutJob::exec()
QString defaultKeyboardPath;
if ( QDir( destDir.absoluteFilePath( "etc/default" ) ).exists() )
{
defaultKeyboardPath = destDir.absoluteFilePath( "etc/default/keyboard" );
}
// Get the path to the destination's path to the converted key mappings
QString convertedKeymapPath = m_convertedKeymapPath;