-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 | |||
@@ -19,2 +19,6 @@ | |||
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> |
@@ -28,2 +32,5 @@ | |||
28 | static QApplication *configApp; | 32 | static QApplication *configApp; |
33 | #if QT_VERSION >= 300 | ||
34 | static QSettings *configSettings; | ||
35 | #endif | ||
29 | 36 | ||
@@ -75,5 +82,13 @@ static void updateMenuList(P* parent, struct menu* menu) | |||
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 | ||
@@ -122,10 +137,4 @@ void ConfigItem::updateMenu(void) | |||
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 | ||
@@ -133,11 +142,9 @@ void ConfigItem::updateMenu(void) | |||
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; |
@@ -145,9 +152,3 @@ void ConfigItem::updateMenu(void) | |||
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 | ||
@@ -206,3 +207,5 @@ void ConfigItem::updateMenu(void) | |||
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 |
@@ -220,2 +223,14 @@ void ConfigItem::updateMenu(void) | |||
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) |
@@ -239,9 +254,10 @@ void ConfigItem::init(void) | |||
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 | } |
@@ -253,3 +269,9 @@ 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 | } |
@@ -275,3 +297,3 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | |||
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; |
@@ -282,2 +304,3 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | |||
282 | e->accept(); | 304 | e->accept(); |
305 | parent()->list->setFocus(); | ||
283 | hide(); | 306 | hide(); |
@@ -285,3 +308,3 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | |||
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), |
@@ -354,2 +377,3 @@ void ConfigList::updateList(ConfigItem* item) | |||
354 | updateMenuList(this, rootEntry); | 377 | updateMenuList(this, rootEntry); |
378 | triggerUpdate(); | ||
355 | } | 379 | } |
@@ -384,3 +408,3 @@ void ConfigList::setValue(ConfigItem* item, tristate val) | |||
384 | item->setOpen(TRUE); | 408 | item->setOpen(TRUE); |
385 | emit symbolChanged(item); | 409 | parent()->updateList(item); |
386 | break; | 410 | break; |
@@ -416,3 +440,3 @@ void ConfigList::changeValue(ConfigItem* item) | |||
416 | if (oldexpr != newexpr) | 440 | if (oldexpr != newexpr) |
417 | emit symbolChanged(item); | 441 | parent()->updateList(item); |
418 | break; | 442 | break; |
@@ -426,3 +450,3 @@ void ConfigList::changeValue(ConfigItem* item) | |||
426 | #endif | 450 | #endif |
427 | lineEdit->show(item); | 451 | parent()->lineEdit->show(item); |
428 | break; | 452 | break; |
@@ -518,3 +542,3 @@ void ConfigList::contentsMousePressEvent(QMouseEvent* e) | |||
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 | } |
@@ -565,3 +589,3 @@ 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 | } |
@@ -572,3 +596,3 @@ void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) | |||
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 | } |
@@ -589,2 +613,4 @@ void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) | |||
589 | emit menuSelected(menu); | 613 | emit menuSelected(menu); |
614 | else if (menu->sym) | ||
615 | changeValue(item); | ||
590 | 616 | ||
@@ -592,3 +618,3 @@ 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 | } |
@@ -607,2 +633,43 @@ void ConfigList::focusInEvent(QFocusEvent *e) | |||
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 | /* |
@@ -610,4 +677,5 @@ void ConfigList::focusInEvent(QFocusEvent *e) | |||
610 | */ | 677 | */ |
611 | ConfigView::ConfigView(void) | 678 | ConfigMainWindow::ConfigMainWindow(void) |
612 | { | 679 | { |
680 | ConfigView* view; | ||
613 | QMenuBar* menu; | 681 | QMenuBar* menu; |
@@ -615,2 +683,21 @@ ConfigView::ConfigView(void) | |||
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 | ||
@@ -622,3 +709,4 @@ ConfigView::ConfigView(void) | |||
622 | 709 | ||
623 | menuList = new ConfigList(split1, this); | 710 | view = new ConfigView(split1, this); |
711 | menuList = view->list; | ||
624 | 712 | ||
@@ -628,12 +716,4 @@ ConfigView::ConfigView(void) | |||
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 | ||
@@ -687,2 +767,7 @@ ConfigView::ConfigView(void) | |||
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 |
@@ -716,2 +801,9 @@ ConfigView::ConfigView(void) | |||
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 *)), |
@@ -771,3 +863,3 @@ static void expr_print_help(void *data, const char *str) | |||
771 | */ | 863 | */ |
772 | void ConfigView::setHelp(QListViewItem* item) | 864 | void ConfigMainWindow::setHelp(QListViewItem* item) |
773 | { | 865 | { |
@@ -776,3 +868,3 @@ void ConfigView::setHelp(QListViewItem* item) | |||
776 | 868 | ||
777 | configList->lineEdit->hide(); | 869 | configList->parent()->lineEdit->hide(); |
778 | if (item) { | 870 | if (item) { |
@@ -859,3 +951,3 @@ void ConfigView::setHelp(QListViewItem* item) | |||
859 | 951 | ||
860 | void ConfigView::loadConfig(void) | 952 | void ConfigMainWindow::loadConfig(void) |
861 | { | 953 | { |
@@ -866,5 +958,6 @@ void ConfigView::loadConfig(void) | |||
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 | { |
@@ -874,3 +967,3 @@ void ConfigView::saveConfig(void) | |||
874 | 967 | ||
875 | void ConfigView::saveConfigAs(void) | 968 | void ConfigMainWindow::saveConfigAs(void) |
876 | { | 969 | { |
@@ -883,3 +976,3 @@ void ConfigView::saveConfigAs(void) | |||
883 | 976 | ||
884 | void ConfigView::changeMenu(struct menu *menu) | 977 | void ConfigMainWindow::changeMenu(struct menu *menu) |
885 | { | 978 | { |
@@ -889,3 +982,3 @@ void ConfigView::changeMenu(struct menu *menu) | |||
889 | 982 | ||
890 | void ConfigView::listFocusChanged(void) | 983 | void ConfigMainWindow::listFocusChanged(void) |
891 | { | 984 | { |
@@ -900,3 +993,3 @@ void ConfigView::listFocusChanged(void) | |||
900 | 993 | ||
901 | void ConfigView::goBack(void) | 994 | void ConfigMainWindow::goBack(void) |
902 | { | 995 | { |
@@ -917,3 +1010,3 @@ void ConfigView::goBack(void) | |||
917 | 1010 | ||
918 | void ConfigView::showSingleView(void) | 1011 | void ConfigMainWindow::showSingleView(void) |
919 | { | 1012 | { |
@@ -930,3 +1023,3 @@ void ConfigView::showSingleView(void) | |||
930 | 1023 | ||
931 | void ConfigView::showSplitView(void) | 1024 | void ConfigMainWindow::showSplitView(void) |
932 | { | 1025 | { |
@@ -946,3 +1039,3 @@ void ConfigView::showSplitView(void) | |||
946 | 1039 | ||
947 | void ConfigView::showFullView(void) | 1040 | void ConfigMainWindow::showFullView(void) |
948 | { | 1041 | { |
@@ -959,3 +1052,3 @@ void ConfigView::showFullView(void) | |||
959 | 1052 | ||
960 | void ConfigView::setShowAll(bool b) | 1053 | void ConfigMainWindow::setShowAll(bool b) |
961 | { | 1054 | { |
@@ -969,3 +1062,3 @@ void ConfigView::setShowAll(bool b) | |||
969 | 1062 | ||
970 | void ConfigView::setShowDebug(bool b) | 1063 | void ConfigMainWindow::setShowDebug(bool b) |
971 | { | 1064 | { |
@@ -976,3 +1069,3 @@ void ConfigView::setShowDebug(bool b) | |||
976 | 1069 | ||
977 | void ConfigView::setShowName(bool b) | 1070 | void ConfigMainWindow::setShowName(bool b) |
978 | { | 1071 | { |
@@ -984,3 +1077,3 @@ void ConfigView::setShowName(bool b) | |||
984 | 1077 | ||
985 | void ConfigView::setShowRange(bool b) | 1078 | void ConfigMainWindow::setShowRange(bool b) |
986 | { | 1079 | { |
@@ -992,3 +1085,3 @@ void ConfigView::setShowRange(bool b) | |||
992 | 1085 | ||
993 | void ConfigView::setShowData(bool b) | 1086 | void ConfigMainWindow::setShowData(bool b) |
994 | { | 1087 | { |
@@ -1004,3 +1097,3 @@ void ConfigView::setShowData(bool b) | |||
1004 | */ | 1097 | */ |
1005 | void ConfigView::closeEvent(QCloseEvent* e) | 1098 | void ConfigMainWindow::closeEvent(QCloseEvent* e) |
1006 | { | 1099 | { |
@@ -1027,2 +1120,27 @@ void ConfigView::closeEvent(QCloseEvent* e) | |||
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) |
@@ -1040,3 +1158,3 @@ int main(int ac, char** av) | |||
1040 | { | 1158 | { |
1041 | ConfigView* v; | 1159 | ConfigMainWindow* v; |
1042 | const char *name; | 1160 | const char *name; |
@@ -1048,2 +1166,5 @@ int main(int ac, char** av) | |||
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] == '-') { |
@@ -1065,3 +1186,4 @@ int main(int ac, char** av) | |||
1065 | //zconfdump(stdout); | 1186 | //zconfdump(stdout); |
1066 | v = new ConfigView(); | 1187 | |
1188 | v = new ConfigMainWindow(); | ||
1067 | 1189 | ||
@@ -1071,2 +1193,10 @@ int main(int ac, char** av) | |||
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; |