diff --git a/src/frontends/qt4/GuiInclude.cpp b/src/frontends/qt4/GuiInclude.cpp index edbf7a19c4..d87f78c409 100644 --- a/src/frontends/qt4/GuiInclude.cpp +++ b/src/frontends/qt4/GuiInclude.cpp @@ -32,6 +32,7 @@ #include "insets/InsetInclude.h" #include +#include #include #include @@ -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"); diff --git a/src/frontends/qt4/ui/IncludeUi.ui b/src/frontends/qt4/ui/IncludeUi.ui index 0522d3d0af..bbd2c5b0aa 100644 --- a/src/frontends/qt4/ui/IncludeUi.ui +++ b/src/frontends/qt4/ui/IncludeUi.ui @@ -1,58 +1,73 @@ - + + IncludeUi - - + + 0 0 - 371 - 374 + 440 + 442 - + - + true - - + + 9 - + + 9 + + + 9 + + + 9 + + 6 - - - - - 7 - 7 + + + + 0 0 - + Listing Parameters - - + + 9 - + + 9 + + + 9 + + + 9 + + 6 - - - - - 5 - 7 + + + + 0 0 - + 0 0 @@ -60,19 +75,19 @@ - - - + + + Check it to enter parameters that are not recognizable by LyX - + &Bypass validation - - - + + + 150 0 @@ -80,80 +95,78 @@ - - - + + + C&aption: - + captionLE - - + + - - - + + + La&bel: - + labelLE - - - + + + Mo&re parameters - + listingsED - - - - - 0 - 7 + + + + 0 0 - + 0 0 - + 120 16777215 - - 0 + + ArrowCursor - + Qt::NoFocus - + true - + QFrame::NoFrame - + QFrame::Plain - + 0 - + false @@ -161,69 +174,83 @@ - - - - 0 - - + + + 6 + + 0 + + + 0 + + + 0 + + + 0 + - - - - 3 - 0 + + + 0 0 - + Underline spaces in generated output - + &Mark spaces in output - - - - 3 - 0 + + + 0 0 - + Show LaTeX preview - + &Show preview - - - + + + + 6 + + 0 - - 6 + + 0 + + + 0 + + + 0 - + Qt::Horizontal - + QSizePolicy::Expanding - + 20 20 @@ -232,93 +259,93 @@ - - + + &OK - + true - + true - - + + &Close - + false - - - + + + - + &File: - + filenameED - - - - File name to include + + + + File name to include. (You can create a new file by entering the name of one that does not yet exist.) - - - + + + &Include Type: - + typeCO - - + + - + Include - + Input - + Verbatim - + Program Listing - + - + Qt::Horizontal - + QSizePolicy::Expanding - + 28 28 @@ -326,22 +353,22 @@ - - - + + + Select a file - + &Browse... - - - + + + Edit the file - + &Edit @@ -363,7 +390,7 @@ closePB - qt_i18n.h + qt_i18n.h diff --git a/status.23x b/status.23x index aef6ca68ad..b5e54b41c6 100644 --- a/status.23x +++ b/status.23x @@ -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