mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +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,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>IncludeUi</class>
|
||||
<widget class="QDialog" name="IncludeUi">
|
||||
@ -5,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>371</width>
|
||||
<height>374</height>
|
||||
<width>440</width>
|
||||
<height>442</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -16,7 +17,16 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin" >
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
@ -25,9 +35,7 @@
|
||||
<item row="3" column="0" colspan="6">
|
||||
<widget class="QGroupBox" name="listingsGB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -36,7 +44,16 @@
|
||||
<string>Listing Parameters</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin" >
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
@ -45,9 +62,7 @@
|
||||
<item row="3" column="1">
|
||||
<widget class="QTextEdit" name="listingsED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -116,9 +131,7 @@
|
||||
<item row="3" column="0">
|
||||
<widget class="QTextBrowser" name="listingsTB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -135,8 +148,8 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor" >
|
||||
<cursor>0</cursor>
|
||||
<property name="cursor" stdset="0">
|
||||
<cursorShape>ArrowCursor</cursorShape>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
@ -163,18 +176,25 @@
|
||||
</item>
|
||||
<item row="2" column="0" colspan="6">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -190,9 +210,7 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="previewCB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -209,12 +227,21 @@
|
||||
</item>
|
||||
<item row="4" column="0" colspan="6">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
@ -223,7 +250,7 @@
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
@ -236,10 +263,10 @@
|
||||
<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>
|
||||
@ -272,7 +299,7 @@
|
||||
<item row="0" column="1" colspan="4">
|
||||
<widget class="QLineEdit" name="filenameED">
|
||||
<property name="toolTip">
|
||||
<string>File name to include</string>
|
||||
<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>
|
||||
@ -318,7 +345,7 @@
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
|
@ -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