]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiPrefs.cpp
add support for decimal alignment in tables
[features.git] / src / frontends / qt4 / GuiPrefs.cpp
index f2a40b2641812bfc4542a69e6916a8069b41349e..d8f1504b4fa5b1feeaf3ebd7eb59c3e23fc69246 100644 (file)
@@ -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"
@@ -114,9 +115,9 @@ QString browseFile(QString const & filename,
        FileDialog::Result result;
 
        if (save)
-               result = dlg.save(lastPath, filters, onlyFilename(filename));
+               result = dlg.save(lastPath, filters, onlyFileName(filename));
        else
-               result = dlg.open(lastPath, filters, onlyFilename(filename));
+               result = dlg.open(lastPath, filters, onlyFileName(filename));
 
        return result.second;
 }
@@ -136,14 +137,14 @@ QString browseLibFile(QString const & dir,
        // FIXME UNICODE
        QString const label1 = qt_("System files|#S#s");
        QString const dir1 =
-               toqstr(addName(package().system_support().absFilename(), fromqstr(dir)));
+               toqstr(addName(package().system_support().absFileName(), fromqstr(dir)));
 
        QString const label2 = qt_("User files|#U#u");
        QString const dir2 =
-               toqstr(addName(package().user_support().absFilename(), fromqstr(dir)));
+               toqstr(addName(package().user_support().absFileName(), fromqstr(dir)));
 
        QString const result = browseFile(toqstr(
-               libFileSearch(dir, name, ext).absFilename()),
+               libFileSearch(dir, name, ext).absFileName()),
                title, filters, false, dir1, dir2, QString(), QString(), dir1);
 
        // remove the extension if it is the default one
@@ -154,8 +155,8 @@ QString browseLibFile(QString const & dir,
                noextresult = result;
 
        // remove the directory, if it is the default one
-       QString const file = onlyFilename(noextresult);
-       if (toqstr(libFileSearch(dir, file, ext).absFilename()) == result)
+       QString const file = onlyFileName(noextresult);
+       if (toqstr(libFileSearch(dir, file, ext).absFileName()) == result)
                return file;
        else
                return noextresult;
@@ -183,7 +184,7 @@ QString browseDir(QString const & pathname,
        dlg.setButton2(label2, dir2);
 
        FileDialog::Result const result =
-               dlg.opendir(lastPath, onlyFilename(pathname));
+               dlg.opendir(lastPath, onlyFileName(pathname));
 
        return result.second;
 }
@@ -324,34 +325,6 @@ static void setComboxFont(QComboBox * cb, string const & family,
 }
 
 
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefPlaintext
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefPlaintext::PrefPlaintext(GuiPreferences * form)
-       : PrefModule(qt_(catOutput), qt_("Plain text"), form)
-{
-       setupUi(this);
-       connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
-               this, SIGNAL(changed()));
-}
-
-
-void PrefPlaintext::apply(LyXRC & rc) const
-{
-       rc.plaintext_linelen = plaintextLinelengthSB->value();
-}
-
-
-void PrefPlaintext::update(LyXRC const & rc)
-{
-       plaintextLinelengthSB->setValue(rc.plaintext_linelen);
-}
-
-
 /////////////////////////////////////////////////////////////////////
 //
 // StrftimeValidator
@@ -383,21 +356,40 @@ 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(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
+               this, SIGNAL(changed()));
+       connect(overwriteCO, SIGNAL(activated(int)),
+               this, SIGNAL(changed()));
+       connect(dviCB, SIGNAL(editTextChanged(QString)),
+               this, SIGNAL(changed()));
+       connect(pdfCB, SIGNAL(editTextChanged(QString)),
+               this, SIGNAL(changed()));
+       dviCB->addItem("");
+       dviCB->addItem("xdvi -sourceposition $$n:$$t $$o");
+       dviCB->addItem("yap -1 -s $$n$$t $$o");
+       dviCB->addItem("okular --unique $$o#src:$$n$$t");
+       dviCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"evince -p %{page+1} $$o\"");
+       pdfCB->addItem("");
+       pdfCB->addItem("CMCDDE SUMATRA control [ForwardSearch(\\\"$$o\\\",\\\"$$t\\\",$$n,0,0,1)]");
+       pdfCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"xpdf -raise -remote $$t.tmp $$o %{page+1}\"");
+       pdfCB->addItem("okular --unique $$o#src:$$n$$t");
+       pdfCB->addItem("synctex view -i $$n:0:$$t -o $$o -x \"evince -p %{page+1} $$o\"");
+       pdfCB->addItem("/Applications/Skim.app/Contents/SharedSupport/displayline $$n $$o $$t");
 }
 
 
