]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt/GuiPrefs.cpp
"System Default" viewer/editor option
[lyx.git] / src / frontends / qt / GuiPrefs.cpp
index 7d880856cf21d2ac44c538883004429052668c4a..e6074712993a03234d4b073c27a6995db64e3a2b 100644 (file)
@@ -931,8 +931,12 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
                this, SLOT(selectTypewriter(QString)));
 #endif
 
+#if QT_VERSION >= 0x060000
+       const QStringList families(QFontDatabase::families());
+#else
        QFontDatabase fontdb;
-       QStringList families(fontdb.families());
+       const QStringList families(fontdb.families());
+#endif
        for (auto const & family : families) {
                screenRomanCO->addItem(family);
                screenSansCO->addItem(family);
@@ -1153,7 +1157,7 @@ void PrefColors::applyRC(LyXRC & rc) const
 void PrefColors::updateRC(LyXRC const & rc)
 {
        for (size_type i = 0; i < lcolors_.size(); ++i) {
-               QColor color = QColor(guiApp->colorCache().get(lcolors_[i], false));
+               QColor color = guiApp->colorCache().get(lcolors_[i], false);
                QPixmap coloritem(32, 32);
                coloritem.fill(color);
                lyxObjectsLW->item(int(i))->setIcon(QIcon(coloritem));
@@ -2321,6 +2325,7 @@ void PrefFileformats::updateViewers()
        viewerCO->blockSignals(true);
        viewerCO->clear();
        viewerCO->addItem(qt_("None"), QString());
+       viewerCO->addItem(qt_("System Default"), QString("auto"));
        updateComboBox(viewer_alternatives, f.name(), viewerCO);
        viewerCO->addItem(qt_("Custom"), QString("custom viewer"));
        viewerCO->blockSignals(false);
@@ -2344,6 +2349,7 @@ void PrefFileformats::updateEditors()
        editorCO->blockSignals(true);
        editorCO->clear();
        editorCO->addItem(qt_("None"), QString());
+       editorCO->addItem(qt_("System Default"), QString("auto"));
        updateComboBox(editor_alternatives, f.name(), editorCO);
        editorCO->addItem(qt_("Custom"), QString("custom editor"));
        editorCO->blockSignals(false);
@@ -3083,10 +3089,10 @@ QTreeWidgetItem * PrefShortcuts::insertShortcutItem(FuncRequest const & lfun,
        QTreeWidgetItem * newItem = nullptr;
        // for unbind items, try to find an existing item in the system bind list
        if (tag == KeyMap::UserUnbind) {
-               QList<QTreeWidgetItem*> const items = shortcutsTW->findItems(lfun_name,
-                       Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 0);
+               QList<QTreeWidgetItem*> const items = shortcutsTW->findItems(shortcut,
+                       Qt::MatchFlags(Qt::MatchExactly | Qt::MatchRecursive), 1);
                for (auto const & item : items) {
-                       if (item->text(1) == shortcut) {
+                       if (item->text(0) == lfun_name || lfun == FuncRequest::unknown) {
                                newItem = item;
                                break;
                        }
@@ -3121,10 +3127,10 @@ QTreeWidgetItem * PrefShortcuts::insertShortcutItem(FuncRequest const & lfun,
                        // this should not happen
                        newItem = new QTreeWidgetItem(shortcutsTW);
                }
+               newItem->setText(0, lfun_name);
+               newItem->setText(1, shortcut);
        }
 
-       newItem->setText(0, lfun_name);
-       newItem->setText(1, shortcut);
        // record BindFile representation to recover KeySequence when needed.
        newItem->setData(1, Qt::UserRole, toqstr(seq.print(KeySequence::BindFile)));
        setItemType(newItem, tag);
@@ -3443,7 +3449,8 @@ void PrefShortcuts::shortcutOkPressed()
        if (item) {
                user_bind_.bind(&k, func);
                shortcutsTW->sortItems(0, Qt::AscendingOrder);
-               item->parent()->setExpanded(true);
+               if (item->parent())
+                       item->parent()->setExpanded(true);
                shortcutsTW->setCurrentItem(item);
                shortcutsTW->scrollToItem(item);
        } else {