diff --git a/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp b/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp index 98fca85fe..e51f8ef16 100644 --- a/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp +++ b/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac + * Copyright 2019, Adriaan de Groot * * Originally from the Manjaro Installation Framework * by Roland Singer @@ -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"; #endif -//### -//### Public methods -//### - - -QMap KeyboardGlobal::getKeyboardLayouts() { - return parseKeyboardLayouts( XKB_FILE ); -} - - -QMap KeyboardGlobal::getKeyboardModels() { - return parseKeyboardModels( XKB_FILE ); -} - - - -//### -//### Private methods -//### - - //### Source by Georg Grabler ###// -QMap KeyboardGlobal::parseKeyboardModels(QString filepath) +static KeyboardGlobal::ModelsMap parseKeyboardModels(const char* filepath) { - QMap models; + KeyboardGlobal::ModelsMap models; QFile fh(filepath); fh.open(QIODevice::ReadOnly); @@ -97,10 +77,9 @@ QMap KeyboardGlobal::parseKeyboardModels(QString filepath) } - -QMap< QString, KeyboardGlobal::KeyboardInfo > KeyboardGlobal::parseKeyboardLayouts(QString filepath) +KeyboardGlobal::LayoutsMap parseKeyboardLayouts(const char* filepath) { - QMap< QString, KeyboardInfo > layouts; + KeyboardGlobal::LayoutsMap layouts; //### Get Layouts ###// @@ -130,7 +109,7 @@ QMap< QString, KeyboardGlobal::KeyboardInfo > KeyboardGlobal::parseKeyboardLayou // insert into the layout map if (rx.indexIn(line) != -1) { - KeyboardInfo info; + KeyboardGlobal::KeyboardInfo info; info.description = rx.cap(2); info.variants.insert(QObject::tr("Default"), ""); 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)); } else { // create a new map in the multimap - the value was not found. - KeyboardInfo info; + KeyboardGlobal::KeyboardInfo info; info.description = rx.cap(2); info.variants.insert(QObject::tr("Default"), ""); info.variants.insert(rx.cap(3), rx.cap(1)); @@ -177,3 +156,14 @@ QMap< QString, KeyboardGlobal::KeyboardInfo > KeyboardGlobal::parseKeyboardLayou return layouts; } + + +KeyboardGlobal::LayoutsMap KeyboardGlobal::getKeyboardLayouts() { + return parseKeyboardLayouts( XKB_FILE ); +} + + +KeyboardGlobal::ModelsMap KeyboardGlobal::getKeyboardModels() { + return parseKeyboardModels( XKB_FILE ); +} + diff --git a/src/modules/keyboard/keyboardwidget/keyboardglobal.h b/src/modules/keyboard/keyboardwidget/keyboardglobal.h index a438ed53c..349ef2d36 100644 --- a/src/modules/keyboard/keyboardwidget/keyboardglobal.h +++ b/src/modules/keyboard/keyboardwidget/keyboardglobal.h @@ -44,14 +44,10 @@ public: }; using LayoutsMap = QMap< QString, KeyboardInfo >; + using ModelsMap = QMap< QString, QString >; static LayoutsMap getKeyboardLayouts(); - static QMap< QString, QString > getKeyboardModels(); - - -private: - static QMap< QString, QString > parseKeyboardModels(QString filepath); - static LayoutsMap parseKeyboardLayouts(QString filepath); + static ModelsMap getKeyboardModels(); }; #endif // KEYBOARDGLOBAL_H