source: src-qt4/PCDM/src/dialogKeyboard.cpp @ 72c9698

9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 72c9698 was 72c9698, checked in by Ken Moore <ken@…>, 5 months ago

Fix up PCDM compilation on 10.x

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/* PCDM Login Manager:
2*  Written by Ken Moore (ken@pcbsd.org) 2012/2013
3*  Copyright(c) 2013 by the PC-BSD Project
4*  Available under the 3-clause BSD license
5*
6* Note: This file initially copied from the graphical PC-BSD installer
7*/
8
9#include "pcdm-backend.h"
10#include "dialogKeyboard.h"
11#include "ui_dialogKeyboard.h"
12
13widgetKeyboard::widgetKeyboard(QWidget* parent) : QWidget(parent){
14  setupUi(this);
15}
16
17void widgetKeyboard::programInit(QStringList kModel, QStringList kLayouts)
18{
19  connect(pushClose, SIGNAL(clicked()), this, SLOT(slotClose()));
20  connect(pushApply, SIGNAL(clicked()), this, SLOT(slotApply()));
21  keyboardModels = kModel;
22  keyboardLayouts = kLayouts;
23  connectKeyboardSlots();
24}
25
26void widgetKeyboard::slotClose()
27{
28  close();
29}
30
31void widgetKeyboard::slotApply()
32{
33  slotUpdateKbOnSys();
34}
35
36void widgetKeyboard::connectKeyboardSlots()
37{
38  // load keyboards
39  listKbLayouts->clear();
40  listKbLayouts->addItems(keyboardLayouts);
41  comboBoxKeyboardModel->addItems(keyboardModels);
42
43  // Set the default keyboard stuff
44  setKbDefaults();
45  slotCurrentKbLayoutChanged(0);
46  groupKeyboard->setEnabled(true);
47
48
49  // Connect all our slots
50  connect(listKbLayouts, SIGNAL(currentRowChanged(int)), this, SLOT(slotCurrentKbLayoutChanged(int)));
51  connect(listKbVariants,SIGNAL(currentRowChanged(int)), this, SLOT(slotCurrentKbVariantChanged(int)));
52  connect(listKbLayouts, SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectedKbItemChanged()));
53  connect(listKbVariants,SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectedKbItemChanged()));
54  connect(comboBoxKeyboardModel,SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateKbOnSys()));
55}
56
57void widgetKeyboard::slotCurrentKbLayoutChanged(int row)
58{
59    if (row != -1) {
60        QString kbLayout = listKbLayouts->currentItem()->text();
61        setKbVariants(kbLayout);
62    }
63
64   slotUpdateKbOnSys();
65}
66
67void widgetKeyboard::slotUpdateKbOnSys()
68{
69  QString model, layout, variant;
70
71  if ( ! (comboBoxKeyboardModel->currentIndex() == -1) )
72     return;
73  if ( ! listKbLayouts->currentItem() )
74     return;
75  if ( ! listKbVariants->currentItem() )
76     return;
77
78  model = comboBoxKeyboardModel->currentText();
79  model = model.remove(0, model.indexOf("- (") + 3 );
80  model.truncate(model.size() -1 );
81
82  layout = listKbLayouts->currentItem()->text();
83  layout = layout.remove(0, layout.indexOf("- (") + 3 );
84  layout.truncate(layout.size() -1 );
85
86  variant = listKbVariants->currentItem()->text();
87  if ( variant != "<none>" ) {
88    variant = variant.remove(0, variant.indexOf("- (") + 3 );
89    variant.truncate(variant.size() -1 );
90  } else {
91    variant = "";
92  }
93 
94  Backend::changeKbMap(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(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.