-rw-r--r-- | scripts/kconfig/qconf.cc | 274 |
1 files changed, 202 insertions, 72 deletions
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index feefa1c..bed541d 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc | |||
@@ -1,176 +1,177 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
3 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qmainwindow.h> | 7 | #include <qmainwindow.h> |
8 | #include <qtoolbar.h> | 8 | #include <qtoolbar.h> |
9 | #include <qvbox.h> | 9 | #include <qvbox.h> |
10 | #include <qsplitter.h> | 10 | #include <qsplitter.h> |
11 | #include <qlistview.h> | 11 | #include <qlistview.h> |
12 | #include <qtextview.h> | 12 | #include <qtextview.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qmenubar.h> | 14 | #include <qmenubar.h> |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qaction.h> | 16 | #include <qaction.h> |
17 | #include <qheader.h> | 17 | #include <qheader.h> |
18 | #include <qfiledialog.h> | 18 | #include <qfiledialog.h> |
19 | #include <qregexp.h> | 19 | #include <qregexp.h> |
20 | #if QT_VERSION >= 300 | ||
21 | #include <qsettings.h> | ||
22 | #endif | ||
23 | |||
20 | #include <stdlib.h> | 24 | #include <stdlib.h> |
21 | 25 | ||
22 | #include "lkc.h" | 26 | #include "lkc.h" |
23 | #include "qconf.h" | 27 | #include "qconf.h" |
24 | 28 | ||
25 | #include "qconf.moc" | 29 | #include "qconf.moc" |
26 | #include "images.c" | 30 | #include "images.c" |
27 | 31 | ||
28 | static QApplication *configApp; | 32 | static QApplication *configApp; |
33 | #if QT_VERSION >= 300 | ||
34 | static QSettings *configSettings; | ||
35 | #endif | ||
29 | 36 | ||
30 | /* | 37 | /* |
31 | * update all the children of a menu entry | 38 | * update all the children of a menu entry |
32 | * removes/adds the entries from the parent widget as necessary | 39 | * removes/adds the entries from the parent widget as necessary |
33 | * | 40 | * |
34 | * parent: either the menu list widget or a menu entry widget | 41 | * parent: either the menu list widget or a menu entry widget |
35 | * menu: entry to be updated | 42 | * menu: entry to be updated |
36 | */ | 43 | */ |
37 | template <class P> | 44 | template <class P> |
38 | static void updateMenuList(P* parent, struct menu* menu) | 45 | static void updateMenuList(P* parent, struct menu* menu) |
39 | { | 46 | { |
40 | struct menu* child; | 47 | struct menu* child; |
41 | ConfigList* list = parent->listView(); | 48 | ConfigList* list = parent->listView(); |
42 | ConfigItem* item; | 49 | ConfigItem* item; |
43 | ConfigItem* last; | 50 | ConfigItem* last; |
44 | bool visible; | 51 | bool visible; |
45 | bool showAll = list->showAll; | 52 | bool showAll = list->showAll; |
46 | enum listMode mode = list->mode; | 53 | enum listMode mode = list->mode; |
47 | enum prop_type type; | 54 | enum prop_type type; |
48 | 55 | ||
49 | if (!menu) { | 56 | if (!menu) { |
50 | while ((item = parent->firstChild())) | 57 | while ((item = parent->firstChild())) |
51 | delete item; | 58 | delete item; |
52 | return; | 59 | return; |
53 | } | 60 | } |
54 | 61 | ||
55 | last = 0; | 62 | last = 0; |
56 | for (child = menu->list; child; child = child->next) { | 63 | for (child = menu->list; child; child = child->next) { |
57 | item = last ? last->nextSibling() : parent->firstChild(); | 64 | item = last ? last->nextSibling() : parent->firstChild(); |
58 | type = child->prompt ? child->prompt->type : P_UNKNOWN; | 65 | type = child->prompt ? child->prompt->type : P_UNKNOWN; |
59 | 66 | ||
60 | switch (mode) { | 67 | switch (mode) { |
61 | case menuMode: | 68 | case menuMode: |
62 | if (type != P_ROOTMENU) | 69 | if (type != P_ROOTMENU) |
63 | goto hide; | 70 | goto hide; |
64 | break; | 71 | break; |
65 | case symbolMode: | 72 | case symbolMode: |
66 | if (type == P_ROOTMENU) | 73 | if (type == P_ROOTMENU) |
67 | goto hide; | 74 | goto hide; |
68 | break; | 75 | break; |
69 | default: | 76 | default: |
70 | break; | 77 | break; |
71 | } | 78 | } |
72 | 79 | ||
73 | visible = menu_is_visible(child); | 80 | visible = menu_is_visible(child); |
74 | if (showAll || visible) { | 81 | if (showAll || visible) { |
75 | if (!item || item->menu != child) | 82 | if (!item || item->menu != child) |
76 | item = new ConfigItem(parent, last, child); | 83 | item = new ConfigItem(parent, last, child, visible); |
77 | item->visible = visible; | 84 | else { |
78 | item->updateMenu(); | 85 | item->visible = visible; |
86 | if (item->updateNeeded()) { | ||
87 | ConfigItem* i = (ConfigItem*)child->data; | ||
88 | for (; i; i = i->nextItem) { | ||
89 | i->updateMenu(); | ||
90 | } | ||
91 | } else if (list->updateAll) | ||
92 | item->updateMenu(); | ||
93 | } | ||
79 | 94 | ||
80 | if (mode == fullMode || mode == menuMode || | 95 | if (mode == fullMode || mode == menuMode || |
81 | (type != P_MENU && type != P_ROOTMENU)) | 96 | (type != P_MENU && type != P_ROOTMENU)) |
82 | updateMenuList(item, child); | 97 | updateMenuList(item, child); |
83 | else | 98 | else |
84 | updateMenuList(item, 0); | 99 | updateMenuList(item, 0); |
85 | last = item; | 100 | last = item; |
86 | continue; | 101 | continue; |
87 | } | 102 | } |
88 | hide: | 103 | hide: |
89 | if (item && item->menu == child) { | 104 | if (item && item->menu == child) { |
90 | last = parent->firstChild(); | 105 | last = parent->firstChild(); |
91 | if (last == item) | 106 | if (last == item) |
92 | last = 0; | 107 | last = 0; |
93 | else while (last->nextSibling() != item) | 108 | else while (last->nextSibling() != item) |
94 | last = last->nextSibling(); | 109 | last = last->nextSibling(); |
95 | delete item; | 110 | delete item; |
96 | } | 111 | } |
97 | } | 112 | } |
98 | } | 113 | } |
99 | 114 | ||
100 | #if QT_VERSION >= 300 | 115 | #if QT_VERSION >= 300 |
101 | /* | 116 | /* |
102 | * set the new data | 117 | * set the new data |
103 | * TODO check the value | 118 | * TODO check the value |
104 | */ | 119 | */ |
105 | void ConfigItem::okRename(int col) | 120 | void ConfigItem::okRename(int col) |
106 | { | 121 | { |
107 | Parent::okRename(col); | 122 | Parent::okRename(col); |
108 | sym_set_string_value(menu->sym, text(dataColIdx).latin1()); | 123 | sym_set_string_value(menu->sym, text(dataColIdx).latin1()); |
109 | } | 124 | } |
110 | #endif | 125 | #endif |
111 | 126 | ||
112 | /* | 127 | /* |
113 | * update the displayed of a menu entry | 128 | * update the displayed of a menu entry |
114 | */ | 129 | */ |
115 | void ConfigItem::updateMenu(void) | 130 | void ConfigItem::updateMenu(void) |
116 | { | 131 | { |
117 | ConfigList* list; | 132 | ConfigList* list; |
118 | struct symbol* sym; | 133 | struct symbol* sym; |
119 | QString prompt; | 134 | QString prompt; |
120 | int type; | 135 | int type; |
121 | enum prop_type ptype; | 136 | enum prop_type ptype; |
122 | tristate expr; | 137 | tristate expr; |
123 | bool update; | ||
124 | 138 | ||
125 | list = listView(); | 139 | list = listView(); |
126 | update = doInit; | ||
127 | if (update) | ||
128 | doInit = false; | ||
129 | else | ||
130 | update = list->updateAll; | ||
131 | 140 | ||
132 | sym = menu->sym; | 141 | sym = menu->sym; |
133 | if (!sym) { | 142 | if (!sym) { |
134 | if (update) { | 143 | setText(promptColIdx, menu_get_prompt(menu)); |
135 | setText(promptColIdx, menu_get_prompt(menu)); | 144 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
136 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 145 | if ((ptype == P_ROOTMENU || ptype == P_MENU) && |
137 | if ((ptype == P_ROOTMENU || ptype == P_MENU) && | 146 | (list->mode == singleMode || list->mode == symbolMode)) |
138 | (list->mode == singleMode || list->mode == symbolMode)) | 147 | setPixmap(promptColIdx, list->menuPix); |
139 | setPixmap(promptColIdx, list->menuPix); | 148 | else |
140 | else | 149 | setPixmap(promptColIdx, 0); |
141 | setPixmap(promptColIdx, 0); | ||
142 | } | ||
143 | return; | 150 | return; |
144 | } | 151 | } |
145 | 152 | ||
146 | sym_calc_value(sym); | 153 | setText(nameColIdx, sym->name); |
147 | if (!(sym->flags & SYMBOL_CHANGED) && !update) | ||
148 | return; | ||
149 | |||
150 | sym->flags &= ~SYMBOL_CHANGED; | ||
151 | |||
152 | setText(nameColIdx, menu->sym->name); | ||
153 | 154 | ||
154 | type = sym_get_type(sym); | 155 | type = sym_get_type(sym); |
155 | switch (type) { | 156 | switch (type) { |
156 | case S_BOOLEAN: | 157 | case S_BOOLEAN: |
157 | case S_TRISTATE: | 158 | case S_TRISTATE: |
158 | char ch; | 159 | char ch; |
159 | 160 | ||
160 | prompt = menu_get_prompt(menu); | 161 | prompt = menu_get_prompt(menu); |
161 | if (!sym_is_changable(sym) && !list->showAll) { | 162 | if (!sym_is_changable(sym) && !list->showAll) { |
162 | setText(noColIdx, 0); | 163 | setText(noColIdx, 0); |
163 | setText(modColIdx, 0); | 164 | setText(modColIdx, 0); |
164 | setText(yesColIdx, 0); | 165 | setText(yesColIdx, 0); |
165 | break; | 166 | break; |
166 | } | 167 | } |
167 | expr = sym_get_tristate_value(sym); | 168 | expr = sym_get_tristate_value(sym); |
168 | switch (expr) { | 169 | switch (expr) { |
169 | case yes: | 170 | case yes: |
170 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) | 171 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) |
171 | setPixmap(promptColIdx, list->choiceYesPix); | 172 | setPixmap(promptColIdx, list->choiceYesPix); |
172 | else | 173 | else |
173 | setPixmap(promptColIdx, list->symbolYesPix); | 174 | setPixmap(promptColIdx, list->symbolYesPix); |
174 | setText(yesColIdx, "Y"); | 175 | setText(yesColIdx, "Y"); |
175 | ch = 'Y'; | 176 | ch = 'Y'; |
176 | break; | 177 | break; |
@@ -183,128 +184,150 @@ void ConfigItem::updateMenu(void) | |||
183 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) | 184 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) |
184 | setPixmap(promptColIdx, list->choiceNoPix); | 185 | setPixmap(promptColIdx, list->choiceNoPix); |
185 | else | 186 | else |
186 | setPixmap(promptColIdx, list->symbolNoPix); | 187 | setPixmap(promptColIdx, list->symbolNoPix); |
187 | setText(noColIdx, "N"); | 188 | setText(noColIdx, "N"); |
188 | ch = 'N'; | 189 | ch = 'N'; |
189 | break; | 190 | break; |
190 | } | 191 | } |
191 | if (expr != no) | 192 | if (expr != no) |
192 | setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); | 193 | setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); |
193 | if (expr != mod) | 194 | if (expr != mod) |
194 | setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); | 195 | setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); |
195 | if (expr != yes) | 196 | if (expr != yes) |
196 | setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); | 197 | setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); |
197 | 198 | ||
198 | setText(dataColIdx, QChar(ch)); | 199 | setText(dataColIdx, QChar(ch)); |
199 | break; | 200 | break; |
200 | case S_INT: | 201 | case S_INT: |
201 | case S_HEX: | 202 | case S_HEX: |
202 | case S_STRING: | 203 | case S_STRING: |
203 | const char* data; | 204 | const char* data; |
204 | 205 | ||
205 | data = sym_get_string_value(sym); | 206 | data = sym_get_string_value(sym); |
206 | #if QT_VERSION >= 300 | 207 | #if QT_VERSION >= 300 |
207 | setRenameEnabled(list->mapIdx(dataColIdx), TRUE); | 208 | int i = list->mapIdx(dataColIdx); |
209 | if (i >= 0) | ||
210 | setRenameEnabled(i, TRUE); | ||
208 | #endif | 211 | #endif |
209 | setText(dataColIdx, data); | 212 | setText(dataColIdx, data); |
210 | if (type == S_STRING) | 213 | if (type == S_STRING) |
211 | prompt.sprintf("%s: %s", menu_get_prompt(menu), data); | 214 | prompt.sprintf("%s: %s", menu_get_prompt(menu), data); |
212 | else | 215 | else |
213 | prompt.sprintf("(%s) %s", data, menu_get_prompt(menu)); | 216 | prompt.sprintf("(%s) %s", data, menu_get_prompt(menu)); |
214 | break; | 217 | break; |
215 | } | 218 | } |
216 | if (!sym_has_value(sym) && visible) | 219 | if (!sym_has_value(sym) && visible) |
217 | prompt += " (NEW)"; | 220 | prompt += " (NEW)"; |
218 | setText(promptColIdx, prompt); | 221 | setText(promptColIdx, prompt); |
219 | } | 222 | } |
220 | 223 | ||
224 | bool ConfigItem::updateNeeded(void) | ||
225 | { | ||
226 | struct symbol* sym = menu->sym; | ||
227 | if (sym) | ||
228 | sym_calc_value(sym); | ||
229 | if (menu->flags & MENU_CHANGED) { | ||
230 | menu->flags &= ~MENU_CHANGED; | ||
231 | return true; | ||
232 | } | ||
233 | return false; | ||
234 | } | ||
235 | |||
221 | void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) | 236 | void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) |
222 | { | 237 | { |
223 | ConfigList* list = listView(); | 238 | ConfigList* list = listView(); |
224 | 239 | ||
225 | if (visible) { | 240 | if (visible) { |
226 | if (isSelected() && !list->hasFocus() && list->mode == menuMode) | 241 | if (isSelected() && !list->hasFocus() && list->mode == menuMode) |
227 | Parent::paintCell(p, list->inactivedColorGroup, column, width, align); | 242 | Parent::paintCell(p, list->inactivedColorGroup, column, width, align); |
228 | else | 243 | else |
229 | Parent::paintCell(p, cg, column, width, align); | 244 | Parent::paintCell(p, cg, column, width, align); |
230 | } else | 245 | } else |
231 | Parent::paintCell(p, list->disabledColorGroup, column, width, align); | 246 | Parent::paintCell(p, list->disabledColorGroup, column, width, align); |
232 | } | 247 | } |
233 | 248 | ||
234 | /* | 249 | /* |
235 | * construct a menu entry | 250 | * construct a menu entry |
236 | */ | 251 | */ |
237 | void ConfigItem::init(void) | 252 | void ConfigItem::init(void) |
238 | { | 253 | { |
239 | ConfigList* list = listView(); | 254 | ConfigList* list = listView(); |
240 | #if QT_VERSION < 300 | 255 | nextItem = (ConfigItem*)menu->data; |
241 | visible = TRUE; | 256 | menu->data = this; |
242 | #endif | 257 | |
243 | //menu->data = this; | ||
244 | if (list->mode != fullMode) | 258 | if (list->mode != fullMode) |
245 | setOpen(TRUE); | 259 | setOpen(TRUE); |
246 | doInit= true; | 260 | if (menu->sym) |
261 | sym_calc_value(menu->sym); | ||
262 | updateMenu(); | ||
247 | } | 263 | } |
248 | 264 | ||
249 | /* | 265 | /* |
250 | * destruct a menu entry | 266 | * destruct a menu entry |
251 | */ | 267 | */ |
252 | ConfigItem::~ConfigItem(void) | 268 | ConfigItem::~ConfigItem(void) |
253 | { | 269 | { |
254 | //menu->data = 0; | 270 | ConfigItem** ip = &(ConfigItem*)menu->data; |
271 | for (; *ip; ip = &(*ip)->nextItem) { | ||
272 | if (*ip == this) { | ||
273 | *ip = nextItem; | ||
274 | break; | ||
275 | } | ||
276 | } | ||
255 | } | 277 | } |
256 | 278 | ||
257 | void ConfigLineEdit::show(ConfigItem* i) | 279 | void ConfigLineEdit::show(ConfigItem* i) |
258 | { | 280 | { |
259 | item = i; | 281 | item = i; |
260 | if (sym_get_string_value(item->menu->sym)) | 282 | if (sym_get_string_value(item->menu->sym)) |
261 | setText(sym_get_string_value(item->menu->sym)); | 283 | setText(sym_get_string_value(item->menu->sym)); |
262 | else | 284 | else |
263 | setText(0); | 285 | setText(0); |
264 | Parent::show(); | 286 | Parent::show(); |
265 | setFocus(); | 287 | setFocus(); |
266 | } | 288 | } |
267 | 289 | ||
268 | void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | 290 | void ConfigLineEdit::keyPressEvent(QKeyEvent* e) |
269 | { | 291 | { |
270 | switch (e->key()) { | 292 | switch (e->key()) { |
271 | case Key_Escape: | 293 | case Key_Escape: |
272 | break; | 294 | break; |
273 | case Key_Return: | 295 | case Key_Return: |
274 | case Key_Enter: | 296 | case Key_Enter: |
275 | sym_set_string_value(item->menu->sym, text().latin1()); | 297 | sym_set_string_value(item->menu->sym, text().latin1()); |
276 | emit lineChanged(item); | 298 | parent()->updateList(item); |
277 | break; | 299 | break; |
278 | default: | 300 | default: |
279 | Parent::keyPressEvent(e); | 301 | Parent::keyPressEvent(e); |
280 | return; | 302 | return; |
281 | } | 303 | } |
282 | e->accept(); | 304 | e->accept(); |
305 | parent()->list->setFocus(); | ||
283 | hide(); | 306 | hide(); |
284 | } | 307 | } |
285 | 308 | ||
286 | ConfigList::ConfigList(QWidget* p, ConfigView* cv) | 309 | ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv) |
287 | : Parent(p), cview(cv), | 310 | : Parent(p), cview(cv), |
288 | updateAll(false), | 311 | updateAll(false), |
289 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), | 312 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), |
290 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), menuPix(xpm_menu), menuInvPix(xpm_menu_inv), | 313 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), menuPix(xpm_menu), menuInvPix(xpm_menu_inv), |
291 | showAll(false), showName(false), showRange(false), showData(false), | 314 | showAll(false), showName(false), showRange(false), showData(false), |
292 | rootEntry(0) | 315 | rootEntry(0) |
293 | { | 316 | { |
294 | int i; | 317 | int i; |
295 | 318 | ||
296 | setSorting(-1); | 319 | setSorting(-1); |
297 | setRootIsDecorated(TRUE); | 320 | setRootIsDecorated(TRUE); |
298 | disabledColorGroup = palette().active(); | 321 | disabledColorGroup = palette().active(); |
299 | disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); | 322 | disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); |
300 | inactivedColorGroup = palette().active(); | 323 | inactivedColorGroup = palette().active(); |
301 | inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); | 324 | inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); |
302 | 325 | ||
303 | connect(this, SIGNAL(selectionChanged(void)), | 326 | connect(this, SIGNAL(selectionChanged(void)), |
304 | SLOT(updateSelection(void))); | 327 | SLOT(updateSelection(void))); |
305 | 328 | ||
306 | for (i = 0; i < colNr; i++) | 329 | for (i = 0; i < colNr; i++) |
307 | colMap[i] = colRevMap[i] = -1; | 330 | colMap[i] = colRevMap[i] = -1; |
308 | addColumn(promptColIdx, "Option"); | 331 | addColumn(promptColIdx, "Option"); |
309 | 332 | ||
310 | reinit(); | 333 | reinit(); |
@@ -331,121 +354,122 @@ void ConfigList::reinit(void) | |||
331 | updateListAll(); | 354 | updateListAll(); |
332 | } | 355 | } |
333 | 356 | ||
334 | void ConfigList::updateSelection(void) | 357 | void ConfigList::updateSelection(void) |
335 | { | 358 | { |
336 | struct menu *menu; | 359 | struct menu *menu; |
337 | enum prop_type type; | 360 | enum prop_type type; |
338 | 361 | ||
339 | ConfigItem* item = (ConfigItem*)selectedItem(); | 362 | ConfigItem* item = (ConfigItem*)selectedItem(); |
340 | if (!item) | 363 | if (!item) |
341 | return; | 364 | return; |
342 | 365 | ||
343 | cview->setHelp(item); | 366 | cview->setHelp(item); |
344 | 367 | ||
345 | menu = item->menu; | 368 | menu = item->menu; |
346 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 369 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
347 | if (mode == menuMode && (type == P_MENU || type == P_ROOTMENU)) | 370 | if (mode == menuMode && (type == P_MENU || type == P_ROOTMENU)) |
348 | emit menuSelected(menu); | 371 | emit menuSelected(menu); |
349 | } | 372 | } |
350 | 373 | ||
351 | void ConfigList::updateList(ConfigItem* item) | 374 | void ConfigList::updateList(ConfigItem* item) |
352 | { | 375 | { |
353 | (void)item;// unused so far | 376 | (void)item;// unused so far |
354 | updateMenuList(this, rootEntry); | 377 | updateMenuList(this, rootEntry); |
378 | triggerUpdate(); | ||
355 | } | 379 | } |
356 | 380 | ||
357 | void ConfigList::setAllOpen(bool open) | 381 | void ConfigList::setAllOpen(bool open) |
358 | { | 382 | { |
359 | QListViewItemIterator it(this); | 383 | QListViewItemIterator it(this); |
360 | 384 | ||
361 | for (; it.current(); it++) | 385 | for (; it.current(); it++) |
362 | it.current()->setOpen(open); | 386 | it.current()->setOpen(open); |
363 | } | 387 | } |
364 | 388 | ||
365 | void ConfigList::setValue(ConfigItem* item, tristate val) | 389 | void ConfigList::setValue(ConfigItem* item, tristate val) |
366 | { | 390 | { |
367 | struct symbol* sym; | 391 | struct symbol* sym; |
368 | int type; | 392 | int type; |
369 | tristate oldval; | 393 | tristate oldval; |
370 | 394 | ||
371 | sym = item->menu->sym; | 395 | sym = item->menu->sym; |
372 | if (!sym) | 396 | if (!sym) |
373 | return; | 397 | return; |
374 | 398 | ||
375 | type = sym_get_type(sym); | 399 | type = sym_get_type(sym); |
376 | switch (type) { | 400 | switch (type) { |
377 | case S_BOOLEAN: | 401 | case S_BOOLEAN: |
378 | case S_TRISTATE: | 402 | case S_TRISTATE: |
379 | oldval = sym_get_tristate_value(sym); | 403 | oldval = sym_get_tristate_value(sym); |
380 | 404 | ||
381 | if (!sym_set_tristate_value(sym, val)) | 405 | if (!sym_set_tristate_value(sym, val)) |
382 | return; | 406 | return; |
383 | if (oldval == no && item->menu->list) | 407 | if (oldval == no && item->menu->list) |
384 | item->setOpen(TRUE); | 408 | item->setOpen(TRUE); |
385 | emit symbolChanged(item); | 409 | parent()->updateList(item); |
386 | break; | 410 | break; |
387 | } | 411 | } |
388 | } | 412 | } |
389 | 413 | ||
390 | void ConfigList::changeValue(ConfigItem* item) | 414 | void ConfigList::changeValue(ConfigItem* item) |
391 | { | 415 | { |
392 | struct symbol* sym; | 416 | struct symbol* sym; |
393 | struct menu* menu; | 417 | struct menu* menu; |
394 | int type, oldexpr, newexpr; | 418 | int type, oldexpr, newexpr; |
395 | 419 | ||
396 | menu = item->menu; | 420 | menu = item->menu; |
397 | sym = menu->sym; | 421 | sym = menu->sym; |
398 | if (!sym) { | 422 | if (!sym) { |
399 | if (item->menu->list) | 423 | if (item->menu->list) |
400 | item->setOpen(!item->isOpen()); | 424 | item->setOpen(!item->isOpen()); |
401 | return; | 425 | return; |
402 | } | 426 | } |
403 | 427 | ||
404 | type = sym_get_type(sym); | 428 | type = sym_get_type(sym); |
405 | switch (type) { | 429 | switch (type) { |
406 | case S_BOOLEAN: | 430 | case S_BOOLEAN: |
407 | case S_TRISTATE: | 431 | case S_TRISTATE: |
408 | oldexpr = sym_get_tristate_value(sym); | 432 | oldexpr = sym_get_tristate_value(sym); |
409 | newexpr = sym_toggle_tristate_value(sym); | 433 | newexpr = sym_toggle_tristate_value(sym); |
410 | if (item->menu->list) { | 434 | if (item->menu->list) { |
411 | if (oldexpr == newexpr) | 435 | if (oldexpr == newexpr) |
412 | item->setOpen(!item->isOpen()); | 436 | item->setOpen(!item->isOpen()); |
413 | else if (oldexpr == no) | 437 | else if (oldexpr == no) |
414 | item->setOpen(TRUE); | 438 | item->setOpen(TRUE); |
415 | } | 439 | } |
416 | if (oldexpr != newexpr) | 440 | if (oldexpr != newexpr) |
417 | emit symbolChanged(item); | 441 | parent()->updateList(item); |
418 | break; | 442 | break; |
419 | case S_INT: | 443 | case S_INT: |
420 | case S_HEX: | 444 | case S_HEX: |
421 | case S_STRING: | 445 | case S_STRING: |
422 | #if QT_VERSION >= 300 | 446 | #if QT_VERSION >= 300 |
423 | if (colMap[dataColIdx] >= 0) | 447 | if (colMap[dataColIdx] >= 0) |
424 | item->startRename(colMap[dataColIdx]); | 448 | item->startRename(colMap[dataColIdx]); |
425 | else | 449 | else |
426 | #endif | 450 | #endif |
427 | lineEdit->show(item); | 451 | parent()->lineEdit->show(item); |
428 | break; | 452 | break; |
429 | } | 453 | } |
430 | } | 454 | } |
431 | 455 | ||
432 | void ConfigList::setRootMenu(struct menu *menu) | 456 | void ConfigList::setRootMenu(struct menu *menu) |
433 | { | 457 | { |
434 | enum prop_type type; | 458 | enum prop_type type; |
435 | 459 | ||
436 | if (rootEntry == menu) | 460 | if (rootEntry == menu) |
437 | return; | 461 | return; |
438 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; | 462 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; |
439 | if (type != P_MENU && type != P_ROOTMENU) | 463 | if (type != P_MENU && type != P_ROOTMENU) |
440 | return; | 464 | return; |
441 | updateMenuList(this, 0); | 465 | updateMenuList(this, 0); |
442 | rootEntry = menu; | 466 | rootEntry = menu; |
443 | updateListAll(); | 467 | updateListAll(); |
444 | setSelected(currentItem(), hasFocus()); | 468 | setSelected(currentItem(), hasFocus()); |
445 | } | 469 | } |
446 | 470 | ||
447 | void ConfigList::setParentMenu(void) | 471 | void ConfigList::setParentMenu(void) |
448 | { | 472 | { |
449 | ConfigItem* item; | 473 | ConfigItem* item; |
450 | struct menu *oldroot, *newroot; | 474 | struct menu *oldroot, *newroot; |
451 | 475 | ||
@@ -495,168 +519,224 @@ void ConfigList::keyPressEvent(QKeyEvent* ev) | |||
495 | } | 519 | } |
496 | case Key_Space: | 520 | case Key_Space: |
497 | changeValue(item); | 521 | changeValue(item); |
498 | break; | 522 | break; |
499 | case Key_N: | 523 | case Key_N: |
500 | setValue(item, no); | 524 | setValue(item, no); |
501 | break; | 525 | break; |
502 | case Key_M: | 526 | case Key_M: |
503 | setValue(item, mod); | 527 | setValue(item, mod); |
504 | break; | 528 | break; |
505 | case Key_Y: | 529 | case Key_Y: |
506 | setValue(item, yes); | 530 | setValue(item, yes); |
507 | break; | 531 | break; |
508 | default: | 532 | default: |
509 | Parent::keyPressEvent(ev); | 533 | Parent::keyPressEvent(ev); |
510 | return; | 534 | return; |
511 | } | 535 | } |
512 | ev->accept(); | 536 | ev->accept(); |
513 | } | 537 | } |
514 | 538 | ||
515 | void ConfigList::contentsMousePressEvent(QMouseEvent* e) | 539 | void ConfigList::contentsMousePressEvent(QMouseEvent* e) |
516 | { | 540 | { |
517 | //QPoint p(contentsToViewport(e->pos())); | 541 | //QPoint p(contentsToViewport(e->pos())); |
518 | //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); | 542 | //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); |
519 | QListView::contentsMousePressEvent(e); | 543 | Parent::contentsMousePressEvent(e); |
520 | } | 544 | } |
521 | 545 | ||
522 | void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) | 546 | void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) |
523 | { | 547 | { |
524 | QPoint p(contentsToViewport(e->pos())); | 548 | QPoint p(contentsToViewport(e->pos())); |
525 | ConfigItem* item = (ConfigItem*)itemAt(p); | 549 | ConfigItem* item = (ConfigItem*)itemAt(p); |
526 | struct menu *menu; | 550 | struct menu *menu; |
527 | const QPixmap* pm; | 551 | const QPixmap* pm; |
528 | int idx, x; | 552 | int idx, x; |
529 | 553 | ||
530 | if (!item) | 554 | if (!item) |
531 | goto skip; | 555 | goto skip; |
532 | 556 | ||
533 | menu = item->menu; | 557 | menu = item->menu; |
534 | x = header()->offset() + p.x(); | 558 | x = header()->offset() + p.x(); |
535 | idx = colRevMap[header()->sectionAt(x)]; | 559 | idx = colRevMap[header()->sectionAt(x)]; |
536 | switch (idx) { | 560 | switch (idx) { |
537 | case promptColIdx: | 561 | case promptColIdx: |
538 | pm = item->pixmap(promptColIdx); | 562 | pm = item->pixmap(promptColIdx); |
539 | if (pm) { | 563 | if (pm) { |
540 | int off = header()->sectionPos(0) + itemMargin() + | 564 | int off = header()->sectionPos(0) + itemMargin() + |
541 | treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); | 565 | treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); |
542 | if (x >= off && x < off + pm->width()) { | 566 | if (x >= off && x < off + pm->width()) { |
543 | if (menu->sym) | 567 | if (menu->sym) |
544 | changeValue(item); | 568 | changeValue(item); |
545 | else | 569 | else |
546 | emit menuSelected(menu); | 570 | emit menuSelected(menu); |
547 | } | 571 | } |
548 | } | 572 | } |
549 | break; | 573 | break; |
550 | case noColIdx: | 574 | case noColIdx: |
551 | setValue(item, no); | 575 | setValue(item, no); |
552 | break; | 576 | break; |
553 | case modColIdx: | 577 | case modColIdx: |
554 | setValue(item, mod); | 578 | setValue(item, mod); |
555 | break; | 579 | break; |
556 | case yesColIdx: | 580 | case yesColIdx: |
557 | setValue(item, yes); | 581 | setValue(item, yes); |
558 | break; | 582 | break; |
559 | case dataColIdx: | 583 | case dataColIdx: |
560 | changeValue(item); | 584 | changeValue(item); |
561 | break; | 585 | break; |
562 | } | 586 | } |
563 | 587 | ||
564 | skip: | 588 | skip: |
565 | //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); | 589 | //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); |
566 | QListView::contentsMouseReleaseEvent(e); | 590 | Parent::contentsMouseReleaseEvent(e); |
567 | } | 591 | } |
568 | 592 | ||
569 | void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) | 593 | void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) |
570 | { | 594 | { |
571 | //QPoint p(contentsToViewport(e->pos())); | 595 | //QPoint p(contentsToViewport(e->pos())); |
572 | //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); | 596 | //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); |
573 | QListView::contentsMouseMoveEvent(e); | 597 | Parent::contentsMouseMoveEvent(e); |
574 | } | 598 | } |
575 | 599 | ||
576 | void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) | 600 | void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) |
577 | { | 601 | { |
578 | QPoint p(contentsToViewport(e->pos())); | 602 | QPoint p(contentsToViewport(e->pos())); |
579 | ConfigItem* item = (ConfigItem*)itemAt(p); | 603 | ConfigItem* item = (ConfigItem*)itemAt(p); |
580 | struct menu *menu; | 604 | struct menu *menu; |
581 | enum prop_type ptype; | 605 | enum prop_type ptype; |
582 | 606 | ||
583 | if (!item) | 607 | if (!item) |
584 | goto skip; | 608 | goto skip; |
585 | menu = item->menu; | 609 | menu = item->menu; |
586 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 610 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
587 | if ((ptype == P_ROOTMENU || ptype == P_MENU) && | 611 | if ((ptype == P_ROOTMENU || ptype == P_MENU) && |
588 | (mode == singleMode || mode == symbolMode)) | 612 | (mode == singleMode || mode == symbolMode)) |
589 | emit menuSelected(menu); | 613 | emit menuSelected(menu); |
614 | else if (menu->sym) | ||
615 | changeValue(item); | ||
590 | 616 | ||
591 | skip: | 617 | skip: |
592 | //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); | 618 | //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); |
593 | QListView::contentsMouseDoubleClickEvent(e); | 619 | Parent::contentsMouseDoubleClickEvent(e); |
594 | } | 620 | } |
595 | 621 | ||
596 | void ConfigList::focusInEvent(QFocusEvent *e) | 622 | void ConfigList::focusInEvent(QFocusEvent *e) |
597 | { | 623 | { |
598 | Parent::focusInEvent(e); | 624 | Parent::focusInEvent(e); |
599 | 625 | ||
600 | QListViewItem* item = currentItem(); | 626 | QListViewItem* item = currentItem(); |
601 | if (!item) | 627 | if (!item) |
602 | return; | 628 | return; |
603 | 629 | ||
604 | setSelected(item, TRUE); | 630 | setSelected(item, TRUE); |
605 | emit gotFocus(); | 631 | emit gotFocus(); |
606 | } | 632 | } |
607 | 633 | ||
634 | ConfigView* ConfigView::viewList; | ||
635 | |||
636 | ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview) | ||
637 | : Parent(parent) | ||
638 | { | ||
639 | list = new ConfigList(this, cview); | ||
640 | lineEdit = new ConfigLineEdit(this); | ||
641 | lineEdit->hide(); | ||
642 | |||
643 | this->nextView = viewList; | ||
644 | viewList = this; | ||
645 | } | ||
646 | |||
647 | ConfigView::~ConfigView(void) | ||
648 | { | ||
649 | ConfigView** vp; | ||
650 | |||
651 | for (vp = &viewList; *vp; vp = &(*vp)->nextView) { | ||
652 | if (*vp == this) { | ||
653 | *vp = nextView; | ||
654 | break; | ||
655 | } | ||
656 | } | ||
657 | } | ||
658 | |||
659 | void ConfigView::updateList(ConfigItem* item) | ||
660 | { | ||
661 | ConfigView* v; | ||
662 | |||
663 | for (v = viewList; v; v = v->nextView) | ||
664 | v->list->updateList(item); | ||
665 | } | ||
666 | |||
667 | void ConfigView::updateListAll(void) | ||
668 | { | ||
669 | ConfigView* v; | ||
670 | |||
671 | for (v = viewList; v; v = v->nextView) | ||
672 | v->list->updateListAll(); | ||
673 | } | ||
674 | |||
608 | /* | 675 | /* |
609 | * Construct the complete config widget | 676 | * Construct the complete config widget |
610 | */ | 677 | */ |
611 | ConfigView::ConfigView(void) | 678 | ConfigMainWindow::ConfigMainWindow(void) |
612 | { | 679 | { |
680 | ConfigView* view; | ||
613 | QMenuBar* menu; | 681 | QMenuBar* menu; |
614 | QSplitter* split1; | 682 | QSplitter* split1; |
615 | QSplitter* split2; | 683 | QSplitter* split2; |
684 | bool ok; | ||
685 | int x, y, width, height; | ||
686 | |||
687 | QWidget *d = configApp->desktop(); | ||
688 | |||
689 | #if QT_VERSION >= 300 | ||
690 | width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64); | ||
691 | height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64); | ||
692 | resize(width, height); | ||
693 | x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok); | ||
694 | if (ok) | ||
695 | y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok); | ||
696 | if (ok) | ||
697 | move(x, y); | ||
698 | #else | ||
699 | width = d->width() - 64; | ||
700 | height = d->height() - 64; | ||
701 | resize(width, height); | ||
702 | #endif | ||
616 | 703 | ||
617 | showDebug = false; | 704 | showDebug = false; |
618 | 705 | ||
619 | split1 = new QSplitter(this); | 706 | split1 = new QSplitter(this); |
620 | split1->setOrientation(QSplitter::Horizontal); | 707 | split1->setOrientation(QSplitter::Horizontal); |
621 | setCentralWidget(split1); | 708 | setCentralWidget(split1); |
622 | 709 | ||
623 | menuList = new ConfigList(split1, this); | 710 | view = new ConfigView(split1, this); |
711 | menuList = view->list; | ||
624 | 712 | ||
625 | split2 = new QSplitter(split1); | 713 | split2 = new QSplitter(split1); |
626 | split2->setOrientation(QSplitter::Vertical); | 714 | split2->setOrientation(QSplitter::Vertical); |
627 | 715 | ||
628 | // create config tree | 716 | // create config tree |
629 | QVBox* box = new QVBox(split2); | 717 | view = new ConfigView(split2, this); |
630 | configList = new ConfigList(box, this); | 718 | configList = view->list; |
631 | configList->lineEdit = new ConfigLineEdit(box); | ||
632 | configList->lineEdit->hide(); | ||
633 | configList->connect(configList, SIGNAL(symbolChanged(ConfigItem*)), | ||
634 | configList, SLOT(updateList(ConfigItem*))); | ||
635 | configList->connect(configList, SIGNAL(symbolChanged(ConfigItem*)), | ||
636 | menuList, SLOT(updateList(ConfigItem*))); | ||
637 | configList->connect(configList->lineEdit, SIGNAL(lineChanged(ConfigItem*)), | ||
638 | SLOT(updateList(ConfigItem*))); | ||
639 | 719 | ||
640 | helpText = new QTextView(split2); | 720 | helpText = new QTextView(split2); |
641 | helpText->setTextFormat(Qt::RichText); | 721 | helpText->setTextFormat(Qt::RichText); |
642 | 722 | ||
643 | setTabOrder(configList, helpText); | 723 | setTabOrder(configList, helpText); |
644 | configList->setFocus(); | 724 | configList->setFocus(); |
645 | 725 | ||
646 | menu = menuBar(); | 726 | menu = menuBar(); |
647 | toolBar = new QToolBar("Tools", this); | 727 | toolBar = new QToolBar("Tools", this); |
648 | 728 | ||
649 | backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); | 729 | backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); |
650 | connect(backAction, SIGNAL(activated()), SLOT(goBack())); | 730 | connect(backAction, SIGNAL(activated()), SLOT(goBack())); |
651 | backAction->setEnabled(FALSE); | 731 | backAction->setEnabled(FALSE); |
652 | QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); | 732 | QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); |
653 | connect(quitAction, SIGNAL(activated()), SLOT(close())); | 733 | connect(quitAction, SIGNAL(activated()), SLOT(close())); |
654 | QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); | 734 | QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); |
655 | connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); | 735 | connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); |
656 | QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); | 736 | QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); |
657 | connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); | 737 | connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); |
658 | QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); | 738 | QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); |
659 | connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); | 739 | connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); |
660 | QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); | 740 | QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); |
661 | connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); | 741 | connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); |
662 | QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); | 742 | QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); |
@@ -664,77 +744,89 @@ ConfigView::ConfigView(void) | |||
664 | QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); | 744 | QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); |
665 | connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); | 745 | connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); |
666 | 746 | ||
667 | QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); | 747 | QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); |
668 | showNameAction->setToggleAction(TRUE); | 748 | showNameAction->setToggleAction(TRUE); |
669 | showNameAction->setOn(configList->showName); | 749 | showNameAction->setOn(configList->showName); |
670 | connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool))); | 750 | connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool))); |
671 | QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); | 751 | QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); |
672 | showRangeAction->setToggleAction(TRUE); | 752 | showRangeAction->setToggleAction(TRUE); |
673 | showRangeAction->setOn(configList->showRange); | 753 | showRangeAction->setOn(configList->showRange); |
674 | connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool))); | 754 | connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool))); |
675 | QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); | 755 | QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); |
676 | showDataAction->setToggleAction(TRUE); | 756 | showDataAction->setToggleAction(TRUE); |
677 | showDataAction->setOn(configList->showData); | 757 | showDataAction->setOn(configList->showData); |
678 | connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool))); | 758 | connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool))); |
679 | QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); | 759 | QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); |
680 | showAllAction->setToggleAction(TRUE); | 760 | showAllAction->setToggleAction(TRUE); |
681 | showAllAction->setOn(configList->showAll); | 761 | showAllAction->setOn(configList->showAll); |
682 | connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool))); | 762 | connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool))); |
683 | QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); | 763 | QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); |
684 | showDebugAction->setToggleAction(TRUE); | 764 | showDebugAction->setToggleAction(TRUE); |
685 | showDebugAction->setOn(showDebug); | 765 | showDebugAction->setOn(showDebug); |
686 | connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); | 766 | connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); |
687 | 767 | ||
768 | QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this); | ||
769 | connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); | ||
770 | QAction *showAboutAction = new QAction(NULL, "About", 0, this); | ||
771 | connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); | ||
772 | |||
688 | // init tool bar | 773 | // init tool bar |
689 | backAction->addTo(toolBar); | 774 | backAction->addTo(toolBar); |
690 | toolBar->addSeparator(); | 775 | toolBar->addSeparator(); |
691 | loadAction->addTo(toolBar); | 776 | loadAction->addTo(toolBar); |
692 | saveAction->addTo(toolBar); | 777 | saveAction->addTo(toolBar); |
693 | toolBar->addSeparator(); | 778 | toolBar->addSeparator(); |
694 | singleViewAction->addTo(toolBar); | 779 | singleViewAction->addTo(toolBar); |
695 | splitViewAction->addTo(toolBar); | 780 | splitViewAction->addTo(toolBar); |
696 | fullViewAction->addTo(toolBar); | 781 | fullViewAction->addTo(toolBar); |
697 | 782 | ||
698 | // create config menu | 783 | // create config menu |
699 | QPopupMenu* config = new QPopupMenu(this); | 784 | QPopupMenu* config = new QPopupMenu(this); |
700 | menu->insertItem("&File", config); | 785 | menu->insertItem("&File", config); |
701 | loadAction->addTo(config); | 786 | loadAction->addTo(config); |
702 | saveAction->addTo(config); | 787 | saveAction->addTo(config); |
703 | saveAsAction->addTo(config); | 788 | saveAsAction->addTo(config); |
704 | config->insertSeparator(); | 789 | config->insertSeparator(); |
705 | quitAction->addTo(config); | 790 | quitAction->addTo(config); |
706 | 791 | ||
707 | // create options menu | 792 | // create options menu |
708 | QPopupMenu* optionMenu = new QPopupMenu(this); | 793 | QPopupMenu* optionMenu = new QPopupMenu(this); |
709 | menu->insertItem("&Option", optionMenu); | 794 | menu->insertItem("&Option", optionMenu); |
710 | showNameAction->addTo(optionMenu); | 795 | showNameAction->addTo(optionMenu); |
711 | showRangeAction->addTo(optionMenu); | 796 | showRangeAction->addTo(optionMenu); |
712 | showDataAction->addTo(optionMenu); | 797 | showDataAction->addTo(optionMenu); |
713 | optionMenu->insertSeparator(); | 798 | optionMenu->insertSeparator(); |
714 | showAllAction->addTo(optionMenu); | 799 | showAllAction->addTo(optionMenu); |
715 | showDebugAction->addTo(optionMenu); | 800 | showDebugAction->addTo(optionMenu); |
716 | 801 | ||
802 | // create help menu | ||
803 | QPopupMenu* helpMenu = new QPopupMenu(this); | ||
804 | menu->insertSeparator(); | ||
805 | menu->insertItem("&Help", helpMenu); | ||
806 | showIntroAction->addTo(helpMenu); | ||
807 | showAboutAction->addTo(helpMenu); | ||
808 | |||
717 | connect(configList, SIGNAL(menuSelected(struct menu *)), | 809 | connect(configList, SIGNAL(menuSelected(struct menu *)), |
718 | SLOT(changeMenu(struct menu *))); | 810 | SLOT(changeMenu(struct menu *))); |
719 | connect(configList, SIGNAL(parentSelected()), | 811 | connect(configList, SIGNAL(parentSelected()), |
720 | SLOT(goBack())); | 812 | SLOT(goBack())); |
721 | connect(menuList, SIGNAL(menuSelected(struct menu *)), | 813 | connect(menuList, SIGNAL(menuSelected(struct menu *)), |
722 | SLOT(changeMenu(struct menu *))); | 814 | SLOT(changeMenu(struct menu *))); |
723 | 815 | ||
724 | connect(configList, SIGNAL(gotFocus(void)), | 816 | connect(configList, SIGNAL(gotFocus(void)), |
725 | SLOT(listFocusChanged(void))); | 817 | SLOT(listFocusChanged(void))); |
726 | connect(menuList, SIGNAL(gotFocus(void)), | 818 | connect(menuList, SIGNAL(gotFocus(void)), |
727 | SLOT(listFocusChanged(void))); | 819 | SLOT(listFocusChanged(void))); |
728 | 820 | ||
729 | //showFullView(); | 821 | //showFullView(); |
730 | showSplitView(); | 822 | showSplitView(); |
731 | } | 823 | } |
732 | 824 | ||
733 | static QString print_filter(const char *str) | 825 | static QString print_filter(const char *str) |
734 | { | 826 | { |
735 | QRegExp re("[<>&\"\\n]"); | 827 | QRegExp re("[<>&\"\\n]"); |
736 | QString res = str; | 828 | QString res = str; |
737 | for (int i = 0; (i = res.find(re, i)) >= 0;) { | 829 | for (int i = 0; (i = res.find(re, i)) >= 0;) { |
738 | switch (res[i].latin1()) { | 830 | switch (res[i].latin1()) { |
739 | case '<': | 831 | case '<': |
740 | res.replace(i, 1, "<"); | 832 | res.replace(i, 1, "<"); |
@@ -748,54 +840,54 @@ static QString print_filter(const char *str) | |||
748 | res.replace(i, 1, "&"); | 840 | res.replace(i, 1, "&"); |
749 | i += 5; | 841 | i += 5; |
750 | break; | 842 | break; |
751 | case '"': | 843 | case '"': |
752 | res.replace(i, 1, """); | 844 | res.replace(i, 1, """); |
753 | i += 6; | 845 | i += 6; |
754 | break; | 846 | break; |
755 | case '\n': | 847 | case '\n': |
756 | res.replace(i, 1, "<br>"); | 848 | res.replace(i, 1, "<br>"); |
757 | i += 4; | 849 | i += 4; |
758 | break; | 850 | break; |
759 | } | 851 | } |
760 | } | 852 | } |
761 | return res; | 853 | return res; |
762 | } | 854 | } |
763 | 855 | ||
764 | static void expr_print_help(void *data, const char *str) | 856 | static void expr_print_help(void *data, const char *str) |
765 | { | 857 | { |
766 | ((QString*)data)->append(print_filter(str)); | 858 | ((QString*)data)->append(print_filter(str)); |
767 | } | 859 | } |
768 | 860 | ||
769 | /* | 861 | /* |
770 | * display a new help entry as soon as a new menu entry is selected | 862 | * display a new help entry as soon as a new menu entry is selected |
771 | */ | 863 | */ |
772 | void ConfigView::setHelp(QListViewItem* item) | 864 | void ConfigMainWindow::setHelp(QListViewItem* item) |
773 | { | 865 | { |
774 | struct symbol* sym; | 866 | struct symbol* sym; |
775 | struct menu* menu; | 867 | struct menu* menu; |
776 | 868 | ||
777 | configList->lineEdit->hide(); | 869 | configList->parent()->lineEdit->hide(); |
778 | if (item) { | 870 | if (item) { |
779 | QString head, debug, help; | 871 | QString head, debug, help; |
780 | menu = ((ConfigItem*)item)->menu; | 872 | menu = ((ConfigItem*)item)->menu; |
781 | sym = menu->sym; | 873 | sym = menu->sym; |
782 | if (sym) { | 874 | if (sym) { |
783 | if (menu->prompt) { | 875 | if (menu->prompt) { |
784 | head += "<big><b>"; | 876 | head += "<big><b>"; |
785 | head += print_filter(menu->prompt->text); | 877 | head += print_filter(menu->prompt->text); |
786 | head += "</b></big>"; | 878 | head += "</b></big>"; |
787 | if (sym->name) { | 879 | if (sym->name) { |
788 | head += " ("; | 880 | head += " ("; |
789 | head += print_filter(sym->name); | 881 | head += print_filter(sym->name); |
790 | head += ")"; | 882 | head += ")"; |
791 | } | 883 | } |
792 | } else if (sym->name) { | 884 | } else if (sym->name) { |
793 | head += "<big><b>"; | 885 | head += "<big><b>"; |
794 | head += print_filter(sym->name); | 886 | head += print_filter(sym->name); |
795 | head += "</b></big>"; | 887 | head += "</b></big>"; |
796 | } | 888 | } |
797 | head += "<br><br>"; | 889 | head += "<br><br>"; |
798 | 890 | ||
799 | if (showDebug) { | 891 | if (showDebug) { |
800 | debug += "type: "; | 892 | debug += "type: "; |
801 | debug += print_filter(sym_type_name(sym->type)); | 893 | debug += print_filter(sym_type_name(sym->type)); |
@@ -836,238 +928,276 @@ void ConfigView::setHelp(QListViewItem* item) | |||
836 | } | 928 | } |
837 | } | 929 | } |
838 | debug += "<br>"; | 930 | debug += "<br>"; |
839 | } | 931 | } |
840 | 932 | ||
841 | help = print_filter(sym->help); | 933 | help = print_filter(sym->help); |
842 | } else if (menu->prompt) { | 934 | } else if (menu->prompt) { |
843 | head += "<big><b>"; | 935 | head += "<big><b>"; |
844 | head += print_filter(menu->prompt->text); | 936 | head += print_filter(menu->prompt->text); |
845 | head += "</b></big><br><br>"; | 937 | head += "</b></big><br><br>"; |
846 | if (showDebug) { | 938 | if (showDebug) { |
847 | if (menu->prompt->visible.expr) { | 939 | if (menu->prompt->visible.expr) { |
848 | debug += " dep: "; | 940 | debug += " dep: "; |
849 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); | 941 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); |
850 | debug += "<br>"; | 942 | debug += "<br>"; |
851 | } | 943 | } |
852 | } | 944 | } |
853 | } | 945 | } |
854 | helpText->setText(head + debug + help); | 946 | helpText->setText(head + debug + help); |
855 | return; | 947 | return; |
856 | } | 948 | } |
857 | helpText->setText(NULL); | 949 | helpText->setText(NULL); |
858 | } | 950 | } |
859 | 951 | ||
860 | void ConfigView::loadConfig(void) | 952 | void ConfigMainWindow::loadConfig(void) |
861 | { | 953 | { |
862 | QString s = QFileDialog::getOpenFileName(".config", NULL, this); | 954 | QString s = QFileDialog::getOpenFileName(".config", NULL, this); |
863 | if (s.isNull()) | 955 | if (s.isNull()) |
864 | return; | 956 | return; |
865 | if (conf_read(s.latin1())) | 957 | if (conf_read(s.latin1())) |
866 | QMessageBox::information(this, "qconf", "Unable to load configuration!"); | 958 | QMessageBox::information(this, "qconf", "Unable to load configuration!"); |
959 | ConfigView::updateListAll(); | ||
867 | } | 960 | } |
868 | 961 | ||
869 | void ConfigView::saveConfig(void) | 962 | void ConfigMainWindow::saveConfig(void) |
870 | { | 963 | { |
871 | if (conf_write(NULL)) | 964 | if (conf_write(NULL)) |
872 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); | 965 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); |
873 | } | 966 | } |
874 | 967 | ||
875 | void ConfigView::saveConfigAs(void) | 968 | void ConfigMainWindow::saveConfigAs(void) |
876 | { | 969 | { |
877 | QString s = QFileDialog::getSaveFileName(".config", NULL, this); | 970 | QString s = QFileDialog::getSaveFileName(".config", NULL, this); |
878 | if (s.isNull()) | 971 | if (s.isNull()) |
879 | return; | 972 | return; |
880 | if (conf_write(s.latin1())) | 973 | if (conf_write(s.latin1())) |
881 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); | 974 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); |
882 | } | 975 | } |
883 | 976 | ||
884 | void ConfigView::changeMenu(struct menu *menu) | 977 | void ConfigMainWindow::changeMenu(struct menu *menu) |
885 | { | 978 | { |
886 | configList->setRootMenu(menu); | 979 | configList->setRootMenu(menu); |
887 | backAction->setEnabled(TRUE); | 980 | backAction->setEnabled(TRUE); |
888 | } | 981 | } |
889 | 982 | ||
890 | void ConfigView::listFocusChanged(void) | 983 | void ConfigMainWindow::listFocusChanged(void) |
891 | { | 984 | { |
892 | if (menuList->hasFocus()) { | 985 | if (menuList->hasFocus()) { |
893 | if (menuList->mode == menuMode) | 986 | if (menuList->mode == menuMode) |
894 | configList->clearSelection(); | 987 | configList->clearSelection(); |
895 | setHelp(menuList->selectedItem()); | 988 | setHelp(menuList->selectedItem()); |
896 | } else if (configList->hasFocus()) { | 989 | } else if (configList->hasFocus()) { |
897 | setHelp(configList->selectedItem()); | 990 | setHelp(configList->selectedItem()); |
898 | } | 991 | } |
899 | } | 992 | } |
900 | 993 | ||
901 | void ConfigView::goBack(void) | 994 | void ConfigMainWindow::goBack(void) |
902 | { | 995 | { |
903 | ConfigItem* item; | 996 | ConfigItem* item; |
904 | 997 | ||
905 | configList->setParentMenu(); | 998 | configList->setParentMenu(); |
906 | if (configList->rootEntry == &rootmenu) | 999 | if (configList->rootEntry == &rootmenu) |
907 | backAction->setEnabled(FALSE); | 1000 | backAction->setEnabled(FALSE); |
908 | item = (ConfigItem*)menuList->selectedItem(); | 1001 | item = (ConfigItem*)menuList->selectedItem(); |
909 | while (item) { | 1002 | while (item) { |
910 | if (item->menu == configList->rootEntry) { | 1003 | if (item->menu == configList->rootEntry) { |
911 | menuList->setSelected(item, TRUE); | 1004 | menuList->setSelected(item, TRUE); |
912 | break; | 1005 | break; |
913 | } | 1006 | } |
914 | item = (ConfigItem*)item->parent(); | 1007 | item = (ConfigItem*)item->parent(); |
915 | } | 1008 | } |
916 | } | 1009 | } |
917 | 1010 | ||
918 | void ConfigView::showSingleView(void) | 1011 | void ConfigMainWindow::showSingleView(void) |
919 | { | 1012 | { |
920 | menuList->hide(); | 1013 | menuList->hide(); |
921 | menuList->setRootMenu(0); | 1014 | menuList->setRootMenu(0); |
922 | configList->mode = singleMode; | 1015 | configList->mode = singleMode; |
923 | if (configList->rootEntry == &rootmenu) | 1016 | if (configList->rootEntry == &rootmenu) |
924 | configList->updateListAll(); | 1017 | configList->updateListAll(); |
925 | else | 1018 | else |
926 | configList->setRootMenu(&rootmenu); | 1019 | configList->setRootMenu(&rootmenu); |
927 | configList->setAllOpen(TRUE); | 1020 | configList->setAllOpen(TRUE); |
928 | configList->setFocus(); | 1021 | configList->setFocus(); |
929 | } | 1022 | } |
930 | 1023 | ||
931 | void ConfigView::showSplitView(void) | 1024 | void ConfigMainWindow::showSplitView(void) |
932 | { | 1025 | { |
933 | configList->mode = symbolMode; | 1026 | configList->mode = symbolMode; |
934 | if (configList->rootEntry == &rootmenu) | 1027 | if (configList->rootEntry == &rootmenu) |
935 | configList->updateListAll(); | 1028 | configList->updateListAll(); |
936 | else | 1029 | else |
937 | configList->setRootMenu(&rootmenu); | 1030 | configList->setRootMenu(&rootmenu); |
938 | configList->setAllOpen(TRUE); | 1031 | configList->setAllOpen(TRUE); |
939 | configApp->processEvents(); | 1032 | configApp->processEvents(); |
940 | menuList->mode = menuMode; | 1033 | menuList->mode = menuMode; |
941 | menuList->setRootMenu(&rootmenu); | 1034 | menuList->setRootMenu(&rootmenu); |
942 | menuList->show(); | 1035 | menuList->show(); |
943 | menuList->setAllOpen(TRUE); | 1036 | menuList->setAllOpen(TRUE); |
944 | menuList->setFocus(); | 1037 | menuList->setFocus(); |
945 | } | 1038 | } |
946 | 1039 | ||
947 | void ConfigView::showFullView(void) | 1040 | void ConfigMainWindow::showFullView(void) |
948 | { | 1041 | { |
949 | menuList->hide(); | 1042 | menuList->hide(); |
950 | menuList->setRootMenu(0); | 1043 | menuList->setRootMenu(0); |
951 | configList->mode = fullMode; | 1044 | configList->mode = fullMode; |
952 | if (configList->rootEntry == &rootmenu) | 1045 | if (configList->rootEntry == &rootmenu) |
953 | configList->updateListAll(); | 1046 | configList->updateListAll(); |
954 | else | 1047 | else |
955 | configList->setRootMenu(&rootmenu); | 1048 | configList->setRootMenu(&rootmenu); |
956 | configList->setAllOpen(FALSE); | 1049 | configList->setAllOpen(FALSE); |
957 | configList->setFocus(); | 1050 | configList->setFocus(); |
958 | } | 1051 | } |
959 | 1052 | ||
960 | void ConfigView::setShowAll(bool b) | 1053 | void ConfigMainWindow::setShowAll(bool b) |
961 | { | 1054 | { |
962 | if (configList->showAll == b) | 1055 | if (configList->showAll == b) |
963 | return; | 1056 | return; |
964 | configList->showAll = b; | 1057 | configList->showAll = b; |
965 | configList->updateListAll(); | 1058 | configList->updateListAll(); |
966 | menuList->showAll = b; | 1059 | menuList->showAll = b; |
967 | menuList->updateListAll(); | 1060 | menuList->updateListAll(); |
968 | } | 1061 | } |
969 | 1062 | ||
970 | void ConfigView::setShowDebug(bool b) | 1063 | void ConfigMainWindow::setShowDebug(bool b) |
971 | { | 1064 | { |
972 | if (showDebug == b) | 1065 | if (showDebug == b) |
973 | return; | 1066 | return; |
974 | showDebug = b; | 1067 | showDebug = b; |
975 | } | 1068 | } |
976 | 1069 | ||
977 | void ConfigView::setShowName(bool b) | 1070 | void ConfigMainWindow::setShowName(bool b) |
978 | { | 1071 | { |
979 | if (configList->showName == b) | 1072 | if (configList->showName == b) |
980 | return; | 1073 | return; |
981 | configList->showName = b; | 1074 | configList->showName = b; |
982 | configList->reinit(); | 1075 | configList->reinit(); |
983 | } | 1076 | } |
984 | 1077 | ||
985 | void ConfigView::setShowRange(bool b) | 1078 | void ConfigMainWindow::setShowRange(bool b) |
986 | { | 1079 | { |
987 | if (configList->showRange == b) | 1080 | if (configList->showRange == b) |
988 | return; | 1081 | return; |
989 | configList->showRange = b; | 1082 | configList->showRange = b; |
990 | configList->reinit(); | 1083 | configList->reinit(); |
991 | } | 1084 | } |
992 | 1085 | ||
993 | void ConfigView::setShowData(bool b) | 1086 | void ConfigMainWindow::setShowData(bool b) |
994 | { | 1087 | { |
995 | if (configList->showData == b) | 1088 | if (configList->showData == b) |
996 | return; | 1089 | return; |
997 | configList->showData = b; | 1090 | configList->showData = b; |
998 | configList->reinit(); | 1091 | configList->reinit(); |
999 | } | 1092 | } |
1000 | 1093 | ||
1001 | /* | 1094 | /* |
1002 | * ask for saving configuration before quitting | 1095 | * ask for saving configuration before quitting |
1003 | * TODO ask only when something changed | 1096 | * TODO ask only when something changed |
1004 | */ | 1097 | */ |
1005 | void ConfigView::closeEvent(QCloseEvent* e) | 1098 | void ConfigMainWindow::closeEvent(QCloseEvent* e) |
1006 | { | 1099 | { |
1007 | if (!sym_change_count) { | 1100 | if (!sym_change_count) { |
1008 | e->accept(); | 1101 | e->accept(); |
1009 | return; | 1102 | return; |
1010 | } | 1103 | } |
1011 | QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, | 1104 | QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, |
1012 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); | 1105 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); |
1013 | mb.setButtonText(QMessageBox::Yes, "&Save Changes"); | 1106 | mb.setButtonText(QMessageBox::Yes, "&Save Changes"); |
1014 | mb.setButtonText(QMessageBox::No, "&Discard Changes"); | 1107 | mb.setButtonText(QMessageBox::No, "&Discard Changes"); |
1015 | mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); | 1108 | mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); |
1016 | switch (mb.exec()) { | 1109 | switch (mb.exec()) { |
1017 | case QMessageBox::Yes: | 1110 | case QMessageBox::Yes: |
1018 | conf_write(NULL); | 1111 | conf_write(NULL); |
1019 | case QMessageBox::No: | 1112 | case QMessageBox::No: |
1020 | e->accept(); | 1113 | e->accept(); |
1021 | break; | 1114 | break; |
1022 | case QMessageBox::Cancel: | 1115 | case QMessageBox::Cancel: |
1023 | e->ignore(); | 1116 | e->ignore(); |
1024 | break; | 1117 | break; |
1025 | } | 1118 | } |
1026 | } | 1119 | } |
1027 | 1120 | ||
1121 | void ConfigMainWindow::showIntro(void) | ||
1122 | { | ||
1123 | static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" | ||
1124 | "For each option, a blank box indicates the feature is disabled, a check\n" | ||
1125 | "indicates it is enabled, and a dot indicates that it is to be compiled\n" | ||
1126 | "as a module. Clicking on the box will cycle through the three states.\n\n" | ||
1127 | "If you do not see an option (e.g., a device driver) that you believe\n" | ||
1128 | "should be present, try turning on Show All Options under the Options menu.\n" | ||
1129 | "Although there is no cross reference yet to help you figure out what other\n" | ||
1130 | "options must be enabled to support the option you are interested in, you can\n" | ||
1131 | "still view the help of a grayed-out option.\n\n" | ||
1132 | "Toggling Show Debug Info under the Options menu will show the dependencies,\n" | ||
1133 | "which you can then match by examining other options.\n\n"; | ||
1134 | |||
1135 | QMessageBox::information(this, "qconf", str); | ||
1136 | } | ||
1137 | |||
1138 | void ConfigMainWindow::showAbout(void) | ||
1139 | { | ||
1140 | static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n" | ||
1141 | "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; | ||
1142 | |||
1143 | QMessageBox::information(this, "qconf", str); | ||
1144 | } | ||
1145 | |||
1028 | void fixup_rootmenu(struct menu *menu) | 1146 | void fixup_rootmenu(struct menu *menu) |
1029 | { | 1147 | { |
1030 | struct menu *child; | 1148 | struct menu *child; |
1031 | 1149 | ||
1032 | if (!menu->prompt || menu->prompt->type != P_MENU) | 1150 | if (!menu->prompt || menu->prompt->type != P_MENU) |
1033 | return; | 1151 | return; |
1034 | menu->prompt->type = P_ROOTMENU; | 1152 | menu->prompt->type = P_ROOTMENU; |
1035 | for (child = menu->list; child; child = child->next) | 1153 | for (child = menu->list; child; child = child->next) |
1036 | fixup_rootmenu(child); | 1154 | fixup_rootmenu(child); |
1037 | } | 1155 | } |
1038 | 1156 | ||
1039 | int main(int ac, char** av) | 1157 | int main(int ac, char** av) |
1040 | { | 1158 | { |
1041 | ConfigView* v; | 1159 | ConfigMainWindow* v; |
1042 | const char *name; | 1160 | const char *name; |
1043 | 1161 | ||
1044 | #ifndef LKC_DIRECT_LINK | 1162 | #ifndef LKC_DIRECT_LINK |
1045 | kconfig_load(); | 1163 | kconfig_load(); |
1046 | #endif | 1164 | #endif |
1047 | 1165 | ||
1048 | configApp = new QApplication(ac, av); | 1166 | configApp = new QApplication(ac, av); |
1167 | #if QT_VERSION >= 300 | ||
1168 | configSettings = new QSettings; | ||
1169 | #endif | ||
1049 | if (ac > 1 && av[1][0] == '-') { | 1170 | if (ac > 1 && av[1][0] == '-') { |
1050 | switch (av[1][1]) { | 1171 | switch (av[1][1]) { |
1051 | case 'a': | 1172 | case 'a': |
1052 | //showAll = 1; | 1173 | //showAll = 1; |
1053 | break; | 1174 | break; |
1054 | case 'h': | 1175 | case 'h': |
1055 | case '?': | 1176 | case '?': |
1056 | printf("%s <config>\n", av[0]); | 1177 | printf("%s <config>\n", av[0]); |
1057 | exit(0); | 1178 | exit(0); |
1058 | } | 1179 | } |
1059 | name = av[2]; | 1180 | name = av[2]; |
1060 | } else | 1181 | } else |
1061 | name = av[1]; | 1182 | name = av[1]; |
1062 | conf_parse(name); | 1183 | conf_parse(name); |
1063 | fixup_rootmenu(&rootmenu); | 1184 | fixup_rootmenu(&rootmenu); |
1064 | conf_read(NULL); | 1185 | conf_read(NULL); |
1065 | //zconfdump(stdout); | 1186 | //zconfdump(stdout); |
1066 | v = new ConfigView(); | 1187 | |
1188 | v = new ConfigMainWindow(); | ||
1067 | 1189 | ||
1068 | //zconfdump(stdout); | 1190 | //zconfdump(stdout); |
1069 | v->show(); | 1191 | v->show(); |
1070 | configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); | 1192 | configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); |
1071 | configApp->exec(); | 1193 | configApp->exec(); |
1194 | |||
1195 | #if QT_VERSION >= 300 | ||
1196 | configSettings->writeEntry("/kconfig/qconf/window x", v->pos().x()); | ||
1197 | configSettings->writeEntry("/kconfig/qconf/window y", v->pos().y()); | ||
1198 | configSettings->writeEntry("/kconfig/qconf/window width", v->size().width()); | ||
1199 | configSettings->writeEntry("/kconfig/qconf/window height", v->size().height()); | ||
1200 | delete configSettings; | ||
1201 | #endif | ||
1072 | return 0; | 1202 | return 0; |
1073 | } | 1203 | } |