source: src-qt4/pc-installgui/dialogKeyboard.cpp @ 1620346

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 1620346 was 1620346, checked in by Kris Moore <kris@…>, 19 months ago

Initial import of PC-BSD /current/ SVN repo

  • 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}
95
96void widgetKeyboard::slotCurrentKbVariantChanged(int row)
97{
98   if (row != -1)
99      listKbVariants->currentItem()->text();
100
101   slotUpdateKbOnSys();
102}
103
104void widgetKeyboard::setKbVariants(const QString &kbLayout)
105{
106    QString laycode = kbLayout;
107    listKbVariants->clear();
108
109    // Get the code we should search for
110    laycode = laycode.remove(0, laycode.indexOf("(") + 1);
111    laycode.truncate(laycode.indexOf(")") );
112
113    listKbVariants->addItem("<none>");
114    listKbVariants->addItems(Scripts::Backend::keyVariants(laycode, savedKeyVariants));
115
116    listKbVariants->setCurrentRow(0);
117}
118
119void widgetKeyboard::slotSelectedKbItemChanged()
120{
121    lineKbTest->clear();
122}
123
124// set the keyboard layout and variant defaults
125void widgetKeyboard::setKbDefaults()
126{
127        // Find the "us" key layout as the default
128        for ( int i = 0; i < listKbLayouts->count(); i++ )
129                if ( listKbLayouts->item(i)->text().indexOf("(us)") != -1 )
130                        listKbLayouts->setCurrentRow(i);
131
132
133        comboBoxKeyboardModel->setCurrentIndex(2);
134}
Note: See TracBrowser for help on using the repository browser.