[keyboard] Refactor keyboard model loading
- Don't need private static methods - Pass char* if that's what we've got
This commit is contained in:
parent
3c014a868c
commit
fa70b3aa60
@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2019, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Originally from the Manjaro Installation Framework
|
* Originally from the Manjaro Installation Framework
|
||||||
* by Roland Singer <roland@manjaro.org>
|
* by Roland Singer <roland@manjaro.org>
|
||||||
@ -30,31 +31,10 @@ static const char XKB_FILE[] = "/usr/local/share/X11/xkb/rules/base.lst";
|
|||||||
static const char XKB_FILE[] = "/usr/share/X11/xkb/rules/base.lst";
|
static const char XKB_FILE[] = "/usr/share/X11/xkb/rules/base.lst";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//###
|
|
||||||
//### Public methods
|
|
||||||
//###
|
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, KeyboardGlobal::KeyboardInfo> KeyboardGlobal::getKeyboardLayouts() {
|
|
||||||
return parseKeyboardLayouts( XKB_FILE );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QString> KeyboardGlobal::getKeyboardModels() {
|
|
||||||
return parseKeyboardModels( XKB_FILE );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//###
|
|
||||||
//### Private methods
|
|
||||||
//###
|
|
||||||
|
|
||||||
|
|
||||||
//### Source by Georg Grabler <ggrabler@gmail.com> ###//
|
//### Source by Georg Grabler <ggrabler@gmail.com> ###//
|
||||||
QMap<QString, QString> KeyboardGlobal::parseKeyboardModels(QString filepath)
|
static KeyboardGlobal::ModelsMap parseKeyboardModels(const char* filepath)
|
||||||
{
|
{
|
||||||
QMap<QString, QString> models;
|
KeyboardGlobal::ModelsMap models;
|
||||||
|
|
||||||
QFile fh(filepath);
|
QFile fh(filepath);
|
||||||
fh.open(QIODevice::ReadOnly);
|
fh.open(QIODevice::ReadOnly);
|
||||||
@ -97,10 +77,9 @@ QMap<QString, QString> KeyboardGlobal::parseKeyboardModels(QString filepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
KeyboardGlobal::LayoutsMap parseKeyboardLayouts(const char* filepath)
|
||||||
QMap< QString, KeyboardGlobal::KeyboardInfo > KeyboardGlobal::parseKeyboardLayouts(QString filepath)
|
|
||||||
{
|
{
|
||||||
QMap< QString, KeyboardInfo > layouts;
|
KeyboardGlobal::LayoutsMap layouts;
|
||||||
|
|
||||||
//### Get Layouts ###//
|
//### Get Layouts ###//
|
||||||
|
|
||||||
@ -130,7 +109,7 @@ QMap< QString, KeyboardGlobal::KeyboardInfo > KeyboardGlobal::parseKeyboardLayou
|
|||||||
|
|
||||||
// insert into the layout map
|
// insert into the layout map
|
||||||
if (rx.indexIn(line) != -1) {
|
if (rx.indexIn(line) != -1) {
|
||||||
KeyboardInfo info;
|
KeyboardGlobal::KeyboardInfo info;
|
||||||
info.description = rx.cap(2);
|
info.description = rx.cap(2);
|
||||||
info.variants.insert(QObject::tr("Default"), "");
|
info.variants.insert(QObject::tr("Default"), "");
|
||||||
layouts.insert(rx.cap(1), info);
|
layouts.insert(rx.cap(1), info);
|
||||||
@ -166,7 +145,7 @@ QMap< QString, KeyboardGlobal::KeyboardInfo > KeyboardGlobal::parseKeyboardLayou
|
|||||||
layouts.find(rx.cap(2)).value().variants.insert(rx.cap(3), rx.cap(1));
|
layouts.find(rx.cap(2)).value().variants.insert(rx.cap(3), rx.cap(1));
|
||||||
} else {
|
} else {
|
||||||
// create a new map in the multimap - the value was not found.
|
// create a new map in the multimap - the value was not found.
|
||||||
KeyboardInfo info;
|
KeyboardGlobal::KeyboardInfo info;
|
||||||
info.description = rx.cap(2);
|
info.description = rx.cap(2);
|
||||||
info.variants.insert(QObject::tr("Default"), "");
|
info.variants.insert(QObject::tr("Default"), "");
|
||||||
info.variants.insert(rx.cap(3), rx.cap(1));
|
info.variants.insert(rx.cap(3), rx.cap(1));
|
||||||
@ -177,3 +156,14 @@ QMap< QString, KeyboardGlobal::KeyboardInfo > KeyboardGlobal::parseKeyboardLayou
|
|||||||
|
|
||||||
return layouts;
|
return layouts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
KeyboardGlobal::LayoutsMap KeyboardGlobal::getKeyboardLayouts() {
|
||||||
|
return parseKeyboardLayouts( XKB_FILE );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
KeyboardGlobal::ModelsMap KeyboardGlobal::getKeyboardModels() {
|
||||||
|
return parseKeyboardModels( XKB_FILE );
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -44,14 +44,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
using LayoutsMap = QMap< QString, KeyboardInfo >;
|
using LayoutsMap = QMap< QString, KeyboardInfo >;
|
||||||
|
using ModelsMap = QMap< QString, QString >;
|
||||||
|
|
||||||
static LayoutsMap getKeyboardLayouts();
|
static LayoutsMap getKeyboardLayouts();
|
||||||
static QMap< QString, QString > getKeyboardModels();
|
static ModelsMap getKeyboardModels();
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
static QMap< QString, QString > parseKeyboardModels(QString filepath);
|
|
||||||
static LayoutsMap parseKeyboardLayouts(QString filepath);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEYBOARDGLOBAL_H
|
#endif // KEYBOARDGLOBAL_H
|
||||||
|
Loading…
Reference in New Issue
Block a user