ALSA: usb-audio: add support for Akai MPD16
[safe/jmp/linux-2.6] / scripts / kconfig / qconf.cc
index c0ae0a7..00c5150 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <qapplication.h>
 #include <qmainwindow.h>
+#include <qdesktopwidget.h>
 #include <qtoolbar.h>
 #include <qlayout.h>
 #include <qvbox.h>
@@ -89,6 +90,7 @@ void ConfigItem::okRename(int col)
 {
        Parent::okRename(col);
        sym_set_string_value(menu->sym, text(dataColIdx).latin1());
+       listView()->updateList(this);
 }
 #endif
 
@@ -113,7 +115,7 @@ void ConfigItem::updateMenu(void)
 
        sym = menu->sym;
        prop = menu->prompt;
-       prompt = QString::fromLocal8Bit(menu_get_prompt(menu));
+       prompt = _(menu_get_prompt(menu));
 
        if (prop) switch (prop->type) {
        case P_MENU:
@@ -207,7 +209,7 @@ void ConfigItem::updateMenu(void)
                break;
        }
        if (!sym_has_value(sym) && visible)
-               prompt += " (NEW)";
+               prompt += _(" (NEW)");
 set_prompt:
        setText(promptColIdx, prompt);
 }
@@ -296,10 +298,10 @@ void ConfigLineEdit::show(ConfigItem* i)
 void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
 {
        switch (e->key()) {
-       case Key_Escape:
+       case Qt::Key_Escape:
                break;
-       case Key_Return:
-       case Key_Enter:
+       case Qt::Key_Return:
+       case Qt::Key_Enter:
                sym_set_string_value(item->menu->sym, text().latin1());
                parent()->updateList(item);
                break;
@@ -345,7 +347,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
 
        for (i = 0; i < colNr; i++)
                colMap[i] = colRevMap[i] = -1;
-       addColumn(promptColIdx, "Option");
+       addColumn(promptColIdx, _("Option"));
 
        reinit();
 }
@@ -359,14 +361,14 @@ void ConfigList::reinit(void)
        removeColumn(nameColIdx);
 
        if (showName)
-               addColumn(nameColIdx, "Name");
+               addColumn(nameColIdx, _("Name"));
        if (showRange) {
                addColumn(noColIdx, "N");
                addColumn(modColIdx, "M");
                addColumn(yesColIdx, "Y");
        }
        if (showData)
-               addColumn(dataColIdx, "Value");
+               addColumn(dataColIdx, _("Value"));
 
        updateListAll();
 }
