-rw-r--r-- | scripts/kconfig/qconf.cc | 405 |
1 files changed, 253 insertions, 152 deletions
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index bed541d..52419ad 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc | |||
@@ -37,75 +37,65 @@ static QSettings *configSettings; | |||
37 | /* | 37 | /* |
38 | * update all the children of a menu entry | 38 | * update all the children of a menu entry |
39 | * removes/adds the entries from the parent widget as necessary | 39 | * removes/adds the entries from the parent widget as necessary |
40 | * | 40 | * |
41 | * parent: either the menu list widget or a menu entry widget | 41 | * parent: either the menu list widget or a menu entry widget |
42 | * menu: entry to be updated | 42 | * menu: entry to be updated |
43 | */ | 43 | */ |
44 | template <class P> | 44 | template <class P> |
45 | static void updateMenuList(P* parent, struct menu* menu) | 45 | void ConfigList::updateMenuList(P* parent, struct menu* menu) |
46 | { | 46 | { |
47 | struct menu* child; | 47 | struct menu* child; |
48 | ConfigList* list = parent->listView(); | ||
49 | ConfigItem* item; | 48 | ConfigItem* item; |
50 | ConfigItem* last; | 49 | ConfigItem* last; |
51 | bool visible; | 50 | bool visible; |
52 | bool showAll = list->showAll; | ||
53 | enum listMode mode = list->mode; | ||
54 | enum prop_type type; | 51 | enum prop_type type; |
55 | 52 | ||
56 | if (!menu) { | 53 | if (!menu) { |
57 | while ((item = parent->firstChild())) | 54 | while ((item = parent->firstChild())) |
58 | delete item; | 55 | delete item; |
59 | return; | 56 | return; |
60 | } | 57 | } |
61 | 58 | ||
62 | last = 0; | 59 | last = parent->firstChild(); |
60 | if (last && !last->goParent) | ||
61 | last = 0; | ||
63 | for (child = menu->list; child; child = child->next) { | 62 | for (child = menu->list; child; child = child->next) { |
64 | item = last ? last->nextSibling() : parent->firstChild(); | 63 | item = last ? last->nextSibling() : parent->firstChild(); |
65 | type = child->prompt ? child->prompt->type : P_UNKNOWN; | 64 | type = child->prompt ? child->prompt->type : P_UNKNOWN; |
66 | 65 | ||
67 | switch (mode) { | 66 | switch (mode) { |
68 | case menuMode: | 67 | case menuMode: |
69 | if (type != P_ROOTMENU) | 68 | if (!(child->flags & MENU_ROOT)) |
70 | goto hide; | 69 | goto hide; |
71 | break; | 70 | break; |
72 | case symbolMode: | 71 | case symbolMode: |
73 | if (type == P_ROOTMENU) | 72 | if (child->flags & MENU_ROOT) |
74 | goto hide; | 73 | goto hide; |
75 | break; | 74 | break; |
76 | default: | 75 | default: |
77 | break; | 76 | break; |
78 | } | 77 | } |
79 | 78 | ||
80 | visible = menu_is_visible(child); | 79 | visible = menu_is_visible(child); |
81 | if (showAll || visible) { | 80 | if (showAll || visible) { |
82 | if (!item || item->menu != child) | 81 | if (!item || item->menu != child) |
83 | item = new ConfigItem(parent, last, child, visible); | 82 | item = new ConfigItem(parent, last, child, visible); |
84 | else { | 83 | else |
85 | item->visible = visible; | 84 | item->testUpdateMenu(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 | } | ||
94 | 85 | ||
95 | if (mode == fullMode || mode == menuMode || | 86 | if (mode == fullMode || mode == menuMode || type != P_MENU) |
96 | (type != P_MENU && type != P_ROOTMENU)) | ||
97 | updateMenuList(item, child); | 87 | updateMenuList(item, child); |
98 | else | 88 | else |
99 | updateMenuList(item, 0); | 89 | updateMenuList(item, 0); |
100 | last = item; | 90 | last = item; |
101 | continue; | 91 | continue; |
102 | } | 92 | } |
103 | hide: | 93 | hide: |
104 | if (item && item->menu == child) { | 94 | if (item && item->menu == child) { |
105 | last = parent->firstChild(); | 95 | last = parent->firstChild(); |
106 | if (last == item) | 96 | if (last == item) |
107 | last = 0; | 97 | last = 0; |
108 | else while (last->nextSibling() != item) | 98 | else while (last->nextSibling() != item) |
109 | last = last->nextSibling(); | 99 | last = last->nextSibling(); |
110 | delete item; | 100 | delete item; |
111 | } | 101 | } |
@@ -126,45 +116,66 @@ void ConfigItem::okRename(int col) | |||
126 | 116 | ||
127 | /* | 117 | /* |
128 | * update the displayed of a menu entry | 118 | * update the displayed of a menu entry |
129 | */ | 119 | */ |
130 | void ConfigItem::updateMenu(void) | 120 | void ConfigItem::updateMenu(void) |
131 | { | 121 | { |
132 | ConfigList* list; | 122 | ConfigList* list; |
133 | struct symbol* sym; | 123 | struct symbol* sym; |
124 | struct property *prop; | ||
134 | QString prompt; | 125 | QString prompt; |
135 | int type; | 126 | int type; |
136 | enum prop_type ptype; | ||
137 | tristate expr; | 127 | tristate expr; |
138 | 128 | ||
139 | list = listView(); | 129 | list = listView(); |
130 | if (goParent) { | ||
131 | setPixmap(promptColIdx, list->menuBackPix); | ||
132 | prompt = ".."; | ||
133 | goto set_prompt; | ||
134 | } | ||
140 | 135 | ||
141 | sym = menu->sym; | 136 | sym = menu->sym; |
142 | if (!sym) { | 137 | prop = menu->prompt; |
143 | setText(promptColIdx, menu_get_prompt(menu)); | 138 | prompt = menu_get_prompt(menu); |
144 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 139 | |
145 | if ((ptype == P_ROOTMENU || ptype == P_MENU) && | 140 | if (prop) switch (prop->type) { |
146 | (list->mode == singleMode || list->mode == symbolMode)) | 141 | case P_MENU: |
142 | if (list->mode == singleMode || list->mode == symbolMode) { | ||
143 | /* a menuconfig entry is displayed differently | ||
144 | * depending whether it's at the view root or a child. | ||
145 | */ | ||
146 | if (sym && list->rootEntry == menu) | ||
147 | break; | ||
147 | setPixmap(promptColIdx, list->menuPix); | 148 | setPixmap(promptColIdx, list->menuPix); |
148 | else | 149 | } else { |
150 | if (sym) | ||
151 | break; | ||
149 | setPixmap(promptColIdx, 0); | 152 | setPixmap(promptColIdx, 0); |
150 | return; | 153 | } |
154 | goto set_prompt; | ||
155 | case P_COMMENT: | ||
156 | setPixmap(promptColIdx, 0); | ||
157 | goto set_prompt; | ||
158 | default: | ||
159 | ; | ||
151 | } | 160 | } |
161 | if (!sym) | ||
162 | goto set_prompt; | ||
152 | 163 | ||
153 | setText(nameColIdx, sym->name); | 164 | setText(nameColIdx, sym->name); |
154 | 165 | ||
155 | type = sym_get_type(sym); | 166 | type = sym_get_type(sym); |
156 | switch (type) { | 167 | switch (type) { |
157 | case S_BOOLEAN: | 168 | case S_BOOLEAN: |
158 | case S_TRISTATE: | 169 | case S_TRISTATE: |
159 | char ch; | 170 | char ch; |
160 | 171 | ||
161 | prompt = menu_get_prompt(menu); | ||
162 | if (!sym_is_changable(sym) && !list->showAll) { | 172 | if (!sym_is_changable(sym) && !list->showAll) { |
173 | setPixmap(promptColIdx, 0); | ||
163 | setText(noColIdx, 0); | 174 | setText(noColIdx, 0); |
164 | setText(modColIdx, 0); | 175 | setText(modColIdx, 0); |
165 | setText(yesColIdx, 0); | 176 | setText(yesColIdx, 0); |
166 | break; | 177 | break; |
167 | } | 178 | } |
168 | expr = sym_get_tristate_value(sym); | 179 | expr = sym_get_tristate_value(sym); |
169 | switch (expr) { | 180 | switch (expr) { |
170 | case yes: | 181 | case yes: |
@@ -206,36 +217,43 @@ void ConfigItem::updateMenu(void) | |||
206 | data = sym_get_string_value(sym); | 217 | data = sym_get_string_value(sym); |
207 | #if QT_VERSION >= 300 | 218 | #if QT_VERSION >= 300 |
208 | int i = list->mapIdx(dataColIdx); | 219 | int i = list->mapIdx(dataColIdx); |
209 | if (i >= 0) | 220 | if (i >= 0) |
210 | setRenameEnabled(i, TRUE); | 221 | setRenameEnabled(i, TRUE); |
211 | #endif | 222 | #endif |
212 | setText(dataColIdx, data); | 223 | setText(dataColIdx, data); |
213 | if (type == S_STRING) | 224 | if (type == S_STRING) |
214 | prompt.sprintf("%s: %s", menu_get_prompt(menu), data); | 225 | prompt.sprintf("%s: %s", prompt.latin1(), data); |
215 | else | 226 | else |
216 | prompt.sprintf("(%s) %s", data, menu_get_prompt(menu)); | 227 | prompt.sprintf("(%s) %s", data, prompt.latin1()); |
217 | break; | 228 | break; |
218 | } | 229 | } |
219 | if (!sym_has_value(sym) && visible) | 230 | if (!sym_has_value(sym) && visible) |
220 | prompt += " (NEW)"; | 231 | prompt += " (NEW)"; |
232 | set_prompt: | ||
221 | setText(promptColIdx, prompt); | 233 | setText(promptColIdx, prompt); |
222 | } | 234 | } |
223 | 235 | ||
224 | bool ConfigItem::updateNeeded(void) | 236 | void ConfigItem::testUpdateMenu(bool v) |
225 | { | 237 | { |
226 | struct symbol* sym = menu->sym; | 238 | ConfigItem* i; |
227 | if (sym) | 239 | |
228 | sym_calc_value(sym); | 240 | visible = v; |
241 | if (!menu) | ||
242 | return; | ||
243 | |||
244 | sym_calc_value(menu->sym); | ||
229 | if (menu->flags & MENU_CHANGED) { | 245 | if (menu->flags & MENU_CHANGED) { |
246 | /* the menu entry changed, so update all list items */ | ||
230 | menu->flags &= ~MENU_CHANGED; | 247 | menu->flags &= ~MENU_CHANGED; |
231 | return true; | 248 | for (i = (ConfigItem*)menu->data; i; i = i->nextItem) |
232 | } | 249 | i->updateMenu(); |
233 | return false; | 250 | } else if (listView()->updateAll) |
251 | updateMenu(); | ||
234 | } | 252 | } |
235 | 253 | ||
236 | void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) | 254 | void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) |
237 | { | 255 | { |
238 | ConfigList* list = listView(); | 256 | ConfigList* list = listView(); |
239 | 257 | ||
240 | if (visible) { | 258 | if (visible) { |
241 | if (isSelected() && !list->hasFocus() && list->mode == menuMode) | 259 | if (isSelected() && !list->hasFocus() && list->mode == menuMode) |
@@ -246,37 +264,40 @@ void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int w | |||
246 | Parent::paintCell(p, list->disabledColorGroup, column, width, align); | 264 | Parent::paintCell(p, list->disabledColorGroup, column, width, align); |
247 | } | 265 | } |
248 | 266 | ||
249 | /* | 267 | /* |
250 | * construct a menu entry | 268 | * construct a menu entry |
251 | */ | 269 | */ |
252 | void ConfigItem::init(void) | 270 | void ConfigItem::init(void) |
253 | { | 271 | { |
254 | ConfigList* list = listView(); | 272 | if (menu) { |
255 | nextItem = (ConfigItem*)menu->data; | 273 | ConfigList* list = listView(); |
256 | menu->data = this; | 274 | nextItem = (ConfigItem*)menu->data; |
275 | menu->data = this; | ||
257 | 276 | ||
258 | if (list->mode != fullMode) | 277 | if (list->mode != fullMode) |
259 | setOpen(TRUE); | 278 | setOpen(TRUE); |
260 | if (menu->sym) | ||
261 | sym_calc_value(menu->sym); | 279 | sym_calc_value(menu->sym); |
280 | } | ||
262 | updateMenu(); | 281 | updateMenu(); |
263 | } | 282 | } |
264 | 283 | ||
265 | /* | 284 | /* |
266 | * destruct a menu entry | 285 | * destruct a menu entry |
267 | */ | 286 | */ |
268 | ConfigItem::~ConfigItem(void) | 287 | ConfigItem::~ConfigItem(void) |
269 | { | 288 | { |
270 | ConfigItem** ip = &(ConfigItem*)menu->data; | 289 | if (menu) { |
271 | for (; *ip; ip = &(*ip)->nextItem) { | 290 | ConfigItem** ip = (ConfigItem**)&menu->data; |
272 | if (*ip == this) { | 291 | for (; *ip; ip = &(*ip)->nextItem) { |
273 | *ip = nextItem; | 292 | if (*ip == this) { |
274 | break; | 293 | *ip = nextItem; |
294 | break; | ||
295 | } | ||
275 | } | 296 | } |
276 | } | 297 | } |
277 | } | 298 | } |
278 | 299 | ||
279 | void ConfigLineEdit::show(ConfigItem* i) | 300 | void ConfigLineEdit::show(ConfigItem* i) |
280 | { | 301 | { |
281 | item = i; | 302 | item = i; |
282 | if (sym_get_string_value(item->menu->sym)) | 303 | if (sym_get_string_value(item->menu->sym)) |
@@ -305,17 +326,18 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | |||
305 | parent()->list->setFocus(); | 326 | parent()->list->setFocus(); |
306 | hide(); | 327 | hide(); |
307 | } | 328 | } |
308 | 329 | ||
309 | ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv) | 330 | ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv) |
310 | : Parent(p), cview(cv), | 331 | : Parent(p), cview(cv), |
311 | updateAll(false), | 332 | updateAll(false), |
312 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), | 333 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), |
313 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), menuPix(xpm_menu), menuInvPix(xpm_menu_inv), | 334 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), |
335 | menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), | ||
314 | showAll(false), showName(false), showRange(false), showData(false), | 336 | showAll(false), showName(false), showRange(false), showData(false), |
315 | rootEntry(0) | 337 | rootEntry(0) |
316 | { | 338 | { |
317 | int i; | 339 | int i; |
318 | 340 | ||
319 | setSorting(-1); | 341 | setSorting(-1); |
320 | setRootIsDecorated(TRUE); | 342 | setRootIsDecorated(TRUE); |
321 | disabledColorGroup = palette().active(); | 343 | disabledColorGroup = palette().active(); |
@@ -361,24 +383,47 @@ void ConfigList::updateSelection(void) | |||
361 | 383 | ||
362 | ConfigItem* item = (ConfigItem*)selectedItem(); | 384 | ConfigItem* item = (ConfigItem*)selectedItem(); |
363 | if (!item) | 385 | if (!item) |
364 | return; | 386 | return; |
365 | 387 | ||
366 | cview->setHelp(item); | 388 | cview->setHelp(item); |
367 | 389 | ||
368 | menu = item->menu; | 390 | menu = item->menu; |
391 | if (!menu) | ||
392 | return; | ||
369 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 393 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
370 | if (mode == menuMode && (type == P_MENU || type == P_ROOTMENU)) | 394 | if (mode == menuMode && type == P_MENU) |
371 | emit menuSelected(menu); | 395 | emit menuSelected(menu); |
372 | } | 396 | } |
373 | 397 | ||
374 | void ConfigList::updateList(ConfigItem* item) | 398 | void ConfigList::updateList(ConfigItem* item) |
375 | { | 399 | { |
376 | (void)item;// unused so far | 400 | ConfigItem* last = 0; |
401 | |||
402 | if (!rootEntry) | ||
403 | goto update; | ||
404 | |||
405 | if (rootEntry != &rootmenu && (mode == singleMode || | ||
406 | (mode == symbolMode && rootEntry->parent != &rootmenu))) { | ||
407 | item = firstChild(); | ||
408 | if (!item) | ||
409 | item = new ConfigItem(this, 0, true); | ||
410 | last = item; | ||
411 | } | ||
412 | if (mode == singleMode && rootEntry->sym && rootEntry->prompt) { | ||
413 | item = last ? last->nextSibling() : firstChild(); | ||
414 | if (!item) | ||
415 | item = new ConfigItem(this, last, rootEntry, true); | ||
416 | |||
417 | updateMenuList(item, rootEntry); | ||
418 | triggerUpdate(); | ||
419 | return; | ||
420 | } | ||
421 | update: | ||
377 | updateMenuList(this, rootEntry); | 422 | updateMenuList(this, rootEntry); |
378 | triggerUpdate(); | 423 | triggerUpdate(); |
379 | } | 424 | } |
380 | 425 | ||
381 | void ConfigList::setAllOpen(bool open) | 426 | void ConfigList::setAllOpen(bool open) |
382 | { | 427 | { |
383 | QListViewItemIterator it(this); | 428 | QListViewItemIterator it(this); |
384 | 429 | ||
@@ -387,17 +432,17 @@ void ConfigList::setAllOpen(bool open) | |||
387 | } | 432 | } |
388 | 433 | ||
389 | void ConfigList::setValue(ConfigItem* item, tristate val) | 434 | void ConfigList::setValue(ConfigItem* item, tristate val) |
390 | { | 435 | { |
391 | struct symbol* sym; | 436 | struct symbol* sym; |
392 | int type; | 437 | int type; |
393 | tristate oldval; | 438 | tristate oldval; |
394 | 439 | ||
395 | sym = item->menu->sym; | 440 | sym = item->menu ? item->menu->sym : 0; |
396 | if (!sym) | 441 | if (!sym) |
397 | return; | 442 | return; |
398 | 443 | ||
399 | type = sym_get_type(sym); | 444 | type = sym_get_type(sym); |
400 | switch (type) { | 445 | switch (type) { |
401 | case S_BOOLEAN: | 446 | case S_BOOLEAN: |
402 | case S_TRISTATE: | 447 | case S_TRISTATE: |
403 | oldval = sym_get_tristate_value(sym); | 448 | oldval = sym_get_tristate_value(sym); |
@@ -413,16 +458,18 @@ void ConfigList::setValue(ConfigItem* item, tristate val) | |||
413 | 458 | ||
414 | void ConfigList::changeValue(ConfigItem* item) | 459 | void ConfigList::changeValue(ConfigItem* item) |
415 | { | 460 | { |
416 | struct symbol* sym; | 461 | struct symbol* sym; |
417 | struct menu* menu; | 462 | struct menu* menu; |
418 | int type, oldexpr, newexpr; | 463 | int type, oldexpr, newexpr; |
419 | 464 | ||
420 | menu = item->menu; | 465 | menu = item->menu; |
466 | if (!menu) | ||
467 | return; | ||
421 | sym = menu->sym; | 468 | sym = menu->sym; |
422 | if (!sym) { | 469 | if (!sym) { |
423 | if (item->menu->list) | 470 | if (item->menu->list) |
424 | item->setOpen(!item->isOpen()); | 471 | item->setOpen(!item->isOpen()); |
425 | return; | 472 | return; |
426 | } | 473 | } |
427 | 474 | ||
428 | type = sym_get_type(sym); | 475 | type = sym_get_type(sym); |
@@ -455,34 +502,33 @@ void ConfigList::changeValue(ConfigItem* item) | |||
455 | 502 | ||
456 | void ConfigList::setRootMenu(struct menu *menu) | 503 | void ConfigList::setRootMenu(struct menu *menu) |
457 | { | 504 | { |
458 | enum prop_type type; | 505 | enum prop_type type; |
459 | 506 | ||
460 | if (rootEntry == menu) | 507 | if (rootEntry == menu) |
461 | return; | 508 | return; |
462 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; | 509 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; |
463 | if (type != P_MENU && type != P_ROOTMENU) | 510 | if (type != P_MENU) |
464 | return; | 511 | return; |
465 | updateMenuList(this, 0); | 512 | updateMenuList(this, 0); |
466 | rootEntry = menu; | 513 | rootEntry = menu; |
467 | updateListAll(); | 514 | updateListAll(); |
468 | setSelected(currentItem(), hasFocus()); | 515 | setSelected(currentItem(), hasFocus()); |
469 | } | 516 | } |
470 | 517 | ||
471 | void ConfigList::setParentMenu(void) | 518 | void ConfigList::setParentMenu(void) |
472 | { | 519 | { |
473 | ConfigItem* item; | 520 | ConfigItem* item; |
474 | struct menu *oldroot, *newroot; | 521 | struct menu *oldroot; |
475 | 522 | ||
476 | oldroot = rootEntry; | 523 | oldroot = rootEntry; |
477 | newroot = menu_get_parent_menu(oldroot); | 524 | if (rootEntry == &rootmenu) |
478 | if (newroot == oldroot) | ||
479 | return; | 525 | return; |
480 | setRootMenu(newroot); | 526 | setRootMenu(menu_get_parent_menu(rootEntry->parent)); |
481 | 527 | ||
482 | QListViewItemIterator it(this); | 528 | QListViewItemIterator it(this); |
483 | for (; (item = (ConfigItem*)it.current()); it++) { | 529 | for (; (item = (ConfigItem*)it.current()); it++) { |
484 | if (item->menu == oldroot) { | 530 | if (item->menu == oldroot) { |
485 | setCurrentItem(item); | 531 | setCurrentItem(item); |
486 | ensureItemVisible(item); | 532 | ensureItemVisible(item); |
487 | break; | 533 | break; |
488 | } | 534 | } |
@@ -506,19 +552,26 @@ void ConfigList::keyPressEvent(QKeyEvent* ev) | |||
506 | Parent::keyPressEvent(ev); | 552 | Parent::keyPressEvent(ev); |
507 | return; | 553 | return; |
508 | } | 554 | } |
509 | item = (ConfigItem*)i; | 555 | item = (ConfigItem*)i; |
510 | 556 | ||
511 | switch (ev->key()) { | 557 | switch (ev->key()) { |
512 | case Key_Return: | 558 | case Key_Return: |
513 | case Key_Enter: | 559 | case Key_Enter: |
560 | if (item->goParent) { | ||
561 | emit parentSelected(); | ||
562 | break; | ||
563 | } | ||
514 | menu = item->menu; | 564 | menu = item->menu; |
565 | if (!menu) | ||
566 | break; | ||
515 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 567 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
516 | if ((type == P_MENU || type == P_ROOTMENU) && mode != fullMode) { | 568 | if (type == P_MENU && rootEntry != menu && |
569 | mode != fullMode && mode != menuMode) { | ||
517 | emit menuSelected(menu); | 570 | emit menuSelected(menu); |
518 | break; | 571 | break; |
519 | } | 572 | } |
520 | case Key_Space: | 573 | case Key_Space: |
521 | changeValue(item); | 574 | changeValue(item); |
522 | break; | 575 | break; |
523 | case Key_N: | 576 | case Key_N: |
524 | setValue(item, no); | 577 | setValue(item, no); |
@@ -543,36 +596,44 @@ void ConfigList::contentsMousePressEvent(QMouseEvent* e) | |||
543 | Parent::contentsMousePressEvent(e); | 596 | Parent::contentsMousePressEvent(e); |
544 | } | 597 | } |
545 | 598 | ||
546 | void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) | 599 | void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) |
547 | { | 600 | { |
548 | QPoint p(contentsToViewport(e->pos())); | 601 | QPoint p(contentsToViewport(e->pos())); |
549 | ConfigItem* item = (ConfigItem*)itemAt(p); | 602 | ConfigItem* item = (ConfigItem*)itemAt(p); |
550 | struct menu *menu; | 603 | struct menu *menu; |
604 | enum prop_type ptype; | ||
551 | const QPixmap* pm; | 605 | const QPixmap* pm; |
552 | int idx, x; | 606 | int idx, x; |
553 | 607 | ||
554 | if (!item) | 608 | if (!item) |
555 | goto skip; | 609 | goto skip; |
556 | 610 | ||
557 | menu = item->menu; | 611 | menu = item->menu; |
558 | x = header()->offset() + p.x(); | 612 | x = header()->offset() + p.x(); |
559 | idx = colRevMap[header()->sectionAt(x)]; | 613 | idx = colRevMap[header()->sectionAt(x)]; |
560 | switch (idx) { | 614 | switch (idx) { |
561 | case promptColIdx: | 615 | case promptColIdx: |
562 | pm = item->pixmap(promptColIdx); | 616 | pm = item->pixmap(promptColIdx); |
563 | if (pm) { | 617 | if (pm) { |
564 | int off = header()->sectionPos(0) + itemMargin() + | 618 | int off = header()->sectionPos(0) + itemMargin() + |
565 | treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); | 619 | treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); |
566 | if (x >= off && x < off + pm->width()) { | 620 | if (x >= off && x < off + pm->width()) { |
567 | if (menu->sym) | 621 | if (item->goParent) { |
568 | changeValue(item); | 622 | emit parentSelected(); |
569 | else | 623 | break; |
624 | } else if (!menu) | ||
625 | break; | ||
626 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
627 | if (ptype == P_MENU && rootEntry != menu && | ||
628 | mode != fullMode && mode != menuMode) | ||
570 | emit menuSelected(menu); | 629 | emit menuSelected(menu); |
630 | else | ||
631 | changeValue(item); | ||
571 | } | 632 | } |
572 | } | 633 | } |
573 | break; | 634 | break; |
574 | case noColIdx: | 635 | case noColIdx: |
575 | setValue(item, no); | 636 | setValue(item, no); |
576 | break; | 637 | break; |
577 | case modColIdx: | 638 | case modColIdx: |
578 | setValue(item, mod); | 639 | setValue(item, mod); |
@@ -601,20 +662,25 @@ void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) | |||
601 | { | 662 | { |
602 | QPoint p(contentsToViewport(e->pos())); | 663 | QPoint p(contentsToViewport(e->pos())); |
603 | ConfigItem* item = (ConfigItem*)itemAt(p); | 664 | ConfigItem* item = (ConfigItem*)itemAt(p); |
604 | struct menu *menu; | 665 | struct menu *menu; |
605 | enum prop_type ptype; | 666 | enum prop_type ptype; |
606 | 667 | ||
607 | if (!item) | 668 | if (!item) |
608 | goto skip; | 669 | goto skip; |
670 | if (item->goParent) { | ||
671 | emit parentSelected(); | ||
672 | goto skip; | ||
673 | } | ||
609 | menu = item->menu; | 674 | menu = item->menu; |
675 | if (!menu) | ||
676 | goto skip; | ||
610 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 677 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
611 | if ((ptype == P_ROOTMENU || ptype == P_MENU) && | 678 | if (ptype == P_MENU && (mode == singleMode || mode == symbolMode)) |
612 | (mode == singleMode || mode == symbolMode)) | ||
613 | emit menuSelected(menu); | 679 | emit menuSelected(menu); |
614 | else if (menu->sym) | 680 | else if (menu->sym) |
615 | changeValue(item); | 681 | changeValue(item); |
616 | 682 | ||
617 | skip: | 683 | skip: |
618 | //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); | 684 | //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); |
619 | Parent::contentsMouseDoubleClickEvent(e); | 685 | Parent::contentsMouseDoubleClickEvent(e); |
620 | } | 686 | } |
@@ -672,17 +738,16 @@ void ConfigView::updateListAll(void) | |||
672 | v->list->updateListAll(); | 738 | v->list->updateListAll(); |
673 | } | 739 | } |
674 | 740 | ||
675 | /* | 741 | /* |
676 | * Construct the complete config widget | 742 | * Construct the complete config widget |
677 | */ | 743 | */ |
678 | ConfigMainWindow::ConfigMainWindow(void) | 744 | ConfigMainWindow::ConfigMainWindow(void) |
679 | { | 745 | { |
680 | ConfigView* view; | ||
681 | QMenuBar* menu; | 746 | QMenuBar* menu; |
682 | QSplitter* split1; | 747 | QSplitter* split1; |
683 | QSplitter* split2; | 748 | QSplitter* split2; |
684 | bool ok; | 749 | bool ok; |
685 | int x, y, width, height; | 750 | int x, y, width, height; |
686 | 751 | ||
687 | QWidget *d = configApp->desktop(); | 752 | QWidget *d = configApp->desktop(); |
688 | 753 | ||
@@ -702,25 +767,25 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
702 | #endif | 767 | #endif |
703 | 768 | ||
704 | showDebug = false; | 769 | showDebug = false; |
705 | 770 | ||
706 | split1 = new QSplitter(this); | 771 | split1 = new QSplitter(this); |
707 | split1->setOrientation(QSplitter::Horizontal); | 772 | split1->setOrientation(QSplitter::Horizontal); |
708 | setCentralWidget(split1); | 773 | setCentralWidget(split1); |
709 | 774 | ||
710 | view = new ConfigView(split1, this); | 775 | menuView = new ConfigView(split1, this); |
711 | menuList = view->list; | 776 | menuList = menuView->list; |
712 | 777 | ||
713 | split2 = new QSplitter(split1); | 778 | split2 = new QSplitter(split1); |
714 | split2->setOrientation(QSplitter::Vertical); | 779 | split2->setOrientation(QSplitter::Vertical); |
715 | 780 | ||
716 | // create config tree | 781 | // create config tree |
717 | view = new ConfigView(split2, this); | 782 | configView = new ConfigView(split2, this); |
718 | configList = view->list; | 783 | configList = configView->list; |
719 | 784 | ||
720 | helpText = new QTextView(split2); | 785 | helpText = new QTextView(split2); |
721 | helpText->setTextFormat(Qt::RichText); | 786 | helpText->setTextFormat(Qt::RichText); |
722 | 787 | ||
723 | setTabOrder(configList, helpText); | 788 | setTabOrder(configList, helpText); |
724 | configList->setFocus(); | 789 | configList->setFocus(); |
725 | 790 | ||
726 | menu = menuBar(); | 791 | menu = menuBar(); |
@@ -813,17 +878,16 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
813 | connect(menuList, SIGNAL(menuSelected(struct menu *)), | 878 | connect(menuList, SIGNAL(menuSelected(struct menu *)), |
814 | SLOT(changeMenu(struct menu *))); | 879 | SLOT(changeMenu(struct menu *))); |
815 | 880 | ||
816 | connect(configList, SIGNAL(gotFocus(void)), | 881 | connect(configList, SIGNAL(gotFocus(void)), |
817 | SLOT(listFocusChanged(void))); | 882 | SLOT(listFocusChanged(void))); |
818 | connect(menuList, SIGNAL(gotFocus(void)), | 883 | connect(menuList, SIGNAL(gotFocus(void)), |
819 | SLOT(listFocusChanged(void))); | 884 | SLOT(listFocusChanged(void))); |
820 | 885 | ||
821 | //showFullView(); | ||
822 | showSplitView(); | 886 | showSplitView(); |
823 | } | 887 | } |
824 | 888 | ||
825 | static QString print_filter(const char *str) | 889 | static QString print_filter(const char *str) |
826 | { | 890 | { |
827 | QRegExp re("[<>&\"\\n]"); | 891 | QRegExp re("[<>&\"\\n]"); |
828 | QString res = str; | 892 | QString res = str; |
829 | for (int i = 0; (i = res.find(re, i)) >= 0;) { | 893 | for (int i = 0; (i = res.find(re, i)) >= 0;) { |
@@ -859,99 +923,117 @@ static void expr_print_help(void *data, const char *str) | |||
859 | } | 923 | } |
860 | 924 | ||
861 | /* | 925 | /* |
862 | * display a new help entry as soon as a new menu entry is selected | 926 | * display a new help entry as soon as a new menu entry is selected |
863 | */ | 927 | */ |
864 | void ConfigMainWindow::setHelp(QListViewItem* item) | 928 | void ConfigMainWindow::setHelp(QListViewItem* item) |
865 | { | 929 | { |
866 | struct symbol* sym; | 930 | struct symbol* sym; |
867 | struct menu* menu; | 931 | struct menu* menu = 0; |
868 | 932 | ||
869 | configList->parent()->lineEdit->hide(); | 933 | configList->parent()->lineEdit->hide(); |
870 | if (item) { | 934 | if (item) |
871 | QString head, debug, help; | ||
872 | menu = ((ConfigItem*)item)->menu; | 935 | menu = ((ConfigItem*)item)->menu; |
873 | sym = menu->sym; | 936 | if (!menu) { |
874 | if (sym) { | 937 | helpText->setText(NULL); |
875 | if (menu->prompt) { | 938 | return; |
876 | head += "<big><b>"; | 939 | } |
877 | head += print_filter(menu->prompt->text); | 940 | |
878 | head += "</b></big>"; | 941 | QString head, debug, help; |
879 | if (sym->name) { | 942 | menu = ((ConfigItem*)item)->menu; |
880 | head += " ("; | 943 | sym = menu->sym; |
881 | head += print_filter(sym->name); | 944 | if (sym) { |
882 | head += ")"; | 945 | if (menu->prompt) { |
883 | } | 946 | head += "<big><b>"; |
884 | } else if (sym->name) { | 947 | head += print_filter(menu->prompt->text); |
885 | head += "<big><b>"; | 948 | head += "</b></big>"; |
949 | if (sym->name) { | ||
950 | head += " ("; | ||
886 | head += print_filter(sym->name); | 951 | head += print_filter(sym->name); |
887 | head += "</b></big>"; | 952 | head += ")"; |
888 | } | 953 | } |
889 | head += "<br><br>"; | 954 | } else if (sym->name) { |
890 | 955 | head += "<big><b>"; | |
891 | if (showDebug) { | 956 | head += print_filter(sym->name); |
892 | debug += "type: "; | 957 | head += "</b></big>"; |
893 | debug += print_filter(sym_type_name(sym->type)); | 958 | } |
959 | head += "<br><br>"; | ||
960 | |||
961 | if (showDebug) { | ||
962 | debug += "type: "; | ||
963 | debug += print_filter(sym_type_name(sym->type)); | ||
964 | if (sym_is_choice(sym)) | ||
965 | debug += " (choice)"; | ||
966 | debug += "<br>"; | ||
967 | if (sym->rev_dep.expr) { | ||
968 | debug += "reverse dep: "; | ||
969 | expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); | ||
894 | debug += "<br>"; | 970 | debug += "<br>"; |
895 | for (struct property *prop = sym->prop; prop; prop = prop->next) { | 971 | } |
896 | switch (prop->type) { | 972 | for (struct property *prop = sym->prop; prop; prop = prop->next) { |
897 | case P_PROMPT: | 973 | switch (prop->type) { |
898 | debug += "prompt: "; | 974 | case P_PROMPT: |
899 | debug += print_filter(prop->text); | 975 | case P_MENU: |
900 | debug += "<br>"; | 976 | debug += "prompt: "; |
901 | if (prop->visible.expr) { | 977 | debug += print_filter(prop->text); |
902 | debug += " dep: "; | 978 | debug += "<br>"; |
903 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); | 979 | break; |
904 | debug += "<br>"; | 980 | case P_DEFAULT: |
905 | } | 981 | debug += "default: "; |
906 | break; | 982 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
907 | case P_DEFAULT: | 983 | debug += "<br>"; |
908 | debug += "default: "; | 984 | break; |
909 | if (sym_is_choice(sym)) | 985 | case P_CHOICE: |
910 | debug += print_filter(prop->def->name); | 986 | if (sym_is_choice(sym)) { |
911 | else { | 987 | debug += "choice: "; |
912 | sym_calc_value(prop->def); | 988 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
913 | debug += print_filter(sym_get_string_value(prop->def)); | ||
914 | } | ||
915 | debug += "<br>"; | ||
916 | if (prop->visible.expr) { | ||
917 | debug += " dep: "; | ||
918 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); | ||
919 | debug += "<br>"; | ||
920 | } | ||
921 | break; | ||
922 | case P_CHOICE: | ||
923 | break; | ||
924 | default: | ||
925 | debug += "unknown property: "; | ||
926 | debug += prop_get_type_name(prop->type); | ||
927 | debug += "<br>"; | 989 | debug += "<br>"; |
928 | } | 990 | } |
991 | break; | ||
992 | case P_SELECT: | ||
993 | debug += "select: "; | ||
994 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
995 | debug += "<br>"; | ||
996 | break; | ||
997 | case P_RANGE: | ||
998 | debug += "range: "; | ||
999 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1000 | debug += "<br>"; | ||
1001 | break; | ||
1002 | default: | ||
1003 | debug += "unknown property: "; | ||
1004 | debug += prop_get_type_name(prop->type); | ||
1005 | debug += "<br>"; | ||
929 | } | 1006 | } |
930 | debug += "<br>"; | 1007 | if (prop->visible.expr) { |
931 | } | 1008 | debug += " dep: "; |
932 | 1009 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); | |
933 | help = print_filter(sym->help); | ||
934 | } else if (menu->prompt) { | ||
935 | head += "<big><b>"; | ||
936 | head += print_filter(menu->prompt->text); | ||
937 | head += "</b></big><br><br>"; | ||
938 | if (showDebug) { | ||
939 | if (menu->prompt->visible.expr) { | ||
940 | debug += " dep: "; | ||
941 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); | ||
942 | debug += "<br>"; | 1010 | debug += "<br>"; |
943 | } | 1011 | } |
944 | } | 1012 | } |
1013 | debug += "<br>"; | ||
1014 | } | ||
1015 | |||
1016 | help = print_filter(sym->help); | ||
1017 | } else if (menu->prompt) { | ||
1018 | head += "<big><b>"; | ||
1019 | head += print_filter(menu->prompt->text); | ||
1020 | head += "</b></big><br><br>"; | ||
1021 | if (showDebug) { | ||
1022 | if (menu->prompt->visible.expr) { | ||
1023 | debug += " dep: "; | ||
1024 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); | ||
1025 | debug += "<br><br>"; | ||
1026 | } | ||
945 | } | 1027 | } |
946 | helpText->setText(head + debug + help); | ||
947 | return; | ||
948 | } | 1028 | } |
949 | helpText->setText(NULL); | 1029 | if (showDebug) |
1030 | debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno); | ||
1031 | helpText->setText(head + debug + help); | ||
950 | } | 1032 | } |
951 | 1033 | ||
952 | void ConfigMainWindow::loadConfig(void) | 1034 | void ConfigMainWindow::loadConfig(void) |
953 | { | 1035 | { |
954 | QString s = QFileDialog::getOpenFileName(".config", NULL, this); | 1036 | QString s = QFileDialog::getOpenFileName(".config", NULL, this); |
955 | if (s.isNull()) | 1037 | if (s.isNull()) |
956 | return; | 1038 | return; |
957 | if (conf_read(s.latin1())) | 1039 | if (conf_read(s.latin1())) |
@@ -1005,17 +1087,17 @@ void ConfigMainWindow::goBack(void) | |||
1005 | break; | 1087 | break; |
1006 | } | 1088 | } |
1007 | item = (ConfigItem*)item->parent(); | 1089 | item = (ConfigItem*)item->parent(); |
1008 | } | 1090 | } |
1009 | } | 1091 | } |
1010 | 1092 | ||
1011 | void ConfigMainWindow::showSingleView(void) | 1093 | void ConfigMainWindow::showSingleView(void) |
1012 | { | 1094 | { |
1013 | menuList->hide(); | 1095 | menuView->hide(); |
1014 | menuList->setRootMenu(0); | 1096 | menuList->setRootMenu(0); |
1015 | configList->mode = singleMode; | 1097 | configList->mode = singleMode; |
1016 | if (configList->rootEntry == &rootmenu) | 1098 | if (configList->rootEntry == &rootmenu) |
1017 | configList->updateListAll(); | 1099 | configList->updateListAll(); |
1018 | else | 1100 | else |
1019 | configList->setRootMenu(&rootmenu); | 1101 | configList->setRootMenu(&rootmenu); |
1020 | configList->setAllOpen(TRUE); | 1102 | configList->setAllOpen(TRUE); |
1021 | configList->setFocus(); | 1103 | configList->setFocus(); |
@@ -1027,24 +1109,24 @@ void ConfigMainWindow::showSplitView(void) | |||
1027 | if (configList->rootEntry == &rootmenu) | 1109 | if (configList->rootEntry == &rootmenu) |
1028 | configList->updateListAll(); | 1110 | configList->updateListAll(); |
1029 | else | 1111 | else |
1030 | configList->setRootMenu(&rootmenu); | 1112 | configList->setRootMenu(&rootmenu); |
1031 | configList->setAllOpen(TRUE); | 1113 | configList->setAllOpen(TRUE); |
1032 | configApp->processEvents(); | 1114 | configApp->processEvents(); |
1033 | menuList->mode = menuMode; | 1115 | menuList->mode = menuMode; |
1034 | menuList->setRootMenu(&rootmenu); | 1116 | menuList->setRootMenu(&rootmenu); |
1035 | menuList->show(); | ||
1036 | menuList->setAllOpen(TRUE); | 1117 | menuList->setAllOpen(TRUE); |
1118 | menuView->show(); | ||
1037 | menuList->setFocus(); | 1119 | menuList->setFocus(); |
1038 | } | 1120 | } |
1039 | 1121 | ||
1040 | void ConfigMainWindow::showFullView(void) | 1122 | void ConfigMainWindow::showFullView(void) |
1041 | { | 1123 | { |
1042 | menuList->hide(); | 1124 | menuView->hide(); |
1043 | menuList->setRootMenu(0); | 1125 | menuList->setRootMenu(0); |
1044 | configList->mode = fullMode; | 1126 | configList->mode = fullMode; |
1045 | if (configList->rootEntry == &rootmenu) | 1127 | if (configList->rootEntry == &rootmenu) |
1046 | configList->updateListAll(); | 1128 | configList->updateListAll(); |
1047 | else | 1129 | else |
1048 | configList->setRootMenu(&rootmenu); | 1130 | configList->setRootMenu(&rootmenu); |
1049 | configList->setAllOpen(FALSE); | 1131 | configList->setAllOpen(FALSE); |
1050 | configList->setFocus(); | 1132 | configList->setFocus(); |
@@ -1068,32 +1150,38 @@ void ConfigMainWindow::setShowDebug(bool b) | |||
1068 | } | 1150 | } |
1069 | 1151 | ||
1070 | void ConfigMainWindow::setShowName(bool b) | 1152 | void ConfigMainWindow::setShowName(bool b) |
1071 | { | 1153 | { |
1072 | if (configList->showName == b) | 1154 | if (configList->showName == b) |
1073 | return; | 1155 | return; |
1074 | configList->showName = b; | 1156 | configList->showName = b; |
1075 | configList->reinit(); | 1157 | configList->reinit(); |
1158 | menuList->showName = b; | ||
1159 | menuList->reinit(); | ||
1076 | } | 1160 | } |
1077 | 1161 | ||
1078 | void ConfigMainWindow::setShowRange(bool b) | 1162 | void ConfigMainWindow::setShowRange(bool b) |
1079 | { | 1163 | { |
1080 | if (configList->showRange == b) | 1164 | if (configList->showRange == b) |
1081 | return; | 1165 | return; |
1082 | configList->showRange = b; | 1166 | configList->showRange = b; |
1083 | configList->reinit(); | 1167 | configList->reinit(); |
1168 | menuList->showRange = b; | ||
1169 | menuList->reinit(); | ||
1084 | } | 1170 | } |
1085 | 1171 | ||
1086 | void ConfigMainWindow::setShowData(bool b) | 1172 | void ConfigMainWindow::setShowData(bool b) |
1087 | { | 1173 | { |
1088 | if (configList->showData == b) | 1174 | if (configList->showData == b) |
1089 | return; | 1175 | return; |
1090 | configList->showData = b; | 1176 | configList->showData = b; |
1091 | configList->reinit(); | 1177 | configList->reinit(); |
1178 | menuList->showData = b; | ||
1179 | menuList->reinit(); | ||
1092 | } | 1180 | } |
1093 | 1181 | ||
1094 | /* | 1182 | /* |
1095 | * ask for saving configuration before quitting | 1183 | * ask for saving configuration before quitting |
1096 | * TODO ask only when something changed | 1184 | * TODO ask only when something changed |
1097 | */ | 1185 | */ |
1098 | void ConfigMainWindow::closeEvent(QCloseEvent* e) | 1186 | void ConfigMainWindow::closeEvent(QCloseEvent* e) |
1099 | { | 1187 | { |
@@ -1141,50 +1229,63 @@ void ConfigMainWindow::showAbout(void) | |||
1141 | "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; | 1229 | "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; |
1142 | 1230 | ||
1143 | QMessageBox::information(this, "qconf", str); | 1231 | QMessageBox::information(this, "qconf", str); |
1144 | } | 1232 | } |
1145 | 1233 | ||
1146 | void fixup_rootmenu(struct menu *menu) | 1234 | void fixup_rootmenu(struct menu *menu) |
1147 | { | 1235 | { |
1148 | struct menu *child; | 1236 | struct menu *child; |
1237 | static int menu_cnt = 0; | ||
1149 | 1238 | ||
1150 | if (!menu->prompt || menu->prompt->type != P_MENU) | 1239 | menu->flags |= MENU_ROOT; |
1151 | return; | 1240 | for (child = menu->list; child; child = child->next) { |
1152 | menu->prompt->type = P_ROOTMENU; | 1241 | if (child->prompt && child->prompt->type == P_MENU) { |
1153 | for (child = menu->list; child; child = child->next) | 1242 | menu_cnt++; |
1154 | fixup_rootmenu(child); | 1243 | fixup_rootmenu(child); |
1244 | menu_cnt--; | ||
1245 | } else if (!menu_cnt) | ||
1246 | fixup_rootmenu(child); | ||
1247 | } | ||
1248 | } | ||
1249 | |||
1250 | static const char *progname; | ||
1251 | |||
1252 | static void usage(void) | ||
1253 | { | ||
1254 | printf("%s <config>\n", progname); | ||
1255 | exit(0); | ||
1155 | } | 1256 | } |
1156 | 1257 | ||
1157 | int main(int ac, char** av) | 1258 | int main(int ac, char** av) |
1158 | { | 1259 | { |
1159 | ConfigMainWindow* v; | 1260 | ConfigMainWindow* v; |
1160 | const char *name; | 1261 | const char *name; |
1161 | 1262 | ||
1162 | #ifndef LKC_DIRECT_LINK | 1263 | #ifndef LKC_DIRECT_LINK |
1163 | kconfig_load(); | 1264 | kconfig_load(); |
1164 | #endif | 1265 | #endif |
1165 | 1266 | ||
1267 | progname = av[0]; | ||
1166 | configApp = new QApplication(ac, av); | 1268 | configApp = new QApplication(ac, av); |
1167 | #if QT_VERSION >= 300 | 1269 | #if QT_VERSION >= 300 |
1168 | configSettings = new QSettings; | 1270 | configSettings = new QSettings; |
1169 | #endif | 1271 | #endif |
1170 | if (ac > 1 && av[1][0] == '-') { | 1272 | if (ac > 1 && av[1][0] == '-') { |
1171 | switch (av[1][1]) { | 1273 | switch (av[1][1]) { |
1172 | case 'a': | ||
1173 | //showAll = 1; | ||
1174 | break; | ||
1175 | case 'h': | 1274 | case 'h': |
1176 | case '?': | 1275 | case '?': |
1177 | printf("%s <config>\n", av[0]); | 1276 | usage(); |
1178 | exit(0); | ||
1179 | } | 1277 | } |
1180 | name = av[2]; | 1278 | name = av[2]; |
1181 | } else | 1279 | } else |
1182 | name = av[1]; | 1280 | name = av[1]; |
1281 | if (!name) | ||
1282 | usage(); | ||
1283 | |||
1183 | conf_parse(name); | 1284 | conf_parse(name); |
1184 | fixup_rootmenu(&rootmenu); | 1285 | fixup_rootmenu(&rootmenu); |
1185 | conf_read(NULL); | 1286 | conf_read(NULL); |
1186 | //zconfdump(stdout); | 1287 | //zconfdump(stdout); |
1187 | 1288 | ||
1188 | v = new ConfigMainWindow(); | 1289 | v = new ConfigMainWindow(); |
1189 | 1290 | ||
1190 | //zconfdump(stdout); | 1291 | //zconfdump(stdout); |