support to set the examples folder in the preferences

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21776 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2007-11-25 18:26:58 +00:00
parent 49051b32ea
commit 58135f8b27
6 changed files with 169 additions and 110 deletions

View File

@ -785,6 +785,10 @@ bool LyX::init()
lyxrc.tempdir_path = package().temp_dir().absFilename(); lyxrc.tempdir_path = package().temp_dir().absFilename();
lyxrc.document_path = package().document_dir().absFilename(); lyxrc.document_path = package().document_dir().absFilename();
if (lyxrc.example_path.empty()) {
lyxrc.example_path = addPath(package().system_support().absFilename(),
"examples");
}
if (lyxrc.template_path.empty()) { if (lyxrc.template_path.empty()) {
lyxrc.template_path = addPath(package().system_support().absFilename(), lyxrc.template_path = addPath(package().system_support().absFilename(),
"templates"); "templates");

View File

@ -92,6 +92,7 @@ keyword_item lyxrcTags[] = {
{ "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS }, { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
{ "\\document_path", LyXRC::RC_DOCUMENTPATH }, { "\\document_path", LyXRC::RC_DOCUMENTPATH },
{ "\\escape_chars", LyXRC::RC_ESC_CHARS }, { "\\escape_chars", LyXRC::RC_ESC_CHARS },
{ "\\example_path", LyXRC::RC_EXAMPLEPATH },
{ "\\font_encoding", LyXRC::RC_FONT_ENCODING }, { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
{ "\\format", LyXRC::RC_FORMAT }, { "\\format", LyXRC::RC_FORMAT },
{ "\\index_command", LyXRC::RC_INDEX_COMMAND }, { "\\index_command", LyXRC::RC_INDEX_COMMAND },
@ -705,6 +706,13 @@ int LyXRC::read(Lexer & lexrc)
} }
break; break;
case RC_EXAMPLEPATH:
if (lexrc.next()) {
example_path = os::internal_path(lexrc.getString());
example_path = expandPath(example_path);
}
break;
case RC_TEMPLATEPATH: case RC_TEMPLATEPATH:
if (lexrc.next()) { if (lexrc.next()) {
template_path = os::internal_path(lexrc.getString()); template_path = os::internal_path(lexrc.getString());
@ -1932,6 +1940,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
} }
if (tag != RC_LAST) if (tag != RC_LAST)
break; break;
case RC_EXAMPLEPATH:
if (ignore_system_lyxrc ||
example_path != system_lyxrc.example_path) {
string const path = os::external_path(example_path);
os << "\\example_path \"" << path << "\"\n";
}
if (tag != RC_LAST)
break;
case RC_TEMPLATEPATH: case RC_TEMPLATEPATH:
if (ignore_system_lyxrc || if (ignore_system_lyxrc ||
template_path != system_lyxrc.template_path) { template_path != system_lyxrc.template_path) {
@ -2411,6 +2427,10 @@ string const LyXRC::getDescription(LyXRCTags tag)
str = _("Specify additional chars that can be part of a word."); str = _("Specify additional chars that can be part of a word.");
break; break;
case RC_EXAMPLEPATH:
str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from.");
break;
case RC_FONT_ENCODING: case RC_FONT_ENCODING:
str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages."); str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
break; break;

View File

@ -63,6 +63,7 @@ public:
RC_DISPLAY_GRAPHICS, RC_DISPLAY_GRAPHICS,
RC_DOCUMENTPATH, RC_DOCUMENTPATH,
RC_ESC_CHARS, RC_ESC_CHARS,
RC_EXAMPLEPATH,
RC_FONT_ENCODING, RC_FONT_ENCODING,
RC_FORMAT, RC_FORMAT,
RC_INDEX_COMMAND, RC_INDEX_COMMAND,
@ -226,6 +227,8 @@ public:
/// ///
std::string document_path; std::string document_path;
/// ///
std::string example_path;
///
std::string template_path; std::string template_path;
/// ///
std::string tempdir_path; std::string tempdir_path;

View File

@ -740,6 +740,7 @@ PrefPaths::PrefPaths(GuiPreferences * form, QWidget * parent)
: PrefModule(_("Paths"), form, parent) : PrefModule(_("Paths"), form, parent)
{ {
setupUi(this); setupUi(this);
connect(exampleDirPB, SIGNAL(clicked()), this, SLOT(select_exampledir()));
connect(templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir())); connect(templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir()));
connect(tempDirPB, SIGNAL(clicked()), this, SLOT(select_tempdir())); connect(tempDirPB, SIGNAL(clicked()), this, SLOT(select_tempdir()));
connect(backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir())); connect(backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir()));
@ -747,6 +748,8 @@ PrefPaths::PrefPaths(GuiPreferences * form, QWidget * parent)
connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe())); connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe()));
connect(workingDirED, SIGNAL(textChanged(QString)), connect(workingDirED, SIGNAL(textChanged(QString)),
this, SIGNAL(changed())); this, SIGNAL(changed()));
connect(exampleDirPB, SIGNAL(textChanged(QString)),
this, SIGNAL(changed()));
connect(templateDirED, SIGNAL(textChanged(QString)), connect(templateDirED, SIGNAL(textChanged(QString)),
this, SIGNAL(changed())); this, SIGNAL(changed()));
connect(backupDirED, SIGNAL(textChanged(QString)), connect(backupDirED, SIGNAL(textChanged(QString)),
@ -763,6 +766,7 @@ PrefPaths::PrefPaths(GuiPreferences * form, QWidget * parent)
void PrefPaths::apply(LyXRC & rc) const void PrefPaths::apply(LyXRC & rc) const
{ {
rc.document_path = internal_path(fromqstr(workingDirED->text())); rc.document_path = internal_path(fromqstr(workingDirED->text()));
rc.example_path = internal_path(fromqstr(exampleDirED->text()));
rc.template_path = internal_path(fromqstr(templateDirED->text())); rc.template_path = internal_path(fromqstr(templateDirED->text()));
rc.backupdir_path = internal_path(fromqstr(backupDirED->text())); rc.backupdir_path = internal_path(fromqstr(backupDirED->text()));
rc.tempdir_path = internal_path(fromqstr(tempDirED->text())); rc.tempdir_path = internal_path(fromqstr(tempDirED->text()));
@ -775,6 +779,7 @@ void PrefPaths::apply(LyXRC & rc) const
void PrefPaths::update(LyXRC const & rc) void PrefPaths::update(LyXRC const & rc)
{ {
workingDirED->setText(toqstr(external_path(rc.document_path))); workingDirED->setText(toqstr(external_path(rc.document_path)));
exampleDirED->setText(toqstr(external_path(rc.example_path)));
templateDirED->setText(toqstr(external_path(rc.template_path))); templateDirED->setText(toqstr(external_path(rc.template_path)));
backupDirED->setText(toqstr(external_path(rc.backupdir_path))); backupDirED->setText(toqstr(external_path(rc.backupdir_path)));
tempDirED->setText(toqstr(external_path(rc.tempdir_path))); tempDirED->setText(toqstr(external_path(rc.tempdir_path)));
@ -784,6 +789,16 @@ void PrefPaths::update(LyXRC const & rc)
} }
void PrefPaths::select_exampledir()
{
docstring file(form_->browsedir(
from_utf8(internal_path(fromqstr(exampleDirED->text()))),
_("Select a document templates directory")));
if (!file.empty())
exampleDirED->setText(toqstr(file));
}
void PrefPaths::select_templatedir() void PrefPaths::select_templatedir()
{ {
docstring file(form_->browsedir( docstring file(form_->browsedir(

View File

@ -197,6 +197,7 @@ public:
void update(LyXRC const & rc); void update(LyXRC const & rc);
private Q_SLOTS: private Q_SLOTS:
void select_exampledir();
void select_templatedir(); void select_templatedir();
void select_tempdir(); void select_tempdir();
void select_backupdir(); void select_backupdir();

View File

@ -6,67 +6,25 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>347</width> <width>347</width>
<height>227</height> <height>259</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
<string/> <string/>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="margin" > <item row="0" column="0" >
<number>9</number> <widget class="QLabel" name="workingDirLA" >
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="3" column="0" >
<widget class="QLabel" name="lyxserverDirLA" >
<property name="text" > <property name="text" >
<string>Ly&amp;XServer pipe:</string> <string>&amp;Working directory:</string>
</property> </property>
<property name="buddy" > <property name="buddy" >
<cstring>lyxserverDirED</cstring> <cstring>workingDirED</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2" > <item row="0" column="1" >
<widget class="QPushButton" name="templateDirPB" > <widget class="QLineEdit" name="workingDirED" />
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2" >
<widget class="QLineEdit" name="pathPrefixED" />
</item>
<item row="2" column="2" >
<widget class="QPushButton" name="backupDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="2" >
<widget class="QPushButton" name="tempDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="lyxserverDirED" />
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="templateDirED" />
</item> </item>
<item row="0" column="2" > <item row="0" column="2" >
<widget class="QPushButton" name="workingDirPB" > <widget class="QPushButton" name="workingDirPB" >
@ -78,62 +36,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" >
<widget class="QLabel" name="pathPrefixLA" >
<property name="text" >
<string>&amp;PATH prefix:</string>
</property>
<property name="buddy" >
<cstring>pathPrefixED</cstring>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="tempDirLA" >
<property name="text" >
<string>&amp;Temporary directory:</string>
</property>
<property name="buddy" >
<cstring>tempDirED</cstring>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="backupDirLA" >
<property name="text" >
<string>&amp;Backup directory:</string>
</property>
<property name="buddy" >
<cstring>backupDirED</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="backupDirED" />
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="workingDirED" />
</item>
<item row="3" column="2" >
<widget class="QPushButton" name="lyxserverDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="workingDirLA" >
<property name="text" >
<string>&amp;Working directory:</string>
</property>
<property name="buddy" >
<cstring>workingDirED</cstring>
</property>
</widget>
</item>
<item row="1" column="0" > <item row="1" column="0" >
<widget class="QLabel" name="templateDirLA" > <widget class="QLabel" name="templateDirLA" >
<property name="text" > <property name="text" >
@ -144,10 +46,125 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" >
<widget class="QLineEdit" name="templateDirED" />
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="templateDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="exampleDirLA" >
<property name="text" >
<string>&amp;Example files:</string>
</property>
<property name="buddy" >
<cstring>templateDirED</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="exampleDirED" />
</item>
<item row="2" column="2" >
<widget class="QPushButton" name="exampleDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="backupDirLA" >
<property name="text" >
<string>&amp;Backup directory:</string>
</property>
<property name="buddy" >
<cstring>backupDirED</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="backupDirED" />
</item>
<item row="3" column="2" >
<widget class="QPushButton" name="backupDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="lyxserverDirLA" >
<property name="text" >
<string>Ly&amp;XServer pipe:</string>
</property>
<property name="buddy" >
<cstring>lyxserverDirED</cstring>
</property>
</widget>
</item>
<item row="4" column="1" > <item row="4" column="1" >
<widget class="QLineEdit" name="lyxserverDirED" />
</item>
<item row="4" column="2" >
<widget class="QPushButton" name="lyxserverDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="tempDirLA" >
<property name="text" >
<string>&amp;Temporary directory:</string>
</property>
<property name="buddy" >
<cstring>tempDirED</cstring>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QLineEdit" name="tempDirED" /> <widget class="QLineEdit" name="tempDirED" />
</item> </item>
<item row="6" column="0" colspan="3" > <item row="5" column="2" >
<widget class="QPushButton" name="tempDirPB" >
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="pathPrefixLA" >
<property name="text" >
<string>&amp;PATH prefix:</string>
</property>
<property name="buddy" >
<cstring>pathPrefixED</cstring>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2" >
<widget class="QLineEdit" name="pathPrefixED" />
</item>
<item row="7" column="0" colspan="3" >
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -165,10 +182,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<pixmapfunction></pixmapfunction>
<includes>
<include location="local" >qt_helpers.h</include>
</includes>
<tabstops> <tabstops>
<tabstop>workingDirED</tabstop> <tabstop>workingDirED</tabstop>
<tabstop>workingDirPB</tabstop> <tabstop>workingDirPB</tabstop>
@ -181,6 +194,9 @@
<tabstop>tempDirED</tabstop> <tabstop>tempDirED</tabstop>
<tabstop>tempDirPB</tabstop> <tabstop>tempDirPB</tabstop>
</tabstops> </tabstops>
<includes>
<include location="local" >qt_helpers.h</include>
</includes>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>