mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Fix bug 4475.
Add ability to create child from the include dialog.
(cherry picked from commit a385b7dc2b
)
This commit is contained in:
parent
1c21beb14c
commit
3a7560dcb0
@ -32,6 +32,7 @@
|
||||
#include "insets/InsetInclude.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QFile>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
@ -265,6 +266,61 @@ void GuiInclude::applyView()
|
||||
else
|
||||
params_.setCmdName("verbatiminput");
|
||||
}
|
||||
|
||||
// Do we need to create a LyX file?
|
||||
if (item == 0 || item == 1) {
|
||||
QString fname = filenameED->text();
|
||||
string const mypath = buffer().absFileName();
|
||||
string const bpath = buffer().filePath();
|
||||
QString absfname = makeAbsPath(fname, toqstr(bpath));
|
||||
if (!QFile::exists(absfname)) {
|
||||
dispatch(FuncRequest(LFUN_BUFFER_NEW, fromqstr(absfname)));
|
||||
dispatch(FuncRequest(LFUN_BUFFER_WRITE));
|
||||
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, mypath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GuiInclude::edit()
|
||||
{
|
||||
if (!isValid())
|
||||
return;
|
||||
if (bc().policy().buttonStatus(ButtonPolicy::OKAY)) {
|
||||
slotOK();
|
||||
applyView();
|
||||
} else
|
||||
hideView();
|
||||
dispatch(FuncRequest(LFUN_INSET_EDIT));
|
||||
}
|
||||
|
||||
|
||||
bool GuiInclude::isValid()
|
||||
{
|
||||
QString fname = filenameED->text();
|
||||
bool fempty = fname.isEmpty();
|
||||
if (fempty || !validate_listings_params().empty()) {
|
||||
editPB->setEnabled(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
int const item = typeCO->currentIndex();
|
||||
// Are we inputting or including a LyX file?
|
||||
if (item != 0 && item != 1) {
|
||||
okPB->setText("OK");
|
||||
return true;
|
||||
}
|
||||
// Do we have a LyX filename?
|
||||
if (!support::isLyXFileName(fromqstr(fname))) {
|
||||
okPB->setText("OK");
|
||||
return false;
|
||||
}
|
||||
string const bpath = buffer().filePath();
|
||||
QString absfname = makeAbsPath(fname, toqstr(bpath));
|
||||
bool const fexists = QFile::exists(absfname);
|
||||
okPB->setText(fexists ? "OK" : "Create");
|
||||
editPB->setEnabled(fexists);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -288,25 +344,6 @@ void GuiInclude::browse()
|
||||
}
|
||||
|
||||
|
||||
void GuiInclude::edit()
|
||||
{
|
||||
if (!isValid())
|
||||
return;
|
||||
if (bc().policy().buttonStatus(ButtonPolicy::OKAY)) {
|
||||
slotOK();
|
||||
applyView();
|
||||
} else
|
||||
hideView();
|
||||
dispatch(FuncRequest(LFUN_INSET_EDIT));
|
||||
}
|
||||
|
||||
|
||||
bool GuiInclude::isValid()
|
||||
{
|
||||
return !filenameED->text().isEmpty() && validate_listings_params().empty();
|
||||
}
|
||||
|
||||
|
||||
QString GuiInclude::browse(QString const & in_name, Type in_type) const
|
||||
{
|
||||
QString const title = qt_("Select document to include");
|
||||
|
@ -1,58 +1,73 @@
|
||||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>IncludeUi</class>
|
||||
<widget class="QDialog" name="IncludeUi" >
|
||||
<property name="geometry" >
|
||||
<widget class="QDialog" name="IncludeUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>371</width>
|
||||
<height>374</height>
|
||||
<width>440</width>
|
||||
<height>442</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="sizeGripEnabled" >
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="3" column="0" colspan="6" >
|
||||
<widget class="QGroupBox" name="listingsGB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<item row="3" column="0" colspan="6">
|
||||
<widget class="QGroupBox" name="listingsGB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<property name="title">
|
||||
<string>Listing Parameters</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="3" column="1" >
|
||||
<widget class="QTextEdit" name="listingsED" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<item row="3" column="1">
|
||||
<widget class="QTextEdit" name="listingsED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
@ -60,19 +75,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2" >
|
||||
<widget class="QCheckBox" name="bypassCB" >
|
||||
<property name="toolTip" >
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="bypassCB">
|
||||
<property name="toolTip">
|
||||
<string>Check it to enter parameters that are not recognizable by LyX</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>&Bypass validation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="captionLE" >
|
||||
<property name="minimumSize" >
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="captionLE">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
@ -80,80 +95,78 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="captionLabel" >
|
||||
<property name="text" >
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="captionLabel">
|
||||
<property name="text">
|
||||
<string>C&aption:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>captionLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="labelLE" />
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="labelLE"/>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="labelLabel" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelLabel">
|
||||
<property name="text">
|
||||
<string>La&bel:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>labelLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Mo&re parameters</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>listingsED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QTextBrowser" name="listingsTB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<item row="3" column="0">
|
||||
<widget class="QTextBrowser" name="listingsTB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor" >
|
||||
<cursor>0</cursor>
|
||||
<property name="cursor" stdset="0">
|
||||
<cursorShape>ArrowCursor</cursorShape>
|
||||
</property>
|
||||
<property name="focusPolicy" >
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="acceptDrops" >
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth" >
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="acceptRichText" >
|
||||
<property name="acceptRichText">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
@ -161,69 +174,83 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="6" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<item row="2" column="0" colspan="6">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="visiblespaceCB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<widget class="QCheckBox" name="visiblespaceCB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<property name="toolTip">
|
||||
<string>Underline spaces in generated output</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>&Mark spaces in output</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="previewCB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<widget class="QCheckBox" name="previewCB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<property name="toolTip">
|
||||
<string>Show LaTeX preview</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>&Show preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="6" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<item row="4" column="0" colspan="6">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
@ -232,93 +259,93 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okPB" >
|
||||
<property name="text" >
|
||||
<widget class="QPushButton" name="okPB">
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoDefault" >
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closePB" >
|
||||
<property name="text" >
|
||||
<widget class="QPushButton" name="closePB">
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
<property name="autoDefault" >
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="filenameLA" >
|
||||
<property name="toolTip" >
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="filenameLA">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>&File:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>filenameED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="4" >
|
||||
<widget class="QLineEdit" name="filenameED" >
|
||||
<property name="toolTip" >
|
||||
<string>File name to include</string>
|
||||
<item row="0" column="1" colspan="4">
|
||||
<widget class="QLineEdit" name="filenameED">
|
||||
<property name="toolTip">
|
||||
<string>File name to include. (You can create a new file by entering the name of one that does not yet exist.)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2" >
|
||||
<widget class="QLabel" name="TextLabel1" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="TextLabel1">
|
||||
<property name="text">
|
||||
<string>&Include Type:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>typeCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" >
|
||||
<widget class="QComboBox" name="typeCO" >
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="typeCO">
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Include</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Input</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Verbatim</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Program Listing</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" >
|
||||
<item row="1" column="3">
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
@ -326,22 +353,22 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="5" >
|
||||
<widget class="QPushButton" name="browsePB" >
|
||||
<property name="toolTip" >
|
||||
<item row="0" column="5">
|
||||
<widget class="QPushButton" name="browsePB">
|
||||
<property name="toolTip">
|
||||
<string>Select a file</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>&Browse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5" >
|
||||
<widget class="QPushButton" name="editPB" >
|
||||
<property name="toolTip" >
|
||||
<item row="1" column="5">
|
||||
<widget class="QPushButton" name="editPB">
|
||||
<property name="toolTip">
|
||||
<string>Edit the file</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>&Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
@ -363,7 +390,7 @@
|
||||
<tabstop>closePB</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
<include location="local">qt_i18n.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -30,6 +30,8 @@ What's new
|
||||
|
||||
- Focus keyword field in Thesaurus dialog.
|
||||
|
||||
- Allow creation of a child file from the include dialog (bug 4475).
|
||||
|
||||
|
||||
* MISCELLANEOUS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user