@@ -605,6 +607,8 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
 
                visible = menu_is_visible(child);
                if (showAll || visible) {
+                       if (!child->sym && !child->list && !child->prompt)
+                               continue;
                        if (!item || item->menu != child)
                                item = new ConfigItem(parent, last, child, visible);
                        else
@@ -636,7 +640,7 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
        struct menu *menu;
        enum prop_type type;
 
-       if (ev->key() == Key_Escape && mode != fullMode && mode != listMode) {
+       if (ev->key() == Qt::Key_Escape && mode != fullMode && mode != listMode) {
                emit parentSelected();
                ev->accept();
                return;
@@ -649,8 +653,8 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
        item = (ConfigItem*)i;
 
        switch (ev->key()) {
-       case Key_Return:
-       case Key_Enter:
+       case Qt::Key_Return:
+       case Qt::Key_Enter:
                if (item->goParent) {
                        emit parentSelected();
                        break;
@@ -664,16 +668,16 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
                        emit menuSelected(menu);
                        break;
                }
-       case Key_Space:
+       case Qt::Key_Space:
                changeValue(item);
                break;
-       case Key_N:
+       case Qt::Key_N:
                setValue(item, no);
                break;
-       case Key_M:
+       case Qt::Key_M:
                setValue(item, mod);
                break;
-       case Key_Y:
+       case Qt::Key_Y:
                setValue(item, yes);
                break;
        default:
@@ -800,7 +804,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                        QAction *action;
 
                        headerPopup = new QPopupMenu(this);
-                       action = new QAction(NULL, "Show Name", 0, this);
+                       action = new QAction(NULL, _("Show Name"), 0, this);
                          action->setToggleAction(TRUE);
                          connect(action, SIGNAL(toggled(bool)),
                                  parent(), SLOT(setShowName(bool)));
@@ -808,7 +812,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                                  action, SLOT(setOn(bool)));
                          action->setOn(showName);
                          action->addTo(headerPopup);
-                       action = new QAction(NULL, "Show Range", 0, this);
+                       action = new QAction(NULL, _("Show Range"), 0, this);
                          action->setToggleAction(TRUE);
                          connect(action, SIGNAL(toggled(bool)),
                                  parent(), SLOT(setShowRange(bool)));
@@ -816,7 +820,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                                  action, SLOT(setOn(bool)));
                          action->setOn(showRange);
                          action->addTo(headerPopup);
-                       action = new QAction(NULL, "Show Data", 0, this);
+                       action = new QAction(NULL, _("Show Data"), 0, this);
                          action->setToggleAction(TRUE);
                          connect(action, SIGNAL(toggled(bool)),
                                  parent(), SLOT(setShowData(bool)));
@@ -917,7 +921,7 @@ void ConfigView::updateListAll(void)
 }
 
 ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
-       : Parent(parent, name), menu(0), sym(0)
+       : Parent(parent, name), sym(0), menu(0)
 {
        if (name) {
                configSettings->beginGroup(name);
@@ -1038,7 +1042,10 @@ void ConfigInfoView::menuInfo(void)
                if (showDebug())
                        debug = debug_info(sym);
 
-               help = print_filter(_(sym->help));
+               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));
@@ -1080,7 +1087,11 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
                        debug += "</a><br>";
                        break;
                case P_DEFAULT:
-                       debug += "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;
@@ -1091,16 +1102,6 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
                                debug += "<br>";
                        }
                        break;
-               case P_SELECT:
-                       debug += "select: ";
-                       expr_print(prop->expr, expr_print_help, &debug, E_NONE);
-                       debug += "<br>";
-                       break;
-               case P_RANGE:
-                       debug += "range: ";
-                       expr_print(prop->expr, expr_print_help, &debug, E_NONE);
-                       debug += "<br>";
-                       break;
                default:
                        debug += "unknown property: ";
                        debug += prop_get_type_name(prop->type);
@@ -1164,7 +1165,7 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
 QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
 {
        QPopupMenu* popup = Parent::createPopupMenu(pos);
-       QAction* action = new QAction(NULL,"Show Debug Info", 0, popup);
+       QAction* action = new QAction(NULL, _("Show Debug Info"), 0, popup);
          action->setToggleAction(TRUE);
          connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
          connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
@@ -1179,30 +1180,33 @@ void ConfigInfoView::contentsContextMenuEvent(QContextMenuEvent *e)
        Parent::contentsContextMenuEvent(e);
 }
 
-ConfigSearchWindow::ConfigSearchWindow(QWidget* parent, const char *name)
+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));
+       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 = 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(QSplitter::Vertical);
+       split->setOrientation(Qt::Vertical);
        list = new ConfigView(split, name);
        list->list->mode = listMode;
        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) {
@@ -1247,6 +1251,7 @@ void ConfigSearchWindow::search(void)
 
        free(result);
        list->list->clear();
+       info->clear();
 
        result = sym_re_search(editField->text().latin1());
        if (!result)
@@ -1267,8 +1272,12 @@ ConfigMainWindow::ConfigMainWindow(void)
        QMenuBar* menu;
        bool ok;
        int x, y, width, height;
+       char title[256];
 
-       QWidget *d = configApp->desktop();
+       QDesktopWidget *d = configApp->desktop();
+       snprintf(title, sizeof(title), _("Linux Kernel v%s Configuration"),
+               getenv("KERNELVERSION"));
+       setCaption(title);
 
        width = configSettings->readNumEntry("/window width", d->width() - 64);
        height = configSettings->readNumEntry("/window height", d->height() - 64);
@@ -1280,14 +1289,14 @@ ConfigMainWindow::ConfigMainWindow(void)
                move(x, y);
 
        split1 = new QSplitter(this);
-       split1->setOrientation(QSplitter::Horizontal);
+       split1->setOrientation(Qt::Horizontal);
        setCentralWidget(split1);
 
        menuView = new ConfigView(split1, "menu");
        menuList = menuView->list;
 
        split2 = new QSplitter(split1);
-       split2->setOrientation(QSplitter::Vertical);
+       split2->setOrientation(Qt::Vertical);
 
        // create config tree
        configView = new ConfigView(split2, "config");
@@ -1302,58 +1311,58 @@ ConfigMainWindow::ConfigMainWindow(void)
        menu = menuBar();
        toolBar = new QToolBar("Tools", this);
 
-       backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this);
+       backAction = new QAction("Back", QPixmap(xpm_back), _("Back"), 0, this);
          connect(backAction, SIGNAL(activated()), SLOT(goBack()));
          backAction->setEnabled(FALSE);
