#include "Buffer.h"
#include "BufferParams.h"
#include "CiteEnginesList.h"
+#include "Encoding.h"
#include "FuncRequest.h"
#include "LyXRC.h"
#include "qt_helpers.h"
#include "support/gettext.h"
#include "support/lstrings.h"
+#include <QDialogButtonBox>
#include <QPushButton>
#include <QListWidget>
#include <QCheckBox>
QDialog::setModal(true);
setWindowModality(Qt::WindowModal);
- connect(okPB, SIGNAL(clicked()),
- this, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()),
- this, SLOT(slotClose()));
+ connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
+ this, SLOT(slotButtonBox(QAbstractButton *)));
connect(stylePB, SIGNAL(clicked()),
this, SLOT(browsePressed()));
connect(deletePB, SIGNAL(clicked()),
this, SLOT(rescanClicked()));
connect(biblatexOptsLE, SIGNAL(textChanged(QString)),
this, SLOT(change_adaptor()));
+ connect(bibEncodingCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
add_ = new GuiBibtexAddDialog(this);
add_bc_.setPolicy(ButtonPolicy::OkCancelPolicy);
- add_bc_.setOK(add_->addPB);
- add_bc_.setCancel(add_->closePB);
+ add_bc_.setOK(add_->buttonBox->button(QDialogButtonBox::Ok));
+ add_bc_.setCancel(add_->buttonBox->button(QDialogButtonBox::Cancel));
add_bc_.addCheckedLineEdit(add_->bibED, 0);
connect(add_->bibED, SIGNAL(textChanged(QString)),
this, SLOT(bibEDChanged()));
- connect(add_->addPB, SIGNAL(clicked()),
- this, SLOT(addDatabase()));
- connect(add_->addPB, SIGNAL(clicked()),
- add_, SLOT(accept()));
+ connect(add_->buttonBox, SIGNAL(clicked(QAbstractButton *)),
+ this, SLOT(addBBClicked(QAbstractButton *)));
connect(add_->rescanPB, SIGNAL(clicked()),
this, SLOT(rescanClicked()));
connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
this, SLOT(availableChanged()));
connect(add_->browsePB, SIGNAL(clicked()),
this, SLOT(browseBibPressed()));
- connect(add_->closePB, SIGNAL(clicked()),
- add_, SLOT(reject()));
add_->bibLW->setToolTip(formatToolTip(qt_("This list consists of all databases that are indexed by LaTeX and thus are found without a file path. "
"This is usually everything in the bib/ subdirectory of LaTeX's texmf tree. "
"If you want to reuse your own database, this is the place you should store it.")));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
- bc().setOK(okPB);
- bc().setCancel(closePB);
+ bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
+ bc().setApply(buttonBox->button(QDialogButtonBox::Apply));
+ bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
bc().addReadOnly(databaseLW);
bc().addReadOnly(stylePB);
bc().addReadOnly(styleCB);
bc().addReadOnly(bibtocCB);
bc().addReadOnly(addBibPB);
+ bc().addReadOnly(bibEncodingCO);
// Delete/Up/Down are handled with more conditions in
// databaseChanged().
+ // Always put the default encoding in the first position.
+ bibEncodingCO->addItem(qt_("Document Encoding"), "default");
+ QMap<QString, QString> encodinglist;
+ for (auto const & encvar : encodings) {
+ if (!encvar.unsafe() && !encvar.guiName().empty())
+ encodinglist.insert(qt_(encvar.guiName()), toqstr(encvar.name()));
+ }
+ QMap<QString, QString>::const_iterator it = encodinglist.constBegin();
+ while (it != encodinglist.constEnd()) {
+ bibEncodingCO->addItem(it.key(), it.value());
+ ++it;
+ }
+
// Make sure the delete/up/down buttons are disabled if necessary.
databaseChanged();
}
+void GuiBibtex::addBBClicked(QAbstractButton * button)
+{
+ switch (add_->buttonBox->standardButton(button)) {
+ case QDialogButtonBox::Ok:
+ addDatabase();
+ add_->accept();
+ break;
+ case QDialogButtonBox::Cancel:
+ add_->reject();
+ break;
+ default:
+ break;
+ }
+}
+
+
void GuiBibtex::bibEDChanged()
{
// Indicate to the button controller that the contents have
btprint = from_ascii("btPrintCited");
btPrintCO->setCurrentIndex(btPrintCO->findData(toqstr(btprint)));
+ docstring encoding = params_["encoding"];
+ if (encoding.empty())
+ // default
+ encoding = from_ascii("default");
+ bibEncodingCO->setCurrentIndex(bibEncodingCO->findData(toqstr(encoding)));
+
// Only useful for biblatex
biblatexOptsLA->setVisible(biblatex);
biblatexOptsLE->setVisible(biblatex);
// only useful for BibTeX
- styleCB->setVisible(!biblatex);
- styleLA->setVisible(!biblatex);
- stylePB->setVisible(!biblatex);
+ bstGB->setVisible(!biblatex);
if (!biblatex) {
styleCB->clear();
params_["biblatexopts"] = qstring_to_ucs4(biblatexOptsLE->text());
params_["btprint"] = qstring_to_ucs4(btPrintCO->itemData(btPrintCO->currentIndex()).toString());
+
+ params_["encoding"] = qstring_to_ucs4(bibEncodingCO->itemData(bibEncodingCO->currentIndex()).toString());
}