From c81f205007aef67cc8892ea1e12a5e3ffd76ad3a Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Thu, 16 Jun 2005 15:53:18 +0000 Subject: [PATCH] Various path fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_3_X@10078 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 8 ++++ src/converter.C | 2 +- src/frontends/qt2/ChangeLog | 9 +++++ src/frontends/qt2/QPrefs.C | 68 +++++++++++++++++++++----------- src/frontends/qt2/QPrefsDialog.C | 21 +++++++++- src/lyxrc.C | 68 ++++++++++++++++++++------------ 6 files changed, 124 insertions(+), 52 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index bd28be5f42..1aac027451 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2005-06-16 Angus Leeming + + * 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. + + * converter.C (view): enable the viewer to use the '$$s' placeholder. + 2005-06-14 Angus Leeming * lyx_main.C (init): ensure that the LyX binary dir is the first diff --git a/src/converter.C b/src/converter.C index 5f3459f013..89fe9ce3ab 100644 --- a/src/converter.C +++ b/src/converter.C @@ -185,7 +185,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()) { diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 2b6284c56f..1be98d2b3a 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,12 @@ +2005-06-16 Angus Leeming + + * 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 * QPrefs.C (setComboxFont): ensure that only the font family name diff --git a/src/frontends/qt2/QPrefs.C b/src/frontends/qt2/QPrefs.C index 9c11aa51ef..d2bac9eb8b 100644 --- a/src/frontends/qt2/QPrefs.C +++ b/src/frontends/qt2/QPrefs.C @@ -11,6 +11,7 @@ #include #include "support/lstrings.h" +#include "support/os.h" #include "Lsstream.h" #include @@ -92,6 +93,16 @@ void QPrefs::build_dialog() } +namespace { + +string const internal_path(QString const & input) +{ + return os::internal_path(fromqstr(input)); +} + +} + + void QPrefs::apply() { LyXRC & rc(controller().rc()); @@ -112,8 +123,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; @@ -125,8 +136,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); @@ -177,18 +188,16 @@ void QPrefs::apply() gc.changeDisplay(); } #endif - 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.document_path = internal_path(pathsmod->workingDirED->text()); + rc.template_path = internal_path(pathsmod->templateDirED->text()); + rc.backupdir_path = internal_path(pathsmod->backupDirED->text()); rc.use_tempdir = pathsmod->tempDirCB->isChecked(); - rc.tempdir_path = fromqstr(pathsmod->tempDirED->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); @@ -201,7 +210,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(); @@ -224,7 +233,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()); @@ -347,6 +356,17 @@ void setComboxFont(QComboBox * cb, string const & family, } + +namespace { + +QString const external_path(string const & input) +{ + return toqstr(os::external_path(input)); +} + +} + + void QPrefs::update_contents() { LyXRC const & rc(controller().rc()); @@ -369,8 +389,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 @@ -393,8 +413,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); @@ -439,14 +459,14 @@ 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->workingDirED->setText(external_path(rc.document_path)); + pathsmod->templateDirED->setText(external_path(rc.template_path)); + pathsmod->backupDirED->setText(external_path(rc.backupdir_path)); pathsmod->tempDirCB->setChecked(rc.use_tempdir); - pathsmod->tempDirED->setText(toqstr(rc.tempdir_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); @@ -462,7 +482,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); @@ -484,7 +504,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)); diff --git a/src/frontends/qt2/QPrefsDialog.C b/src/frontends/qt2/QPrefsDialog.C index e816c44924..8d643b4752 100644 --- a/src/frontends/qt2/QPrefsDialog.C +++ b/src/frontends/qt2/QPrefsDialog.C @@ -409,6 +409,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())); @@ -420,6 +424,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); } @@ -474,7 +483,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()); @@ -493,6 +507,11 @@ void QPrefsDialog::modify_format() fileformatsModule->formatsLB->setUpdatesEnabled(true); fileformatsModule->formatsLB->update(); + QListBoxItem * const item = + fileformatsModule->formatsLB->findItem(current_text); + fileformatsModule->formatsLB->setCurrentItem(item); + fileformatsModule->formatsLB->setTopItem(top_item); + updateConverters(); } diff --git a/src/lyxrc.C b/src/lyxrc.C index 16b1c890cc..8843ce1544 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -343,7 +343,7 @@ int LyXRC::read(string const & filename) break; case RC_BINDFILE: // RVDK_PATCH_5 if (lexrc.next()) { - string const tmp(lexrc.getString()); + string const tmp(os::internal_path(lexrc.getString())); if (hasBindFile) { // We are already in the // "actually read bind file" @@ -360,7 +360,7 @@ int LyXRC::read(string const & filename) case RC_UIFILE: if (lexrc.next()) { - ui_file = lexrc.getString(); + ui_file = os::internal_path(lexrc.getString()); } break; @@ -397,7 +397,7 @@ int LyXRC::read(string const & filename) 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, @@ -411,7 +411,7 @@ int LyXRC::read(string const & filename) 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, @@ -497,7 +497,7 @@ int LyXRC::read(string const & filename) case RC_PRINTTOFILE: if (lexrc.next()) { - print_to_file = lexrc.getString(); + print_to_file = os::internal_path(lexrc.getString()); } break; @@ -672,19 +672,22 @@ int LyXRC::read(string const & filename) 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; @@ -696,7 +699,8 @@ int LyXRC::read(string const & filename) case RC_LASTFILES: if (lexrc.next()) { - lastfiles = ExpandPath(lexrc.getString()); + lastfiles = os::internal_path(lexrc.getString()); + lastfiles = ExpandPath(lastfiles); } break; @@ -859,7 +863,8 @@ int LyXRC::read(string const & filename) } case RC_SERVERPIPE: if (lexrc.next()) { - lyxpipes = ExpandPath(lexrc.getString()); + lyxpipes = os::internal_path(lexrc.getString()); + lyxpipes = ExpandPath(lyxpipes); } break; @@ -930,7 +935,7 @@ int LyXRC::read(string const & filename) 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: @@ -945,7 +950,8 @@ int LyXRC::read(string const & filename) 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: @@ -1170,7 +1176,8 @@ void LyXRC::output(ostream & os) const // bindings is not written to the preferences file. case RC_BINDFILE: if (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 @@ -1188,7 +1195,8 @@ void LyXRC::output(ostream & os) const case RC_UIFILE: if (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 (auto_region_delete != system_lyxrc.auto_region_delete) { @@ -1273,16 +1281,18 @@ void LyXRC::output(ostream & os) const } case RC_KBMAP_PRIMARY: if (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 (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 (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 (date_insert_format != system_lyxrc.date_insert_format) { @@ -1545,7 +1555,8 @@ void LyXRC::output(ostream & os) const } case RC_PRINTTOFILE: if (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 (print_file_extension != system_lyxrc.print_file_extension) { @@ -1587,11 +1598,13 @@ void LyXRC::output(ostream & os) const case RC_DOCUMENTPATH: if (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 (lastfiles != system_lyxrc.lastfiles) { - os << "\\lastfiles \"" << lastfiles << "\"\n"; + string const path = os::external_path(lastfiles); + os << "\\lastfiles \"" << path << "\"\n"; } case RC_NUMLASTFILES: if (num_lastfiles != system_lyxrc.num_lastfiles) { @@ -1604,11 +1617,13 @@ void LyXRC::output(ostream & os) const } case RC_TEMPLATEPATH: if (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 (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: if (use_tempdir != system_lyxrc.use_tempdir) { @@ -1624,7 +1639,8 @@ void LyXRC::output(ostream & os) const } case RC_BACKUPDIR_PATH: if (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" @@ -1682,8 +1698,8 @@ void LyXRC::output(ostream & os) 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 (isp_use_input_encoding