summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-08 22:50:40 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-09 02:02:13 -0600
commit01e92019e6616d46a85beb5db6ddb84f58e253b6 (patch)
treee3bd5af3fdd8c610a2b823e6ec64a5454e36bf80 /ui
parent61b3bc944db6787711eb7a3f572ac4a306deca8b (diff)
downloadhorizon-01e92019e6616d46a85beb5db6ddb84f58e253b6.tar.gz
horizon-01e92019e6616d46a85beb5db6ddb84f58e253b6.tar.bz2
horizon-01e92019e6616d46a85beb5db6ddb84f58e253b6.tar.xz
horizon-01e92019e6616d46a85beb5db6ddb84f58e253b6.zip
Qt UI: Implement UI.Input page
Diffstat (limited to 'ui')
-rw-r--r--ui/qt5/CMakeLists.txt4
-rw-r--r--ui/qt5/horizonwizard.cc2
-rw-r--r--ui/qt5/inputpage.cc99
-rw-r--r--ui/qt5/inputpage.hh28
4 files changed, 133 insertions, 0 deletions
diff --git a/ui/qt5/CMakeLists.txt b/ui/qt5/CMakeLists.txt
index 38ede75..0dd441b 100644
--- a/ui/qt5/CMakeLists.txt
+++ b/ui/qt5/CMakeLists.txt
@@ -8,6 +8,7 @@ set(UI_SOURCES
main.cc
intropage.cc
+ inputpage.cc
networkingpage.cc
horizon.qrc)
@@ -17,5 +18,8 @@ target_link_libraries(horizon-qt5 Qt5::Widgets)
install(TARGETS horizon-qt5 DESTINATION bin)
IF(INSTALL)
+ pkg_check_modules(XKBFile REQUIRED xkbfile)
+ pkg_check_modules(LIBX11 REQUIRED x11)
+ target_link_libraries(horizon-qt5 ${LIBX11_LIBRARIES} ${XKBFile_LIBRARIES})
# add_executable(horizon-run-qt5 ${RUN_QT_SOURCES})
ENDIF(INSTALL)
diff --git a/ui/qt5/horizonwizard.cc b/ui/qt5/horizonwizard.cc
index ae25238..89a25d1 100644
--- a/ui/qt5/horizonwizard.cc
+++ b/ui/qt5/horizonwizard.cc
@@ -20,6 +20,7 @@
#include <string>
#include "intropage.hh"
+#include "inputpage.hh"
#include "networkingpage.hh"
#include "netsimplewifipage.hh"
@@ -64,6 +65,7 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) {
setSizeGripEnabled(false);
setPage(Page_Intro, new IntroPage);
+ setPage(Page_Input, new InputPage);
setPage(Page_Network, new NetworkingPage);
QObject::connect(this, &QWizard::helpRequested, [=](void) {
diff --git a/ui/qt5/inputpage.cc b/ui/qt5/inputpage.cc
new file mode 100644
index 0000000..f0816b4
--- /dev/null
+++ b/ui/qt5/inputpage.cc
@@ -0,0 +1,99 @@
+/*
+ * inputpage.cc - Implementation of the UI.Input page
+ * horizon-qt5, the Qt 5 user interface for
+ * Project Horizon
+ *
+ * Copyright (c) 2019 Adélie Linux and contributors. All rights reserved.
+ * This code is licensed under the AGPL 3.0 license, as noted in the
+ * LICENSE-code file in the root directory of this repository.
+ *
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+#include "inputpage.hh"
+
+#include <QLabel>
+#include <QVBoxLayout>
+
+/* XXX TODO: Share with hscript/meta.cc - perhaps make a common header? */
+#include <set>
+#include <string>
+const std::set<std::string> valid_keymaps = {
+ "us", "ad", "af", "ara", "al", "am", "at", "az", "by", "be", "bd", "in",
+ "ba", "br", "bg", "ma", "mm", "ca", "cd", "cn", "hr", "cz", "dk", "nl",
+ "bt", "ee", "ir", "iq", "fo", "fi", "fr", "gh", "gn", "ge", "de", "gr",
+ "hu", "is", "il", "it", "jp", "kg", "kh", "kz", "la", "latam", "lt", "lv",
+ "mao", "me", "mk", "mt", "mn", "no", "pl", "pt", "ro", "ru", "rs", "si",
+ "sk", "es", "se", "ch", "sy", "tj", "lk", "th", "tr", "ua", "gb", "uz",
+ "vn", "kr", "ie", "pk", "mv", "za", "epo", "np", "ng", "et", "sn", "brai",
+ "tm", "ml", "tz", "ke", "bw", "ph"
+};
+
+#ifdef HAS_INSTALL_ENV
+#include <QProcess>
+#include <QPushButton>
+#include <QLineEdit>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKBrules.h>
+#endif /* HAS_INSTALL_ENV */
+
+InputPage::InputPage(QWidget *parent) : HorizonWizardPage(parent) {
+ QLabel *descLabel;
+ QVBoxLayout *layout;
+
+ loadWatermark("intro");
+ setTitle(tr("Keyboard Layout"));
+
+ descLabel = new QLabel(tr("Choose the layout of your keyboard."));
+
+ /* REQ: UI.Input.LayoutList */
+ layoutList = new QListWidget(this);
+ layoutList->setSelectionMode(QAbstractItemView::SingleSelection);
+ layoutList->setWhatsThis(tr("This is a list of keyboard layouts. Select one to choose the layout of the keyboard you will be using on your Adélie Linux computer."));
+ for(auto &map : valid_keymaps) {
+ layoutList->addItem(map.c_str());
+ }
+
+ registerField("keymap*", layoutList);
+
+#ifdef HAS_INSTALL_ENV
+ /* REQ: UI.Input.ChooseLayout */
+ QObject::connect(layoutList, &QListWidget::currentItemChanged,
+ [](QListWidgetItem *current, QListWidgetItem *) {
+ if(current == nullptr) return;
+
+ QProcess setxkbmap;
+ setxkbmap.execute("setxkbmap", {current->text()});
+ });
+
+ /* REQ: UI.Input.Test */
+ QLineEdit *testArea = new QLineEdit(this);
+ testArea->setPlaceholderText(tr("Type here to test the keyboard layout you've selected."));
+ testArea->setWhatsThis(tr("By typing into this box, you can ensure the layout you've selected is the correct one."));
+#endif /* HAS_INSTALL_ENV */
+
+ layout = new QVBoxLayout(this);
+ layout->addWidget(descLabel);
+ layout->addSpacing(20);
+ layout->addWidget(layoutList);
+#ifdef HAS_INSTALL_ENV
+ layout->addStretch();
+ layout->addWidget(testArea);
+#endif /* HAS_INSTALL_ENV */
+
+ setLayout(layout);
+}
+
+void InputPage::initializePage() {
+#ifdef HAS_INSTALL_ENV
+ /* Select the current keyboard layout, if available. */
+ Display *dpy = XOpenDisplay(nullptr);
+ if(dpy != nullptr) {
+ XkbRF_VarDefsRec vardefs;
+ XkbRF_GetNamesProp(dpy, nullptr, &vardefs);
+ QList<QListWidgetItem *> items = layoutList->findItems(vardefs.layout, Qt::MatchExactly);
+ if(!items.empty()) layoutList->setCurrentItem(items.at(0));
+ XCloseDisplay(dpy);
+ }
+#endif /* HAS_INSTALL_ENV */
+}
diff --git a/ui/qt5/inputpage.hh b/ui/qt5/inputpage.hh
new file mode 100644
index 0000000..5b371bf
--- /dev/null
+++ b/ui/qt5/inputpage.hh
@@ -0,0 +1,28 @@
+/*
+ * inputpage.hh - Definition of the UI.Input page
+ * horizon-qt5, the Qt 5 user interface for
+ * Project Horizon
+ *
+ * Copyright (c) 2019 Adélie Linux and contributors. All rights reserved.
+ * This code is licensed under the AGPL 3.0 license, as noted in the
+ * LICENSE-code file in the root directory of this repository.
+ *
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+#ifndef INPUTPAGE_HH
+#define INPUTPAGE_HH
+
+#include <QListWidget>
+
+#include "horizonwizardpage.hh"
+
+class InputPage : public HorizonWizardPage {
+public:
+ InputPage(QWidget *parent = nullptr);
+ void initializePage() override;
+private:
+ QListWidget *layoutList;
+};
+
+#endif /* !INPUTPAGE_HH */