756
785
void ConfigList::focusInEvent(QFocusEvent *e)
787
struct menu *menu = NULL;
758
789
Parent::focusInEvent(e);
760
QListViewItem* item = currentItem();
764
setSelected(item, TRUE);
791
ConfigItem* item = (ConfigItem *)currentItem();
793
setSelected(item, TRUE);
799
void ConfigList::contextMenuEvent(QContextMenuEvent *e)
801
if (e->y() <= header()->geometry().bottom()) {
805
headerPopup = new QPopupMenu(this);
806
action = new QAction(NULL, _("Show Name"), 0, this);
807
action->setToggleAction(TRUE);
808
connect(action, SIGNAL(toggled(bool)),
809
parent(), SLOT(setShowName(bool)));
810
connect(parent(), SIGNAL(showNameChanged(bool)),
811
action, SLOT(setOn(bool)));
812
action->setOn(showName);
813
action->addTo(headerPopup);
814
action = new QAction(NULL, _("Show Range"), 0, this);
815
action->setToggleAction(TRUE);
816
connect(action, SIGNAL(toggled(bool)),
817
parent(), SLOT(setShowRange(bool)));
818
connect(parent(), SIGNAL(showRangeChanged(bool)),
819
action, SLOT(setOn(bool)));
820
action->setOn(showRange);
821
action->addTo(headerPopup);
822
action = new QAction(NULL, _("Show Data"), 0, this);
823
action->setToggleAction(TRUE);
824
connect(action, SIGNAL(toggled(bool)),
825
parent(), SLOT(setShowData(bool)));
826
connect(parent(), SIGNAL(showDataChanged(bool)),
827
action, SLOT(setOn(bool)));
828
action->setOn(showData);
829
action->addTo(headerPopup);
831
headerPopup->exec(e->globalPos());
768
837
ConfigView* ConfigView::viewList;
770
ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview,
771
ConfigSettings *configSettings)
839
ConfigView::ConfigView(QWidget* parent, const char *name)
840
: Parent(parent, name)
774
list = new ConfigList(this, cview, configSettings);
842
list = new ConfigList(this, name);
775
843
lineEdit = new ConfigLineEdit(this);
776
844
lineEdit->hide();
807
919
v->list->updateListAll();
922
ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
923
: Parent(parent, name), menu(0), sym(0)
926
configSettings->beginGroup(name);
927
_showDebug = configSettings->readBoolEntry("/showDebug", false);
928
configSettings->endGroup();
929
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
933
void ConfigInfoView::saveSettings(void)
936
configSettings->beginGroup(name());
937
configSettings->writeEntry("/showDebug", showDebug());
938
configSettings->endGroup();
942
void ConfigInfoView::setShowDebug(bool b)
944
if (_showDebug != b) {
950
emit showDebugChanged(b);
954
void ConfigInfoView::setInfo(struct menu *m)
966
void ConfigInfoView::setSource(const QString& name)
968
const char *p = name.latin1();
977
if (sscanf(p, "m%p", &m) == 1 && menu != m) {
980
emit menuSelected(menu);
986
if (sscanf(p, "s%p", &s) == 1 && sym != s) {
994
void ConfigInfoView::symbolInfo(void)
998
str += "<big>Symbol: <b>";
999
str += print_filter(sym->name);
1000
str += "</b></big><br><br>value: ";
1001
str += print_filter(sym_get_string_value(sym));
1002
str += "<br>visibility: ";
1003
str += sym->visible == yes ? "y" : sym->visible == mod ? "m" : "n";
1005
str += debug_info(sym);
1010
void ConfigInfoView::menuInfo(void)
1013
QString head, debug, help;
1019
head += print_filter(_(menu->prompt->text));
1020
head += "</b></big>";
1024
head += QString().sprintf("<a href=\"s%p\">", sym);
1025
head += print_filter(sym->name);
1030
} else if (sym->name) {
1033
head += QString().sprintf("<a href=\"s%p\">", sym);
1034
head += print_filter(sym->name);
1037
head += "</b></big>";
1042
debug = debug_info(sym);
1044
help = menu_get_help(menu);
1045
/* Gettextize if the help text not empty */
1047
help = print_filter(menu_get_help(menu));
1049
help = print_filter(_(menu_get_help(menu)));
1050
} else if (menu->prompt) {
1052
head += print_filter(_(menu->prompt->text));
1053
head += "</b></big><br><br>";
1055
if (menu->prompt->visible.expr) {
1056
debug += " dep: ";
1057
expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
1058
debug += "<br><br>";
1063
debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno);
1065
setText(head + debug + help);
1068
QString ConfigInfoView::debug_info(struct symbol *sym)
1073
debug += print_filter(sym_type_name(sym->type));
1074
if (sym_is_choice(sym))
1075
debug += " (choice)";
1077
if (sym->rev_dep.expr) {
1078
debug += "reverse dep: ";
1079
expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
1082
for (struct property *prop = sym->prop; prop; prop = prop->next) {
1083
switch (prop->type) {
1086
debug += QString().sprintf("prompt: <a href=\"m%p\">", prop->menu);
1087
debug += print_filter(_(prop->text));
1088
debug += "</a><br>";
1094
debug += prop_get_type_name(prop->type);
1096
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1100
if (sym_is_choice(sym)) {
1101
debug += "choice: ";
1102
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1107
debug += "unknown property: ";
1108
debug += prop_get_type_name(prop->type);
1111
if (prop->visible.expr) {
1112
debug += " dep: ";
1113
expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
1122
QString ConfigInfoView::print_filter(const QString &str)
1124
QRegExp re("[<>&\"\\n]");
1126
for (int i = 0; (i = res.find(re, i)) >= 0;) {
1127
switch (res[i].latin1()) {
1129
res.replace(i, 1, "<");
1133
res.replace(i, 1, ">");
1137
res.replace(i, 1, "&");
1141
res.replace(i, 1, """);
1145
res.replace(i, 1, "<br>");
1153
void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
1155
QString* text = reinterpret_cast<QString*>(data);
1156
QString str2 = print_filter(str);
1158
if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
1159
*text += QString().sprintf("<a href=\"s%p\">", sym);
1166
QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
1168
QPopupMenu* popup = Parent::createPopupMenu(pos);
1169
QAction* action = new QAction(NULL, _("Show Debug Info"), 0, popup);
1170
action->setToggleAction(TRUE);
1171
connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
1172
connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
1173
action->setOn(showDebug());
1174
popup->insertSeparator();
1175
action->addTo(popup);
1179
void ConfigInfoView::contentsContextMenuEvent(QContextMenuEvent *e)
1181
Parent::contentsContextMenuEvent(e);
1184
ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name)
1185
: Parent(parent, name), result(NULL)
1187
setCaption("Search Config");
1189
QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6);
1190
QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6);
1191
layout2->addWidget(new QLabel(_("Find:"), this));
1192
editField = new QLineEdit(this);
1193
connect(editField, SIGNAL(returnPressed()), SLOT(search()));
1194
layout2->addWidget(editField);
1195
searchButton = new QPushButton(_("Search"), this);
1196
searchButton->setAutoDefault(FALSE);
1197
connect(searchButton, SIGNAL(clicked()), SLOT(search()));
1198
layout2->addWidget(searchButton);
1199
layout1->addLayout(layout2);
1201
split = new QSplitter(this);
1202
split->setOrientation(QSplitter::Vertical);
1203
list = new ConfigView(split, name);
1204
list->list->mode = listMode;
1205
info = new ConfigInfoView(split, name);
1206
connect(list->list, SIGNAL(menuChanged(struct menu *)),
1207
info, SLOT(setInfo(struct menu *)));
1208
connect(list->list, SIGNAL(menuChanged(struct menu *)),
1209
parent, SLOT(setMenuLink(struct menu *)));
1211
layout1->addWidget(split);
1214
int x, y, width, height;
1217
configSettings->beginGroup(name);
1218
width = configSettings->readNumEntry("/window width", parent->width() / 2);
1219
height = configSettings->readNumEntry("/window height", parent->height() / 2);
1220
resize(width, height);
1221
x = configSettings->readNumEntry("/window x", 0, &ok);
1223
y = configSettings->readNumEntry("/window y", 0, &ok);
1226
QValueList<int> sizes = configSettings->readSizes("/split", &ok);
1228
split->setSizes(sizes);
1229
configSettings->endGroup();
1230
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
1234
void ConfigSearchWindow::saveSettings(void)
1237
configSettings->beginGroup(name());
1238
configSettings->writeEntry("/window x", pos().x());
1239
configSettings->writeEntry("/window y", pos().y());
1240
configSettings->writeEntry("/window width", size().width());
1241
configSettings->writeEntry("/window height", size().height());
1242
configSettings->writeSizes("/split", split->sizes());
1243
configSettings->endGroup();
1247
void ConfigSearchWindow::search(void)
1250
struct property *prop;
1251
ConfigItem *lastItem = NULL;
1254
list->list->clear();
1257
result = sym_re_search(editField->text().latin1());
1260
for (p = result; *p; p++) {
1261
for_all_prompts((*p), prop)
1262
lastItem = new ConfigItem(list->list, lastItem, prop->menu,
1263
menu_is_visible(prop->menu));
811
1268
* Construct the complete config widget
813
1270
ConfigMainWindow::ConfigMainWindow(void)
817
1275
int x, y, width, height;
819
1278
QWidget *d = configApp->desktop();
1279
snprintf(title, sizeof(title), _("Linux Kernel v%s Configuration"),
1280
getenv("KERNELVERSION"));
821
ConfigSettings* configSettings = new ConfigSettings();
822
#if QT_VERSION >= 300
823
width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64);
824
height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64);
1283
width = configSettings->readNumEntry("/window width", d->width() - 64);
1284
height = configSettings->readNumEntry("/window height", d->height() - 64);
825
1285
resize(width, height);
826
x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok);
1286
x = configSettings->readNumEntry("/window x", 0, &ok);
828
y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok);
1288
y = configSettings->readNumEntry("/window y", 0, &ok);
831
showDebug = configSettings->readBoolEntry("/kconfig/qconf/showDebug", false);
833
// read list settings into configSettings, will be used later for ConfigList setup
834
configSettings->readListSettings();
836
width = d->width() - 64;
837
height = d->height() - 64;
838
resize(width, height);
842
1292
split1 = new QSplitter(this);
843
1293
split1->setOrientation(QSplitter::Horizontal);
844
1294
setCentralWidget(split1);
846
menuView = new ConfigView(split1, this, configSettings);
1296
menuView = new ConfigView(split1, "menu");
847
1297
menuList = menuView->list;
849
1299
split2 = new QSplitter(split1);
850
1300
split2->setOrientation(QSplitter::Vertical);
852
1302
// create config tree
853
configView = new ConfigView(split2, this, configSettings);
1303
configView = new ConfigView(split2, "config");
854
1304
configList = configView->list;
856
helpText = new QTextView(split2);
1306
helpText = new ConfigInfoView(split2, "help");
857
1307
helpText->setTextFormat(Qt::RichText);
859
1309
setTabOrder(configList, helpText);
862
1312
menu = menuBar();
863
1313
toolBar = new QToolBar("Tools", this);
865
backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this);
1315
backAction = new QAction("Back", QPixmap(xpm_back), _("Back"), 0, this);
866
1316
connect(backAction, SIGNAL(activated()), SLOT(goBack()));
867
1317
backAction->setEnabled(FALSE);
868
QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this);
1318
QAction *quitAction = new QAction("Quit", _("&Quit"), CTRL+Key_Q, this);
869
1319
connect(quitAction, SIGNAL(activated()), SLOT(close()));
870
QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this);
1320
QAction *loadAction = new QAction("Load", QPixmap(xpm_load), _("&Load"), CTRL+Key_L, this);
871
1321
connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
872
QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this);
1322
saveAction = new QAction("Save", QPixmap(xpm_save), _("&Save"), CTRL+Key_S, this);
873
1323
connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
874
QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this);
1324
conf_set_changed_callback(conf_changed);
1325
// Set saveAction's initial state
1327
QAction *saveAsAction = new QAction("Save As...", _("Save &As..."), 0, this);
875
1328
connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
876
QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this);
1329
QAction *searchAction = new QAction("Find", _("&Find"), CTRL+Key_F, this);
1330
connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
1331
QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
877
1332
connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
878
QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this);
1333
QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
879
1334
connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
880
QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this);
1335
QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
881
1336
connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
883
QAction *showNameAction = new QAction(NULL, "Show Name", 0, this);
1338
QAction *showNameAction = new QAction(NULL, _("Show Name"), 0, this);
884
1339
showNameAction->setToggleAction(TRUE);
885
showNameAction->setOn(configList->showName);
886
connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool)));
887
QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this);
1340
connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
1341
connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool)));
1342
showNameAction->setOn(configView->showName());
1343
QAction *showRangeAction = new QAction(NULL, _("Show Range"), 0, this);
888
1344
showRangeAction->setToggleAction(TRUE);
1345
connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
1346
connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool)));
889
1347
showRangeAction->setOn(configList->showRange);
890
connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool)));
891
QAction *showDataAction = new QAction(NULL, "Show Data", 0, this);
1348
QAction *showDataAction = new QAction(NULL, _("Show Data"), 0, this);
892
1349
showDataAction->setToggleAction(TRUE);
1350
connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
1351
connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
893
1352
showDataAction->setOn(configList->showData);
894
connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool)));
895
QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this);
1353
QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this);
896
1354
showAllAction->setToggleAction(TRUE);
1355
connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool)));
1356
connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool)));
897
1357
showAllAction->setOn(configList->showAll);
898
connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool)));
899
QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this);
1358
QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this);
900
1359
showDebugAction->setToggleAction(TRUE);
901
showDebugAction->setOn(showDebug);
902
connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
1360
connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
1361
connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
1362
showDebugAction->setOn(helpText->showDebug());
904
QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this);
1364
QAction *showIntroAction = new QAction(NULL, _("Introduction"), 0, this);
905
1365
connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
906
QAction *showAboutAction = new QAction(NULL, "About", 0, this);
1366
QAction *showAboutAction = new QAction(NULL, _("About"), 0, this);
907
1367
connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
909
1369
// init tool bar
938
1403
// create help menu
939
1404
QPopupMenu* helpMenu = new QPopupMenu(this);
940
1405
menu->insertSeparator();
941
menu->insertItem("&Help", helpMenu);
1406
menu->insertItem(_("&Help"), helpMenu);
942
1407
showIntroAction->addTo(helpMenu);
943
1408
showAboutAction->addTo(helpMenu);
1410
connect(configList, SIGNAL(menuChanged(struct menu *)),
1411
helpText, SLOT(setInfo(struct menu *)));
945
1412
connect(configList, SIGNAL(menuSelected(struct menu *)),
946
1413
SLOT(changeMenu(struct menu *)));
947
1414
connect(configList, SIGNAL(parentSelected()),
948
1415
SLOT(goBack()));
1416
connect(menuList, SIGNAL(menuChanged(struct menu *)),
1417
helpText, SLOT(setInfo(struct menu *)));
949
1418
connect(menuList, SIGNAL(menuSelected(struct menu *)),
950
1419
SLOT(changeMenu(struct menu *)));
952
connect(configList, SIGNAL(gotFocus(void)),
953
SLOT(listFocusChanged(void)));
954
connect(menuList, SIGNAL(gotFocus(void)),
955
SLOT(listFocusChanged(void)));
1421
connect(configList, SIGNAL(gotFocus(struct menu *)),
1422
helpText, SLOT(setInfo(struct menu *)));
1423
connect(menuList, SIGNAL(gotFocus(struct menu *)),
1424
helpText, SLOT(setInfo(struct menu *)));
1425
connect(menuList, SIGNAL(gotFocus(struct menu *)),
1426
SLOT(listFocusChanged(void)));
1427
connect(helpText, SIGNAL(menuSelected(struct menu *)),
1428
SLOT(setMenuLink(struct menu *)));
957
#if QT_VERSION >= 300
958
QString listMode = configSettings->readEntry("/kconfig/qconf/listMode", "symbol");
1430
QString listMode = configSettings->readEntry("/listMode", "symbol");
959
1431
if (listMode == "single")
960
1432
showSingleView();
961
1433
else if (listMode == "full")
964
1436
showSplitView();
966
1438
// UI setup done, restore splitter positions
967
QValueList<int> sizes = configSettings->readSizes("/kconfig/qconf/split1", &ok);
1439
QValueList<int> sizes = configSettings->readSizes("/split1", &ok);
969
1441
split1->setSizes(sizes);
971
sizes = configSettings->readSizes("/kconfig/qconf/split2", &ok);
1443
sizes = configSettings->readSizes("/split2", &ok);
973
1445
split2->setSizes(sizes);
977
delete configSettings;
980
static QString print_filter(const QString &str)
982
QRegExp re("[<>&\"\\n]");
984
for (int i = 0; (i = res.find(re, i)) >= 0;) {
985
switch (res[i].latin1()) {
987
res.replace(i, 1, "<");
991
res.replace(i, 1, ">");
995
res.replace(i, 1, "&");
999
res.replace(i, 1, """);
1003
res.replace(i, 1, "<br>");
1011
static void expr_print_help(void *data, const char *str)
1013
reinterpret_cast<QString*>(data)->append(print_filter(str));
1017
* display a new help entry as soon as a new menu entry is selected
1019
void ConfigMainWindow::setHelp(QListViewItem* item)
1022
struct menu* menu = 0;
1024
configList->parent()->lineEdit->hide();
1026
menu = ((ConfigItem*)item)->menu;
1028
helpText->setText(QString::null);
1032
QString head, debug, help;
1033
menu = ((ConfigItem*)item)->menu;
1038
head += print_filter(_(menu->prompt->text));
1039
head += "</b></big>";
1042
head += print_filter(_(sym->name));
1045
} else if (sym->name) {
1047
head += print_filter(_(sym->name));
1048
head += "</b></big>";
1054
debug += print_filter(sym_type_name(sym->type));
1055
if (sym_is_choice(sym))
1056
debug += " (choice)";
1058
if (sym->rev_dep.expr) {
1059
debug += "reverse dep: ";
1060
expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
1063
for (struct property *prop = sym->prop; prop; prop = prop->next) {
1064
switch (prop->type) {
1067
debug += "prompt: ";
1068
debug += print_filter(_(prop->text));
1072
debug += "default: ";
1073
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1077
if (sym_is_choice(sym)) {
1078
debug += "choice: ";
1079
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1084
debug += "select: ";
1085
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1090
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1094
debug += "unknown property: ";
1095
debug += prop_get_type_name(prop->type);
1098
if (prop->visible.expr) {
1099
debug += " dep: ";
1100
expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
1107
help = print_filter(_(sym->help));
1108
} else if (menu->prompt) {
1110
head += print_filter(_(menu->prompt->text));
1111
head += "</b></big><br><br>";
1113
if (menu->prompt->visible.expr) {
1114
debug += " dep: ";
1115
expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
1116
debug += "<br><br>";
1121
debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno);
1122
helpText->setText(head + debug + help);
1125
1448
void ConfigMainWindow::loadConfig(void)