-       QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this);
+       QAction *quitAction = new QAction("Quit", _("&Quit"), Qt::CTRL + Qt::Key_Q, this);
          connect(quitAction, SIGNAL(activated()), SLOT(close()));
-       QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this);
+       QAction *loadAction = new QAction("Load", QPixmap(xpm_load), _("&Load"), Qt::CTRL + Qt::Key_L, this);
          connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
-       saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this);
+       saveAction = new QAction("Save", QPixmap(xpm_save), _("&Save"), Qt::CTRL + Qt::Key_S, this);
          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...", "Save &As...", 0, this);
+       QAction *saveAsAction = new QAction("Save As...", _("Save &As..."), 0, this);
          connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
-       QAction *searchAction = new QAction("Search", "&Search", CTRL+Key_F, this);
+       QAction *searchAction = new QAction("Find", _("&Find"), Qt::CTRL + Qt::Key_F, this);
          connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
-       QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this);
+       QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
          connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
-       QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this);
+       QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
          connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
-       QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this);
+       QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
          connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
 
-       QAction *showNameAction = new QAction(NULL, "Show Name", 0, this);
+       QAction *showNameAction = new QAction(NULL, _("Show Name"), 0, this);
          showNameAction->setToggleAction(TRUE);
          connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
          connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool)));
          showNameAction->setOn(configView->showName());
-       QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this);
+       QAction *showRangeAction = new QAction(NULL, _("Show Range"), 0, this);
          showRangeAction->setToggleAction(TRUE);
          connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
          connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool)));
          showRangeAction->setOn(configList->showRange);
-       QAction *showDataAction = new QAction(NULL, "Show Data", 0, this);
+       QAction *showDataAction = new QAction(NULL, _("Show Data"), 0, this);
          showDataAction->setToggleAction(TRUE);
          connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
          connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
          showDataAction->setOn(configList->showData);
-       QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this);
+       QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this);
          showAllAction->setToggleAction(TRUE);
          connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool)));
          connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool)));
          showAllAction->setOn(configList->showAll);
-       QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this);
+       QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this);
          showDebugAction->setToggleAction(TRUE);
          connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
          connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
          showDebugAction->setOn(helpText->showDebug());
 
-       QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this);
+       QAction *showIntroAction = new QAction(NULL, _("Introduction"), 0, this);
          connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
-       QAction *showAboutAction = new QAction(NULL, "About", 0, this);
+       QAction *showAboutAction = new QAction(NULL, _("About"), 0, this);
          connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
 
        // init tool bar
@@ -1368,18 +1377,21 @@ ConfigMainWindow::ConfigMainWindow(void)
 
        // create config menu
        QPopupMenu* config = new QPopupMenu(this);
-       menu->insertItem("&File", config);
+       menu->insertItem(_("&File"), config);
        loadAction->addTo(config);
        saveAction->addTo(config);
        saveAsAction->addTo(config);
        config->insertSeparator();
-       searchAction->addTo(config);
-       config->insertSeparator();
        quitAction->addTo(config);
 
+       // create edit menu
+       QPopupMenu* editMenu = new QPopupMenu(this);
+       menu->insertItem(_("&Edit"), editMenu);
+       searchAction->addTo(editMenu);
+
        // create options menu
        QPopupMenu* optionMenu = new QPopupMenu(this);
