'Forward port' various path fixes from the 1.3.x branch.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10084 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2005-06-18 00:18:29 +00:00
parent 02ab1bf675
commit 029c5c4732
6 changed files with 143 additions and 58 deletions

View File

@ -1,3 +1,11 @@
2005-06-16 Angus Leeming <leeming@lyx.org>
* lyxrc.C (output, read): wrap all input and output of paths with
calls to os::internal_path and os::external_path, respectively.
(output): wrap bind_file inside quotes.
* format.C (view): enable the viewer to use the '$$s' placeholder.
2005-06-16 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* LColor.[Ch] (getFromLaTeXName): new

View File

@ -27,6 +27,7 @@
using lyx::support::bformat;
using lyx::support::compare_ascii_no_case;
using lyx::support::contains;
using lyx::support::LibScriptSearch;
using lyx::support::MakeDisplayPath;
using lyx::support::OnlyFilename;
using lyx::support::OnlyPath;
@ -231,7 +232,7 @@ bool Formats::view(Buffer const & buffer, string const & filename,
return false;
}
string command = format->viewer();
string command = LibScriptSearch(format->viewer());
if (format_name == "dvi" &&
!lyxrc.view_dvi_paper_option.empty()) {

View File

@ -1,3 +1,18 @@
2005-06-16 Angus Leeming <leeming@lyx.org>
* QPrefs.C (apply, update_contents): wrap all input and output of
paths with calls to os::internal_path and os::external_path,
respectively.
* QPrefsDialog.C (modify_format, modify_converter): keep the
current item selected after pressing the "Modify" button.
2005-06-12 Angus Leeming <leeming@lyx.org>
* QPrefs.C (setComboxFont): ensure that only the font family name
(not the name of the foundary also) is used when trying to find
the system default font in the list of all fonts.
2005-06-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* qfont_loader.C (addToFontPath): delete the data structure
@ -5,8 +20,8 @@
2005-06-09 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* qfont_loader.h:
* qfont_loader.C (charwidth): do no do font width caching with
* qfont_loader.h:
* qfont_loader.C (charwidth): do no do font width caching with
Qt >= 3.1.0.
2005-06-06 Lars Gullik Bjonnes <larsbj@gullik.net>

View File

@ -40,6 +40,7 @@
#include "lyxfont.h"
#include "support/lstrings.h"
#include "support/os.h"
#include "controllers/ControlPrefs.h"
#include "controllers/frnt_lang.h"
@ -140,6 +141,16 @@ void QPrefs::build_dialog()
}
namespace {
string const internal_path(QString const & input)
{
return lyx::support::os::internal_path(fromqstr(input));
}
}
void QPrefs::apply()
{
LyXRC & rc(controller().rc());
@ -160,8 +171,8 @@ void QPrefs::apply()
QPrefUIModule * uimod(dialog_->uiModule);
rc.ui_file = fromqstr(uimod->uiFileED->text());
rc.bind_file = fromqstr(uimod->bindFileED->text());
rc.ui_file = internal_path(uimod->uiFileED->text());
rc.bind_file = internal_path(uimod->bindFileED->text());
rc.cursor_follows_scrollbar = uimod->cursorFollowsCB->isChecked();
rc.wheel_jump = uimod->wheelMouseSB->value();
rc.autosave = uimod->autoSaveSB->value() * 60;
@ -173,8 +184,8 @@ void QPrefs::apply()
// FIXME: can derive CB from the two EDs
rc.use_kbmap = keymod->keymapCB->isChecked();
rc.primary_kbmap = fromqstr(keymod->firstKeymapED->text());
rc.secondary_kbmap = fromqstr(keymod->secondKeymapED->text());
rc.primary_kbmap = internal_path(keymod->firstKeymapED->text());
rc.secondary_kbmap = internal_path(keymod->secondKeymapED->text());
QPrefAsciiModule * ascmod(dialog_->asciiModule);
@ -239,13 +250,13 @@ void QPrefs::apply()
QPrefPathsModule * pathsmod(dialog_->pathsModule);
rc.document_path = fromqstr(pathsmod->workingDirED->text());
rc.template_path = fromqstr(pathsmod->templateDirED->text());
rc.backupdir_path = fromqstr(pathsmod->backupDirED->text());
rc.tempdir_path = fromqstr(pathsmod->tempDirED->text());
rc.document_path = internal_path(pathsmod->workingDirED->text());
rc.template_path = internal_path(pathsmod->templateDirED->text());
rc.backupdir_path = internal_path(pathsmod->backupDirED->text());
rc.tempdir_path = internal_path(pathsmod->tempDirED->text());
rc.path_prefix = fromqstr(pathsmod->pathPrefixED->text());
// FIXME: should be a checkbox only
rc.lyxpipes = fromqstr(pathsmod->lyxserverDirED->text());
rc.lyxpipes = internal_path(pathsmod->lyxserverDirED->text());
QPrefSpellcheckerModule * spellmod(dialog_->spellcheckerModule);
@ -269,7 +280,7 @@ void QPrefs::apply()
rc.isp_esc_chars = fromqstr(spellmod->escapeCharactersED->text());
rc.isp_use_esc_chars = !rc.isp_esc_chars.empty();
// FIXME: remove isp_use_pers_dict
rc.isp_pers_dict = fromqstr(spellmod->persDictionaryED->text());
rc.isp_pers_dict = internal_path(spellmod->persDictionaryED->text());
rc.isp_use_pers_dict = !rc.isp_pers_dict.empty();
rc.isp_accept_compound = spellmod->compoundWordCB->isChecked();
rc.isp_use_input_encoding = spellmod->inputEncodingCB->isChecked();
@ -292,7 +303,7 @@ void QPrefs::apply()
rc.print_oddpage_flag = fromqstr(printmod->printerOddED->text());
rc.print_collcopies_flag = fromqstr(printmod->printerCollatedED->text());
rc.print_landscape_flag = fromqstr(printmod->printerLandscapeED->text());
rc.print_to_file = fromqstr(printmod->printerToFileED->text());
rc.print_to_file = internal_path(printmod->printerToFileED->text());
rc.print_extra_options = fromqstr(printmod->printerExtraED->text());
rc.print_spool_printerprefix = fromqstr(printmod->printerSpoolPrefixED->text());
rc.print_paper_dimension_flag = fromqstr(printmod->printerPaperSizeED->text());
@ -416,13 +427,13 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry
if (family == lyx_gui::roman_font_name()) {
font.setStyleHint(QFont::Serif);
font.setFamily(lyx_gui::roman_font_name().c_str());
font.setFamily(family.c_str());
} else if (family == lyx_gui::sans_font_name()) {
font.setStyleHint(QFont::SansSerif);
font.setFamily(lyx_gui::sans_font_name().c_str());
font.setFamily(family.c_str());
} else if (family == lyx_gui::typewriter_font_name()) {
font.setStyleHint(QFont::TypeWriter);
font.setFamily(lyx_gui::typewriter_font_name().c_str());
font.setFamily(family.c_str());
} else {
lyxerr << "FAILED to find the default font !"
<< foundry << ", " << family << endl;
@ -430,11 +441,14 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry
}
QFontInfo info(font);
lyxerr << "Apparent font is " << info.family() << endl;
pair<string, string> tmp = parseFontName(info.family());
string const & default_font_name = tmp.first;
lyxerr << "Apparent font is " << default_font_name << endl;
for (int i = 0; i < cb->count(); ++i) {
lyxerr << "Looking at " << fromqstr(cb->text(i)) << endl;
if (compare_no_case(fromqstr(cb->text(i)), fromqstr(info.family())) == 0) {
if (compare_no_case(fromqstr(cb->text(i)),
default_font_name) == 0) {
cb->setCurrentItem(i);
return;
}
@ -447,6 +461,16 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry
} // end namespace anon
namespace {
QString const external_path(string const & input)
{
return toqstr(lyx::support::os::external_path(input));
}
}
void QPrefs::update_contents()
{
LyXRC const & rc(controller().rc());
@ -469,8 +493,8 @@ void QPrefs::update_contents()
QPrefUIModule * uimod(dialog_->uiModule);
uimod->uiFileED->setText(toqstr(rc.ui_file));
uimod->bindFileED->setText(toqstr(rc.bind_file));
uimod->uiFileED->setText(external_path(rc.ui_file));
uimod->bindFileED->setText(external_path(rc.bind_file));
uimod->cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
uimod->wheelMouseSB->setValue(rc.wheel_jump);
// convert to minutes
@ -498,8 +522,8 @@ void QPrefs::update_contents()
keymod->secondKeymapED->setEnabled(rc.use_kbmap);
keymod->secondKeymapPB->setEnabled(rc.use_kbmap);
keymod->secondKeymapLA->setEnabled(rc.use_kbmap);
keymod->firstKeymapED->setText(toqstr(rc.primary_kbmap));
keymod->secondKeymapED->setText(toqstr(rc.secondary_kbmap));
keymod->firstKeymapED->setText(external_path(rc.primary_kbmap));
keymod->secondKeymapED->setText(external_path(rc.secondary_kbmap));
QPrefAsciiModule * ascmod(dialog_->asciiModule);
@ -556,13 +580,13 @@ void QPrefs::update_contents()
QPrefPathsModule * pathsmod(dialog_->pathsModule);
pathsmod->workingDirED->setText(toqstr(rc.document_path));
pathsmod->templateDirED->setText(toqstr(rc.template_path));
pathsmod->backupDirED->setText(toqstr(rc.backupdir_path));
pathsmod->tempDirED->setText(toqstr(rc.tempdir_path));
pathsmod->workingDirED->setText(external_path(rc.document_path));
pathsmod->templateDirED->setText(external_path(rc.template_path));
pathsmod->backupDirED->setText(external_path(rc.backupdir_path));
pathsmod->tempDirED->setText(external_path(rc.tempdir_path));
pathsmod->pathPrefixED->setText(toqstr(rc.path_prefix));
// FIXME: should be a checkbox only
pathsmod->lyxserverDirED->setText(toqstr(rc.lyxpipes));
pathsmod->lyxserverDirED->setText(external_path(rc.lyxpipes));
QPrefSpellcheckerModule * spellmod(dialog_->spellcheckerModule);
@ -587,7 +611,7 @@ void QPrefs::update_contents()
// FIXME: remove isp_use_esc_chars
spellmod->escapeCharactersED->setText(toqstr(rc.isp_esc_chars));
// FIXME: remove isp_use_pers_dict
spellmod->persDictionaryED->setText(toqstr(rc.isp_pers_dict));
spellmod->persDictionaryED->setText(external_path(rc.isp_pers_dict));
spellmod->compoundWordCB->setChecked(rc.isp_accept_compound);
spellmod->inputEncodingCB->setChecked(rc.isp_use_input_encoding);
@ -609,7 +633,7 @@ void QPrefs::update_contents()
printmod->printerOddED->setText(toqstr(rc.print_oddpage_flag));
printmod->printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
printmod->printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
printmod->printerToFileED->setText(toqstr(rc.print_to_file));
printmod->printerToFileED->setText(external_path(rc.print_to_file));
printmod->printerExtraED->setText(toqstr(rc.print_extra_options));
printmod->printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
printmod->printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));

View File

@ -451,6 +451,10 @@ void QPrefsDialog::new_converter()
void QPrefsDialog::modify_converter()
{
int const top_item = convertersModule->convertersLB->topItem();
QString const current_text =
convertersModule->convertersLB->currentText();
Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
string flags(fromqstr(convertersModule->converterFlagED->text()));
@ -462,6 +466,11 @@ void QPrefsDialog::modify_converter()
form_->converters().updateLast(form_->formats());
}
updateConverters();
QListBoxItem * const item =
convertersModule->convertersLB->findItem(current_text);
convertersModule->convertersLB->setCurrentItem(item);
convertersModule->convertersLB->setTopItem(top_item);
}
@ -813,7 +822,12 @@ void QPrefsDialog::new_format()
void QPrefsDialog::modify_format()
{
Format const & oldformat(form_->formats().get(fileformatsModule->formatsLB->currentItem()));
int const top_item = fileformatsModule->formatsLB->topItem();
int const current_item = fileformatsModule->formatsLB->currentItem();
QString const current_text =
fileformatsModule->formatsLB->currentText();
Format const & oldformat(form_->formats().get(current_item));
string const oldpretty(oldformat.prettyname());
string const name(fromqstr(fileformatsModule->formatED->text()));
form_->formats().erase(oldformat.name());
@ -834,6 +848,11 @@ void QPrefsDialog::modify_format()
updateConverters();
updateFormatsButtons();
QListBoxItem * const item =
fileformatsModule->formatsLB->findItem(current_text);
fileformatsModule->formatsLB->setCurrentItem(item);
fileformatsModule->formatsLB->setTopItem(top_item);
}

