forked from TheNiteCoder/system-keyboard-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow.h
79 lines (65 loc) · 1.93 KB
/
window.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef WINDOW_H
#define WINDOW_H
#include <QWidget>
#include <QListWidgetItem>
#include "translation.h"
#include "keyboardlayouts.h"
#include <QStringListModel>
#include <QSortFilterProxyModel>
#include "cmd.h"
namespace Ui {
class Window;
}
QT_BEGIN_NAMESPACE
class QComboBox;
QT_END_NAMESPACE
enum ComboBoxRoles
{
OptionName = Qt::UserRole,
};
const QStringList hotkeyOptions = {"grp", "lv3", "Compose key"};
const QStringList advancedOptions = {"grp_led", "caps", "terminate"};
const QString KeyboardDefaultFile = "/etc/default/keyboard";
class KeyboardLayoutListWidgetItem : public QListWidgetItem
{
public:
KeyboardLayoutListWidgetItem(KeyboardConfigItem layout, KeyboardConfigItem variant, QIcon icon)
: m_layout(layout), m_variant(variant)
{
QString variantTranslated = keyboardtr(variant.description);
if(variant.description.isEmpty())
variantTranslated = "";
setText(keyboardtr(m_layout.name) + " " + keyboardtr(m_layout.description) + " " + variantTranslated);
setIcon(icon);
}
virtual ~KeyboardLayoutListWidgetItem();
KeyboardConfigItem m_layout;
KeyboardConfigItem m_variant;
};
class Window : public QWidget
{
Q_OBJECT
public:
explicit Window(QWidget *parent = nullptr);
~Window();
private slots:
void refreshLayoutButtonStates();
QString generateOutput();
void loadDefaults();
private:
bool apply();
QString getModel();
QPair<QStringList, QStringList> getLayoutsAndVariants();
QStringList getOptions();
Cmd *shell;
private:
void addLayout(KeyboardConfigItem layout, KeyboardConfigItem variant);
void populateLayout(QLayout* layout, QStringList options);
QMap<QComboBox*, QMap<int, QString>> m_comboBoxInfo;
Ui::Window *ui;
KeyboardInfo m_keyboardInfo;
QStringList m_extraOptions;
QStringListModel m_keyboardModelsModel;
QSortFilterProxyModel m_keyboardModelsModelFilter;
};
#endif // WINDOW_H