-       menu->insertItem("&Option", optionMenu);
+       menu->insertItem(_("&Option"), optionMenu);
        showNameAction->addTo(optionMenu);
        showRangeAction->addTo(optionMenu);
        showDataAction->addTo(optionMenu);
@@ -1390,7 +1402,7 @@ ConfigMainWindow::ConfigMainWindow(void)
        // create help menu
        QPopupMenu* helpMenu = new QPopupMenu(this);
        menu->insertSeparator();
-       menu->insertItem("&Help", helpMenu);
+       menu->insertItem(_("&Help"), helpMenu);
        showIntroAction->addTo(helpMenu);
        showAboutAction->addTo(helpMenu);
 
@@ -1434,27 +1446,27 @@ ConfigMainWindow::ConfigMainWindow(void)
 
 void ConfigMainWindow::loadConfig(void)
 {
-       QString s = QFileDialog::getOpenFileName(".config", NULL, this);
+       QString s = QFileDialog::getOpenFileName(conf_get_configname(), NULL, this);
        if (s.isNull())
                return;
        if (conf_read(QFile::encodeName(s)))
-               QMessageBox::information(this, "qconf", "Unable to load configuration!");
+               QMessageBox::information(this, "qconf", _("Unable to load configuration!"));
        ConfigView::updateListAll();
 }
 
 void ConfigMainWindow::saveConfig(void)
 {
        if (conf_write(NULL))
-               QMessageBox::information(this, "qconf", "Unable to save configuration!");
+               QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
 }
 
 void ConfigMainWindow::saveConfigAs(void)
 {
-       QString s = QFileDialog::getSaveFileName(".config", NULL, this);
+       QString s = QFileDialog::getSaveFileName(conf_get_configname(), NULL, this);
        if (s.isNull())
                return;
        if (conf_write(QFile::encodeName(s)))
-               QMessageBox::information(this, "qconf", "Unable to save configuration!");
+               QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
 }
 
 void ConfigMainWindow::searchConfig(void)
@@ -1467,7 +1479,10 @@ void ConfigMainWindow::searchConfig(void)
 void ConfigMainWindow::changeMenu(struct menu *menu)
 {
        configList->setRootMenu(menu);
-       backAction->setEnabled(TRUE);
+       if (configList->rootEntry->parent == &rootmenu)
+               backAction->setEnabled(FALSE);
+       else
+               backAction->setEnabled(TRUE);
 }
 
 void ConfigMainWindow::setMenuLink(struct menu *menu)
@@ -1508,6 +1523,8 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
        case fullMode:
                list = configList;
                break;
+       default:
+               break;
        }
 
        if (list) {
@@ -1595,11 +1612,11 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
                e->accept();
                return;
        }
-       QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning,
+       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");
+       mb.setButtonText(QMessageBox::Yes, _("&Save Changes"));
+       mb.setButtonText(QMessageBox::No, _("&Discard Changes"));
+       mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
        switch (mb.exec()) {
        case QMessageBox::Yes:
                conf_write(NULL);
@@ -1614,7 +1631,7 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
 
 void ConfigMainWindow::showIntro(void)
 {
-       static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n"
+       static const QString str = _("Welcome to the qconf graphical kernel configuration tool for Linux.\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"
@@ -1624,15 +1641,15 @@ void ConfigMainWindow::showIntro(void)
                "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";
+               "which you can then match by examining other options.\n\n");
 
        QMessageBox::information(this, "qconf", str);
 }
 
 void ConfigMainWindow::showAbout(void)
 {
-       static char 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";
+       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);
 }
@@ -1657,6 +1674,9 @@ void ConfigMainWindow::saveSettings(void)
        case fullMode :
                entry = "full";
                break;
+
+       default:
+               break;
        }
        configSettings->writeEntry("/listMode", entry);
 
@@ -1690,7 +1710,7 @@ static const char *progname;
 
 static void usage(void)
 {
-       printf("%s <config>\n", progname);
+       printf(_("%s <config>\n"), progname);
        exit(0);
 }