8 #if QT_VERSION < 0x040000
9 #include <qmainwindow.h>
11 #include <qvaluelist.h>
12 #include <qtextbrowser.h>
15 #include <qfiledialog.h>
16 #include <qdragobject.h>
17 #include <qpopupmenu.h>
19 #include <q3mainwindow.h>
21 #include <q3valuelist.h>
22 #include <q3textbrowser.h>
25 #include <q3filedialog.h>
26 #include <q3dragobject.h>
27 #include <q3popupmenu.h>
30 #include <qapplication.h>
31 #include <qdesktopwidget.h>
34 #include <qsplitter.h>
35 #include <qlineedit.h>
37 #include <qpushbutton.h>
39 #include <qmessagebox.h>
56 static QApplication *configApp;
59 Q3Action *ConfigMainWindow::saveAction;
61 static inline QString qgettext(
const char*
str)
63 return QString::fromLocal8Bit(gettext(str));
66 static inline QString qgettext(
const QString&
str)
68 return QString::fromLocal8Bit(gettext(str.latin1()));
77 QStringList entryList = readListEntry(key, ok);
78 QStringList::Iterator it;
80 for (it = entryList.begin(); it != entryList.end(); ++it)
81 result.push_back((*it).toInt());
91 QStringList stringList;
92 Q3ValueList<int>::ConstIterator it;
94 for (it = value.begin(); it != value.end(); ++it)
95 stringList.push_back(QString::number(*it));
96 return writeEntry(key, stringList);
106 Parent::okRename(col);
134 if (prop)
switch (prop->
type) {
173 expr = sym_get_tristate_value(sym);
176 if (sym_is_choice_value(sym) && type ==
S_BOOLEAN)
189 if (sym_is_choice_value(sym) && type ==
S_BOOLEAN)
215 setRenameEnabled(i,
TRUE);
218 prompt = QString(
"%1: %2").arg(prompt).arg(data);
220 prompt = QString(
"(%2) %1").arg(prompt).arg(data);
223 if (!sym_has_value(sym) &&
visible)
224 prompt +=
_(
" (NEW)");
252 if (isSelected() && !list->hasFocus() && list->
mode ==
menuMode)
255 Parent::paintCell(p, cg, column, width, align);
296 connect(
this,
SIGNAL(lostFocus()),
SLOT(hide()));
305 setText(QString::null);
321 Parent::keyPressEvent(e);
332 symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
333 choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
334 menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
336 rootEntry(0), headerPopup(0)
341 setRootIsDecorated(
TRUE);
347 connect(
this,
SIGNAL(selectionChanged(
void)),
351 configSettings->beginGroup(name);
352 showName = configSettings->readBoolEntry(
"/showName",
false);
353 showRange = configSettings->readBoolEntry(
"/showRange",
false);
354 showData = configSettings->readBoolEntry(
"/showData",
false);
356 configSettings->endGroup();
360 for (i = 0; i <
colNr; i++)
361 colMap[i] = colRevMap[i] = -1;
402 configSettings->beginGroup(
name());
403 configSettings->writeEntry(
"/showName",
showName);
404 configSettings->writeEntry(
"/showRange",
showRange);
405 configSettings->writeEntry(
"/showData",
showData);
406 configSettings->writeEntry(
"/optionMode", (
int)
optMode);
407 configSettings->endGroup();
451 for (; it.current(); ++it) {
490 sym = item->
menu ? item->
menu->sym : 0;
498 oldval = sym_get_tristate_value(sym);
502 if (oldval ==
no && item->
menu->list)
513 int type, oldexpr, newexpr;
520 if (item->
menu->list)
521 item->setOpen(!item->isOpen());
529 oldexpr = sym_get_tristate_value(sym);
531 if (item->
menu->list) {
532 if (oldexpr == newexpr)
533 item->setOpen(!item->isOpen());
534 else if (oldexpr ==
no)
537 if (oldexpr != newexpr)
563 setSelected(currentItem(), hasFocus());
564 ensureItemVisible(currentItem());
570 struct menu *oldroot;
578 for (; (item = (
ConfigItem*)it.current()); it++) {
579 if (item->
menu == oldroot) {
580 setCurrentItem(item);
581 ensureItemVisible(item);
612 for (child = menu->
list; child; child = child->
next) {
633 if (!item || item->
menu != child)
634 item =
new ConfigItem(parent, last, child, visible);
646 if (item && item->
menu == child) {
671 Parent::keyPressEvent(ev);
705 Parent::keyPressEvent(ev);
715 Parent::contentsMousePressEvent(e);
720 QPoint
p(contentsToViewport(e->pos()));
731 x =
header()->offset() + p.x();
732 idx = colRevMap[
header()->sectionAt(x)];
737 int off =
header()->sectionPos(0) + itemMargin() +
738 treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0));
739 if (x >= off && x < off + pm->
width()) {
770 Parent::contentsMouseReleaseEvent(e);
777 Parent::contentsMouseMoveEvent(e);
782 QPoint
p(contentsToViewport(e->pos()));
804 Parent::contentsMouseDoubleClickEvent(e);
811 Parent::focusInEvent(e);
815 setSelected(item,
TRUE);
823 if (e->y() <=
header()->geometry().bottom()) {
829 action->setToggleAction(
TRUE);
830 connect(action,
SIGNAL(toggled(
bool)),
833 action,
SLOT(setOn(
bool)));
837 action->setToggleAction(
TRUE);
838 connect(action,
SIGNAL(toggled(
bool)),
841 action,
SLOT(setOn(
bool)));
845 action->setToggleAction(
TRUE);
846 connect(action,
SIGNAL(toggled(
bool)),
849 action,
SLOT(setOn(
bool)));
865 : Parent(parent, name)
896 list->updateListAll();
901 if (
list->showName != b) {
910 if (
list->showRange != b) {
919 if (
list->showData != b) {
930 for (; it.current(); it++)
931 it.current()->setOpen(open);
951 : Parent(parent, name),
sym(0), _menu(0)
954 configSettings->beginGroup(name);
955 _showDebug = configSettings->readBoolEntry(
"/showDebug",
false);
956 configSettings->endGroup();
964 configSettings->beginGroup(
name());
965 configSettings->writeEntry(
"/showDebug",
showDebug());
966 configSettings->endGroup();
998 str +=
"<big>Symbol: <b>";
1000 str +=
"</b></big><br><br>value: ";
1002 str +=
"<br>visibility: ";
1003 str +=
sym->visible ==
yes ?
"y" :
sym->visible ==
mod ?
"m" :
"n";
1017 if (
_menu->prompt) {
1020 head +=
"</b></big>";
1024 head += QString().sprintf(
"<a href=\"s%p\">", sym);
1030 }
else if (sym->
name) {
1033 head += QString().sprintf(
"<a href=\"s%p\">", sym);
1037 head +=
"</b></big>";
1048 }
else if (
_menu->prompt) {
1051 head +=
"</b></big><br><br>";
1053 if (
_menu->prompt->visible.expr) {
1054 debug +=
" dep: ";
1056 debug +=
"<br><br>";
1061 debug += QString().sprintf(
"defined at %s:%d<br><br>",
_menu->file->name,
_menu->lineno);
1063 setText(head + debug + help);
1072 if (sym_is_choice(sym))
1073 debug +=
" (choice)";
1076 debug +=
"reverse dep: ";
1080 for (
struct property *prop = sym->
prop; prop; prop = prop->next) {
1081 switch (prop->type) {
1084 debug += QString().sprintf(
"prompt: <a href=\"m%p\">", prop->menu);
1086 debug +=
"</a><br>";
1098 if (sym_is_choice(sym)) {
1099 debug +=
"choice: ";
1105 debug +=
"unknown property: ";
1109 if (prop->visible.expr) {
1110 debug +=
" dep: ";
1122 QRegExp re(
"[<>&\"\\n]");
1124 for (
int i = 0; (
i = res.find(re,
i)) >= 0;) {
1125 switch (res[
i].latin1()) {
1127 res.replace(
i, 1,
"<");
1131 res.replace(
i, 1,
">");
1135 res.replace(
i, 1,
"&");
1139 res.replace(
i, 1,
""");
1143 res.replace(
i, 1,
"<br>");
1153 QString*
text =
reinterpret_cast<QString*
>(
data);
1157 *text += QString().sprintf(
"<a href=\"s%p\">", sym);
1166 Q3PopupMenu* popup = Parent::createPopupMenu(pos);
1168 action->setToggleAction(
TRUE);
1172 popup->insertSeparator();
1173 action->addTo(popup);
1179 Parent::contentsContextMenuEvent(e);
1185 setCaption(
"Search Config");
1187 QVBoxLayout* layout1 =
new QVBoxLayout(
this, 11, 6);
1188 QHBoxLayout* layout2 =
new QHBoxLayout(0, 0, 6);
1189 layout2->addWidget(
new QLabel(
_(
"Find:"),
this));
1197 layout1->addLayout(layout2);
1199 split =
new QSplitter(
this);
1200 split->setOrientation(Qt::Vertical);
1207 parent,
SLOT(setMenuLink(
struct menu *)));
1209 layout1->addWidget(
split);
1215 configSettings->beginGroup(name);
1216 width = configSettings->readNumEntry(
"/window width", parent->width() / 2);
1217 height = configSettings->readNumEntry(
"/window height", parent->height() / 2);
1218 resize(width, height);
1219 x = configSettings->readNumEntry(
"/window x", 0, &ok);
1221 y = configSettings->readNumEntry(
"/window y", 0, &ok);
1224 Q3ValueList<int> sizes = configSettings->
readSizes(
"/split", &ok);
1226 split->setSizes(sizes);
1227 configSettings->endGroup();
1235 configSettings->beginGroup(
name());
1236 configSettings->writeEntry(
"/window x",
pos().
x());
1237 configSettings->writeEntry(
"/window y",
pos().
y());
1238 configSettings->writeEntry(
"/window width",
size().
width());
1239 configSettings->writeEntry(
"/window height",
size().
height());
1241 configSettings->endGroup();
1252 list->list->clear();
1276 QDesktopWidget *
d = configApp->desktop();
1277 snprintf(title,
sizeof(title),
"%s%s",
1279 #
if QT_VERSION < 0x040000
1287 width = configSettings->readNumEntry(
"/window width", d->width() - 64);
1288 height = configSettings->readNumEntry(
"/window height", d->height() - 64);
1289 resize(width, height);
1290 x = configSettings->readNumEntry(
"/window x", 0, &ok);
1292 y = configSettings->readNumEntry(
"/window y", 0, &ok);
1296 split1 =
new QSplitter(
this);
1297 split1->setOrientation(Qt::Horizontal);
1298 setCentralWidget(
split1);
1304 split2->setOrientation(Qt::Vertical);
1311 helpText->setTextFormat(Qt::RichText);
1323 connect(quitAction,
SIGNAL(activated()),
SLOT(close()));
1326 saveAction =
new Q3Action(
"Save", QPixmap(xpm_save),
_(
"&Save"),
Qt::CTRL + Qt::Key_S,
this);
1335 Q3Action *singleViewAction =
new Q3Action(
"Single View", QPixmap(xpm_single_view),
_(
"Single View"), 0,
this);
1337 Q3Action *splitViewAction =
new Q3Action(
"Split View", QPixmap(xpm_split_view),
_(
"Split View"), 0,
this);
1339 Q3Action *fullViewAction =
new Q3Action(
"Full View", QPixmap(xpm_tree_view),
_(
"Full View"), 0,
this);
1343 showNameAction->setToggleAction(
TRUE);
1348 showRangeAction->setToggleAction(
TRUE);
1353 showDataAction->setToggleAction(
TRUE);
1358 QActionGroup *optGroup =
new QActionGroup(
this);
1359 optGroup->setExclusive(
TRUE);
1361 SLOT(setOptionMode(QAction *)));
1363 SLOT(setOptionMode(QAction *)));
1365 #if QT_VERSION >= 0x040000
1382 showDebugAction->setToggleAction(
TRUE);
1384 connect(
helpText,
SIGNAL(showDebugChanged(
bool)), showDebugAction,
SLOT(setOn(
bool)));
1398 singleViewAction->addTo(
toolBar);
1399 splitViewAction->addTo(
toolBar);
1400 fullViewAction->addTo(
toolBar);
1404 menu->insertItem(
_(
"&File"), config);
1405 loadAction->addTo(config);
1406 saveAction->addTo(config);
1407 saveAsAction->addTo(config);
1408 config->insertSeparator();
1409 quitAction->addTo(config);
1413 menu->insertItem(
_(
"&Edit"), editMenu);
1414 searchAction->addTo(editMenu);
1418 menu->insertItem(
_(
"&Option"), optionMenu);
1419 showNameAction->addTo(optionMenu);
1420 showRangeAction->addTo(optionMenu);
1421 showDataAction->addTo(optionMenu);
1422 optionMenu->insertSeparator();
1423 optGroup->addTo(optionMenu);
1424 optionMenu->insertSeparator();
1428 menu->insertSeparator();
1429 menu->insertItem(
_(
"&Help"), helpMenu);
1430 showIntroAction->addTo(helpMenu);
1431 showAboutAction->addTo(helpMenu);
1453 QString
listMode = configSettings->readEntry(
"/listMode",
"symbol");
1454 if (listMode ==
"single")
1456 else if (listMode ==
"full")
1462 Q3ValueList<int> sizes = configSettings->
readSizes(
"/split1", &ok);
1466 sizes = configSettings->
readSizes(
"/split2", &ok);
1477 QMessageBox::information(
this,
"qconf",
_(
"Unable to load configuration!"));
1484 QMessageBox::information(
this,
"qconf",
_(
"Unable to save configuration!"));
1559 list->setSelected(item,
TRUE);
1560 list->ensureItemVisible(item);
1610 configApp->processEvents();
1641 QMessageBox
mb(
"qconf",
_(
"Save configuration?"), QMessageBox::Warning,
1642 QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
1643 mb.setButtonText(QMessageBox::Yes,
_(
"&Save Changes"));
1645 mb.setButtonText(QMessageBox::Cancel,
_(
"Cancel Exit"));
1646 switch (mb.exec()) {
1647 case QMessageBox::Yes:
1656 case QMessageBox::Cancel:
1664 static const QString str =
_(
"Welcome to the qconf graphical configuration tool.\n\n"
1665 "For each option, a blank box indicates the feature is disabled, a check\n"
1666 "indicates it is enabled, and a dot indicates that it is to be compiled\n"
1667 "as a module. Clicking on the box will cycle through the three states.\n\n"
1668 "If you do not see an option (e.g., a device driver) that you believe\n"
1669 "should be present, try turning on Show All Options under the Options menu.\n"
1670 "Although there is no cross reference yet to help you figure out what other\n"
1671 "options must be enabled to support the option you are interested in, you can\n"
1672 "still view the help of a grayed-out option.\n\n"
1673 "Toggling Show Debug Info under the Options menu will show the dependencies,\n"
1674 "which you can then match by examining other options.\n\n");
1676 QMessageBox::information(
this,
"qconf", str);
1681 static const QString str =
_(
"qconf is Copyright (C) 2002 Roman Zippel <[email protected]>.\n\n"
1682 "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n");
1684 QMessageBox::information(
this,
"qconf", str);
1689 configSettings->writeEntry(
"/window x",
pos().
x());
1690 configSettings->writeEntry(
"/window y",
pos().
y());
1691 configSettings->writeEntry(
"/window width",
size().
width());
1692 configSettings->writeEntry(
"/window height",
size().
height());
1711 configSettings->writeEntry(
"/listMode", entry);
1717 void ConfigMainWindow::conf_changed(
void)
1726 static int menu_cnt = 0;
1729 for (child = menu->
list; child; child = child->
next) {
1734 }
else if (!menu_cnt)
1739 static const char *progname;
1741 static void usage(
void)
1743 printf(
_(
"%s <config>\n"), progname);
1756 configApp =
new QApplication(ac, av);
1757 if (ac > 1 && av[1][0] ==
'-') {
1775 configSettings->beginGroup(
"/kconfig/qconf");
1779 configApp->setMainWidget(v);
1780 configApp->connect(configApp,
SIGNAL(lastWindowClosed()),
SLOT(quit()));
1781 configApp->connect(configApp,
SIGNAL(aboutToQuit()), v,
SLOT(saveSettings()));
1785 configSettings->endGroup();
1786 delete configSettings;