source: src-qt4/pc-firstbootgui/dialogKeyboard.cpp @ 31290f1

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1
Last change on this file since 31290f1 was 31290f1, checked in by Ken Moore <ken@…>, 14 months ago

Fix compilation of pc-firstbootgui on 10.x

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/****************************************************************************
2** ui.h extension file, included from the uic-generated form implementation.
3**
4** If you want to add, delete, or rename functions or slots, use
5** Qt Designer to update this file, preserving your code.
6**
7** You should not define a constructor or destructor in this file.
8** Instead, write your code in functions called init() and destroy().
9** These will automatically be called by the form's constructor and
10** destructor.
11*****************************************************************************/
12#include "backend.h"
13#include "dialogKeyboard.h"
14#include "ui_dialogKeyboard.h"
15
16void widgetKeyboard::programInit(QStringList kModel, QStringList kLayouts)
17{
18  connect(pushClose, SIGNAL(clicked()), this, SLOT(slotClose()));
19  connect(pushApply, SIGNAL(clicked()), this, SLOT(slotApply()));
20  keyboardModels = kModel;
21  keyboardLayouts = kLayouts;
22  connectKeyboardSlots();
23}
24
25void widgetKeyboard::slotClose()
26{
27  close();
28}
29
30void widgetKeyboard::slotApply()
31{
32  slotUpdateKbOnSys();
33}
34
35void widgetKeyboard::connectKeyboardSlots()
36{
37  // load keyboards
38  listKbLayouts->clear();
39  listKbLayouts->addItems(keyboardLayouts);
40  comboBoxKeyboardModel->addItems(keyboardModels);
41
42  // Set the default keyboard stuff
43  setKbDefaults();
44  slotCurrentKbLayoutChanged(0);
45  groupKeyboard->setEnabled(true);
46
47
48  // Connect all our slots
49  connect(listKbLayouts, SIGNAL(currentRowChanged(int)), this, SLOT(slotCurrentKbLayoutChanged(int)));
50  connect(listKbVariants,SIGNAL(currentRowChanged(int)), this, SLOT(slotCurrentKbVariantChanged(int)));
51  connect(listKbLayouts, SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectedKbItemChanged()));
52  connect(listKbVariants,SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectedKbItemChanged()));
53  connect(comboBoxKeyboardModel,SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateKbOnSys()));
54}
55
56void widgetKeyboard::slotCurrentKbLayoutChanged(int row)
57{
58    if (row != -1) {
59        QString kbLayout = listKbLayouts->currentItem()->text();
60        setKbVariants(kbLayout);
61    }
62
63   slotUpdateKbOnSys();
64}
65
66void widgetKeyboard::slotUpdateKbOnSys()
67{
68  QString model, layout, variant;
69
70  if ( ! (comboBoxKeyboardModel->currentIndex() == -1) )
71     return;
72  if ( ! listKbLayouts->currentItem() )
73     return;
74  if ( ! listKbVariants->currentItem() )
75     return;
76
77  model = comboBoxKeyboardModel->currentText();
78  model = model.remove(0, model.indexOf("- (") + 3 );
79  model.truncate(model.size() -1 );
80
81  layout = listKbLayouts->currentItem()->text();
82  layout = layout.remove(0, layout.indexOf("- (") + 3 );
83  layout.truncate(layout.size() -1 );
84
85  variant = listKbVariants->currentItem()->text();
86  if ( variant != "<none>" ) {
87    variant = variant.remove(0, variant.indexOf("- (") + 3 );
88    variant.truncate(variant.size() -1 );
89  } else {
90    variant = "";
91  }
92 
93  Scripts::Backend::changeKbMap(model, layout, variant);
94  emit changedLayout(model, layout, variant);
95}
96
97void widgetKeyboard::slotCurrentKbVariantChanged(int row)
98{
99   if (row != -1)
100      listKbVariants->currentItem()->text();
101
102   slotUpdateKbOnSys();
103}
104
105void widgetKeyboard::setKbVariants(const QString &kbLayout)
106{
107    QString laycode = kbLayout;
108    listKbVariants->clear();
109
110    // Get the code we should search for
111    laycode = laycode.remove(0, laycode.indexOf("(") + 1);
112    laycode.truncate(laycode.indexOf(")") );
113
114    listKbVariants->addItem("<none>");
115    listKbVariants->addItems(Scripts::Backend::keyVariants(laycode, savedKeyVariants));
116
117    listKbVariants->setCurrentRow(0);
118}
119
120void widgetKeyboard::slotSelectedKbItemChanged()
121{
122    lineKbTest->clear();
123}
124
125// set the keyboard layout and variant defaults
126void widgetKeyboard::setKbDefaults()
127{
128        // Find the "us" key layout as the default
129        for ( int i = 0; i < listKbLayouts->count(); i++ )
130                if ( listKbLayouts->item(i)->text().indexOf("(us)") != -1 )
131                        listKbLayouts->setCurrentRow(i);
132
133
134        comboBoxKeyboardModel->setCurrentIndex(2);
135}
Note: See TracBrowser for help on using the repository browser.