linux/scripts/kconfig/qconf.cc

912 lines
24 KiB
C++
Raw Normal View History

/*
* 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 <q3header.h>
#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"
[PATCH] Kconfig i18n support This patch adds i18n support for make *config, allowing users to have the config process in their own language. No printk was harmed in the process, don't worry, so all the bug reports, kernel messages, etc, remain in english, just the user tools to configure the kernel are internationalized. Users not interested in translations can just unset the related LANG, LC_ALL, etc env variables and have the config process in plain english, something like: LANG= make menuconfig is enough for having the whole config process in english. Or just don't install any translation file. Translations for brazilian portuguese are being done by a team of volunteers at: http://www.visionflex.inf.br/kernel_ptbr/pmwiki.php/Principal/Traducoes To start the translation process: make update-po-config This will generate the pot template named scripts/kconfig/linux.pot, copy it to, say, ~/es.po, to start the translation for spanish. To test your translation, as root issue this command: msgfmt -o /usr/share/locale/es/LC_MESSAGES/linux.mo ~/es.po Replace "es" with your language code. Then execute, for instance: make menuconfig The current patch doesn't use any optimization to reduce the size of the generated .mo file, it is possible to use the config option as a key, but this doesn't prevent the current patch from being used or the translations done under the current scheme to be in any way lost if we chose to do any kind of keying. Thanks to Fabricio Vaccari for starting the pt_BR (brazilian portuguese) translation effort, Thiago Maciera for helping me with the gconf.cc (QT frontent) i18n coding and to all the volunteers that are already working on the first translation, to pt_BR. I left the question on whether to ship the translations with the stock kernel sources to be discussed here, please share your suggestions. Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org Signed-off-by: Andrew Morton <akpm@osdl.org>
2005-05-06 00:09:46 +02:00
#ifdef _
# undef _
# define _ qgettext
#endif
static QApplication *configApp;
static ConfigSettings *configSettings;
QAction *ConfigMainWindow::saveAction;
[PATCH] Kconfig i18n support This patch adds i18n support for make *config, allowing users to have the config process in their own language. No printk was harmed in the process, don't worry, so all the bug reports, kernel messages, etc, remain in english, just the user tools to configure the kernel are internationalized. Users not interested in translations can just unset the related LANG, LC_ALL, etc env variables and have the config process in plain english, something like: LANG= make menuconfig is enough for having the whole config process in english. Or just don't install any translation file. Translations for brazilian portuguese are being done by a team of volunteers at: http://www.visionflex.inf.br/kernel_ptbr/pmwiki.php/Principal/Traducoes To start the translation process: make update-po-config This will generate the pot template named scripts/kconfig/linux.pot, copy it to, say, ~/es.po, to start the translation for spanish. To test your translation, as root issue this command: msgfmt -o /usr/share/locale/es/LC_MESSAGES/linux.mo ~/es.po Replace "es" with your language code. Then execute, for instance: make menuconfig The current patch doesn't use any optimization to reduce the size of the generated .mo file, it is possible to use the config option as a key, but this doesn't prevent the current patch from being used or the translations done under the current scheme to be in any way lost if we chose to do any kind of keying. Thanks to Fabricio Vaccari for starting the pt_BR (brazilian portuguese) translation effort, Thiago Maciera for helping me with the gconf.cc (QT frontent) i18n coding and to all the volunteers that are already working on the first translation, to pt_BR. I left the question on whether to ship the translations with the stock kernel sources to be discussed here, please share your suggestions. Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org Signed-off-by: Andrew Morton <akpm@osdl.org>
2005-05-06 00:09:46 +02:00
static inline QString qgettext(const char* str)
{
return QString::fromLocal8Bit(gettext(str));
[PATCH] Kconfig i18n support This patch adds i18n support for make *config, allowing users to have the config process in their own language. No printk was harmed in the process, don't worry, so all the bug reports, kernel messages, etc, remain in english, just the user tools to configure the kernel are internationalized. Users not interested in translations can just unset the related LANG, LC_ALL, etc env variables and have the config process in plain english, something like: LANG= make menuconfig is enough for having the whole config process in english. Or just don't install any translation file. Translations for brazilian portuguese are being done by a team of volunteers at: http://www.visionflex.inf.br/kernel_ptbr/pmwiki.php/Principal/Traducoes To start the translation process: make update-po-config This will generate the pot template named scripts/kconfig/linux.pot, copy it to, say, ~/es.po, to start the translation for spanish. To test your translation, as root issue this command: msgfmt -o /usr/share/locale/es/LC_MESSAGES/linux.mo ~/es.po Replace "es" with your language code. Then execute, for instance: make menuconfig The current patch doesn't use any optimization to reduce the size of the generated .mo file, it is possible to use the config option as a key, but this doesn't prevent the current patch from being used or the translations done under the current scheme to be in any way lost if we chose to do any kind of keying. Thanks to Fabricio Vaccari for starting the pt_BR (brazilian portuguese) translation effort, Thiago Maciera for helping me with the gconf.cc (QT frontent) i18n coding and to all the volunteers that are already working on the first translation, to pt_BR. I left the question on whether to ship the translations with the stock kernel sources to be discussed here, please share your suggestions. Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org Signed-off-by: Andrew Morton <akpm@osdl.org>
2005-05-06 00:09:46 +02:00
}
static inline QString qgettext(const QString& str)
{
return QString::fromLocal8Bit(gettext(str.latin1()));
[PATCH] Kconfig i18n support This patch adds i18n support for make *config, allowing users to have the config process in their own language. No printk was harmed in the process, don't worry, so all the bug reports, kernel messages, etc, remain in english, just the user tools to configure the kernel are internationalized. Users not interested in translations can just unset the related LANG, LC_ALL, etc env variables and have the config process in plain english, something like: LANG= make menuconfig is enough for having the whole config process in english. Or just don't install any translation file. Translations for brazilian portuguese are being done by a team of volunteers at: http://www.visionflex.inf.br/kernel_ptbr/pmwiki.php/Principal/Traducoes To start the translation process: make update-po-config This will generate the pot template named scripts/kconfig/linux.pot, copy it to, say, ~/es.po, to start the translation for spanish. To test your translation, as root issue this command: msgfmt -o /usr/share/locale/es/LC_MESSAGES/linux.mo ~/es.po Replace "es" with your language code. Then execute, for instance: make menuconfig The current patch doesn't use any optimization to reduce the size of the generated .mo file, it is possible to use the config option as a key, but this doesn't prevent the current patch from being used or the translations done under the current scheme to be in any way lost if we chose to do any kind of keying. Thanks to Fabricio Vaccari for starting the pt_BR (brazilian portuguese) translation effort, Thiago Maciera for helping me with the gconf.cc (QT frontent) i18n coding and to all the volunteers that are already working on the first translation, to pt_BR. I left the question on whether to ship the translations with the stock kernel sources to be discussed here, please share your suggestions. Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org Signed-off-by: Andrew Morton <akpm@osdl.org>
2005-05-06 00:09:46 +02:00
}
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 = readListEntry(key, ok);
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));
return writeEntry(key, stringList);
}
ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
: Parent(parent)
{
connect(this, SIGNAL(lostFocus()), SLOT(hide()));
}
void ConfigLineEdit::show(Q3ListViewItem *i)
{
item = i;
Parent::show();
setFocus();
}
void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
{
switch (e->key()) {
kconfig qconf: add namespace for use of Key_ enum values They are defined in the 'Qt' namespace. Fixes the following compiler errors after a quick conversion with 'qt3to4', which occured with g++ 3.4.6 and 4.1.2, but not anymore with 4.3.2. scripts/kconfig/qconf.cc: In member function 'virtual void ConfigLineEdit::keyPressEvent(QKeyEvent*)': scripts/kconfig/qconf.cc:311: error: 'Key_Escape' was not declared in this scope scripts/kconfig/qconf.cc:313: error: 'Key_Return' was not declared in this scope scripts/kconfig/qconf.cc:314: error: 'Key_Enter' was not declared in this scope scripts/kconfig/qconf.cc: In member function 'virtual void ConfigList::keyPressEvent(QKeyEvent*)': scripts/kconfig/qconf.cc:653: error: 'Key_Escape' was not declared in this scope scripts/kconfig/qconf.cc:666: error: 'Key_Return' was not declared in this scope scripts/kconfig/qconf.cc:667: error: 'Key_Enter' was not declared in this scope scripts/kconfig/qconf.cc:681: error: 'Key_Space' was not declared in this scope scripts/kconfig/qconf.cc:684: error: 'Key_N' was not declared in this scope scripts/kconfig/qconf.cc:687: error: 'Key_M' was not declared in this scope scripts/kconfig/qconf.cc:690: error: 'Key_Y' was not declared in this scope scripts/kconfig/qconf.cc: In constructor 'ConfigMainWindow::ConfigMainWindow()': scripts/kconfig/qconf.cc:1329: error: 'CTRL' was not declared in this scope scripts/kconfig/qconf.cc:1329: error: 'Key_Q' was not declared in this scope scripts/kconfig/qconf.cc:1331: error: 'Key_L' was not declared in this scope scripts/kconfig/qconf.cc:1333: error: 'Key_S' was not declared in this scope scripts/kconfig/qconf.cc:1340: error: 'Key_F' was not declared in this scope Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2009-05-18 01:36:51 +02:00
case Qt::Key_Escape:
break;
kconfig qconf: add namespace for use of Key_ enum values They are defined in the 'Qt' namespace. Fixes the following compiler errors after a quick conversion with 'qt3to4', which occured with g++ 3.4.6 and 4.1.2, but not anymore with 4.3.2. scripts/kconfig/qconf.cc: In member function 'virtual void ConfigLineEdit::keyPressEvent(QKeyEvent*)': scripts/kconfig/qconf.cc:311: error: 'Key_Escape' was not declared in this scope scripts/kconfig/qconf.cc:313: error: 'Key_Return' was not declared in this scope scripts/kconfig/qconf.cc:314: error: 'Key_Enter' was not declared in this scope scripts/kconfig/qconf.cc: In member function 'virtual void ConfigList::keyPressEvent(QKeyEvent*)': scripts/kconfig/qconf.cc:653: error: 'Key_Escape' was not declared in this scope scripts/kconfig/qconf.cc:666: error: 'Key_Return' was not declared in this scope scripts/kconfig/qconf.cc:667: error: 'Key_Enter' was not declared in this scope scripts/kconfig/qconf.cc:681: error: 'Key_Space' was not declared in this scope scripts/kconfig/qconf.cc:684: error: 'Key_N' was not declared in this scope scripts/kconfig/qconf.cc:687: error: 'Key_M' was not declared in this scope scripts/kconfig/qconf.cc:690: error: 'Key_Y' was not declared in this scope scripts/kconfig/qconf.cc: In constructor 'ConfigMainWindow::ConfigMainWindow()': scripts/kconfig/qconf.cc:1329: error: 'CTRL' was not declared in this scope scripts/kconfig/qconf.cc:1329: error: 'Key_Q' was not declared in this scope scripts/kconfig/qconf.cc:1331: error: 'Key_L' was not declared in this scope scripts/kconfig/qconf.cc:1333: error: 'Key_S' was not declared in this scope scripts/kconfig/qconf.cc:1340: error: 'Key_F' was not declared in this scope Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2009-05-18 01:36:51 +02:00
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, name)
{
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
verticalLayout->setContentsMargins(0, 0, 0, 0);
list = new Q3ListView(this, name);
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(Q3ListViewItem* item)
{
}
void ConfigView::updateListAll(void)
{
}
ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
: Parent(parent, name), sym(0), _menu(0)
{
if (name) {
configSettings->beginGroup(name);
_showDebug = configSettings->readBoolEntry("/showDebug", false);
configSettings->endGroup();
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
}
}
void ConfigInfoView::saveSettings(void)
{
if (name()) {
configSettings->beginGroup(name());
configSettings->writeEntry("/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.find(re, i)) >= 0;) {
switch (res[i].latin1()) {
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();
action->addTo(popup);
return popup;
}
void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e)
{
Parent::contextMenuEvent(e);
}
ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name)
: Parent(parent, name), result(NULL)
{
setCaption("Search Config");
QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6);
QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 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) {
int x, y, width, height;
bool ok;
configSettings->beginGroup(name);
width = configSettings->readNumEntry("/window width", parent->width() / 2);
height = configSettings->readNumEntry("/window height", parent->height() / 2);
resize(width, height);
x = configSettings->readNumEntry("/window x", 0, &ok);
if (ok)
y = configSettings->readNumEntry("/window y", 0, &ok);
if (ok)
move(x, y);
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->writeEntry("/window x", pos().x());
configSettings->writeEntry("/window y", pos().y());
configSettings->writeEntry("/window width", size().width());
configSettings->writeEntry("/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;
int x, y, width, height;
char title[256];
QDesktopWidget *d = configApp->desktop();
snprintf(title, sizeof(title), "%s%s",
rootmenu.prompt->text,
""
);
setCaption(title);
width = configSettings->readNumEntry("/window width", d->width() - 64);
height = configSettings->readNumEntry("/window height", d->height() - 64);
resize(width, height);
x = configSettings->readNumEntry("/window x", 0, &ok);
if (ok)
y = configSettings->readNumEntry("/window y", 0, &ok);
if (ok)
move(x, y);
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
backAction->addTo(toolBar);
toolBar->addSeparator();
loadAction->addTo(toolBar);
saveAction->addTo(toolBar);
toolBar->addSeparator();
singleViewAction->addTo(toolBar);
splitViewAction->addTo(toolBar);
fullViewAction->addTo(toolBar);
// create config menu
QMenu* config = new QMenu(this);
menu->insertItem(_("&File"), config);
loadAction->addTo(config);
saveAction->addTo(config);
saveAsAction->addTo(config);
config->addSeparator();
quitAction->addTo(config);
// create edit menu
QMenu* editMenu = new QMenu(this);
menu->insertItem(_("&Edit"), editMenu);
searchAction->addTo(editMenu);
// create options menu
QMenu* optionMenu = new QMenu(this);
menu->insertItem(_("&Option"), optionMenu);
showNameAction->addTo(optionMenu);
showRangeAction->addTo(optionMenu);
showDataAction->addTo(optionMenu);
optionMenu->addSeparator();
optGroup->addTo(optionMenu);
optionMenu->addSeparator();
// create help menu
QMenu* helpMenu = new QMenu(this);
menu->addSeparator();
menu->insertItem(_("&Help"), helpMenu);
showIntroAction->addTo(helpMenu);
showAboutAction->addTo(helpMenu);
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->readEntry("/listMode", "symbol");
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(conf_get_configname(), NULL, this);
if (s.isNull())
return;
[PATCH] Kconfig i18n support This patch adds i18n support for make *config, allowing users to have the config process in their own language. No printk was harmed in the process, don't worry, so all the bug reports, kernel messages, etc, remain in english, just the user tools to configure the kernel are internationalized. Users not interested in translations can just unset the related LANG, LC_ALL, etc env variables and have the config process in plain english, something like: LANG= make menuconfig is enough for having the whole config process in english. Or just don't install any translation file. Translations for brazilian portuguese are being done by a team of volunteers at: http://www.visionflex.inf.br/kernel_ptbr/pmwiki.php/Principal/Traducoes To start the translation process: make update-po-config This will generate the pot template named scripts/kconfig/linux.pot, copy it to, say, ~/es.po, to start the translation for spanish. To test your translation, as root issue this command: msgfmt -o /usr/share/locale/es/LC_MESSAGES/linux.mo ~/es.po Replace "es" with your language code. Then execute, for instance: make menuconfig The current patch doesn't use any optimization to reduce the size of the generated .mo file, it is possible to use the config option as a key, but this doesn't prevent the current patch from being used or the translations done under the current scheme to be in any way lost if we chose to do any kind of keying. Thanks to Fabricio Vaccari for starting the pt_BR (brazilian portuguese) translation effort, Thiago Maciera for helping me with the gconf.cc (QT frontent) i18n coding and to all the volunteers that are already working on the first translation, to pt_BR. I left the question on whether to ship the translations with the stock kernel sources to be discussed here, please share your suggestions. Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org Signed-off-by: Andrew Morton <akpm@osdl.org>
2005-05-06 00:09:46 +02:00
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(conf_get_configname(), NULL, this);
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->writeEntry("/window x", pos().x());
configSettings->writeEntry("/window y", pos().y());
configSettings->writeEntry("/window width", size().width());
configSettings->writeEntry("/window height", size().height());
QString entry;
configSettings->writeEntry("/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"), progname);
exit(0);
}
int main(int ac, char** av)
{
ConfigMainWindow* v;
const char *name;
[PATCH] Kconfig i18n support This patch adds i18n support for make *config, allowing users to have the config process in their own language. No printk was harmed in the process, don't worry, so all the bug reports, kernel messages, etc, remain in english, just the user tools to configure the kernel are internationalized. Users not interested in translations can just unset the related LANG, LC_ALL, etc env variables and have the config process in plain english, something like: LANG= make menuconfig is enough for having the whole config process in english. Or just don't install any translation file. Translations for brazilian portuguese are being done by a team of volunteers at: http://www.visionflex.inf.br/kernel_ptbr/pmwiki.php/Principal/Traducoes To start the translation process: make update-po-config This will generate the pot template named scripts/kconfig/linux.pot, copy it to, say, ~/es.po, to start the translation for spanish. To test your translation, as root issue this command: msgfmt -o /usr/share/locale/es/LC_MESSAGES/linux.mo ~/es.po Replace "es" with your language code. Then execute, for instance: make menuconfig The current patch doesn't use any optimization to reduce the size of the generated .mo file, it is possible to use the config option as a key, but this doesn't prevent the current patch from being used or the translations done under the current scheme to be in any way lost if we chose to do any kind of keying. Thanks to Fabricio Vaccari for starting the pt_BR (brazilian portuguese) translation effort, Thiago Maciera for helping me with the gconf.cc (QT frontent) i18n coding and to all the volunteers that are already working on the first translation, to pt_BR. I left the question on whether to ship the translations with the stock kernel sources to be discussed here, please share your suggestions. Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org Signed-off-by: Andrew Morton <akpm@osdl.org>
2005-05-06 00:09:46 +02:00
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->setMainWidget(v);
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;
}