]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiIndices.cpp
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / GuiIndices.cpp
index a83ed88d25c33c8f0661cdb6a8f9ab1a0d474ce9..8694b98cd74184171128ceb621e881138e5a1176 100644 (file)
@@ -52,6 +52,7 @@ GuiIndices::GuiIndices(QWidget * parent)
        indicesTW->headerItem()->setText(1, qt_("Label Color"));
        indicesTW->setSortingEnabled(true);
 
+       // NOTE: we do not provide "custom" here for security reasons!
        indexCO->clear();
        indexCO->addItem(qt_("Default"), QString("default"));
        for (set<string>::const_iterator it = lyxrc.index_alternatives.begin();
@@ -59,7 +60,9 @@ GuiIndices::GuiIndices(QWidget * parent)
                QString const command = toqstr(*it).left(toqstr(*it).indexOf(" "));
                indexCO->addItem(command, command);
        }
-       indexCO->addItem(qt_("Custom"), QString("custom"));
+
+       indexOptionsLE->setValidator(new NoNewLineValidator(indexOptionsLE));
+       newIndexLE->setValidator(new NoNewLineValidator(newIndexLE));
 }
 
 void GuiIndices::update(BufferParams const & params)
@@ -82,14 +85,14 @@ void GuiIndices::update(BufferParams const & params)
        int const pos = indexCO->findData(toqstr(command));
        if (pos != -1) {
                indexCO->setCurrentIndex(pos);
-               indexOptionsED->setText(toqstr(options).trimmed());
-               indexOptionsLA->setText(qt_("&Options:"));
+               indexOptionsLE->setText(toqstr(options).trimmed());
        } else {
-               indexCO->setCurrentIndex(indexCO->findData(toqstr("custom")));
-               indexOptionsED->setText(toqstr(params.index_command));
-               indexOptionsLA->setText(qt_("Co&mmand:"));
+               // We reset to default if we do not know the specified compiler
+               // This is for security reasons
+               indexCO->setCurrentIndex(indexCO->findData(toqstr("default")));
+               indexOptionsLE->clear();
        }
-       indexOptionsED->setEnabled(
+       indexOptionsLE->setEnabled(
                indexCO->currentIndex() != 0);
 
        updateView();
@@ -145,10 +148,8 @@ void GuiIndices::apply(BufferParams & params) const
        string const index_command =
                fromqstr(indexCO->itemData(
                        indexCO->currentIndex()).toString());
-       string const index_options = fromqstr(indexOptionsED->text());
-       if (index_command == "custom")
-               params.index_command = index_options;
-       else if (index_command == "default" || index_options.empty())
+       string const index_options = fromqstr(indexOptionsLE->text());
+       if (index_command == "default" || index_options.empty())
                params.index_command = index_command;
        else
                params.index_command = index_command + " " + index_options;
@@ -157,17 +158,13 @@ void GuiIndices::apply(BufferParams & params) const
 
 void GuiIndices::on_indexCO_activated(int n)
 {
-       QString const data = indexCO->itemData(n).toString();
-       indexOptionsED->setEnabled(data != "default");
-       if (data == "custom")
-               indexOptionsLA->setText(qt_("Co&mmand:"));
-       else
-               indexOptionsLA->setText(qt_("&Options:"));
+       indexOptionsLE->setEnabled(
+               indexCO->itemData(n).toString() != "default");
        changed();
 }
 
 
-void GuiIndices::on_indexOptionsED_textChanged(QString)
+void GuiIndices::on_indexOptionsLE_textChanged(QString)
 {
        changed();
 }