author | hash <hash> | 2002-08-19 07:21:51 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-19 07:21:51 (UTC) |
commit | 9cc94030d7f6a04b79da8db83e6c609c1580a3d3 (patch) (unidiff) | |
tree | b7c0fbc543d633ec9bd0f9d2ef762ebb92b2da55 /inputmethods/multikey/configdlg.cpp | |
parent | 64a00421be85d223072e087d4d3c9ecdad464095 (diff) | |
download | opie-9cc94030d7f6a04b79da8db83e6c609c1580a3d3.zip opie-9cc94030d7f6a04b79da8db83e6c609c1580a3d3.tar.gz opie-9cc94030d7f6a04b79da8db83e6c609c1580a3d3.tar.bz2 |
parses dir and also lets you add/remove maps located in other places
Diffstat (limited to 'inputmethods/multikey/configdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index a6e4dad..ac132d3 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -83,137 +83,139 @@ ConfigDlg::ConfigDlg () : QTabWidget () | |||
83 | 83 | ||
84 | keymaps->insertItem(custom_maps[i]); | 84 | keymaps->insertItem(custom_maps[i]); |
85 | if (custom_maps[i] == current_map) { | 85 | if (custom_maps[i] == current_map) { |
86 | 86 | ||
87 | keymaps->setSelected(map_dir.count() + i + 1, true); | 87 | keymaps->setSelected(map_dir.count() + i + 1, true); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | // have to "+1" because the "current language" listItem... remember? | 92 | // have to "+1" because the "current language" listItem... remember? |
93 | 93 | ||
94 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); | 94 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
95 | 95 | ||
96 | 96 | ||
97 | QGrid *add_remove_grid = new QGrid(2, map_group); | 97 | QGrid *add_remove_grid = new QGrid(2, map_group); |
98 | add_remove_grid->setMargin(3); | 98 | add_remove_grid->setMargin(3); |
99 | add_remove_grid->setSpacing(3); | 99 | add_remove_grid->setSpacing(3); |
100 | 100 | ||
101 | add_button = new QPushButton(tr("Add"), add_remove_grid); | 101 | add_button = new QPushButton(tr("Add"), add_remove_grid); |
102 | add_button->setFlat((bool)1); | 102 | add_button->setFlat((bool)1); |
103 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); | 103 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); |
104 | 104 | ||
105 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | 105 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); |
106 | remove_button->setFlat((bool)1); | 106 | remove_button->setFlat((bool)1); |
107 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); | 107 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); |
108 | 108 | ||
109 | pick_button = new QCheckBox(tr("Pickboard"), gen_box); | 109 | pick_button = new QCheckBox(tr("Pickboard"), gen_box); |
110 | 110 | ||
111 | config.setGroup ("pickboard"); | 111 | config.setGroup ("pickboard"); |
112 | bool pick_open = config.readBoolEntry ("open", "0"); // default closed | 112 | bool pick_open = config.readBoolEntry ("open", "0"); // default closed |
113 | if (pick_open) { | 113 | if (pick_open) { |
114 | 114 | ||
115 | pick_button->setChecked(true); | 115 | pick_button->setChecked(true); |
116 | } | 116 | } |
117 | 117 | ||
118 | // by connecting it after checking it, the signal isn't emmited | 118 | // by connecting it after checking it, the signal isn't emmited |
119 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); | 119 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); |
120 | 120 | ||
121 | /* | 121 | /* |
122 | * 'color' tab | 122 | * 'color' tab |
123 | */ | 123 | */ |
124 | 124 | ||
125 | QGrid *color_box = new QGrid(2, this); | 125 | QGrid *color_box = new QGrid(2, this); |
126 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 126 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
127 | color_box->setMargin(3); | 127 | color_box->setMargin(3); |
128 | color_box->setSpacing(3); | 128 | color_box->setSpacing(3); |
129 | addTab(color_box, tr("Colors")); | 129 | addTab(color_box, tr("Colors")); |
130 | 130 | ||
131 | QLabel *label; | 131 | QLabel *label; |
132 | 132 | ||
133 | label = new QLabel(tr("Key Color"), color_box); | 133 | label = new QLabel(tr("Key Color"), color_box); |
134 | QPushButton *button = new QPushButton(color_box); | 134 | QPushButton *button = new QPushButton(color_box); |
135 | button->setFlat((bool)1); | 135 | button->setFlat((bool)1); |
136 | label = new QLabel(tr("Key Pressed Color"), color_box); | 136 | label = new QLabel(tr("Key Pressed Color"), color_box); |
137 | button = new QPushButton(color_box); | 137 | button = new QPushButton(color_box); |
138 | button->setFlat((bool)1); | 138 | button->setFlat((bool)1); |
139 | label = new QLabel(tr("Line Color"), color_box); | 139 | label = new QLabel(tr("Line Color"), color_box); |
140 | button = new QPushButton(color_box); | 140 | button = new QPushButton(color_box); |
141 | button->setFlat((bool)1); | 141 | button->setFlat((bool)1); |
142 | label = new QLabel(tr("Text Color"), color_box); | 142 | label = new QLabel(tr("Text Color"), color_box); |
143 | button = new QPushButton(color_box); | 143 | button = new QPushButton(color_box); |
144 | button->setFlat((bool)1); | 144 | button->setFlat((bool)1); |
145 | 145 | ||
146 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand | 146 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand |
147 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 147 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
148 | 148 | ||
149 | } | 149 | } |
150 | 150 | ||
151 | void ConfigDlg::pickTog() { | 151 | void ConfigDlg::pickTog() { |
152 | 152 | ||
153 | Config config ("multikey"); | 153 | Config config ("multikey"); |
154 | config.setGroup ("pickboard"); | 154 | config.setGroup ("pickboard"); |
155 | config.writeEntry ("open", pick_button->isChecked()); // default closed | 155 | config.writeEntry ("open", pick_button->isChecked()); // default closed |
156 | 156 | ||
157 | emit pickboardToggled(pick_button->isChecked()); | 157 | emit pickboardToggled(pick_button->isChecked()); |
158 | } | 158 | } |
159 | 159 | ||
160 | /* | 160 | /* |
161 | * the index is kinda screwy, because in the config file, index 0 is just the | 161 | * the index is kinda screwy, because in the config file, index 0 is just the |
162 | * first element in the QStringList, but here it's the "Current Language" | 162 | * first element in the QStringList, but here it's the "Current Language" |
163 | * listItem. therefor you have to minus one to the index before you access it. | 163 | * listItem. therefor you have to minus one to the index before you access it. |
164 | * | 164 | * |
165 | */ | 165 | */ |
166 | 166 | ||
167 | void ConfigDlg::setMap(int index) { | 167 | void ConfigDlg::setMap(int index) { |
168 | 168 | ||
169 | if (index == 0) { | 169 | if (index == 0) { |
170 | 170 | ||
171 | remove_button->setDisabled(true); | 171 | remove_button->setDisabled(true); |
172 | 172 | ||
173 | emit setMapToDefault(); | 173 | emit setMapToDefault(); |
174 | } | 174 | } |
175 | else if ((uint)index <= default_maps.count()) { | 175 | else if ((uint)index <= default_maps.count()) { |
176 | 176 | ||
177 | remove_button->setDisabled(true); | 177 | remove_button->setDisabled(true); |
178 | 178 | ||
179 | emit setMapToFile(keymaps->text(index)); | ||
180 | |||
179 | } else { | 181 | } else { |
180 | 182 | ||
181 | remove_button->setEnabled(true); | 183 | remove_button->setEnabled(true); |
182 | 184 | ||
183 | emit setMapToFile(keymaps->text(index)); | 185 | emit setMapToFile(keymaps->text(index)); |
184 | } | 186 | } |
185 | } | 187 | } |
186 | 188 | ||
187 | void ConfigDlg::addMap() { | 189 | void ConfigDlg::addMap() { |
188 | 190 | ||
189 | QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); | 191 | QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); |
190 | Config config ("multikey"); | 192 | Config config ("multikey"); |
191 | config.setGroup("keymaps"); | 193 | config.setGroup("keymaps"); |
192 | QStringList maps = config.readListEntry("maps", QChar('|')); | 194 | QStringList maps = config.readListEntry("maps", QChar('|')); |
193 | maps.append(map); | 195 | maps.append(map); |
194 | keymaps->insertItem(map); | 196 | keymaps->insertItem(map); |
195 | keymaps->setSelected(keymaps->count() - 1, true); | 197 | keymaps->setSelected(keymaps->count() - 1, true); |
196 | 198 | ||
197 | 199 | ||
198 | config.writeEntry("maps", maps.join("|")); | 200 | config.writeEntry("maps", maps.join("|")); |
199 | config.writeEntry("current", map); | 201 | config.writeEntry("current", map); |
200 | 202 | ||
201 | } | 203 | } |
202 | 204 | ||
203 | void ConfigDlg::removeMap() { | 205 | void ConfigDlg::removeMap() { |
204 | 206 | ||
205 | cout << "removing : " << custom_maps[keymaps->currentItem() - default_maps.count() - 1] << "\n"; | 207 | cout << "removing : " << custom_maps[keymaps->currentItem() - default_maps.count() - 1] << "\n"; |
206 | cout << "currentItem : " << keymaps->currentItem() << "\n"; | 208 | cout << "currentItem : " << keymaps->currentItem() << "\n"; |
207 | 209 | ||
208 | // move selection up one | 210 | // move selection up one |
209 | keymaps->setSelected(keymaps->currentItem() - 1, true); | 211 | keymaps->setSelected(keymaps->currentItem() - 1, true); |
210 | // delete the next selected item cus you just moved it up | 212 | // delete the next selected item cus you just moved it up |
211 | keymaps->removeItem(keymaps->currentItem() + 1); | 213 | keymaps->removeItem(keymaps->currentItem() + 1); |
212 | 214 | ||
213 | custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]); | 215 | custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]); |
214 | 216 | ||
215 | // write the changes | 217 | // write the changes |
216 | Config config ("multikey"); | 218 | Config config ("multikey"); |
217 | config.setGroup("keymaps"); | 219 | config.setGroup("keymaps"); |
218 | config.writeEntry("maps", custom_maps.join("|")); | 220 | config.writeEntry("maps", custom_maps.join("|")); |
219 | } | 221 | } |