mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-18 21:45:24 +00:00
Fix bug #2844: Need option to overwrite without dialog popup
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@34541 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7ccee2bdb7
commit
4d22872a74
@ -2639,8 +2639,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;
|
||||
for (vector<ExportedFile>::const_iterator it = files.begin();
|
||||
it != files.end() && status != CANCEL; ++it) {
|
||||
string const fmt = formats.getFormatFromFile(it->sourceName);
|
||||
@ -2652,7 +2653,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,
|
||||
|
@ -251,7 +251,7 @@ void LyXAction::init()
|
||||
* \li Action: Inserts the current date.
|
||||
* \li Syntax: date-insert [<ARG>]
|
||||
* \li Params: <ARG>: Format of date. The default value (%x) can be set
|
||||
in Preferences->Date format. For possible formats
|
||||
in Preferences->General. For possible formats
|
||||
see manual page of strftime function.
|
||||
* \li Origin: jdblair, 31 Jan 2000
|
||||
* \endvar
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "Format.h"
|
||||
#include "Session.h"
|
||||
#include "Lexer.h"
|
||||
#include "LyX.h"
|
||||
#include "FontEnums.h"
|
||||
#include "Mover.h"
|
||||
|
||||
@ -87,6 +88,7 @@ LexerKeyword lyxrcTags[] = {
|
||||
{ "\\document_path", LyXRC::RC_DOCUMENTPATH },
|
||||
{ "\\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 },
|
||||
{ "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT },
|
||||
@ -308,6 +310,7 @@ void LyXRC::setDefaults()
|
||||
user_email = to_utf8(support::user_email());
|
||||
open_buffers_in_tabs = true;
|
||||
single_close_tab_button = false;
|
||||
export_overwrite = NO_FILES;
|
||||
|
||||
// Fullscreen settings
|
||||
full_screen_limit = false;
|
||||
@ -1107,6 +1110,21 @@ int LyXRC::read(Lexer & lexrc)
|
||||
case RC_SINGLE_CLOSE_TAB_BUTTON:
|
||||
lexrc >> single_close_tab_button;
|
||||
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;
|
||||
|
||||
case RC_LAST:
|
||||
break; // this is just a dummy
|
||||
@ -2357,6 +2375,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"
|
||||
|
@ -75,6 +75,7 @@ public:
|
||||
RC_DOCUMENTPATH,
|
||||
RC_ESC_CHARS,
|
||||
RC_EXAMPLEPATH,
|
||||
RC_EXPORT_OVERWRITE,
|
||||
RC_FONT_ENCODING,
|
||||
RC_FORMAT,
|
||||
RC_FULL_SCREEN_LIMIT,
|
||||
@ -462,6 +463,8 @@ public:
|
||||
bool open_buffers_in_tabs;
|
||||
///
|
||||
bool single_close_tab_button;
|
||||
///
|
||||
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"
|
||||
@ -386,21 +387,23 @@ QValidator::State StrftimeValidator::validate(QString & input, int & /*pos*/) co
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PrefDate
|
||||
// PrefOutput
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefDate::PrefDate(GuiPreferences * form)
|
||||
: PrefModule(qt_(catOutput), qt_("Date format"), form)
|
||||
PrefOutput::PrefOutput(GuiPreferences * form)
|
||||
: PrefModule(qt_(catOutput), qt_("General"), form)
|
||||
{
|
||||
setupUi(this);
|
||||
DateED->setValidator(new StrftimeValidator(DateED));
|
||||
connect(DateED, SIGNAL(textChanged(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(overwriteCO, SIGNAL(activated(int)),
|
||||
this, SIGNAL(changed()));
|
||||
}
|
||||
|
||||
|
||||
void PrefDate::on_DateED_textChanged(const QString &)
|
||||
void PrefOutput::on_DateED_textChanged(const QString &)
|
||||
{
|
||||
QString t = DateED->text();
|
||||
int p = 0;
|
||||
@ -410,15 +413,39 @@ void PrefDate::on_DateED_textChanged(const QString &)
|
||||
}
|
||||
|
||||
|
||||
void PrefDate::apply(LyXRC & rc) const
|
||||
void PrefOutput::apply(LyXRC & rc) const
|
||||
{
|
||||
rc.date_insert_format = fromqstr(DateED->text());
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PrefDate::update(LyXRC const & rc)
|
||||
void PrefOutput::update(LyXRC const & rc)
|
||||
{
|
||||
DateED->setText(toqstr(rc.date_insert_format));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2668,8 +2695,8 @@ GuiPreferences::GuiPreferences(GuiView & lv)
|
||||
addModule(new PrefSpellchecker(this));
|
||||
|
||||
addModule(new PrefPrinter(this));
|
||||
PrefDate * dateFormat = new PrefDate(this);
|
||||
addModule(dateFormat);
|
||||
PrefOutput * general = new PrefOutput(this);
|
||||
addModule(general);
|
||||
addModule(new PrefPlaintext(this));
|
||||
addModule(new PrefLatex(this));
|
||||
|
||||
@ -2694,7 +2721,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
|
||||
bc().setRestore(restorePB);
|
||||
|
||||
// initialize the strftime validator
|
||||
bc().addCheckedLineEdit(dateFormat->DateED);
|
||||
bc().addCheckedLineEdit(general->DateED);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "ui_PrefsUi.h"
|
||||
|
||||
#include "ui_PrefPlaintextUi.h"
|
||||
#include "ui_PrefDateUi.h"
|
||||
#include "ui_PrefOutputUi.h"
|
||||
#include "ui_PrefInputUi.h"
|
||||
#include "ui_PrefLatexUi.h"
|
||||
#include "ui_PrefScreenFontsUi.h"
|
||||
@ -169,11 +169,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class PrefDate : public PrefModule, public Ui::PrefDateUi
|
||||
class PrefOutput : public PrefModule, public Ui::PrefOutputUi
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PrefDate(GuiPreferences * form);
|
||||
PrefOutput(GuiPreferences * form);
|
||||
|
||||
virtual void apply(LyXRC & rc) const;
|
||||
virtual void update(LyXRC const & rc);
|
||||
|
@ -271,7 +271,6 @@ UIFILES = \
|
||||
PrefColorsUi.ui \
|
||||
PrefCompletionUi.ui \
|
||||
PrefConvertersUi.ui \
|
||||
PrefDateUi.ui \
|
||||
PrefDisplayUi.ui \
|
||||
PrefEditUi.ui \
|
||||
PrefFileformatsUi.ui \
|
||||
@ -279,6 +278,7 @@ UIFILES = \
|
||||
PrefInputUi.ui \
|
||||
PrefLanguageUi.ui \
|
||||
PrefLatexUi.ui \
|
||||
PrefOutputUi.ui \
|
||||
PrefPathsUi.ui \
|
||||
PrefPlaintextUi.ui \
|
||||
PrefPrinterUi.ui \
|
||||
|
@ -1,73 +0,0 @@
|
||||
<ui version="4.0" >
|
||||
<class>PrefDateUi</class>
|
||||
<widget class="QWidget" name="PrefDateUi" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>279</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="DateLA" >
|
||||
<property name="text" >
|
||||
<string>&Date format:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>DateED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="DateED" >
|
||||
<property name="toolTip" >
|
||||
<string>Date format for strftime output</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<includes>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
112
src/frontends/qt4/ui/PrefOutputUi.ui
Normal file
112
src/frontends/qt4/ui/PrefOutputUi.ui
Normal file
@ -0,0 +1,112 @@
|
||||
<ui version="4.0">
|
||||
<class>PrefOutputUi</class>
|
||||
<widget class="QWidget" name="PrefOutputUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>279</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>12</x>
|
||||
<y>12</y>
|
||||
<width>244</width>
|
||||
<height>78</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="DateLA">
|
||||
<property name="text">
|
||||
<string>&Date format:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>DateED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="DateED">
|
||||
<property name="toolTip">
|
||||
<string>Date format for strftime output</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Overwrite on export:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>overwriteCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="overwriteCO">
|
||||
<property name="toolTip">
|
||||
<string>What to do when existing files are going to be overwritten on export.</string>
|
||||
</property>
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<includes>
|
||||
<include location="local">qt_i18n.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -35,12 +35,12 @@ uic PDFSupportUi.ui -o PDFSupportUi.h
|
||||
uic PreambleUi.ui -o PreambleUi.h
|
||||
uic PrefColorsUi.ui -o PrefColorsUi.h
|
||||
uic PrefConvertersUi.ui -o PrefConvertersUi.h
|
||||
uic PrefDateUi.ui -o PrefDateUi.h
|
||||
uic PrefDisplayUi.ui -o PrefDisplayUi.h
|
||||
uic PrefFileformatsUi.ui -o PrefFileformatsUi.h
|
||||
uic PrefIdentityUi.ui -o PrefIdentityUi.h
|
||||
uic PrefLanguageUi.ui -o PrefLanguageUi.h
|
||||
uic PrefLatexUi.ui -o PrefLatexUi.h
|
||||
uic PrefOutputUi.ui -o PrefOutputUi.h
|
||||
uic PrefPathsUi.ui -o PrefPathsUi.h
|
||||
uic PrefPlaintextUi.ui -o PrefPlaintextUi.h
|
||||
uic PrefPrinterUi.ui -o PrefPrinterUi.h
|
||||
|
11
status.16x
11
status.16x
@ -26,8 +26,11 @@ What's new
|
||||
|
||||
- Introduced new -f [--force-overwrite] command line flag. Without any
|
||||
argument (or 'all' as argument) all files are silently overwritten on
|
||||
export. Using 'main' as argument, only the main file will be overwritten.
|
||||
export from command line. Using 'main' as argument, only the main file
|
||||
will be overwritten.
|
||||
|
||||
- Introduced new preference setting for selecting what to do when existing
|
||||
files are going to be overwritten on export from the GUI.
|
||||
|
||||
|
||||
* USER INTERFACE
|
||||
@ -77,8 +80,10 @@ What's new
|
||||
|
||||
- Don't allow creating multiple buffers with same name (bug 6645).
|
||||
|
||||
- Don't automatically overwrite files on export, unless the newly introduced
|
||||
-f flag is used (bug 2762).
|
||||
- Don't automatically overwrite files on export from command line, unless
|
||||
the newly introduced -f flag is used (bug 2762).
|
||||
|
||||
- Allow to overwrite files without dialog popup on export from GUI (bug 2844).
|
||||
|
||||
|
||||
* USER INTERFACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user