#include "insets/InsetListingsParams.h"
#include "support/debug.h"
+#include "support/docstream.h"
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
+#include "support/TempFile.h"
#include "frontends/alert.h"
connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
connect(findLE, SIGNAL(textEdited(const QString &)), this, SLOT(checkFindButton()));
connect(findButtonPB, SIGNAL(clicked()), this, SLOT(findText()));
+ connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal()));
connect(findLE, SIGNAL(returnPressed()), this, SLOT(findText()));
checkFindButton();
// https://stackoverflow.com/questions/13027091/how-to-override-tab-width-in-qt
}
+void PreambleModule::editExternal() {
+ if (!current_id_)
+ return;
+
+ if (tempfile_) {
+ preambleTE->setReadOnly(false);
+ FileName const tempfilename = tempfile_->name();
+ docstring const s = tempfilename.fileContents("UTF-8");
+ preambleTE->document()->setPlainText(toqstr(s));
+ tempfile_.reset();
+ editPB->setText(qt_("Edit"));
+ changed();
+ return;
+ }
+
+ string const format =
+ current_id_->params().documentClass().outputFormat();
+ string const ext = theFormats().extension(format);
+ tempfile_.reset(new TempFile("preamble_editXXXXXX." + ext));
+ FileName const tempfilename = tempfile_->name();
+ string const name = tempfilename.toFilesystemEncoding();
+ ofdocstream os(name.c_str());
+ os << qstring_to_ucs4(preambleTE->document()->toPlainText());
+ os.close();
+ preambleTE->setReadOnly(true);
+ theFormats().edit(*current_id_, tempfilename, format);
+ editPB->setText(qt_("End Edit"));
+ changed();
+}
+
/////////////////////////////////////////////////////////////////////
//
// LocalLayout
connect(locallayoutTE, SIGNAL(textChanged()), this, SLOT(textChanged()));
connect(validatePB, SIGNAL(clicked()), this, SLOT(validatePressed()));
connect(convertPB, SIGNAL(clicked()), this, SLOT(convertPressed()));
+ connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal()));
}
}
+void LocalLayout::editExternal() {
+ if (!current_id_)
+ return;
+
+ if (tempfile_) {
+ locallayoutTE->setReadOnly(false);
+ FileName const tempfilename = tempfile_->name();
+ docstring const s = tempfilename.fileContents("UTF-8");
+ locallayoutTE->document()->setPlainText(toqstr(s));
+ tempfile_.reset();
+ editPB->setText(qt_("Edit"));
+ changed();
+ return;
+ }
+
+ string const format =
+ current_id_->params().documentClass().outputFormat();
+ string const ext = theFormats().extension(format);
+ tempfile_.reset(new TempFile("preamble_editXXXXXX." + ext));
+ FileName const tempfilename = tempfile_->name();
+ string const name = tempfilename.toFilesystemEncoding();
+ ofdocstream os(name.c_str());
+ os << qstring_to_ucs4(locallayoutTE->document()->toPlainText());
+ os.close();
+ locallayoutTE->setReadOnly(true);
+ theFormats().edit(*current_id_, tempfilename, format);
+ editPB->setText(qt_("End Edit"));
+ validatePB->setEnabled(false);
+ hideConvert();
+ changed();
+}
+
/////////////////////////////////////////////////////////////////////
//
// DocumentDialog
{
setupUi(this);
- connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
- connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
- connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
+ connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
+ this, SLOT(slotButtonBox(QAbstractButton *)));
connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
// Manage the restore, ok, apply, restore and cancel/close buttons
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
- bc().setOK(okPB);
- bc().setApply(applyPB);
- bc().setCancel(closePB);
- bc().setRestore(restorePB);
+ bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
+ bc().setApply(buttonBox->button(QDialogButtonBox::Apply));
+ bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
+ bc().setRestore(buttonBox->button(QDialogButtonBox::Reset));
// text layout
fontModule->fontsizeCO->addItem(qt_("12"));
fontModule->fontencCO->addItem(qt_("Automatic"), QString("auto"));
- fontModule->fontencCO->addItem(qt_("Class default"), QString("default"));
+ fontModule->fontencCO->addItem(qt_("Class Default"), QString("default"));
fontModule->fontencCO->addItem(qt_("Custom"), QString("custom"));
for (int n = 0; GuiDocument::fontfamilies_gui[n][0]; ++n)
docPS->addPanel(indicesModule, N_("Indexes"));
docPS->addPanel(pdfSupportModule, N_("PDF Properties"));
docPS->addPanel(mathsModule, N_("Math Options"));
- docPS->addPanel(floatModule, N_("Float Placement"));
+ docPS->addPanel(floatModule, N_("Float Settings"));
docPS->addPanel(listingsModule, N_("Listings[[inset]]"));
docPS->addPanel(bulletsModule, N_("Bullets"));
docPS->addPanel(branchesModule, N_("Branches"));
}
+void GuiDocument::slotButtonBox(QAbstractButton * button)
+{
+ switch (buttonBox->standardButton(button)) {
+ case QDialogButtonBox::Ok:
+ slotOK();
+ break;
+ case QDialogButtonBox::Apply:
+ slotApply();
+ break;
+ case QDialogButtonBox::Cancel:
+ slotClose();
+ break;
+ case QDialogButtonBox::Reset:
+ case QDialogButtonBox::RestoreDefaults:
+ slotRestore();
+ break;
+ default:
+ break;
+ }
+}
+
+
void GuiDocument::includeonlyClicked(QTreeWidgetItem * item, int)
{
if (item == 0)
return;
string const classname = fromqstr(latexModule->classCO->getData(idx));
- if (applyPB->isEnabled()) {
+ if (buttonBox->button(QDialogButtonBox::Apply)->isEnabled()) {
int const ret = Alert::prompt(_("Unapplied changes"),
_("Some changes in the dialog were not yet applied.\n"
"If you do not apply now, they will be lost after this action."),
{
modulesToParams(bp_);
- if (applyPB->isEnabled() && (nonModuleChanged_ || shellescapeChanged_)) {
+ if (buttonBox->button(QDialogButtonBox::Apply)->isEnabled()
+ && (nonModuleChanged_ || shellescapeChanged_)) {
int const ret = Alert::prompt(_("Unapplied changes"),
_("Some changes in the dialog were not yet applied.\n"
"If you do not apply now, they will be lost after this action."),
bp_.maintain_unincluded_children =
masterChildModule->maintainAuxCB->isChecked();
- // Float Placement
- bp_.float_placement = floatModule->get();
+ // Float Settings
+ bp_.float_placement = floatModule->getPlacement();
+ bp_.float_alignment = floatModule->getAlignment();
// Listings
// text should have passed validation
latexModule->refstyleCB->setChecked(bp_.use_refstyle);
// biblio
- string const cite_engine = bp_.citeEngine().list().front();
+ string const cite_engine = bp_.citeEngine();
biblioModule->citeEngineCO->setCurrentIndex(
biblioModule->citeEngineCO->findData(toqstr(cite_engine)));
bp_.maintain_unincluded_children);
// Float Settings
- floatModule->set(bp_.float_placement);
+ floatModule->setPlacement(bp_.float_placement);
+ floatModule->setAlignment(bp_.float_alignment);
// ListingsSettings
// break listings_params to multiple lines
void GuiDocument::useClassDefaults()
{
- if (applyPB->isEnabled()) {
+ if (buttonBox->button(QDialogButtonBox::Apply)->isEnabled()) {
int const ret = Alert::prompt(_("Unapplied changes"),
_("Some changes in the dialog were not yet applied.\n"
"If you do not apply now, they will be lost after this action."),
return
validateListingsParameters().isEmpty() &&
localLayout->isValid() &&
+ !localLayout->editing() &&
+ !preambleModule->editing() &&
(
// if we're asking for skips between paragraphs
!textLayoutModule->skipRB->isChecked() ||