]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPrefs.cpp
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / GuiPrefs.cpp
index b53384dff71692b2201a12f67fb817532549a5bc..6dfd337dcdd005f086eb6add84923f46861ae7a6 100644 (file)
@@ -112,7 +112,7 @@ QString browseFile(QString const & filename,
        else if(!fallback_dir.isEmpty())
                lastPath = fallback_dir;
 
-       FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
+       FileDialog dlg(title);
        dlg.setButton2(label1, dir1);
        dlg.setButton2(label2, dir2);
 
@@ -183,7 +183,7 @@ QString browseDir(QString const & pathname,
        if (!pathname.isEmpty())
                lastPath = onlyPath(pathname);
 
-       FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
+       FileDialog dlg(title);
        dlg.setButton1(label1, dir1);
        dlg.setButton2(label2, dir2);
 
@@ -1893,6 +1893,8 @@ PrefFileformats::PrefFileformats(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(defaultFormatCB, SIGNAL(activated(QString)),
                this, SIGNAL(changed()));
+       connect(defaultOTFFormatCB, SIGNAL(activated(QString)),
+               this, SIGNAL(changed()));
        connect(viewerCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
        connect(editorCO, SIGNAL(activated(int)),
@@ -1920,6 +1922,9 @@ void PrefFileformats::apply(LyXRC & rc) const
        QString const default_format = defaultFormatCB->itemData(
                defaultFormatCB->currentIndex()).toString();
        rc.default_view_format = fromqstr(default_format);
+       QString const default_otf_format = defaultOTFFormatCB->itemData(
+               defaultOTFFormatCB->currentIndex()).toString();
+       rc.default_otf_view_format = fromqstr(default_otf_format);
 }
 
 
@@ -1930,9 +1935,12 @@ void PrefFileformats::update(LyXRC const & rc)
        bool const init = defaultFormatCB->currentText().isEmpty();
        updateView();
        if (init) {
-               int const pos =
+               int pos =
                        defaultFormatCB->findData(toqstr(rc.default_view_format));
                defaultFormatCB->setCurrentIndex(pos);
+               pos = defaultOTFFormatCB->findData(toqstr(rc.default_otf_view_format));
+                               defaultOTFFormatCB->setCurrentIndex(pos);
+               defaultOTFFormatCB->setCurrentIndex(pos);
        }
 }
 
@@ -1941,35 +1949,48 @@ void PrefFileformats::updateView()
 {
        QString const current = formatsCB->currentText();
        QString const current_def = defaultFormatCB->currentText();
+       QString const current_def_otf = defaultOTFFormatCB->currentText();
 
        // update comboboxes with formats
        formatsCB->blockSignals(true);
        defaultFormatCB->blockSignals(true);
+       defaultOTFFormatCB->blockSignals(true);
        formatsCB->clear();
        defaultFormatCB->clear();
+       defaultOTFFormatCB->clear();
        form_->formats().sort();
        Formats::const_iterator cit = form_->formats().begin();
        Formats::const_iterator end = form_->formats().end();
        for (; cit != end; ++cit) {
                formatsCB->addItem(qt_(cit->prettyname()),
                                QVariant(form_->formats().getNumber(cit->name())));
-               if (form_->converters().isReachable("latex", cit->name())
+               if (cit->viewer().empty())
+                       continue;
+               if (form_->converters().isReachable("xhtml", cit->name())
                    || form_->converters().isReachable("dviluatex", cit->name())
-                   || form_->converters().isReachable("pdflatex", cit->name())
                    || form_->converters().isReachable("luatex", cit->name())
-                   || form_->converters().isReachable("xetex", cit->name()))
+                   || form_->converters().isReachable("xetex", cit->name())) {
+                       defaultFormatCB->addItem(qt_(cit->prettyname()),
+                                       QVariant(toqstr(cit->name())));
+                       defaultOTFFormatCB->addItem(qt_(cit->prettyname()),
+                                       QVariant(toqstr(cit->name())));
+               } else if (form_->converters().isReachable("latex", cit->name())
+                          || form_->converters().isReachable("pdflatex", cit->name()))
                        defaultFormatCB->addItem(qt_(cit->prettyname()),
                                        QVariant(toqstr(cit->name())));
        }
 
-       // restore selection
+       // restore selections
        int item = formatsCB->findText(current, Qt::MatchExactly);
        formatsCB->setCurrentIndex(item < 0 ? 0 : item);
        on_formatsCB_currentIndexChanged(item < 0 ? 0 : item);
        item = defaultFormatCB->findText(current_def, Qt::MatchExactly);
        defaultFormatCB->setCurrentIndex(item < 0 ? 0 : item);
+       item = defaultOTFFormatCB->findText(current_def_otf, Qt::MatchExactly);
+       defaultOTFFormatCB->setCurrentIndex(item < 0 ? 0 : item);
        formatsCB->blockSignals(false);
        defaultFormatCB->blockSignals(false);
+       defaultOTFFormatCB->blockSignals(false);
 }
 
 
@@ -2527,7 +2548,6 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form)
 
 #if (!defined Q_WS_X11 || QT_VERSION < 0x040600)
        useSystemThemeIconsCB->hide();
-       themeIconsLA->hide();
 #endif
 }
 
@@ -2703,6 +2723,8 @@ PrefEdit::PrefEdit(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(toggleScrollbarCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
+       connect(toggleStatusbarCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
        connect(toggleToolbarsCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
 }
@@ -2723,6 +2745,7 @@ void PrefEdit::apply(LyXRC & rc) const
        rc.cursor_width = cursorWidthSB->value();
        rc.full_screen_toolbars = toggleToolbarsCB->isChecked();
        rc.full_screen_scrollbar = toggleScrollbarCB->isChecked();
+       rc.full_screen_statusbar = toggleStatusbarCB->isChecked();
        rc.full_screen_tabbar = toggleTabbarCB->isChecked();
        rc.full_screen_menubar = toggleMenubarCB->isChecked();
        rc.full_screen_width = fullscreenWidthSB->value();
@@ -2740,6 +2763,7 @@ void PrefEdit::update(LyXRC const & rc)
        macroEditStyleCO->setCurrentIndex(rc.macro_edit_style);
        cursorWidthSB->setValue(rc.cursor_width);
        toggleScrollbarCB->setChecked(rc.full_screen_scrollbar);
+       toggleScrollbarCB->setChecked(rc.full_screen_statusbar);
        toggleToolbarsCB->setChecked(rc.full_screen_toolbars);
        toggleTabbarCB->setChecked(rc.full_screen_tabbar);
        toggleMenubarCB->setChecked(rc.full_screen_menubar);
@@ -2784,8 +2808,6 @@ PrefShortcuts::PrefShortcuts(GuiPreferences * form)
        shortcut_bc_.setOK(shortcut_->okPB);
        shortcut_bc_.setCancel(shortcut_->cancelPB);
 
-       connect(shortcut_->okPB, SIGNAL(clicked()),
-               shortcut_, SLOT(accept()));
        connect(shortcut_->okPB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(shortcut_->cancelPB, SIGNAL(clicked()),
@@ -3168,20 +3190,40 @@ void PrefShortcuts::shortcutOkPressed()
                // nothing has changed
                return;
        
-       // make sure this key isn't already bound---and, if so, not unbound
+       // make sure this key isn't already bound---and, if so, prompt user
        FuncCode const unbind = user_unbind_.getBinding(k).action();
        docstring const action_string = makeCmdString(oldBinding);
        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.
-               Alert::error(_("Failed to create shortcut"),
-                       bformat(_("Shortcut `%1$s' is already bound to:\n%2$s\n"
-                         "You need to remove that binding before creating a new one."), 
-                       k.print(KeySequence::ForGui), action_string));
-               return;
+               docstring const new_action_string = makeCmdString(func);
+               docstring const text = bformat(_("Shortcut `%1$s' is already bound to "
+                                                "%2$s.\n"
+                                                "Are you sure you want to unbind the "
+                                                "current shortcut and bind it to %3$s?"),
+                                              k.print(KeySequence::ForGui), action_string,
+                                              new_action_string);
+               int ret = Alert::prompt(_("Redefine shortcut?"),
+                                       text, 0, 1, _("&Redefine"), _("&Cancel"));
+               if (ret != 0)
+                       return;
+               QString const sequence_text = toqstr(k.print(KeySequence::ForGui));
+               QList<QTreeWidgetItem*> items = shortcutsTW->findItems(sequence_text,
+                       Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 1);
+               if (items.size() > 0) {
+                       // should always happen
+                       bool expanded = items[0]->parent()->isExpanded();
+                       shortcutsTW->setCurrentItem(items[0]);
+                       removeShortcut();
+                       shortcutsTW->setCurrentItem(0);
+                       // make sure user doesn't see tree expansion if
+                       // old binding wasn't in an expanded tree
+                       if (!expanded)
+                               items[0]->parent()->setExpanded(false);
+               }
        }
 
+       shortcut_->accept();
+
        if (!save_lfun_.isEmpty())
                // real modification of the lfun's shortcut,
                // so remove the previous one