[keyboard] Implemented X11 config writing for additional layout
This commit is contained in:
parent
0dd027af90
commit
bfc60ad2cf
24
src/modules/keyboard/AdditionalLayoutInfo.h
Normal file
24
src/modules/keyboard/AdditionalLayoutInfo.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||||
|
*
|
||||||
|
* SPDX-FileCopyrightText: 2020 Artem Grinev <agrinev@manjaro.org>
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* Calamares is Free Software: see the License-Identifier above.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef KEYBOARD_ADDITIONAL_LAYOUT_INFO_H
|
||||||
|
#define KEYBOARD_ADDITIONAL_LAYOUT_INFO_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
struct AdditionalLayoutInfo {
|
||||||
|
QString additionalLayout;
|
||||||
|
QString additionalVariant;
|
||||||
|
|
||||||
|
QString groupSwitcher;
|
||||||
|
|
||||||
|
QString vconsoleKeymap;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -176,27 +176,33 @@ Config::Config( QObject* parent )
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect( &m_setxkbmapTimer, &QTimer::timeout, this, [=] {
|
connect( &m_setxkbmapTimer, &QTimer::timeout, this, [=] {
|
||||||
AdditionalLayoutInfo info = getAdditionalLayoutInfo( m_selectedLayout);
|
m_selectedLayoutsAdditionalLayoutInfo = getAdditionalLayoutInfo( m_selectedLayout );
|
||||||
|
|
||||||
if(!info.additionalLayout.isEmpty())
|
if(!m_selectedLayoutsAdditionalLayoutInfo.additionalLayout.isEmpty())
|
||||||
{
|
{
|
||||||
m_selectedLayoutsAdditionalLayoutInfo = info;
|
m_selectedLayoutsAdditionalLayoutInfo.groupSwitcher = xkbmap_query_grp_option();
|
||||||
QString switchOption = xkbmap_query_grp_option();
|
|
||||||
|
|
||||||
QProcess::execute( "setxkbmap", xkbmap_layout_args(
|
QProcess::execute( "setxkbmap", xkbmap_layout_args(
|
||||||
{ info.additionalLayout, m_selectedLayout },
|
{ m_selectedLayoutsAdditionalLayoutInfo.additionalLayout, m_selectedLayout },
|
||||||
{ info.additionalVariant, m_selectedVariant },
|
{ m_selectedLayoutsAdditionalLayoutInfo.additionalVariant, m_selectedVariant },
|
||||||
switchOption.isEmpty()?"grp:alt_shift_toggle":QString() )
|
m_selectedLayoutsAdditionalLayoutInfo.groupSwitcher.isEmpty()?"grp:alt_shift_toggle":QString() )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if( m_selectedLayoutsAdditionalLayoutInfo.groupSwitcher.isEmpty() )
|
||||||
|
{
|
||||||
|
m_selectedLayoutsAdditionalLayoutInfo.groupSwitcher = "grp:alt_shift_toggle";
|
||||||
|
}
|
||||||
|
|
||||||
cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant
|
cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant
|
||||||
<< "(added " << info.additionalLayout << "-" << info.additionalVariant << " since current layout is not ASCII-capable)";
|
<< "(added " << m_selectedLayoutsAdditionalLayoutInfo.additionalLayout << "-"
|
||||||
|
<< m_selectedLayoutsAdditionalLayoutInfo.additionalVariant << " since current layout is not ASCII-capable)";
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_selectedLayoutsAdditionalLayoutInfo = AdditionalLayoutInfo();
|
m_selectedLayoutsAdditionalLayoutInfo = AdditionalLayoutInfo();
|
||||||
QProcess::execute( "setxkbmap", xkbmap_layout_args( m_selectedLayout, m_selectedVariant ) );
|
QProcess::execute( "setxkbmap", xkbmap_layout_args( m_selectedLayout, m_selectedVariant ) );
|
||||||
cDebug() << "xkbеmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant;
|
cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant;
|
||||||
}
|
}
|
||||||
m_setxkbmapTimer.disconnect( this );
|
m_setxkbmapTimer.disconnect( this );
|
||||||
} );
|
} );
|
||||||
@ -336,6 +342,7 @@ Config::createJobs()
|
|||||||
Calamares::Job* j = new SetKeyboardLayoutJob( m_selectedModel,
|
Calamares::Job* j = new SetKeyboardLayoutJob( m_selectedModel,
|
||||||
m_selectedLayout,
|
m_selectedLayout,
|
||||||
m_selectedVariant,
|
m_selectedVariant,
|
||||||
|
m_selectedLayoutsAdditionalLayoutInfo,
|
||||||
m_xOrgConfFileName,
|
m_xOrgConfFileName,
|
||||||
m_convertedKeymapPath,
|
m_convertedKeymapPath,
|
||||||
m_writeEtcDefaultKeyboard );
|
m_writeEtcDefaultKeyboard );
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "Job.h"
|
#include "Job.h"
|
||||||
#include "KeyboardLayoutModel.h"
|
#include "KeyboardLayoutModel.h"
|
||||||
|
#include "AdditionalLayoutInfo.h"
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
@ -20,13 +21,6 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
struct AdditionalLayoutInfo {
|
|
||||||
QString additionalLayout;
|
|
||||||
QString additionalVariant;
|
|
||||||
|
|
||||||
QString vconsoleKeymap;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Config : public QObject
|
class Config : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -222,6 +222,7 @@ KeyboardPage::createJobs( const QString& xOrgConfFileName,
|
|||||||
Calamares::Job* j = new SetKeyboardLayoutJob( selectedModel,
|
Calamares::Job* j = new SetKeyboardLayoutJob( selectedModel,
|
||||||
m_selectedLayout,
|
m_selectedLayout,
|
||||||
m_selectedVariant,
|
m_selectedVariant,
|
||||||
|
AdditionalLayoutInfo(),
|
||||||
xOrgConfFileName,
|
xOrgConfFileName,
|
||||||
convertedKeymapPath,
|
convertedKeymapPath,
|
||||||
writeEtcDefaultKeyboard );
|
writeEtcDefaultKeyboard );
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
|
|
||||||
SetKeyboardLayoutJob::SetKeyboardLayoutJob( const QString& model,
|
SetKeyboardLayoutJob::SetKeyboardLayoutJob(const QString& model,
|
||||||
const QString& layout,
|
const QString& layout,
|
||||||
const QString& variant,
|
const QString& variant, const AdditionalLayoutInfo &additionaLayoutInfo,
|
||||||
const QString& xOrgConfFileName,
|
const QString& xOrgConfFileName,
|
||||||
const QString& convertedKeymapPath,
|
const QString& convertedKeymapPath,
|
||||||
bool writeEtcDefaultKeyboard )
|
bool writeEtcDefaultKeyboard )
|
||||||
@ -40,6 +40,7 @@ SetKeyboardLayoutJob::SetKeyboardLayoutJob( const QString& model,
|
|||||||
, m_model( model )
|
, m_model( model )
|
||||||
, m_layout( layout )
|
, m_layout( layout )
|
||||||
, m_variant( variant )
|
, m_variant( variant )
|
||||||
|
, m_additionalLayoutInfo( additionaLayoutInfo )
|
||||||
, m_xOrgConfFileName( xOrgConfFileName )
|
, m_xOrgConfFileName( xOrgConfFileName )
|
||||||
, m_convertedKeymapPath( convertedKeymapPath )
|
, m_convertedKeymapPath( convertedKeymapPath )
|
||||||
, m_writeEtcDefaultKeyboard( writeEtcDefaultKeyboard )
|
, m_writeEtcDefaultKeyboard( writeEtcDefaultKeyboard )
|
||||||
@ -250,19 +251,32 @@ SetKeyboardLayoutJob::writeX11Data( const QString& keyboardConfPath ) const
|
|||||||
" Identifier \"system-keyboard\"\n"
|
" Identifier \"system-keyboard\"\n"
|
||||||
" MatchIsKeyboard \"on\"\n";
|
" MatchIsKeyboard \"on\"\n";
|
||||||
|
|
||||||
if ( !m_layout.isEmpty() )
|
|
||||||
{
|
|
||||||
stream << " Option \"XkbLayout\" \"" << m_layout << "\"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !m_model.isEmpty() )
|
if ( m_additionalLayoutInfo.additionalLayout.isEmpty() )
|
||||||
{
|
{
|
||||||
stream << " Option \"XkbModel\" \"" << m_model << "\"\n";
|
if ( !m_layout.isEmpty() )
|
||||||
}
|
{
|
||||||
|
stream << " Option \"XkbLayout\" \"" << m_layout << "\"\n";
|
||||||
|
}
|
||||||
|
|
||||||
if ( !m_variant.isEmpty() )
|
if ( !m_variant.isEmpty() )
|
||||||
|
{
|
||||||
|
stream << " Option \"XkbVariant\" \"" << m_variant << "\"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
stream << " Option \"XkbVariant\" \"" << m_variant << "\"\n";
|
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 << "EndSection\n";
|
stream << "EndSection\n";
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#define SETKEYBOARDLAYOUTJOB_H
|
#define SETKEYBOARDLAYOUTJOB_H
|
||||||
|
|
||||||
#include "Job.h"
|
#include "Job.h"
|
||||||
|
#include "AdditionalLayoutInfo.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SetKeyboardLayoutJob : public Calamares::Job
|
class SetKeyboardLayoutJob : public Calamares::Job
|
||||||
@ -21,6 +23,7 @@ public:
|
|||||||
SetKeyboardLayoutJob( const QString& model,
|
SetKeyboardLayoutJob( const QString& model,
|
||||||
const QString& layout,
|
const QString& layout,
|
||||||
const QString& variant,
|
const QString& variant,
|
||||||
|
const AdditionalLayoutInfo& additionaLayoutInfo,
|
||||||
const QString& xOrgConfFileName,
|
const QString& xOrgConfFileName,
|
||||||
const QString& convertedKeymapPath,
|
const QString& convertedKeymapPath,
|
||||||
bool writeEtcDefaultKeyboard );
|
bool writeEtcDefaultKeyboard );
|
||||||
@ -38,6 +41,7 @@ private:
|
|||||||
QString m_model;
|
QString m_model;
|
||||||
QString m_layout;
|
QString m_layout;
|
||||||
QString m_variant;
|
QString m_variant;
|
||||||
|
AdditionalLayoutInfo m_additionalLayoutInfo;
|
||||||
QString m_xOrgConfFileName;
|
QString m_xOrgConfFileName;
|
||||||
QString m_convertedKeymapPath;
|
QString m_convertedKeymapPath;
|
||||||
const bool m_writeEtcDefaultKeyboard;
|
const bool m_writeEtcDefaultKeyboard;
|
||||||
|
@ -3,5 +3,6 @@
|
|||||||
<file alias="kbd-model-map">../keyboard/kbd-model-map</file>
|
<file alias="kbd-model-map">../keyboard/kbd-model-map</file>
|
||||||
<file alias="images/restore.png">../keyboard/images/restore.png</file>
|
<file alias="images/restore.png">../keyboard/images/restore.png</file>
|
||||||
<file>keyboardq.qml</file>
|
<file>keyboardq.qml</file>
|
||||||
|
<file alias="non-ascii-layouts">../keyboard/non-ascii-layouts</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
Reference in New Issue
Block a user