mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
parent
2d02c39d56
commit
3847e0ef77
@ -59,11 +59,13 @@
|
|||||||
#include "insets/InsetListingsParams.h"
|
#include "insets/InsetListingsParams.h"
|
||||||
|
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
|
#include "support/docstream.h"
|
||||||
#include "support/FileName.h"
|
#include "support/FileName.h"
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
#include "support/TempFile.h"
|
||||||
|
|
||||||
#include "frontends/alert.h"
|
#include "frontends/alert.h"
|
||||||
|
|
||||||
@ -472,6 +474,7 @@ PreambleModule::PreambleModule(QWidget * parent)
|
|||||||
connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
|
connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
|
||||||
connect(findLE, SIGNAL(textEdited(const QString &)), this, SLOT(checkFindButton()));
|
connect(findLE, SIGNAL(textEdited(const QString &)), this, SLOT(checkFindButton()));
|
||||||
connect(findButtonPB, SIGNAL(clicked()), this, SLOT(findText()));
|
connect(findButtonPB, SIGNAL(clicked()), this, SLOT(findText()));
|
||||||
|
connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal()));
|
||||||
connect(findLE, SIGNAL(returnPressed()), this, SLOT(findText()));
|
connect(findLE, SIGNAL(returnPressed()), this, SLOT(findText()));
|
||||||
checkFindButton();
|
checkFindButton();
|
||||||
// https://stackoverflow.com/questions/13027091/how-to-override-tab-width-in-qt
|
// https://stackoverflow.com/questions/13027091/how-to-override-tab-width-in-qt
|
||||||
@ -546,6 +549,36 @@ void PreambleModule::closeEvent(QCloseEvent * e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
// LocalLayout
|
||||||
@ -561,6 +594,7 @@ LocalLayout::LocalLayout(QWidget * parent)
|
|||||||
connect(locallayoutTE, SIGNAL(textChanged()), this, SLOT(textChanged()));
|
connect(locallayoutTE, SIGNAL(textChanged()), this, SLOT(textChanged()));
|
||||||
connect(validatePB, SIGNAL(clicked()), this, SLOT(validatePressed()));
|
connect(validatePB, SIGNAL(clicked()), this, SLOT(validatePressed()));
|
||||||
connect(convertPB, SIGNAL(clicked()), this, SLOT(convertPressed()));
|
connect(convertPB, SIGNAL(clicked()), this, SLOT(convertPressed()));
|
||||||
|
connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -685,6 +719,38 @@ void LocalLayout::validatePressed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
// DocumentDialog
|
||||||
@ -4262,6 +4328,8 @@ bool GuiDocument::isValid()
|
|||||||
return
|
return
|
||||||
validateListingsParameters().isEmpty() &&
|
validateListingsParameters().isEmpty() &&
|
||||||
localLayout->isValid() &&
|
localLayout->isValid() &&
|
||||||
|
!localLayout->editing() &&
|
||||||
|
!preambleModule->editing() &&
|
||||||
(
|
(
|
||||||
// if we're asking for skips between paragraphs
|
// if we're asking for skips between paragraphs
|
||||||
!textLayoutModule->skipRB->isChecked() ||
|
!textLayoutModule->skipRB->isChecked() ||
|
||||||
|
@ -44,6 +44,10 @@ class LayoutModuleList;
|
|||||||
class LyXModule;
|
class LyXModule;
|
||||||
class TextClass;
|
class TextClass;
|
||||||
|
|
||||||
|
namespace support {
|
||||||
|
class TempFile;
|
||||||
|
}
|
||||||
|
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
class FloatPlacement;
|
class FloatPlacement;
|
||||||
@ -55,7 +59,7 @@ class LocalLayout;
|
|||||||
class FontModule;
|
class FontModule;
|
||||||
|
|
||||||
///
|
///
|
||||||
typedef void const * BufferId;
|
typedef Buffer const * BufferId;
|
||||||
|
|
||||||
template<class UI>
|
template<class UI>
|
||||||
class UiWidget : public QWidget, public UI
|
class UiWidget : public QWidget, public UI
|
||||||
@ -323,6 +327,7 @@ public:
|
|||||||
PreambleModule(QWidget * parent);
|
PreambleModule(QWidget * parent);
|
||||||
void update(BufferParams const & params, BufferId id);
|
void update(BufferParams const & params, BufferId id);
|
||||||
void apply(BufferParams & params);
|
void apply(BufferParams & params);
|
||||||
|
bool editing() const { return (bool)tempfile_; }
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/// signal that something's changed in the Widget.
|
/// signal that something's changed in the Widget.
|
||||||
@ -335,11 +340,13 @@ private:
|
|||||||
typedef std::map<BufferId, std::pair<int,int> > Coords;
|
typedef std::map<BufferId, std::pair<int,int> > Coords;
|
||||||
Coords preamble_coords_;
|
Coords preamble_coords_;
|
||||||
BufferId current_id_;
|
BufferId current_id_;
|
||||||
|
unique_ptr<support::TempFile> tempfile_;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
///
|
///
|
||||||
void checkFindButton();
|
void checkFindButton();
|
||||||
void findText();
|
void findText();
|
||||||
|
void editExternal();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -351,6 +358,7 @@ public:
|
|||||||
void update(BufferParams const & params, BufferId id);
|
void update(BufferParams const & params, BufferId id);
|
||||||
void apply(BufferParams & params);
|
void apply(BufferParams & params);
|
||||||
bool isValid() const { return validated_; }
|
bool isValid() const { return validated_; }
|
||||||
|
bool editing() const { return (bool)tempfile_; }
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/// signal that something's changed in the Widget.
|
/// signal that something's changed in the Widget.
|
||||||
@ -364,10 +372,12 @@ private Q_SLOTS:
|
|||||||
void textChanged();
|
void textChanged();
|
||||||
void validatePressed();
|
void validatePressed();
|
||||||
void convertPressed();
|
void convertPressed();
|
||||||
|
void editExternal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BufferId current_id_;
|
BufferId current_id_;
|
||||||
bool validated_;
|
bool validated_;
|
||||||
|
unique_ptr<support::TempFile> tempfile_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>LocalLayoutUi</class>
|
<class>LocalLayoutUi</class>
|
||||||
<widget class="QWidget" name="LocalLayoutUi">
|
<widget class="QWidget" name="LocalLayoutUi">
|
||||||
@ -13,53 +14,7 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="3" column="2">
|
||||||
<widget class="QTextEdit" name="locallayoutTE">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Document-specific layout information</string>
|
|
||||||
</property>
|
|
||||||
<property name="statusTip">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="acceptRichText">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QPushButton" name="validatePB">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>&Validate</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLabel" name="validLB">
|
|
||||||
<property name="contextMenuPolicy">
|
|
||||||
<enum>Qt::NoContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Errors reported in terminal.</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QPushButton" name="convertPB">
|
|
||||||
<property name="text">
|
|
||||||
<string>Convert</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLabel" name="convertLB">
|
<widget class="QLabel" name="convertLB">
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::NoContextMenu</enum>
|
<enum>Qt::NoContextMenu</enum>
|
||||||
@ -75,6 +30,59 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QPushButton" name="convertPB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Convert</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QLabel" name="validLB">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::NoContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Errors reported in terminal.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QPushButton" name="editPB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Edit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QPushButton" name="validatePB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Validate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" rowspan="2" colspan="3">
|
||||||
|
<widget class="QTextEdit" name="locallayoutTE">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Document-specific layout information</string>
|
||||||
|
</property>
|
||||||
|
<property name="statusTip">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="acceptRichText">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<includes>
|
<includes>
|
||||||
|
@ -39,7 +39,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="1" column="2">
|
||||||
|
<widget class="QPushButton" name="editPB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Edit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="3">
|
||||||
<widget class="QTextEdit" name="preambleTE">
|
<widget class="QTextEdit" name="preambleTE">
|
||||||
<property name="acceptRichText">
|
<property name="acceptRichText">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
Loading…
Reference in New Issue
Block a user