]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiExternal.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiExternal.cpp
index 65790327bb88b7f20b7886074d31743620c3d8fc..7be6be0954a69e49f330522003ee9bf7b00fc34d 100644 (file)
@@ -80,7 +80,7 @@ char const * const origin_gui_strs[] = {
        N_("Top right"), N_("Bottom right"), N_("Baseline right")
 };
 
-} // namespace anon
+} // namespace
 
 
 GuiExternal::GuiExternal(GuiView & lv)
@@ -88,9 +88,8 @@ GuiExternal::GuiExternal(GuiView & lv)
 {
        setupUi(this);
 
-       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
-       connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
-       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
+       connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
+                       this, SLOT(slotButtonBox(QAbstractButton *)));
 
        /*
        connect(displayGB, SIGNAL(toggled(bool)),
@@ -159,9 +158,9 @@ GuiExternal::GuiExternal(GuiView & lv)
 
        bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
 
-       bc().setOK(okPB);
-       bc().setApply(applyPB);
-       bc().setCancel(closePB);
+       bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
+       bc().setApply(buttonBox->button(QDialogButtonBox::Apply));
+       bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
 
        bc().addReadOnly(fileED);
        bc().addReadOnly(browsePB);
@@ -202,10 +201,16 @@ GuiExternal::GuiExternal(GuiView & lv)
        external::TemplateManager::Templates::const_iterator i1, i2;
        i1 = external::TemplateManager::get().getTemplates().begin();
        i2 = external::TemplateManager::get().getTemplates().end();
+       QMap<QString, QString> localizedTemplates;
        for (; i1 != i2; ++i1)
-               externalCO->addItem(qt_(i1->second.guiName), toqstr(i1->second.lyxName));
-       // Sort alphabetically by(localized) GUI name
-       externalCO->model()->sort(0);
+               localizedTemplates.insert(qt_(i1->second.guiName), toqstr(i1->second.lyxName));
+       // Sort alphabetically by (localized) GUI name
+       QStringList keys = localizedTemplates.keys();
+       qSort(keys.begin(), keys.end(), SortLocaleAware);
+       for (QString & key : keys) {
+               QString const value = localizedTemplates[key];
+               externalCO->addItem(key, value);
+       }
 
        // Fill the origins combo
        for (size_t i = 0; i != sizeof(origins) / sizeof(origins[0]); ++i)
@@ -487,6 +492,9 @@ static void getCrop(external::ClipData & data,
 
 void GuiExternal::updateContents()
 {
+       if (params_.filename.empty())
+               tab->setCurrentIndex(0);
+
        string const name =
                params_.filename.outputFileName(fromqstr(bufferFilePath()));
        fileED->setText(toqstr(name));
@@ -525,7 +533,10 @@ void GuiExternal::updateTemplate()
                external::TemplateManager::get();
        external::Template const * const templ = etm.getTemplateByName(
                fromqstr(externalCO->itemData(externalCO->currentIndex()).toString()));
-       externalTB->setPlainText(toqstr(translateIfPossible(templ->helpText)));
+       externalTB->setPlainText(toqstr(translateIfPossible(
+                               templ ? templ->helpText : docstring())));
+       if (!templ)
+               return;
 
        // Ascertain which (if any) transformations the template supports
        // and disable tabs and Group Boxes hosting unsupported transforms.
@@ -617,9 +628,9 @@ void GuiExternal::applyView()
 }
 
 
-bool GuiExternal::initialiseParams(string const & data)
+bool GuiExternal::initialiseParams(string const & sdata)
 {
-       InsetExternal::string2params(data, buffer(), params_);
+       InsetExternal::string2params(sdata, buffer(), params_);
        return true;
 }
 
@@ -663,7 +674,7 @@ QString GuiExternal::browse(QString const & input,
        QString const bufpath = bufferFilePath();
        QStringList const filter = templateFilters(template_name);
 
-       QString const label1 = qt_("Documents|#o#O");
+       QString const label1 = qt_("D&ocuments");
        QString const dir1 = toqstr(lyxrc.document_path);
 
        return browseRelToParent(input, bufpath, title, filter, false, label1, dir1);