-void PrefDate::on_DateED_textChanged(const QString &)
+void PrefOutput::on_DateED_textChanged(const QString &)
 {
        QString t = DateED->text();
        int p = 0;
@@ -407,15 +399,45 @@ 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());
+       rc.plaintext_linelen = plaintextLinelengthSB->value();
+       rc.forward_search_dvi = fromqstr(dviCB->currentText());
+       rc.forward_search_pdf = fromqstr(pdfCB->currentText());
+
+       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));
+       plaintextLinelengthSB->setValue(rc.plaintext_linelen);
+       dviCB->setEditText(toqstr(rc.forward_search_dvi));
+       pdfCB->setEditText(toqstr(rc.forward_search_pdf));
+
+       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;
+       }
 }
 
 
@@ -1005,7 +1027,9 @@ PrefColors::PrefColors(GuiPreferences * form)
                        || lc == Color_magenta
                        || lc == Color_yellow
                        || lc == Color_inherit
-                       || lc == Color_ignore) continue;
+                       || lc == Color_ignore
+                       || lc == Color_greyedouttext
+                       || lc == Color_shadedbg) continue;
 
                lcolors_.push_back(lc);
        }
@@ -1013,7 +1037,7 @@ PrefColors::PrefColors(GuiPreferences * form)
        vector<ColorCode>::const_iterator cit = lcolors_.begin();
        vector<ColorCode>::const_iterator const end = lcolors_.end();
        for (; cit != end; ++cit) {
-                       (void) new QListWidgetItem(QIcon(icon),
+               (void) new QListWidgetItem(QIcon(icon),
                        toqstr(lcolor.getGUIName(*cit)), lyxObjectsLW);
        }
        curcolors_.resize(lcolors_.size());
@@ -1499,6 +1523,8 @@ void PrefConverters::changeConverter()
 
 void PrefConverters::updateButtons()
 {
+       if (form_->formats().size() == 0)
+               return;
        Format const & from = form_->formats().get(converterFromCO->currentIndex());
        Format const & to = form_->formats().get(converterToCO->currentIndex());
        int const sel = form_->converters().getNumber(from.name(), to.name());
@@ -1777,6 +1803,8 @@ void PrefFileformats::updateView()
 
 void PrefFileformats::on_formatsCB_currentIndexChanged(int i)
 {
+       if (form_->formats().size() == 0)
+               return;
        int const nr = formatsCB->itemData(i).toInt();
        Format const f = form_->formats().get(nr);
 
@@ -2042,6 +2070,8 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(uiLanguageCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
+       connect(defaultDecimalPointLE, SIGNAL(textChanged(QString)),
+               this, SIGNAL(changed()));
 
        uiLanguageCO->clear();
 
@@ -2085,6 +2115,7 @@ void PrefLanguage::apply(LyXRC & rc) const
        rc.language_command_end = fromqstr(endCommandED->text());
        rc.gui_language = fromqstr(
                uiLanguageCO->itemData(uiLanguageCO->currentIndex()).toString());
+       rc.default_decimal_point = fromqstr(defaultDecimalPointLE->text());
 }
 
 
@@ -2104,6 +2135,7 @@ void PrefLanguage::update(LyXRC const & rc)
        languagePackageED->setText(toqstr(rc.language_package));
        startCommandED->setText(toqstr(rc.language_command_begin));
        endCommandED->setText(toqstr(rc.language_command_end));
+       defaultDecimalPointLE->setText(toqstr(rc.default_decimal_point));
 
        int pos = uiLanguageCO->findData(toqstr(rc.gui_language));
        uiLanguageCO->blockSignals(true);
@@ -2444,7 +2476,7 @@ 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
-       FileName bind_dir(addPath(package().user_support().absFilename(), "bind"));
+       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;
@@ -2455,7 +2487,7 @@ void PrefShortcuts::apply(LyXRC & rc) const
                       << bind_dir << "'. All user-defined key bindings will be lost." << endl;
                return;
        }
-       FileName user_bind_file(bind_dir.absFilename() + "/user.bind");
+       FileName user_bind_file(bind_dir.absFileName() + "/user.bind");
        user_unbind_.write(user_bind_file.toFilesystemEncoding(), false, true);
        user_bind_.write(user_bind_file.toFilesystemEncoding(), true, false);
        // immediately apply the keybindings. Why this is not done before?
@@ -2560,7 +2592,7 @@ void PrefShortcuts::setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag)
 QTreeWidgetItem * PrefShortcuts::insertShortcutItem(FuncRequest const & lfun,
                KeySequence const & seq, KeyMap::ItemType tag)
 {
-       FuncCode action = lfun.action;
+       FuncCode const action = lfun.action();
        string const action_name = lyxaction.getActionName(action);
        QString const lfun_name = toqstr(from_utf8(action_name)
                        + ' ' + lfun.argument());
@@ -2774,7 +2806,7 @@ void PrefShortcuts::on_searchLE_textEdited()
 
 docstring makeCmdString(FuncRequest const & f)
 {
-       docstring actionStr = from_ascii(lyxaction.getActionName(f.action));
+       docstring actionStr = from_ascii(lyxaction.getActionName(f.action()));
        if (!f.argument().empty())
                actionStr += " " + f.argument();
        return actionStr;
@@ -2786,7 +2818,7 @@ void PrefShortcuts::shortcutOkPressed()
        QString const new_lfun = shortcut_->lfunLE->text();
        FuncRequest func = lyxaction.lookupFunc(fromqstr(new_lfun));
 
-       if (func.action == LFUN_UNKNOWN_ACTION) {
+       if (func.action() == LFUN_UNKNOWN_ACTION) {
                Alert::error(_("Failed to create shortcut"),
                        _("Unknown or invalid LyX function"));
                return;
@@ -2801,16 +2833,16 @@ void PrefShortcuts::shortcutOkPressed()
 
        // check to see if there's been any change
        FuncRequest oldBinding = system_bind_.getBinding(k);
-       if (oldBinding.action == LFUN_UNKNOWN_ACTION)
+       if (oldBinding.action() == LFUN_UNKNOWN_ACTION)
                oldBinding = user_bind_.getBinding(k);
        if (oldBinding == func)
                // nothing has changed
                return;
        
        // make sure this key isn't already bound---and, if so, not unbound
-       FuncCode const unbind = user_unbind_.getBinding(k).action;
+       FuncCode const unbind = user_unbind_.getBinding(k).action();
        docstring const action_string = makeCmdString(oldBinding);
-       if (oldBinding.action > LFUN_NOACTION && unbind == LFUN_UNKNOWN_ACTION
+       if (oldBinding.action() > LFUN_NOACTION && unbind == LFUN_UNKNOWN_ACTION
                  && save_lfun_ != toqstr(action_string)) {
                // FIXME Perhaps we should offer to over-write the old shortcut?
                // If so, we'll need to remove it from our list, etc.
@@ -2925,10 +2957,10 @@ GuiPreferences::GuiPreferences(GuiView & lv)
        addModule(new PrefLanguage(this));
        addModule(new PrefSpellchecker(this));
 
+       //for strftime validator
+       PrefOutput * output = new PrefOutput(this); 
+       addModule(output);
        addModule(new PrefPrinter(this));
-       PrefDate * dateFormat = new PrefDate(this);
-       addModule(dateFormat);
-       addModule(new PrefPlaintext(this));
        addModule(new PrefLatex(this));
 
        PrefConverters * converters = new PrefConverters(this);
@@ -2952,7 +2984,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
        bc().setRestore(restorePB);
 
        // initialize the strftime validator
-       bc().addCheckedLineEdit(dateFormat->DateED);
+       bc().addCheckedLineEdit(output->DateED);
 }