X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiPrefs.cpp;h=290089b3f1bf080d999dfbfe5710e1b5510905e3;hb=ba76bf5eb85db5a10839fccee3430d906d3f7b70;hp=d08b10eab001d3cc5c4bb2f4cebd5b07a4682349;hpb=e7317582fbb1548cf020578b5fabed976fc94dba;p=lyx.git diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index d08b10eab0..290089b3f1 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -20,9 +20,9 @@ #include "BufferList.h" #include "Color.h" #include "ConverterCache.h" -#include "debug.h" +#include "support/debug.h" #include "FuncRequest.h" -#include "gettext.h" +#include "support/gettext.h" #include "GuiFontExample.h" #include "GuiKeySymbol.h" #include "KeyMap.h" @@ -35,7 +35,6 @@ #include "support/FileName.h" #include "support/filetools.h" #include "support/lstrings.h" -#include "support/lyxlib.h" #include "support/os.h" #include "support/Package.h" #include "support/FileFilterList.h" @@ -57,7 +56,6 @@ #include #include #include -#include #include #include @@ -65,26 +63,13 @@ using namespace Ui; -using std::endl; -using std::ostringstream; -using std::string; -using std::vector; +using namespace std; +using namespace lyx::support; +using namespace lyx::support::os; namespace lyx { namespace frontend { -using support::compare_ascii_no_case; -using support::os::external_path; -using support::os::external_path_list; -using support::os::internal_path; -using support::os::internal_path_list; -using support::FileName; -using support::FileFilterList; -using support::addPath; -using support::addName; -using support::mkdir; -using support::package; - ///////////////////////////////////////////////////////////////////// // @@ -93,21 +78,21 @@ using support::package; ///////////////////////////////////////////////////////////////////// template -static size_t findPos_helper(std::vector const & vec, A const & val) +static size_t findPos_helper(vector const & vec, A const & val) { - typedef typename std::vector::const_iterator Cit; + typedef typename vector::const_iterator Cit; - Cit it = std::find(vec.begin(), vec.end(), val); + Cit it = find(vec.begin(), vec.end(), val); if (it == vec.end()) return 0; - return std::distance(vec.begin(), it); + return distance(vec.begin(), it); } static void parseFontName(QString const & mangled0, string & name, string & foundry) { - std::string mangled = fromqstr(mangled0); + string mangled = fromqstr(mangled0); size_t const idx = mangled.find('['); if (idx == string::npos || idx == 0) { name = mangled; @@ -260,12 +245,12 @@ void PrefDate::update(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// // -// PrefKeyboard +// PrefInput // ///////////////////////////////////////////////////////////////////// -PrefKeyboard::PrefKeyboard(GuiPreferences * form, QWidget * parent) - : PrefModule(_("Keyboard"), form, parent) +PrefInput::PrefInput(GuiPreferences * form, QWidget * parent) + : PrefModule(_("Keyboard/Mouse"), form, parent) { setupUi(this); @@ -275,34 +260,38 @@ PrefKeyboard::PrefKeyboard(GuiPreferences * form, QWidget * parent) this, SIGNAL(changed())); connect(secondKeymapED, SIGNAL(textChanged(QString)), this, SIGNAL(changed())); + connect(mouseWheelSpeedSB, SIGNAL(valueChanged(double)), + this, SIGNAL(changed())); } -void PrefKeyboard::apply(LyXRC & rc) const +void PrefInput::apply(LyXRC & rc) const { // FIXME: can derive CB from the two EDs rc.use_kbmap = keymapCB->isChecked(); rc.primary_kbmap = internal_path(fromqstr(firstKeymapED->text())); rc.secondary_kbmap = internal_path(fromqstr(secondKeymapED->text())); + rc.mouse_wheel_speed = mouseWheelSpeedSB->value(); } -void PrefKeyboard::update(LyXRC const & rc) +void PrefInput::update(LyXRC const & rc) { // FIXME: can derive CB from the two EDs keymapCB->setChecked(rc.use_kbmap); firstKeymapED->setText(toqstr(external_path(rc.primary_kbmap))); secondKeymapED->setText(toqstr(external_path(rc.secondary_kbmap))); + mouseWheelSpeedSB->setValue(rc.mouse_wheel_speed); } -QString PrefKeyboard::testKeymap(QString keymap) +QString PrefInput::testKeymap(QString keymap) { return toqstr(form_->browsekbmap(from_utf8(internal_path(fromqstr(keymap))))); } -void PrefKeyboard::on_firstKeymapPB_clicked(bool) +void PrefInput::on_firstKeymapPB_clicked(bool) { QString const file = testKeymap(firstKeymapED->text()); if (!file.isEmpty()) @@ -310,7 +299,7 @@ void PrefKeyboard::on_firstKeymapPB_clicked(bool) } -void PrefKeyboard::on_secondKeymapPB_clicked(bool) +void PrefInput::on_secondKeymapPB_clicked(bool) { QString const file = testKeymap(secondKeymapED->text()); if (!file.isEmpty()) @@ -318,7 +307,7 @@ void PrefKeyboard::on_secondKeymapPB_clicked(bool) } -void PrefKeyboard::on_keymapCB_toggled(bool keymap) +void PrefInput::on_keymapCB_toggled(bool keymap) { firstKeymapLA->setEnabled(keymap); secondKeymapLA->setEnabled(keymap); @@ -451,6 +440,8 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form, QWidget * parent) this, SIGNAL(changed())); connect(screenHugerED, SIGNAL(textChanged(QString)), this, SIGNAL(changed())); + connect(pixmapCacheCB, SIGNAL(toggled(bool)), + this, SIGNAL(changed())); screenTinyED->setValidator(new QDoubleValidator(screenTinyED)); screenSmallestED->setValidator(new QDoubleValidator(screenSmallestED)); @@ -488,6 +479,7 @@ void PrefScreenFonts::apply(LyXRC & rc) const rc.font_sizes[FONT_SIZE_LARGEST] = fromqstr(screenLargestED->text()); rc.font_sizes[FONT_SIZE_HUGE] = fromqstr(screenHugeED->text()); rc.font_sizes[FONT_SIZE_HUGER] = fromqstr(screenHugerED->text()); + rc.use_pixmap_cache = pixmapCacheCB->isChecked(); if (rc.font_sizes != oldrc.font_sizes || rc.roman_font_name != oldrc.roman_font_name @@ -529,6 +521,12 @@ void PrefScreenFonts::update(LyXRC const & rc) screenLargestED->setText(toqstr(rc.font_sizes[FONT_SIZE_LARGEST])); screenHugeED->setText(toqstr(rc.font_sizes[FONT_SIZE_HUGE])); screenHugerED->setText(toqstr(rc.font_sizes[FONT_SIZE_HUGER])); + + pixmapCacheCB->setChecked(rc.use_pixmap_cache); +#if defined(Q_WS_X11) + pixmapCacheCB->setEnabled(false); +#endif + } @@ -592,7 +590,7 @@ PrefColors::PrefColors(GuiPreferences * form, QWidget * parent) lcolors_.push_back(lc); } - std::sort(lcolors_.begin(), lcolors_.end(), ColorSorter()); + sort(lcolors_.begin(), lcolors_.end(), ColorSorter()); vector::const_iterator cit = lcolors_.begin(); vector::const_iterator const end = lcolors_.end(); for (; cit != end; ++cit) { @@ -740,6 +738,7 @@ PrefPaths::PrefPaths(GuiPreferences * form, QWidget * parent) : PrefModule(_("Paths"), form, parent) { setupUi(this); + connect(exampleDirPB, SIGNAL(clicked()), this, SLOT(select_exampledir())); connect(templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir())); connect(tempDirPB, SIGNAL(clicked()), this, SLOT(select_tempdir())); connect(backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir())); @@ -747,6 +746,8 @@ PrefPaths::PrefPaths(GuiPreferences * form, QWidget * parent) connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe())); connect(workingDirED, SIGNAL(textChanged(QString)), this, SIGNAL(changed())); + connect(exampleDirED, SIGNAL(textChanged(QString)), + this, SIGNAL(changed())); connect(templateDirED, SIGNAL(textChanged(QString)), this, SIGNAL(changed())); connect(backupDirED, SIGNAL(textChanged(QString)), @@ -763,6 +764,7 @@ PrefPaths::PrefPaths(GuiPreferences * form, QWidget * parent) void PrefPaths::apply(LyXRC & rc) const { 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.backupdir_path = internal_path(fromqstr(backupDirED->text())); rc.tempdir_path = internal_path(fromqstr(tempDirED->text())); @@ -775,6 +777,7 @@ void PrefPaths::apply(LyXRC & rc) const void PrefPaths::update(LyXRC const & rc) { workingDirED->setText(toqstr(external_path(rc.document_path))); + exampleDirED->setText(toqstr(external_path(rc.example_path))); templateDirED->setText(toqstr(external_path(rc.template_path))); backupDirED->setText(toqstr(external_path(rc.backupdir_path))); tempDirED->setText(toqstr(external_path(rc.tempdir_path))); @@ -784,6 +787,16 @@ void PrefPaths::update(LyXRC const & rc) } +void PrefPaths::select_exampledir() +{ + docstring file(form_->browsedir( + from_utf8(internal_path(fromqstr(exampleDirED->text()))), + _("Select directory for example files"))); + if (!file.empty()) + exampleDirED->setText(toqstr(file)); +} + + void PrefPaths::select_templatedir() { docstring file(form_->browsedir( @@ -1028,7 +1041,7 @@ void PrefConverters::updateGui() Converters::const_iterator ccit = form_->converters().begin(); Converters::const_iterator cend = form_->converters().end(); for (; ccit != cend; ++ccit) { - std::string const name = + string const name = ccit->From->prettyname() + " -> " + ccit->To->prettyname(); int type = form_->converters().getNumber(ccit->From->name(), ccit->To->name()); new QListWidgetItem(toqstr(name), convertersLW, type); @@ -1202,7 +1215,7 @@ FormatNameValidator::FormatNameValidator(QWidget * parent, Formats const & f) { } -std::string FormatNameValidator::str(Formats::const_iterator it) const +string FormatNameValidator::str(Formats::const_iterator it) const { return it->name(); } @@ -1214,7 +1227,7 @@ FormatPrettynameValidator::FormatPrettynameValidator(QWidget * parent, Formats c } -std::string FormatPrettynameValidator::str(Formats::const_iterator it) const +string FormatPrettynameValidator::str(Formats::const_iterator it) const { return it->prettyname(); } @@ -1424,7 +1437,11 @@ PrefLanguage::PrefLanguage(QWidget * parent) { setupUi(this); - connect(rtlCB, SIGNAL(clicked()), + connect(rtlGB, SIGNAL(clicked()), + this, SIGNAL(changed())); + connect(visualCursorRB, SIGNAL(clicked()), + this, SIGNAL(changed())); + connect(logicalCursorRB, SIGNAL(clicked()), this, SIGNAL(changed())); connect(markForeignCB, SIGNAL(clicked()), this, SIGNAL(changed())); @@ -1448,9 +1465,9 @@ PrefLanguage::PrefLanguage(QWidget * parent) defaultLanguageCO->clear(); // store the lang identifiers for later - std::vector const langs = getLanguageData(false); - std::vector::const_iterator lit = langs.begin(); - std::vector::const_iterator lend = langs.end(); + vector const langs = getLanguageData(false); + vector::const_iterator lit = langs.begin(); + vector::const_iterator lend = langs.end(); lang_.clear(); for (; lit != lend; ++lit) { defaultLanguageCO->addItem(toqstr(lit->first)); @@ -1462,7 +1479,8 @@ PrefLanguage::PrefLanguage(QWidget * parent) void PrefLanguage::apply(LyXRC & rc) const { // FIXME: remove rtl_support bool - rc.rtl_support = rtlCB->isChecked(); + rc.rtl_support = rtlGB->isChecked(); + rc.visual_cursor = rtlGB->isChecked() && visualCursorRB->isChecked(); rc.mark_foreign_language = markForeignCB->isChecked(); rc.language_auto_begin = autoBeginCB->isChecked(); rc.language_auto_end = autoEndCB->isChecked(); @@ -1478,7 +1496,11 @@ void PrefLanguage::apply(LyXRC & rc) const void PrefLanguage::update(LyXRC const & rc) { // FIXME: remove rtl_support bool - rtlCB->setChecked(rc.rtl_support); + rtlGB->setChecked(rc.rtl_support); + if (rc.visual_cursor) + visualCursorRB->setChecked(true); + else + logicalCursorRB->setChecked(true); markForeignCB->setChecked(rc.mark_foreign_language); autoBeginCB->setChecked(rc.language_auto_begin); autoEndCB->setChecked(rc.language_auto_end); @@ -1620,13 +1642,15 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent) this, SIGNAL(changed())); connect(sortEnvironmentsCB, SIGNAL(clicked()), this, SIGNAL(changed())); + connect(macroEditStyleCO, SIGNAL(activated(int)), + this, SIGNAL(changed())); connect(autoSaveSB, SIGNAL(valueChanged(int)), this, SIGNAL(changed())); connect(autoSaveCB, SIGNAL(clicked()), this, SIGNAL(changed())); connect(lastfilesSB, SIGNAL(valueChanged(int)), this, SIGNAL(changed())); - connect(pixmapCacheCB, SIGNAL(toggled(bool)), + connect(tooltipCB, SIGNAL(toggled(bool)), this, SIGNAL(changed())); lastfilesSB->setMaximum(maxlastfiles); } @@ -1640,10 +1664,15 @@ void PrefUserInterface::apply(LyXRC & rc) const rc.allow_geometry_session = allowGeometrySessionCB->isChecked(); rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked(); rc.sort_layouts = sortEnvironmentsCB->isChecked(); + switch (macroEditStyleCO->currentIndex()) { + case 0: rc.macro_edit_style = LyXRC::MACRO_EDIT_INLINE_BOX; break; + case 1: rc.macro_edit_style = LyXRC::MACRO_EDIT_INLINE; break; + case 2: rc.macro_edit_style = LyXRC::MACRO_EDIT_LIST; break; + } rc.autosave = autoSaveSB->value() * 60; rc.make_backup = autoSaveCB->isChecked(); rc.num_lastfiles = lastfilesSB->value(); - rc.use_pixmap_cache = pixmapCacheCB->isChecked(); + rc.use_tooltip = tooltipCB->isChecked(); } @@ -1655,6 +1684,7 @@ void PrefUserInterface::update(LyXRC const & rc) allowGeometrySessionCB->setChecked(rc.allow_geometry_session); cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar); sortEnvironmentsCB->setChecked(rc.sort_layouts); + macroEditStyleCO->setCurrentIndex(rc.macro_edit_style); // convert to minutes int mins(rc.autosave / 60); if (rc.autosave && !mins) @@ -1662,10 +1692,7 @@ void PrefUserInterface::update(LyXRC const & rc) autoSaveSB->setValue(mins); autoSaveCB->setChecked(rc.make_backup); lastfilesSB->setValue(rc.num_lastfiles); - pixmapCacheCB->setChecked(rc.use_pixmap_cache); -#if defined(Q_WS_X11) - pixmapCacheGB->setEnabled(false); -#endif + tooltipCB->setChecked(rc.use_tooltip); } @@ -1735,18 +1762,18 @@ void PrefShortcuts::apply(LyXRC & rc) const { rc.bind_file = internal_path(fromqstr(bindFileED->text())); // write user_bind and user_unbind to .lyx/bind/user.bind - string bind_dir = addPath(package().user_support().absFilename(), "bind"); - if (!FileName(bind_dir).exists() && mkdir(FileName(bind_dir), 0777)) { + FileName bind_dir(addPath(package().user_support().absFilename(), "bind")); + if (!bind_dir.exists() && !bind_dir.createDirectory(0777)) { lyxerr << "LyX could not create the user bind directory '" << bind_dir << "'. All user-defined key bindings will be lost." << endl; return; } - if (!FileName(bind_dir).isDirWritable()) { + if (!bind_dir.isDirWritable()) { lyxerr << "LyX could not write to the user bind directory '" << bind_dir << "'. All user-defined key bindings will be lost." << endl; return; } - FileName user_bind_file = FileName(addName(bind_dir, "user.bind")); + FileName user_bind_file(bind_dir.absFilename() + "/user.bind"); user_bind_.write(user_bind_file.toFilesystemEncoding(), false, false); user_unbind_.write(user_bind_file.toFilesystemEncoding(), true, true); // immediately apply the keybindings. Why this is not done before? @@ -2122,10 +2149,9 @@ void PrefIdentity::update(LyXRC const & rc) ///////////////////////////////////////////////////////////////////// GuiPreferences::GuiPreferences(GuiView & lv) - : GuiDialog(lv, "prefs"), update_screen_font_(false) + : GuiDialog(lv, "prefs", qt_("Preferences")), update_screen_font_(false) { setupUi(this); - setViewTitle(_("Preferences")); QDialog::setModal(false); @@ -2139,7 +2165,7 @@ GuiPreferences::GuiPreferences(GuiView & lv) add(new PrefScreenFonts(this)); add(new PrefColors(this)); add(new PrefDisplay); - add(new PrefKeyboard(this)); + add(new PrefInput(this)); add(new PrefPaths(this)); @@ -2184,13 +2210,6 @@ void GuiPreferences::add(PrefModule * module) } -void GuiPreferences::closeEvent(QCloseEvent * e) -{ - slotClose(); - e->accept(); -} - - void GuiPreferences::change_adaptor() { changed(); @@ -2225,7 +2244,7 @@ void GuiPreferences::updateContents() } -bool GuiPreferences::initialiseParams(std::string const &) +bool GuiPreferences::initialiseParams(string const &) { rc_ = lyxrc; formats_ = lyx::formats;