Changeset View
Changeset View
Standalone View
Standalone View
kcms/keyboard/kcm_add_layout_dialog.cpp
Show All 17 Lines | |||||
18 | 18 | | |||
19 | #include "kcm_add_layout_dialog.h" | 19 | #include "kcm_add_layout_dialog.h" | ||
20 | #include <QDebug> | 20 | #include <QDebug> | ||
21 | #include <klocalizedstring.h> | 21 | #include <klocalizedstring.h> | ||
22 | 22 | | |||
23 | #include "xkb_rules.h" | 23 | #include "xkb_rules.h" | ||
24 | #include "flags.h" | 24 | #include "flags.h" | ||
25 | #include "iso_codes.h" | 25 | #include "iso_codes.h" | ||
26 | #include "tastenbrett.h" | ||||
26 | 27 | | |||
27 | #include "ui_kcm_add_layout_dialog.h" | 28 | #include "ui_kcm_add_layout_dialog.h" | ||
28 | 29 | | |||
29 | #include <config-keyboard.h> | 30 | #include <config-keyboard.h> | ||
30 | 31 | | |||
31 | 32 | AddLayoutDialog::AddLayoutDialog(const Rules* rules_, Flags* flags_, const QString& model_, | |||
32 | AddLayoutDialog::AddLayoutDialog(const Rules* rules_, Flags* flags_, const QString& model_, bool showLabel, QWidget* parent): | 33 | const QStringList &options_, bool showLabel, QWidget* parent): | ||
33 | QDialog(parent), | 34 | QDialog(parent), | ||
34 | rules(rules_), | 35 | rules(rules_), | ||
35 | flags(flags_), | 36 | flags(flags_), | ||
36 | model(model_), | 37 | model(model_), | ||
38 | options(options_), | ||||
37 | selectedLanguage(QStringLiteral("no_language")) | 39 | selectedLanguage(QStringLiteral("no_language")) | ||
38 | { | 40 | { | ||
39 | layoutDialogUi = new Ui_AddLayoutDialog(); | 41 | layoutDialogUi = new Ui_AddLayoutDialog(); | ||
40 | layoutDialogUi->setupUi(this); | 42 | layoutDialogUi->setupUi(this); | ||
41 | 43 | | |||
42 | QSet<QString> languages; | 44 | QSet<QString> languages; | ||
43 | foreach(const LayoutInfo* layoutInfo, rules->layoutInfos) { | 45 | foreach(const LayoutInfo* layoutInfo, rules->layoutInfos) { | ||
44 | QSet<QString> langs = QSet<QString>::fromList(layoutInfo->languages); | 46 | QSet<QString> langs = QSet<QString>::fromList(layoutInfo->languages); | ||
Show All 19 Lines | 55 | // } | |||
64 | else { | 66 | else { | ||
65 | layoutDialogUi->labelLabel->setVisible(false); | 67 | layoutDialogUi->labelLabel->setVisible(false); | ||
66 | layoutDialogUi->labelEdit->setVisible(false); | 68 | layoutDialogUi->labelEdit->setVisible(false); | ||
67 | } | 69 | } | ||
68 | 70 | | |||
69 | languageChanged(0); | 71 | languageChanged(0); | ||
70 | connect(layoutDialogUi->languageComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &AddLayoutDialog::languageChanged); | 72 | connect(layoutDialogUi->languageComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &AddLayoutDialog::languageChanged); | ||
71 | connect(layoutDialogUi->layoutComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &AddLayoutDialog::layoutChanged); | 73 | connect(layoutDialogUi->layoutComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &AddLayoutDialog::layoutChanged); | ||
72 | #ifdef NEW_GEOMETRY | 74 | | ||
73 | connect(layoutDialogUi->prevbutton, &QPushButton::clicked, this, &AddLayoutDialog::preview); | 75 | connect(layoutDialogUi->prevbutton, &QPushButton::clicked, this, &AddLayoutDialog::preview); | ||
74 | #else | 76 | layoutDialogUi->prevbutton->setVisible(Tastenbrett::exists()); | ||
75 | layoutDialogUi->prevbutton->setVisible(false); | | |||
76 | #endif | | |||
77 | } | 77 | } | ||
78 | 78 | | |||
79 | void AddLayoutDialog::languageChanged(int langIdx) | 79 | void AddLayoutDialog::languageChanged(int langIdx) | ||
80 | { | 80 | { | ||
81 | QString lang = layoutDialogUi->languageComboBox->itemData(langIdx).toString(); | 81 | QString lang = layoutDialogUi->languageComboBox->itemData(langIdx).toString(); | ||
82 | if( lang == selectedLanguage ) | 82 | if( lang == selectedLanguage ) | ||
83 | return; | 83 | return; | ||
84 | 84 | | |||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 151 | { | |||
155 | if( label == selectedLayoutUnit.layout() ) { | 155 | if( label == selectedLayoutUnit.layout() ) { | ||
156 | label = QLatin1String(""); | 156 | label = QLatin1String(""); | ||
157 | } | 157 | } | ||
158 | selectedLayoutUnit.setDisplayName( label ); | 158 | selectedLayoutUnit.setDisplayName( label ); | ||
159 | selectedLayoutUnit.setShortcut(layoutDialogUi->kkeysequencewidget->keySequence()); | 159 | selectedLayoutUnit.setShortcut(layoutDialogUi->kkeysequencewidget->keySequence()); | ||
160 | QDialog::accept(); | 160 | QDialog::accept(); | ||
161 | } | 161 | } | ||
162 | 162 | | |||
163 | | ||||
164 | #ifdef NEW_GEOMETRY | | |||
165 | void AddLayoutDialog::preview() | 163 | void AddLayoutDialog::preview() | ||
166 | { | 164 | { | ||
167 | int index = layoutDialogUi->variantComboBox->currentIndex(); | 165 | int index = layoutDialogUi->variantComboBox->currentIndex(); | ||
168 | QString variant = layoutDialogUi->variantComboBox->itemData(index).toString(); | 166 | QString variant = layoutDialogUi->variantComboBox->itemData(index).toString(); | ||
169 | KeyboardPainter* layoutPreview = new KeyboardPainter(); | 167 | Tastenbrett::launch(model, selectedLayout, variant, options.join(',')); | ||
170 | | ||||
171 | QString title = Flags::getLongText(LayoutUnit(selectedLayout, variant), rules); | | |||
172 | layoutPreview->generateKeyboardLayout(selectedLayout, variant, model, title); | | |||
173 | layoutPreview->setModal(true); | | |||
174 | layoutPreview->exec(); | | |||
175 | | ||||
176 | delete layoutPreview; | | |||
177 | } | 168 | } | ||
178 | #endif | |