blob: d134a89bfdced88c53424c384b1323651add0fd4 [file] [log] [blame]
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
* Released under the terms of the GNU GPL v2.0.
*/
#include <qglobal.h>
#include <QMainWindow>
#include <QList>
#include <qtextbrowser.h>
#include <QAction>
#include <QFileDialog>
#include <QMenu>
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <qtoolbar.h>
#include <qlayout.h>
#include <qsplitter.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qregexp.h>
#include <qevent.h>
#include <stdlib.h>
#include "lkc.h"
#include "qconf.h"
#include "qconf.moc"
#include "images.c"
#ifdef _
# undef _
# define _ qgettext
#endif
static QApplication *configApp;
static ConfigSettings *configSettings;
QAction *ConfigMainWindow::saveAction;
static inline QString qgettext(const char* str)
{
return QString::fromLocal8Bit(gettext(str));
}
static inline QString qgettext(const QString& str)
{
return QString::fromLocal8Bit(gettext(str.toLatin1()));
}
ConfigSettings::ConfigSettings()
: QSettings("kernel.org", "qconf")
{
}
/**
* Reads a list of integer values from the application settings.
*/
QList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
{
QList<int> result;
QStringList entryList = value(key).toStringList();
QStringList::Iterator it;
for (it = entryList.begin(); it != entryList.end(); ++it)
result.push_back((*it).toInt());
return result;
}
/**
* Writes a list of integer values to the application settings.
*/
bool ConfigSettings::writeSizes(const QString& key, const QList<int>& value)
{
QStringList stringList;
QList<int>::ConstIterator it;
for (it = value.begin(); it != value.end(); ++it)
stringList.push_back(QString::number(*it));
setValue(key, stringList);
return true;
}
ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
: Parent(parent)
{
connect(this, SIGNAL(lostFocus()), SLOT(hide()));
}
void ConfigLineEdit::show(QTreeWidgetItem *i)
{
item = i;
Parent::show();
setFocus();
}
void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
{
switch (e->key()) {
case Qt::Key_Escape:
break;
case Qt::Key_Return:
case Qt::Key_Enter:
parent()->updateList(item);
break;
default:
Parent::keyPressEvent(e);
return;
}
e->accept();
parent()->list->setFocus();
hide();
}
ConfigView*ConfigView::viewList;
QAction *ConfigView::showNormalAction;
QAction *ConfigView::showAllAction;
QAction *ConfigView::showPromptAction;
ConfigView::ConfigView(QWidget* parent, const char *name)
: Parent(parent)
{
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
verticalLayout->setContentsMargins(0, 0, 0, 0);
list = new QTreeWidget(this);
verticalLayout->addWidget(list);
lineEdit = new ConfigLineEdit(this);
lineEdit->hide();
verticalLayout->addWidget(lineEdit);
this->nextView = viewList;
viewList = this;
}
ConfigView::~ConfigView(void)
{
ConfigView** vp;
for (vp = &viewList; *vp; vp = &(*vp)->nextView) {
if (*vp == this) {
*vp = nextView;
break;
}
}
}
void ConfigView::setOptionMode(QAction *act)
{
}
void ConfigView::setShowName(bool b)
{
}
void ConfigView::setShowRange(bool b)
{
}
void ConfigView::setShowData(bool b)
{
}
void ConfigView::updateList(QTreeWidgetItem* item)
{
}
void ConfigView::updateListAll(void)
{
}
ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
: Parent(parent), sym(0), _menu(0)
{
if (name) {
configSettings->beginGroup(name);
_showDebug = configSettings->value("/showDebug", false).toBool();
configSettings->endGroup();
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
}
}
void ConfigInfoView::saveSettings(void)
{
/*if (name()) {
configSettings->beginGroup(name());
configSettings->setValue("/showDebug", showDebug());
configSettings->endGroup();
}*/
}
void ConfigInfoView::setShowDebug(bool b)
{
if (_showDebug != b) {
_showDebug = b;
if (_menu)
menuInfo();
else if (sym)
symbolInfo();
emit showDebugChanged(b);
}
}
void ConfigInfoView::setInfo(struct menu *m)
{
if (_menu == m)
return;
_menu = m;
sym = NULL;
if (!_menu)
clear();
else
menuInfo();
}
void ConfigInfoView::symbolInfo(void)
{
QString str;
str += "<big>Symbol: <b>";
str += print_filter(sym->name);
str += "</b></big><br><br>value: ";
str += print_filter(sym_get_string_value(sym));
str += "<br>visibility: ";
str += sym->visible == yes ? "y" : sym->visible == mod ? "m" : "n";
str += "<br>";
str += debug_info(sym);
setText(str);
}
void ConfigInfoView::menuInfo(void)
{
struct symbol* sym;
QString head, debug, help;
sym = _menu->sym;
if (sym) {
if (_menu->prompt) {
head += "<big><b>";
head += print_filter(_(_menu->prompt->text));
head += "</b></big>";
if (sym->name) {
head += " (";
if (showDebug())
head += QString().sprintf("<a href=\"s%p\">", sym);
head += print_filter(sym->name);
if (showDebug())
head += "</a>";
head += ")";
}
} else if (sym->name) {
head += "<big><b>";
if (showDebug())
head += QString().sprintf("<a href=\"s%p\">", sym);
head += print_filter(sym->name);
if (showDebug())
head += "</a>";
head += "</b></big>";
}
head += "<br><br>";
if (showDebug())
debug = debug_info(sym);
struct gstr help_gstr = str_new();
menu_get_ext_help(_menu, &help_gstr);
help = print_filter(str_get(&help_gstr));
str_free(&help_gstr);
} else if (_menu->prompt) {
head += "<big><b>";
head += print_filter(_(_menu->prompt->text));
head += "</b></big><br><br>";
if (showDebug()) {
if (_menu->prompt->visible.expr) {
debug += "&nbsp;&nbsp;dep: ";
expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
debug += "<br><br>";
}
}
}
if (showDebug())
debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno);
setText(head + debug + help);
}
QString ConfigInfoView::debug_info(struct symbol *sym)
{
QString debug;
debug += "type: ";
debug += print_filter(sym_type_name(sym->type));
if (sym_is_choice(sym))
debug += " (choice)";
debug += "<br>";
if (sym->rev_dep.expr) {
debug += "reverse dep: ";
expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
debug += "<br>";
}
for (struct property *prop = sym->prop; prop; prop = prop->next) {
switch (prop->type) {
case P_PROMPT:
case P_MENU:
debug += QString().sprintf("prompt: <a href=\"m%p\">", prop->menu);
debug += print_filter(_(prop->text));
debug += "</a><br>";
break;
case P_DEFAULT:
case P_SELECT:
case P_RANGE:
case P_ENV:
debug += prop_get_type_name(prop->type);
debug += ": ";
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
debug += "<br>";
break;
case P_CHOICE:
if (sym_is_choice(sym)) {
debug += "choice: ";
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
debug += "<br>";
}
break;
default:
debug += "unknown property: ";
debug += prop_get_type_name(prop->type);
debug += "<br>";
}
if (prop->visible.expr) {
debug += "&nbsp;&nbsp;&nbsp;&nbsp;dep: ";
expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
debug += "<br>";
}
}
debug += "<br>";
return debug;
}
QString ConfigInfoView::print_filter(const QString &str)
{
QRegExp re("[<>&\"\\n]");
QString res = str;
for (int i = 0; (i = res.indexOf(re, i)) >= 0;) {
switch (res[i].toLatin1()) {
case '<':
res.replace(i, 1, "&lt;");
i += 4;
break;
case '>':
res.replace(i, 1, "&gt;");
i += 4;
break;
case '&':
res.replace(i, 1, "&amp;");
i += 5;
break;
case '"':
res.replace(i, 1, "&quot;");
i += 6;
break;
case '\n':
res.replace(i, 1, "<br>");
i += 4;
break;
}
}
return res;
}
void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
{
QString* text = reinterpret_cast<QString*>(data);
QString str2 = print_filter(str);
if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
*text += QString().sprintf("<a href=\"s%p\">", sym);
*text += str2;
*text += "</a>";
} else
*text += str2;
}
QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
{
QMenu* popup = Parent::createStandardContextMenu(pos);
QAction* action = new QAction(_("Show Debug Info"), popup);
action->setCheckable(true);
connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
action->setChecked(showDebug());
popup->addSeparator();
popup->addAction(action);
return popup;
}
void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e)
{
Parent::contextMenuEvent(e);
}
ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name)
: Parent(parent), result(NULL)
{
setWindowTitle("Search Config");
QVBoxLayout* layout1 = new QVBoxLayout(this);
layout1->setContentsMargins(11, 11, 11, 11);
layout1->setSpacing(6);
QHBoxLayout* layout2 = new QHBoxLayout(0);
layout2->setContentsMargins(0, 0, 0, 0);
layout2->setSpacing(6);
layout2->addWidget(new QLabel(_("Find:"), this));
editField = new QLineEdit(this);
connect(editField, SIGNAL(returnPressed()), SLOT(search()));
layout2->addWidget(editField);
searchButton = new QPushButton(_("Search"), this);
searchButton->setAutoDefault(false);
connect(searchButton, SIGNAL(clicked()), SLOT(search()));
layout2->addWidget(searchButton);
layout1->addLayout(layout2);
split = new QSplitter(this);
split->setOrientation(Qt::Vertical);
list = new ConfigView(split, name);
info = new ConfigInfoView(split, name);
connect(list->list, SIGNAL(menuChanged(struct menu *)),
info, SLOT(setInfo(struct menu *)));
connect(list->list, SIGNAL(menuChanged(struct menu *)),
parent, SLOT(setMenuLink(struct menu *)));
layout1->addWidget(split);
if (name) {
QVariant x, y;
int width, height;
bool ok;
configSettings->beginGroup(name);
width = configSettings->value("/window width", parent->width() / 2).toInt();
height = configSettings->value("/window height", parent->height() / 2).toInt();
resize(width, height);
x = configSettings->value("/window x");
y = configSettings->value("/window y");
if ((x.isValid())&&(y.isValid()))
move(x.toInt(), y.toInt());
QList<int> sizes = configSettings->readSizes("/split", &ok);
if (ok)
split->setSizes(sizes);
configSettings->endGroup();
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
}
}
void ConfigSearchWindow::saveSettings(void)
{
/*if (name()) {
configSettings->beginGroup(name());
configSettings->setValue("/window x", pos().x());
configSettings->setValue("/window y", pos().y());
configSettings->setValue("/window width", size().width());
configSettings->setValue("/window height", size().height());
configSettings->writeSizes("/split", split->sizes());
configSettings->endGroup();
}*/
}
void ConfigSearchWindow::search(void)
{
}
/*
* Construct the complete config widget
*/
ConfigMainWindow::ConfigMainWindow(void)
: searchWindow(0)
{
QMenuBar* menu;
bool ok;
QVariant x, y;
int width, height;
char title[256];
QDesktopWidget *d = configApp->desktop();
snprintf(title, sizeof(title), "%s%s",
rootmenu.prompt->text,
""
);
setWindowTitle(title);
width = configSettings->value("/window width", d->width() - 64).toInt();
height = configSettings->value("/window height", d->height() - 64).toInt();
resize(width, height);
x = configSettings->value("/window x");
y = configSettings->value("/window y");
if ((x.isValid())&&(y.isValid()))
move(x.toInt(), y.toInt());
split1 = new QSplitter(this);
split1->setOrientation(Qt::Horizontal);
setCentralWidget(split1);
menuView = new ConfigView(split1, "menu");
menuList = menuView->list;
split2 = new QSplitter(split1);
split2->setOrientation(Qt::Vertical);
// create config tree
configView = new ConfigView(split2, "config");
configList = configView->list;
helpText = new ConfigInfoView(split2, "help");
//helpText->setTextFormat(Qt::RichText);
setTabOrder(configList, helpText);
configList->setFocus();
menu = menuBar();
toolBar = new QToolBar("Tools", this);
addToolBar(toolBar);
backAction = new QAction(QPixmap(xpm_back), _("Back"), this);
connect(backAction, SIGNAL(activated()), SLOT(goBack()));
backAction->setEnabled(false);
QAction *quitAction = new QAction(_("&Quit"), this);
quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
connect(quitAction, SIGNAL(activated()), SLOT(close()));
QAction *loadAction = new QAction(QPixmap(xpm_load), _("&Load"), this);
loadAction->setShortcut(Qt::CTRL + Qt::Key_L);
connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
saveAction = new QAction(QPixmap(xpm_save), _("&Save"), this);
saveAction->setShortcut(Qt::CTRL + Qt::Key_S);
connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
conf_set_changed_callback(conf_changed);
// Set saveAction's initial state
conf_changed();
QAction *saveAsAction = new QAction(_("Save &As..."), this);
connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
QAction *searchAction = new QAction(_("&Find"), this);
searchAction->setShortcut(Qt::CTRL + Qt::Key_F);
connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
singleViewAction = new QAction(QPixmap(xpm_single_view), _("Single View"), this);
singleViewAction->setCheckable(true);
connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
splitViewAction = new QAction(QPixmap(xpm_split_view), _("Split View"), this);
splitViewAction->setCheckable(true);
connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
fullViewAction = new QAction(QPixmap(xpm_tree_view), _("Full View"), this);
fullViewAction->setCheckable(true);
connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
QAction *showNameAction = new QAction(_("Show Name"), this);
showNameAction->setCheckable(true);
connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool)));
showNameAction->setChecked(configView->showName());
QAction *showRangeAction = new QAction(_("Show Range"), this);
showRangeAction->setCheckable(true);
connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool)));
QAction *showDataAction = new QAction(_("Show Data"), this);
showDataAction->setCheckable(true);
connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
QActionGroup *optGroup = new QActionGroup(this);
optGroup->setExclusive(true);
connect(optGroup, SIGNAL(selected(QAction *)), configView,
SLOT(setOptionMode(QAction *)));
connect(optGroup, SIGNAL(selected(QAction *)), menuView,
SLOT(setOptionMode(QAction *)));
configView->showNormalAction = new QAction(_("Show Normal Options"), optGroup);
configView->showAllAction = new QAction(_("Show All Options"), optGroup);
configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup);
configView->showNormalAction->setCheckable(true);
configView->showAllAction->setCheckable(true);
configView->showPromptAction->setCheckable(true);
QAction *showDebugAction = new QAction( _("Show Debug Info"), this);
showDebugAction->setCheckable(true);
connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
showDebugAction->setChecked(helpText->showDebug());
QAction *showIntroAction = new QAction( _("Introduction"), this);
connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
QAction *showAboutAction = new QAction( _("About"), this);
connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
// init tool bar
toolBar->addAction(backAction);
toolBar->addSeparator();
toolBar->addAction(loadAction);
toolBar->addAction(saveAction);
toolBar->addSeparator();
toolBar->addAction(singleViewAction);
toolBar->addAction(splitViewAction);
toolBar->addAction(fullViewAction);
// create config menu
QMenu* config = menu->addMenu(_("&File"));
config->addAction(loadAction);
config->addAction(saveAction);
config->addAction(saveAsAction);
config->addSeparator();
config->addAction(quitAction);
// create edit menu
QMenu* editMenu = menu->addMenu(_("&Edit"));
editMenu->addAction(searchAction);
// create options menu
QMenu* optionMenu = menu->addMenu(_("&Option"));
optionMenu->addAction(showNameAction);
optionMenu->addAction(showRangeAction);
optionMenu->addAction(showDataAction);
optionMenu->addSeparator();
optionMenu->addActions(optGroup->actions());
optionMenu->addSeparator();
// create help menu
menu->addSeparator();
QMenu* helpMenu = menu->addMenu(_("&Help"));
helpMenu->addAction(showIntroAction);
helpMenu->addAction(showAboutAction);
connect(configList, SIGNAL(menuChanged(struct menu *)),
helpText, SLOT(setInfo(struct menu *)));
connect(configList, SIGNAL(menuSelected(struct menu *)),
SLOT(changeMenu(struct menu *)));
connect(configList, SIGNAL(parentSelected()),
SLOT(goBack()));
connect(menuList, SIGNAL(menuChanged(struct menu *)),
helpText, SLOT(setInfo(struct menu *)));
connect(menuList, SIGNAL(menuSelected(struct menu *)),
SLOT(changeMenu(struct menu *)));
connect(configList, SIGNAL(gotFocus(struct menu *)),
helpText, SLOT(setInfo(struct menu *)));
connect(menuList, SIGNAL(gotFocus(struct menu *)),
helpText, SLOT(setInfo(struct menu *)));
connect(menuList, SIGNAL(gotFocus(struct menu *)),
SLOT(listFocusChanged(void)));
connect(helpText, SIGNAL(menuSelected(struct menu *)),
SLOT(setMenuLink(struct menu *)));
QString listMode = configSettings->value("/listMode", "symbol").toString();
if (listMode == "single")
showSingleView();
else if (listMode == "full")
showFullView();
else /*if (listMode == "split")*/
showSplitView();
// UI setup done, restore splitter positions
QList<int> sizes = configSettings->readSizes("/split1", &ok);
if (ok)
split1->setSizes(sizes);
sizes = configSettings->readSizes("/split2", &ok);
if (ok)
split2->setSizes(sizes);
}
void ConfigMainWindow::loadConfig(void)
{
QString s = QFileDialog::getOpenFileName(this, "", conf_get_configname());
if (s.isNull())
return;
if (conf_read(QFile::encodeName(s)))
QMessageBox::information(this, "qconf", _("Unable to load configuration!"));
ConfigView::updateListAll();
}
bool ConfigMainWindow::saveConfig(void)
{
if (conf_write(NULL)) {
QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
return false;
}
return true;
}
void ConfigMainWindow::saveConfigAs(void)
{
QString s = QFileDialog::getSaveFileName(this, "", conf_get_configname());
if (s.isNull())
return;
saveConfig();
}
void ConfigMainWindow::searchConfig(void)
{
if (!searchWindow)
searchWindow = new ConfigSearchWindow(this, "search");
searchWindow->show();
}
void ConfigMainWindow::changeMenu(struct menu *menu)
{
}
void ConfigMainWindow::setMenuLink(struct menu *menu)
{
}
void ConfigMainWindow::listFocusChanged(void)
{
}
void ConfigMainWindow::goBack(void)
{
}
void ConfigMainWindow::showSingleView(void)
{
singleViewAction->setEnabled(false);
singleViewAction->setChecked(true);
splitViewAction->setEnabled(true);
splitViewAction->setChecked(false);
fullViewAction->setEnabled(true);
fullViewAction->setChecked(false);
menuView->hide();
configList->setFocus();
}
void ConfigMainWindow::showSplitView(void)
{
singleViewAction->setEnabled(true);
singleViewAction->setChecked(false);
splitViewAction->setEnabled(false);
splitViewAction->setChecked(true);
fullViewAction->setEnabled(true);
fullViewAction->setChecked(false);
menuView->show();
menuList->setFocus();
}
void ConfigMainWindow::showFullView(void)
{
singleViewAction->setEnabled(true);
singleViewAction->setChecked(false);
splitViewAction->setEnabled(true);
splitViewAction->setChecked(false);
fullViewAction->setEnabled(false);
fullViewAction->setChecked(true);
menuView->hide();
configList->setFocus();
}
/*
* ask for saving configuration before quitting
* TODO ask only when something changed
*/
void ConfigMainWindow::closeEvent(QCloseEvent* e)
{
if (!conf_get_changed()) {
e->accept();
return;
}
QMessageBox mb("qconf", _("Save configuration?"), QMessageBox::Warning,
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
mb.setButtonText(QMessageBox::Yes, _("&Save Changes"));
mb.setButtonText(QMessageBox::No, _("&Discard Changes"));
mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
switch (mb.exec()) {
case QMessageBox::Yes:
if (saveConfig())
e->accept();
else
e->ignore();
break;
case QMessageBox::No:
e->accept();
break;
case QMessageBox::Cancel:
e->ignore();
break;
}
}
void ConfigMainWindow::showIntro(void)
{
static const QString str = _("Welcome to the qconf graphical configuration tool.\n\n"
"For each option, a blank box indicates the feature is disabled, a check\n"
"indicates it is enabled, and a dot indicates that it is to be compiled\n"
"as a module. Clicking on the box will cycle through the three states.\n\n"
"If you do not see an option (e.g., a device driver) that you believe\n"
"should be present, try turning on Show All Options under the Options menu.\n"
"Although there is no cross reference yet to help you figure out what other\n"
"options must be enabled to support the option you are interested in, you can\n"
"still view the help of a grayed-out option.\n\n"
"Toggling Show Debug Info under the Options menu will show the dependencies,\n"
"which you can then match by examining other options.\n\n");
QMessageBox::information(this, "qconf", str);
}
void ConfigMainWindow::showAbout(void)
{
static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
"Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n");
QMessageBox::information(this, "qconf", str);
}
void ConfigMainWindow::saveSettings(void)
{
configSettings->setValue("/window x", pos().x());
configSettings->setValue("/window y", pos().y());
configSettings->setValue("/window width", size().width());
configSettings->setValue("/window height", size().height());
QString entry;
configSettings->setValue("/listMode", entry);
configSettings->writeSizes("/split1", split1->sizes());
configSettings->writeSizes("/split2", split2->sizes());
}
void ConfigMainWindow::conf_changed(void)
{
if (saveAction)
saveAction->setEnabled(conf_get_changed());
}
void fixup_rootmenu(struct menu *menu)
{
struct menu *child;
static int menu_cnt = 0;
menu->flags |= MENU_ROOT;
for (child = menu->list; child; child = child->next) {
if (child->prompt && child->prompt->type == P_MENU) {
menu_cnt++;
fixup_rootmenu(child);
menu_cnt--;
} else if (!menu_cnt)
fixup_rootmenu(child);
}
}
static const char *progname;
static void usage(void)
{
printf(_("%s [-s] <config>\n").toLatin1().constData(), progname);
exit(0);
}
int main(int ac, char** av)
{
ConfigMainWindow* v;
const char *name;
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
progname = av[0];
configApp = new QApplication(ac, av);
if (ac > 1 && av[1][0] == '-') {
switch (av[1][1]) {
case 's':
conf_set_message_callback(NULL);
break;
case 'h':
case '?':
usage();
}
name = av[2];
} else
name = av[1];
if (!name)
usage();
conf_parse(name);
fixup_rootmenu(&rootmenu);
conf_read(NULL);
//zconfdump(stdout);
configSettings = new ConfigSettings();
configSettings->beginGroup("/kconfig/qconf");
v = new ConfigMainWindow();
//zconfdump(stdout);
configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings()));
v->show();
configApp->exec();
configSettings->endGroup();
delete configSettings;
return 0;
}