mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Fix bug #2844: Need option to overwrite without dialog popup
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34229 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cb6208f8e5
commit
3f87d9056d
@ -3377,8 +3377,9 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
|
||||
vector<ExportedFile> const files =
|
||||
runparams.exportdata->externalFiles(format);
|
||||
string const dest = onlyPath(result_file);
|
||||
CopyStatus status = !use_gui && force_overwrite == ALL_FILES ? FORCE
|
||||
: SUCCESS;
|
||||
bool use_force = use_gui ? lyxrc.export_overwrite == ALL_FILES
|
||||
: force_overwrite == ALL_FILES;
|
||||
CopyStatus status = use_force ? FORCE : SUCCESS;
|
||||
|
||||
vector<ExportedFile>::const_iterator it = files.begin();
|
||||
vector<ExportedFile>::const_iterator const en = files.end();
|
||||
@ -3393,7 +3394,9 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
|
||||
message(_("Document export cancelled."));
|
||||
} else if (tmp_result_file.exists()) {
|
||||
// Finally copy the main file
|
||||
if (!use_gui && force_overwrite != NO_FILES)
|
||||
use_force = use_gui ? lyxrc.export_overwrite != NO_FILES
|
||||
: force_overwrite != NO_FILES;
|
||||
if (status == SUCCESS && use_force)
|
||||
status = FORCE;
|
||||
status = copyFile(format, tmp_result_file,
|
||||
FileName(result_file), result_file,
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "FontEnums.h"
|
||||
#include "Format.h"
|
||||
#include "Lexer.h"
|
||||
#include "LyX.h"
|
||||
#include "Mover.h"
|
||||
#include "Session.h"
|
||||
#include "version.h"
|
||||
@ -92,6 +93,7 @@ LexerKeyword lyxrcTags[] = {
|
||||
{ "\\editor_alternatives", LyXRC::RC_EDITOR_ALTERNATIVES },
|
||||
{ "\\escape_chars", LyXRC::RC_ESC_CHARS },
|
||||
{ "\\example_path", LyXRC::RC_EXAMPLEPATH },
|
||||
{ "\\export_overwrite", LyXRC::RC_EXPORT_OVERWRITE },
|
||||
{ "\\font_encoding", LyXRC::RC_FONT_ENCODING },
|
||||
{ "\\format", LyXRC::RC_FORMAT },
|
||||
{ "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI },
|
||||
@ -330,6 +332,7 @@ void LyXRC::setDefaults()
|
||||
single_close_tab_button = false;
|
||||
forward_search_dvi = string();
|
||||
forward_search_pdf = string();
|
||||
export_overwrite = NO_FILES;
|
||||
|
||||
// Fullscreen settings
|
||||
full_screen_limit = false;
|
||||
@ -1168,6 +1171,21 @@ int LyXRC::read(Lexer & lexrc)
|
||||
if (lexrc.next(true))
|
||||
forward_search_pdf = lexrc.getString();
|
||||
break;
|
||||
case RC_EXPORT_OVERWRITE:
|
||||
if (lexrc.next()) {
|
||||
string const tmp = lexrc.getString();
|
||||
if (tmp == "all" || tmp == "true")
|
||||
export_overwrite = ALL_FILES;
|
||||
else if (tmp == "main")
|
||||
export_overwrite = MAIN_FILE;
|
||||
else {
|
||||
export_overwrite = NO_FILES;
|
||||
if (tmp != "ask" && tmp != "false")
|
||||
LYXERR0("Unrecognized export_overwrite status \""
|
||||
<< tmp << '"');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Obsoteted in 1.4.0
|
||||
case RC_USETEMPDIR:
|
||||
@ -2494,6 +2512,25 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
case RC_EXPORT_OVERWRITE:
|
||||
if (ignore_system_lyxrc ||
|
||||
export_overwrite != system_lyxrc.export_overwrite) {
|
||||
string status;
|
||||
switch (export_overwrite) {
|
||||
case NO_FILES:
|
||||
status = "ask";
|
||||
break;
|
||||
case MAIN_FILE:
|
||||
status = "main";
|
||||
break;
|
||||
case ALL_FILES:
|
||||
status = "all";
|
||||
break;
|
||||
}
|
||||
os << "\\export_overwrite " << status << '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
|
||||
os << "\n#\n"
|
||||
<< "# FORMATS SECTION ##########################\n"
|
||||
@ -2831,6 +2868,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
||||
case LyXRC::RC_VIEWER_ALTERNATIVES:
|
||||
case LyXRC::RC_FORWARD_SEARCH_DVI:
|
||||
case LyXRC::RC_FORWARD_SEARCH_PDF:
|
||||
case LyXRC::RC_EXPORT_OVERWRITE:
|
||||
case LyXRC::RC_LAST:
|
||||
break;
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
RC_EDITOR_ALTERNATIVES,
|
||||
RC_ESC_CHARS,
|
||||
RC_EXAMPLEPATH,
|
||||
RC_EXPORT_OVERWRITE,
|
||||
RC_FONT_ENCODING,
|
||||
RC_FORMAT,
|
||||
RC_FORWARD_SEARCH_DVI,
|
||||
@ -496,6 +497,8 @@ public:
|
||||
std::string forward_search_dvi;
|
||||
///
|
||||
std::string forward_search_pdf;
|
||||
///
|
||||
int export_overwrite;
|
||||
};
|
||||
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "KeySequence.h"
|
||||
#include "Language.h"
|
||||
#include "LyXAction.h"
|
||||
#include "LyX.h"
|
||||
#include "PanelStack.h"
|
||||
#include "paper.h"
|
||||
#include "Session.h"
|
||||
@ -368,6 +369,8 @@ PrefOutput::PrefOutput(GuiPreferences * form)
|
||||
this, SIGNAL(changed()));
|
||||
connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(overwriteCO, SIGNAL(activated(int)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(dviCB, SIGNAL(editTextChanged(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(pdfCB, SIGNAL(editTextChanged(QString)),
|
||||
@ -402,6 +405,18 @@ void PrefOutput::apply(LyXRC & rc) const
|
||||
rc.plaintext_linelen = plaintextLinelengthSB->value();
|
||||
rc.forward_search_dvi = fromqstr(dviCB->currentText());
|
||||
rc.forward_search_pdf = fromqstr(pdfCB->currentText());
|
||||
|
||||
switch (overwriteCO->currentIndex()) {
|
||||
case 0:
|
||||
rc.export_overwrite = NO_FILES;
|
||||
break;
|
||||
case 1:
|
||||
rc.export_overwrite = MAIN_FILE;
|
||||
break;
|
||||
case 2:
|
||||
rc.export_overwrite = ALL_FILES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -411,6 +426,18 @@ void PrefOutput::update(LyXRC const & rc)
|
||||
plaintextLinelengthSB->setValue(rc.plaintext_linelen);
|
||||
dviCB->setEditText(toqstr(rc.forward_search_dvi));
|
||||
pdfCB->setEditText(toqstr(rc.forward_search_pdf));
|
||||
|
||||
switch (rc.export_overwrite) {
|
||||
case NO_FILES:
|
||||
overwriteCO->setCurrentIndex(0);
|
||||
break;
|
||||
case MAIN_FILE:
|
||||
overwriteCO->setCurrentIndex(1);
|
||||
break;
|
||||
case ALL_FILES:
|
||||
overwriteCO->setCurrentIndex(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,6 +96,55 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>&Overwrite on export:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>overwriteCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="overwriteCO">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ask permission</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Main file only</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>All files</string>
|
||||
</property>
|
||||
</item>
|
||||
<property name="toolTip" >
|
||||
<string>What to do when existing files are going to be overwritten on export.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
|
Loading…
Reference in New Issue
Block a user