This repository has been archived by the owner on Jul 20, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
204 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* Chaotic Installer Keyboard Picker Screen | ||
I like to write this by hand, do whatever you want, but keep diff clean to read, so I | ||
can keep writing it manually. | ||
Also, consider this file copyright-free. | ||
*/ | ||
|
||
import QtQuick 2.2 | ||
import QtQuick.Controls 2.12 | ||
import QtQuick.Controls.Material 2.12 | ||
|
||
Component { | ||
Column { | ||
Row { | ||
id: pickKeyboardTitleRow | ||
anchors.top: parent.top | ||
anchors.topMargin: 20 | ||
anchors.horizontalCenter: parent.horizontalCenter | ||
|
||
Text { | ||
text: qsTr('Select your key-map:\n\nIf unsure leave default') | ||
} | ||
} | ||
Row { | ||
id: pickKeyboardListView | ||
anchors.top: pickKeyboardTitleRow.bottom | ||
anchors.bottom: pickKeyboardActionRow.top | ||
anchors.bottomMargin: 20 | ||
width: parent.width | ||
|
||
//Flickable { | ||
ScrollView { | ||
anchors.top: parent.top | ||
anchors.bottom: parent.bottom | ||
anchors.horizontalCenter: parent.horizontalCenter | ||
width: 320 | ||
clip: true | ||
|
||
contentWidth: pickKeyboardList.width | ||
contentHeight: pickKeyboardList.height | ||
|
||
ScrollBar.vertical: ScrollBar { | ||
policy: ScrollBar.AlwaysOn; | ||
parent: pickKeyboardListView | ||
anchors.top: parent.top | ||
anchors.right: parent.right | ||
anchors.bottom: parent.bottom | ||
} | ||
|
||
Column { | ||
id: pickKeyboardList | ||
|
||
Repeater { | ||
model: allKeyboards | ||
|
||
RadioButton {text: modelData; onClicked: setupLocale.selectedKeyboard = modelData } | ||
} | ||
} | ||
} | ||
} | ||
|
||
Row { | ||
id: pickKeyboardActionRow | ||
anchors.bottom: parent.bottom | ||
anchors.bottomMargin: 20 | ||
anchors.horizontalCenter: parent.horizontalCenter | ||
spacing: 80 | ||
|
||
Column { | ||
Button { | ||
text: qsTr('Back') | ||
onClicked: contentStack.pop() | ||
} | ||
} | ||
|
||
Column { | ||
TextField { | ||
placeholderText: qsTr('Testing area') | ||
} | ||
} | ||
|
||
Column { | ||
Button { | ||
text: qsTr('Next') | ||
highlighted: true | ||
Material.background: Material.Indigo | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <QProcess> | ||
#include <QDebug> | ||
#include <QtPlatformHeaders/QEglFSFunctions> | ||
|
||
#include "locale.hpp" | ||
|
||
Locale::Locale(QObject *parent) : | ||
QObject (parent) {} | ||
|
||
void Locale::toggleLocale(QString locale) { | ||
//TODO | ||
} | ||
|
||
QString Locale::getSelectedKeyboard() | ||
{ | ||
return selectedKeyboard; | ||
} | ||
|
||
QStringList Locale::getSelectedLocales() | ||
{ | ||
return selectedLocales; | ||
} | ||
|
||
QString Locale::getSelectedZone() | ||
{ | ||
return selectedZone; | ||
} | ||
|
||
void Locale::setKeyboard(const QString &keymap) { | ||
qDebug() << "Setting keymap " << keymap; | ||
|
||
selectedKeyboard = keymap; | ||
QProcess::execute(QStringLiteral("loadkeys %1").arg(keymap)); | ||
QProcess::execute(QStringLiteral("localectl set-keymap %1").arg(keymap)); | ||
QEglFSFunctions::loadKeymap( | ||
keymapDir.filePath(QStringLiteral("%1.map.gz").arg(keymap)) | ||
); | ||
|
||
emit keyboardChanged(); | ||
} | ||
|
||
void Locale::setZone(const QString &zone) { | ||
//TODO | ||
} | ||
|
||
QStringList Locale::keyboardsCache = QStringList(); | ||
QDir Locale::keymapDir = QDir(QStringLiteral("/usr/share/kbd/keymaps/i386/qwerty")); | ||
|
||
QStringList Locale::allKeyboards() const { | ||
if(keyboardsCache.size() < 1) { | ||
keymapDir.setNameFilters(QStringList() << "*.map.gz"); | ||
keyboardsCache = keymapDir | ||
.entryList() | ||
.replaceInStrings(".map.gz", ""); | ||
} | ||
return keyboardsCache; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef LOCALE_H | ||
#define LOCALE_H | ||
|
||
#include <QObject> | ||
#include <QDir> | ||
|
||
class Locale : public QObject { | ||
Q_OBJECT | ||
Q_PROPERTY(QString selectedKeyboard READ getSelectedKeyboard WRITE setKeyboard NOTIFY keyboardChanged) | ||
Q_PROPERTY(QStringList selectedLocales READ getSelectedLocales NOTIFY localesChanged) | ||
Q_PROPERTY(QString selectedZone READ getSelectedZone WRITE setZone NOTIFY zoneChanged) | ||
|
||
private: | ||
QString selectedKeyboard; | ||
QStringList selectedLocales; | ||
QString selectedZone; | ||
static QStringList keyboardsCache; | ||
static QDir keymapDir; | ||
|
||
public: | ||
explicit Locale(QObject *parent = nullptr); | ||
|
||
void setKeyboard(const QString &keymap); | ||
void setZone(const QString &locale); | ||
Q_INVOKABLE void toggleLocale(const QString locale); | ||
|
||
QStringList allKeyboards() const; | ||
QString getSelectedKeyboard(); | ||
QStringList getSelectedLocales(); | ||
QString getSelectedZone(); | ||
signals: | ||
void keyboardChanged(); | ||
void localesChanged(); | ||
void zoneChanged(); | ||
}; | ||
|
||
#endif // LOCALE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters