/* * Copyright (C) 2021 Lliurex project * * Author: * Enrique Medina Gremaldos * * Source: * https://github.com/lliurex/lliurex-sddm-theme * * This file is a part of lliurex sddm theme. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * */ #include "plugin.h" #include #include #include #include #include #include #include #include #include #include using namespace std; X11KeyLayout::X11KeyLayout(QObject* parent): QObject(parent) { } X11KeyLayout::X11KeyLayout(QString name,QString longName) : QObject(nullptr), m_name(name), m_longName(longName) { } Language::Language(QObject* parent): QObject(parent) { } Language::Language(QString name,QString longName) : QObject(nullptr), m_name(name), m_longName(longName) { } LocalePlugin::LocalePlugin(QObject* parent) : QQmlExtensionPlugin(parent) { } static QStringList run(QString cmd,QStringList args) { QProcess p; p.start(cmd,args); p.waitForFinished(); QByteArray out = p.readAll(); QList lines = out.split('\n'); QStringList ret; for (int n=0;n Locale::variantNames; Locale::Locale(QObject* parent): QObject(parent) { fstream file; file.open("/usr/share/X11/xkb/rules/evdev.lst",std::fstream::in); std::string tmp; bool start = false; while(std::getline(file,tmp)) { if (start) { if (tmp.size()==0) { break; } //TODO: some extra checks QString p = QString::fromStdString(tmp); QStringList q = p.split(QLatin1Char(':')); QString a = q[0].simplified(); QString b = q[1].simplified(); QStringList r = a.split(QLatin1Char(' ')); QString name = r[1]+QStringLiteral(":")+r[0]; Locale::variantNames[name]=b; //clog<"< (uri, 1, 0, "X11KeyLayout"); qmlRegisterType (uri, 1, 0, "Language"); qmlRegisterType (uri, 1, 0, "Locale"); qmlRegisterAnonymousType(uri, 1); }