refactor after review - use QStringList
This commit is contained in:
parent
2d0940e555
commit
8ca841d08e
@ -175,6 +175,13 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
|
|||||||
return ::findLegacyKeymap( m_layout, m_model, m_variant );
|
return ::findLegacyKeymap( m_layout, m_model, m_variant );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
SetKeyboardLayoutJob::removeEmpty(QStringList& list) const
|
||||||
|
{
|
||||||
|
list.removeAll(QString());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SetKeyboardLayoutJob::writeVConsoleData( const QString& vconsoleConfPath, const QString& convertedKeymapPath ) const
|
SetKeyboardLayoutJob::writeVConsoleData( const QString& vconsoleConfPath, const QString& convertedKeymapPath ) const
|
||||||
@ -266,32 +273,12 @@ SetKeyboardLayoutJob::writeX11Data( const QString& keyboardConfPath ) const
|
|||||||
" MatchIsKeyboard \"on\"\n";
|
" MatchIsKeyboard \"on\"\n";
|
||||||
|
|
||||||
|
|
||||||
if ( m_additionalLayoutInfo.additionalLayout.isEmpty() )
|
QStringList layouts({m_additionalLayoutInfo.additionalLayout, m_layout});
|
||||||
|
QStringList variants({m_additionalLayoutInfo.additionalVariant, m_variant});
|
||||||
|
stream << " Option \"XkbLayout\" \"" << removeEmpty(layouts).join(",") << "\"\n";
|
||||||
|
stream << " Option \"XkbVariant\" \"" << removeEmpty(variants).join(",") << "\"\n";
|
||||||
|
if ( !m_additionalLayoutInfo.additionalLayout.isEmpty() )
|
||||||
{
|
{
|
||||||
if ( !m_layout.isEmpty() )
|
|
||||||
{
|
|
||||||
stream << " Option \"XkbLayout\" \"" << m_layout << "\"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !m_variant.isEmpty() )
|
|
||||||
{
|
|
||||||
stream << " Option \"XkbVariant\" \"" << m_variant << "\"\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( !m_layout.isEmpty() )
|
|
||||||
{
|
|
||||||
stream << " Option \"XkbLayout\" \"" << m_additionalLayoutInfo.additionalLayout << "," << m_layout
|
|
||||||
<< "\"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !m_variant.isEmpty() )
|
|
||||||
{
|
|
||||||
stream << " Option \"XkbVariant\" \"" << m_additionalLayoutInfo.additionalVariant << "," << m_variant
|
|
||||||
<< "\"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
stream << " Option \"XkbOptions\" \"" << m_additionalLayoutInfo.groupSwitcher << "\"\n";
|
stream << " Option \"XkbOptions\" \"" << m_additionalLayoutInfo.groupSwitcher << "\"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,8 +287,8 @@ SetKeyboardLayoutJob::writeX11Data( const QString& keyboardConfPath ) const
|
|||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
cDebug() << Logger::SubEntry << "Written XkbLayout" << m_layout << "; XkbModel" << m_model << "; XkbVariant"
|
cDebug() << Logger::SubEntry << "Written XkbLayout" << layouts.join(",") << "; XkbModel" << m_model << "; XkbVariant"
|
||||||
<< m_variant << "to X.org file" << keyboardConfPath << stream.status();
|
<< variants.join(",") << "to X.org file" << keyboardConfPath << stream.status();
|
||||||
|
|
||||||
return ( stream.status() == QTextStream::Ok );
|
return ( stream.status() == QTextStream::Ok );
|
||||||
}
|
}
|
||||||
@ -320,38 +307,16 @@ SetKeyboardLayoutJob::writeDefaultKeyboardData( const QString& defaultKeyboardPa
|
|||||||
}
|
}
|
||||||
QTextStream stream( &file );
|
QTextStream stream( &file );
|
||||||
|
|
||||||
|
QStringList layouts({m_additionalLayoutInfo.additionalLayout, m_layout});
|
||||||
|
QStringList variants({m_additionalLayoutInfo.additionalVariant, m_variant});
|
||||||
stream << "# KEYBOARD CONFIGURATION FILE\n\n"
|
stream << "# KEYBOARD CONFIGURATION FILE\n\n"
|
||||||
"# Consult the keyboard(5) manual page.\n\n";
|
"# Consult the keyboard(5) manual page.\n\n";
|
||||||
|
|
||||||
stream << "XKBMODEL=\"" << m_model << "\"\n";
|
stream << "XKBMODEL=\"" << m_model << "\"\n";
|
||||||
if ( m_additionalLayoutInfo.additionalLayout.isEmpty() )
|
stream << "XKBLAYOUT=\"" << removeEmpty(layouts).join(",") << "\"\n";
|
||||||
|
stream << "XKBVARIANT=\"" << removeEmpty(variants).join(",") << "\"\n";
|
||||||
|
if ( !m_additionalLayoutInfo.additionalLayout.isEmpty() )
|
||||||
{
|
{
|
||||||
if ( !m_layout.isEmpty() )
|
|
||||||
{
|
|
||||||
stream << "XKBLAYOUT=\"" << m_layout << "\"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !m_variant.isEmpty() )
|
|
||||||
{
|
|
||||||
stream << "XKBVARIANT=\"" << m_variant << "\"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
stream << "XKBOPTIONS=\"\"\n\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( !m_layout.isEmpty() )
|
|
||||||
{
|
|
||||||
stream << "XKBLAYOUT=\"" << m_additionalLayoutInfo.additionalLayout << "," << m_layout
|
|
||||||
<< "\"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !m_variant.isEmpty() )
|
|
||||||
{
|
|
||||||
stream << "XKBVARIANT=\"" << m_additionalLayoutInfo.additionalVariant << "," << m_variant
|
|
||||||
<< "\"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
stream << "XKBOPTIONS=\"" << m_additionalLayoutInfo.groupSwitcher << "\"\n";
|
stream << "XKBOPTIONS=\"" << m_additionalLayoutInfo.groupSwitcher << "\"\n";
|
||||||
}
|
}
|
||||||
stream << "BACKSPACE=\"guess\"\n";
|
stream << "BACKSPACE=\"guess\"\n";
|
||||||
@ -359,8 +324,8 @@ SetKeyboardLayoutJob::writeDefaultKeyboardData( const QString& defaultKeyboardPa
|
|||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
cDebug() << Logger::SubEntry << "Written XKBMODEL" << m_model << "; XKBLAYOUT" << m_layout << "; XKBVARIANT"
|
cDebug() << Logger::SubEntry << "Written XKBMODEL" << m_model << "; XKBLAYOUT" << layouts.join(",") << "; XKBVARIANT"
|
||||||
<< m_variant << "to /etc/default/keyboard file" << defaultKeyboardPath << stream.status();
|
<< variants.join(",") << "to /etc/default/keyboard file" << defaultKeyboardPath << stream.status();
|
||||||
|
|
||||||
return ( stream.status() == QTextStream::Ok );
|
return ( stream.status() == QTextStream::Ok );
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ private:
|
|||||||
bool writeVConsoleData( const QString& vconsoleConfPath, const QString& convertedKeymapPath ) const;
|
bool writeVConsoleData( const QString& vconsoleConfPath, 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;
|
||||||
|
QStringList removeEmpty(QStringList& list) const;
|
||||||
|
|
||||||
QString m_model;
|
QString m_model;
|
||||||
QString m_layout;
|
QString m_layout;
|
||||||
|
Loading…
Reference in New Issue
Block a user