View File

@ -37,8 +37,11 @@
#include "support/environment.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/os.h"
#include "support/userinfo.h"
namespace os = lyx::support::os;
using lyx::support::ascii_lowercase;
using lyx::support::bformat;
using lyx::support::ExpandPath;
@ -362,15 +365,15 @@ int LyXRC::read(LyXLex & lexrc)
}
}
break;
case RC_BINDFILE: // RVDK_PATCH_5
case RC_BINDFILE:
if (lexrc.next()) {
bind_file = lexrc.getString();
bind_file = os::internal_path(lexrc.getString());
}
break;
case RC_UIFILE:
if (lexrc.next()) {
ui_file = lexrc.getString();
ui_file = os::internal_path(lexrc.getString());
}
break;
@ -406,7 +409,7 @@ int LyXRC::read(LyXLex & lexrc)
case RC_KBMAP_PRIMARY:
if (lexrc.next()) {
string const kmap(lexrc.getString());
string const kmap(os::internal_path(lexrc.getString()));
if (kmap.empty()) {
// nothing
} else if (!LibFileSearch("kbd", kmap,
@ -420,7 +423,7 @@ int LyXRC::read(LyXLex & lexrc)
case RC_KBMAP_SECONDARY:
if (lexrc.next()) {
string const kmap(lexrc.getString());
string const kmap(os::internal_path(lexrc.getString()));
if (kmap.empty()) {
// nothing
} else if (!LibFileSearch("kbd", kmap,
@ -506,7 +509,7 @@ int LyXRC::read(LyXLex & lexrc)
case RC_PRINTTOFILE:
if (lexrc.next()) {
print_to_file = lexrc.getString();
print_to_file = os::internal_path(lexrc.getString());
}
break;
@ -687,19 +690,22 @@ int LyXRC::read(LyXLex & lexrc)
case RC_DOCUMENTPATH:
if (lexrc.next()) {
document_path = ExpandPath(lexrc.getString());
document_path = os::internal_path(lexrc.getString());
document_path = ExpandPath(document_path);
}
break;
case RC_TEMPLATEPATH:
if (lexrc.next()) {
template_path = ExpandPath(lexrc.getString());
template_path = os::internal_path(lexrc.getString());
template_path = ExpandPath(template_path);
}
break;
case RC_TEMPDIRPATH:
if (lexrc.next()) {
tempdir_path = ExpandPath(lexrc.getString());
tempdir_path = os::internal_path(lexrc.getString());
tempdir_path = ExpandPath(tempdir_path);
}
break;
@ -711,7 +717,7 @@ int LyXRC::read(LyXLex & lexrc)
case RC_LASTFILES:
if (lexrc.next()) {
lastfiles = ExpandPath(lexrc.getString());
lastfiles = ExpandPath(os::internal_path(lexrc.getString()));
}
break;
@ -834,7 +840,8 @@ int LyXRC::read(LyXLex & lexrc)
case RC_SERVERPIPE:
if (lexrc.next()) {
lyxpipes = ExpandPath(lexrc.getString());
lyxpipes = os::internal_path(lexrc.getString());
lyxpipes = ExpandPath(lyxpipes);
}
break;
@ -903,7 +910,7 @@ int LyXRC::read(LyXLex & lexrc)
break;
case RC_PERS_DICT:
if (lexrc.next()) {
isp_pers_dict = lexrc.getString();
isp_pers_dict = os::internal_path(lexrc.getString());
}
break;
case RC_ESC_CHARS:
@ -918,7 +925,8 @@ int LyXRC::read(LyXLex & lexrc)
break;
case RC_BACKUPDIR_PATH:
if (lexrc.next()) {
backupdir_path = ExpandPath(lexrc.getString());
backupdir_path = os::internal_path(lexrc.getString());
backupdir_path = ExpandPath(backupdir_path);
}
break;
case RC_DATE_INSERT_FORMAT:
@ -1217,7 +1225,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
case RC_BINDFILE:
if (ignore_system_lyxrc ||
bind_file != system_lyxrc.bind_file) {
os << "\\bind_file " << bind_file << "\n";
string const path = os::external_path(bind_file);
os << "\\bind_file \"" << path << "\"\n";
}
//
// Misc Section
@ -1237,7 +1246,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
case RC_UIFILE:
if (ignore_system_lyxrc ||
ui_file != system_lyxrc.ui_file) {
os << "\\ui_file \"" << ui_file << "\"\n";
string const path = os::external_path(ui_file);
os << "\\ui_file \"" << path << "\"\n";
}
case RC_AUTOREGIONDELETE:
if (ignore_system_lyxrc ||
@ -1339,18 +1349,20 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
case RC_KBMAP_PRIMARY:
if (ignore_system_lyxrc ||
primary_kbmap != system_lyxrc.primary_kbmap) {
os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
string const path = os::external_path(primary_kbmap);
os << "\\kbmap_primary \"" << path << "\"\n";
}
case RC_KBMAP_SECONDARY:
if (ignore_system_lyxrc ||
secondary_kbmap != system_lyxrc.secondary_kbmap) {
os << "\\kbmap_secondary \"" << secondary_kbmap
<< "\"\n";
string const path = os::external_path(secondary_kbmap);
os << "\\kbmap_secondary \"" << path << "\"\n";
}
case RC_SERVERPIPE:
if (ignore_system_lyxrc ||
lyxpipes != system_lyxrc.lyxpipes) {
os << "\\serverpipe \"" << lyxpipes << "\"\n";
string const path = os::external_path(lyxpipes);
os << "\\serverpipe \"" << path << "\"\n";
}
case RC_DATE_INSERT_FORMAT:
if (ignore_system_lyxrc ||
@ -1672,7 +1684,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
case RC_PRINTTOFILE:
if (ignore_system_lyxrc ||
print_to_file != system_lyxrc.print_to_file) {
os << "\\print_to_file \"" << print_to_file << "\"\n";
string const path = os::external_path(print_to_file);
os << "\\print_to_file \"" << path << "\"\n";
}
case RC_PRINTFILEEXTENSION:
if (ignore_system_lyxrc ||
@ -1719,12 +1732,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
case RC_DOCUMENTPATH:
if (ignore_system_lyxrc ||
document_path != system_lyxrc.document_path) {
os << "\\document_path \"" << document_path << "\"\n";
string const path = os::external_path(document_path);
os << "\\document_path \"" << path << "\"\n";
}
case RC_LASTFILES:
if (ignore_system_lyxrc ||
lastfiles != system_lyxrc.lastfiles) {
os << "\\lastfiles \"" << lastfiles << "\"\n";
string const path = os::external_path(lastfiles);
os << "\\lastfiles \"" << path << "\"\n";
}
case RC_NUMLASTFILES:
if (ignore_system_lyxrc ||
@ -1740,12 +1755,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
case RC_TEMPLATEPATH:
if (ignore_system_lyxrc ||
template_path != system_lyxrc.template_path) {
os << "\\template_path \"" << template_path << "\"\n";
string const path = os::external_path(template_path);
os << "\\template_path \"" << path << "\"\n";
}
case RC_TEMPDIRPATH:
if (ignore_system_lyxrc ||
tempdir_path != system_lyxrc.tempdir_path) {
os << "\\tempdir_path \"" << tempdir_path << "\"\n";
string const path = os::external_path(tempdir_path);
os << "\\tempdir_path \"" << path << "\"\n";
}
case RC_USETEMPDIR:
// Ignore it
@ -1762,7 +1779,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
case RC_BACKUPDIR_PATH:
if (ignore_system_lyxrc ||
backupdir_path != system_lyxrc.backupdir_path) {
os << "\\backupdir_path \"" << backupdir_path << "\"\n";
string const path = os::external_path(backupdir_path);
os << "\\backupdir_path \"" << path << "\"\n";
}
os << "\n#\n"
@ -1827,8 +1845,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
}
case RC_PERS_DICT:
if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
os << "\\personal_dictionary \"" << isp_pers_dict
<< "\"\n";
string const path = os::external_path(isp_pers_dict);
os << "\\personal_dictionary \"" << path << "\"\n";
}
case RC_USE_INP_ENC:
if (ignore_system_lyxrc ||