Diffstat (limited to 'inputmethods/multikey/configdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index 7bea589..c4f7413 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -11,71 +11,85 @@ | |||
11 | 11 | ||
12 | #include <qwidget.h> | 12 | #include <qwidget.h> |
13 | #include <qdialog.h> | 13 | #include <qdialog.h> |
14 | #include <qtabwidget.h> | 14 | #include <qtabwidget.h> |
15 | #include <qvbox.h> | 15 | #include <qvbox.h> |
16 | #include <qgrid.h> | 16 | #include <qgrid.h> |
17 | #include <qgroupbox.h> | 17 | #include <qgroupbox.h> |
18 | #include <qlabel.h> | 18 | #include <qlabel.h> |
19 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
20 | #include <qsizepolicy.h> | 20 | #include <qsizepolicy.h> |
21 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
22 | #include <qlistbox.h> | 22 | #include <qlistbox.h> |
23 | #include <qstringlist.h> | ||
23 | #include "configdlg.h" | 24 | #include "configdlg.h" |
24 | #include "keyboard.h" | 25 | #include "keyboard.h" |
25 | 26 | ||
26 | ConfigDlg::ConfigDlg () : QTabWidget () | 27 | ConfigDlg::ConfigDlg () : QTabWidget () |
27 | { | 28 | { |
28 | setCaption( tr("Multikey Configuration") ); | 29 | setCaption( tr("Multikey Configuration") ); |
30 | Config config ("multikey"); | ||
29 | 31 | ||
30 | /* | 32 | /* |
31 | * 'general config' tab | 33 | * 'general config' tab |
32 | */ | 34 | */ |
33 | 35 | ||
34 | QVBox *gen_box = new QVBox (this); | 36 | QVBox *gen_box = new QVBox (this); |
35 | gen_box->setMargin(3); | 37 | gen_box->setMargin(3); |
36 | addTab(gen_box, tr("General Settings")); | 38 | addTab(gen_box, tr("General Settings")); |
37 | 39 | ||
38 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); | 40 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); |
39 | 41 | ||
40 | keymaps = new QListBox (map_group); | 42 | keymaps = new QListBox (map_group); |
41 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 43 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
42 | //keymaps->setMaximumHeight(150); | ||
43 | 44 | ||
44 | QString cur(tr("Current Language")); | 45 | QString cur(tr("Current Language")); |
45 | keymaps->insertItem(cur); | 46 | keymaps->insertItem(cur); |
47 | |||
48 | config.setGroup ("keymaps"); | ||
49 | QStringList maps = config.readListEntry("maps", QChar('|')); | ||
50 | |||
51 | for (unsigned int i = 0; i < maps.count(); i++) { | ||
52 | |||
53 | keymaps->insertItem(maps[i]); | ||
54 | } | ||
55 | |||
56 | // have to "+1" because the "current language" listItem... remember? | ||
57 | keymaps->setSelected(config.readNumEntry("current", 0) + 1, true); | ||
58 | |||
46 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); | 59 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
47 | 60 | ||
61 | /* | ||
48 | QString ko(QPEApplication::qpeDir() + "/share/multikey/ko.keymap"); | 62 | QString ko(QPEApplication::qpeDir() + "/share/multikey/ko.keymap"); |
49 | keymaps->insertItem(ko); | 63 | keymaps->insertItem(ko); |
50 | 64 | ||
51 | QString en(QPEApplication::qpeDir() + "/share/multikey/en.keymap"); | 65 | QString en(QPEApplication::qpeDir() + "/share/multikey/en.keymap"); |
52 | keymaps->insertItem(en); | 66 | keymaps->insertItem(en); |
53 | 67 | ||
54 | QString de(QPEApplication::qpeDir() + "/share/multikey/de.keymap"); | 68 | QString de(QPEApplication::qpeDir() + "/share/multikey/de.keymap"); |
55 | keymaps->insertItem(de); | 69 | keymaps->insertItem(de); |
70 | */ | ||
56 | 71 | ||
57 | QGrid *add_remove_grid = new QGrid(2, map_group); | 72 | QGrid *add_remove_grid = new QGrid(2, map_group); |
58 | add_remove_grid->setMargin(3); | 73 | add_remove_grid->setMargin(3); |
59 | add_remove_grid->setSpacing(3); | 74 | add_remove_grid->setSpacing(3); |
60 | 75 | ||
61 | add_button = new QPushButton(tr("Add"), add_remove_grid); | 76 | add_button = new QPushButton(tr("Add"), add_remove_grid); |
62 | add_button->setFlat((bool)1); | 77 | add_button->setFlat((bool)1); |
63 | 78 | ||
64 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | 79 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); |
65 | remove_button->setFlat((bool)1); | 80 | remove_button->setFlat((bool)1); |
66 | 81 | ||
67 | pick_button = new QCheckBox(tr("Pickboard"), gen_box); | 82 | pick_button = new QCheckBox(tr("Pickboard"), gen_box); |
68 | 83 | ||
69 | Config config ("multikey"); | ||
70 | config.setGroup ("pickboard"); | 84 | config.setGroup ("pickboard"); |
71 | bool pick_open = config.readBoolEntry ("open", "0"); // default closed | 85 | bool pick_open = config.readBoolEntry ("open", "0"); // default closed |
72 | if (pick_open) { | 86 | if (pick_open) { |
73 | 87 | ||
74 | pick_button->setChecked(true); | 88 | pick_button->setChecked(true); |
75 | } | 89 | } |
76 | 90 | ||
77 | // by connecting it after checking it, the signal isn't emmited | 91 | // by connecting it after checking it, the signal isn't emmited |
78 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); | 92 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); |
79 | 93 | ||
80 | /* | 94 | /* |
81 | * 'color' tab | 95 | * 'color' tab |
@@ -107,37 +121,46 @@ ConfigDlg::ConfigDlg () : QTabWidget () | |||
107 | 121 | ||
108 | } | 122 | } |
109 | 123 | ||
110 | void ConfigDlg::pickTog() { | 124 | void ConfigDlg::pickTog() { |
111 | 125 | ||
112 | Config config ("multikey"); | 126 | Config config ("multikey"); |
113 | config.setGroup ("pickboard"); | 127 | config.setGroup ("pickboard"); |
114 | config.writeEntry ("open", pick_button->isChecked()); // default closed | 128 | config.writeEntry ("open", pick_button->isChecked()); // default closed |
115 | 129 | ||
116 | emit pickboardToggled(pick_button->isChecked()); | 130 | emit pickboardToggled(pick_button->isChecked()); |
117 | } | 131 | } |
118 | 132 | ||
133 | /* | ||
134 | * the index is kinda screwy, because in the config file, index 0 is just the | ||
135 | * first element in the QStringList, but here it's the "Current Language" | ||
136 | * listItem. therefor you have to minus one to the index before you access | ||
137 | * it from the config file. | ||
138 | * | ||
139 | * and later on, the "current language" setting should be -1 in the config file | ||
140 | */ | ||
141 | |||
119 | void ConfigDlg::setMap(int index) { | 142 | void ConfigDlg::setMap(int index) { |
120 | 143 | ||
121 | if (index == 0) { | 144 | if (index == 0) { |
122 | 145 | ||
123 | if (remove_button->isEnabled()) | 146 | if (remove_button->isEnabled()) |
124 | remove_button->setDisabled(true); | 147 | remove_button->setDisabled(true); |
125 | 148 | ||
126 | emit setMapToDefault(); | 149 | emit setMapToDefault(); |
127 | } | 150 | } |
128 | else { | 151 | else { |
129 | 152 | ||
130 | if (!remove_button->isEnabled()) | 153 | if (!remove_button->isEnabled()) |
131 | remove_button->setEnabled(true); | 154 | remove_button->setEnabled(true); |
132 | 155 | ||
133 | emit setMapToFile(keymaps->text(index)); | 156 | emit setMapToFile(index - 1); |
134 | } | 157 | } |
135 | } | 158 | } |
136 | 159 | ||
137 | void ConfigDlg::addMap() { | 160 | void ConfigDlg::addMap() { |
138 | 161 | ||
139 | } | 162 | } |
140 | 163 | ||
141 | void ConfigDlg::removeMap(int index) { | 164 | void ConfigDlg::removeMap(int index) { |
142 | 165 | ||
143 | } | 166 | } |