author | kergoth <kergoth> | 2003-01-16 18:04:11 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-01-16 18:04:11 (UTC) |
commit | 3904d85eac20dfd21cf2a3245977f9946865fd92 (patch) (unidiff) | |
tree | 8d5b2217c1b54a0c439815ec02db3f5235c99daa /scripts/kconfig/qconf.cc | |
parent | 0eec393ef2dd8b43db96c86e80e307f73a771fae (diff) | |
download | opie-3904d85eac20dfd21cf2a3245977f9946865fd92.zip opie-3904d85eac20dfd21cf2a3245977f9946865fd92.tar.gz opie-3904d85eac20dfd21cf2a3245977f9946865fd92.tar.bz2 |
Update LinuxKernelConf to 1.3, latest available.
-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 | |||
@@ -14,21 +14,28 @@ | |||
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 |
@@ -70,15 +77,23 @@ static void updateMenuList(P* parent, struct menu* menu) | |||
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); |
@@ -117,42 +132,28 @@ void ConfigItem::updateMenu(void) | |||
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; |
@@ -201,13 +202,15 @@ void ConfigItem::updateMenu(void) | |||
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)); |
@@ -215,12 +218,24 @@ void ConfigItem::updateMenu(void) | |||
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) |
@@ -234,27 +249,34 @@ void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int w | |||
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)) |
@@ -270,23 +292,24 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | |||
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) |
@@ -349,12 +372,13 @@ void ConfigList::updateSelection(void) | |||
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 | ||
@@ -379,13 +403,13 @@ void ConfigList::setValue(ConfigItem* item, tristate val) | |||
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 | { |
@@ -411,23 +435,23 @@ void ConfigList::changeValue(ConfigItem* item) | |||
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 | { |
@@ -513,13 +537,13 @@ void ConfigList::keyPressEvent(QKeyEvent* ev) | |||
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); |
@@ -560,20 +584,20 @@ void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) | |||
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); |
@@ -584,16 +608,18 @@ void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) | |||
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 | ||
@@ -602,43 +628,97 @@ void ConfigList::focusInEvent(QFocusEvent *e) | |||
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(); |
@@ -682,12 +762,17 @@ ConfigView::ConfigView(void) | |||
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(); |
@@ -711,12 +796,19 @@ ConfigView::ConfigView(void) | |||
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 *))); |
@@ -766,18 +858,18 @@ static void expr_print_help(void *data, const char *str) | |||
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) { |
@@ -854,54 +946,55 @@ void ConfigView::setHelp(QListViewItem* item) | |||
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); |
@@ -912,26 +1005,26 @@ void ConfigView::goBack(void) | |||
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); |
@@ -941,71 +1034,71 @@ void ConfigView::showSplitView(void) | |||
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, |
@@ -1022,12 +1115,37 @@ void ConfigView::closeEvent(QCloseEvent* e) | |||
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; |
@@ -1035,20 +1153,23 @@ void fixup_rootmenu(struct menu *menu) | |||
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': |
@@ -1060,14 +1181,23 @@ int main(int ac, char** av) | |||
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 | } |