]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPrefs.cpp
Fix reloading of local layout file (bug #11120)
[lyx.git] / src / frontends / qt4 / GuiPrefs.cpp
index 69877e38daff72356fe0fbddd29e4431baca1133..8e4dbcde6a4608230032c61325f8ce8c690af238 100644 (file)
@@ -112,7 +112,7 @@ QString browseFile(QString const & filename,
                lastPath = fallback_dir;
 
        FileDialog dlg(title);
-       dlg.setButton2(label1, dir1);
+       dlg.setButton1(label1, dir1);
        dlg.setButton2(label2, dir2);
 
        FileDialog::Result result;
@@ -1089,7 +1089,7 @@ void PrefScreenFonts::applyRC(LyXRC & rc) const
        parseFontName(screenTypewriterCO->currentText(),
                rc.typewriter_font_name, rc.typewriter_font_foundry);
 
-       rc.zoom = screenZoomSB->value();
+       rc.defaultZoom = screenZoomSB->value();
        rc.font_sizes[FONT_SIZE_TINY] = widgetToDoubleStr(screenTinyED);
        rc.font_sizes[FONT_SIZE_SCRIPT] = widgetToDoubleStr(screenSmallestED);
        rc.font_sizes[FONT_SIZE_FOOTNOTE] = widgetToDoubleStr(screenSmallerED);
@@ -1106,7 +1106,7 @@ void PrefScreenFonts::applyRC(LyXRC & rc) const
                || rc.roman_font_name != oldrc.roman_font_name
                || rc.sans_font_name != oldrc.sans_font_name
                || rc.typewriter_font_name != oldrc.typewriter_font_name
-               || rc.zoom != oldrc.zoom) {
+               || rc.defaultZoom != oldrc.defaultZoom) {
                // The global QPixmapCache is used in GuiPainter to cache text
                // painting so we must reset it in case any of the above
                // parameter is changed.
@@ -1130,14 +1130,14 @@ void PrefScreenFonts::updateRC(LyXRC const & rc)
        selectSans(screenSansCO->currentText());
        selectTypewriter(screenTypewriterCO->currentText());
 
-       screenZoomSB->setValue(rc.zoom);
+       screenZoomSB->setValue(rc.defaultZoom);
        updateScreenFontSizes(rc);
 
        pixmapCacheCB->setChecked(rc.use_pixmap_cache);
 #if defined(Q_WS_X11) || defined(QPA_XCB)
        pixmapCacheCB->setEnabled(false);
 #endif
-
+       pixmapCacheCB->hide();
 }
 
 
@@ -1294,12 +1294,17 @@ void PrefColors::changeSysColor()
 {
        for (int row = 0 ; row < lyxObjectsLW->count() ; ++row) {
                // skip colors that are taken from system palette
-               bool const hide = syscolorsCB->isChecked()
+               bool const disable = syscolorsCB->isChecked()
                        && guiApp->colorCache().isSystem(lcolors_[row]);
 
-               lyxObjectsLW->item(row)->setHidden(hide);
-       }
+               QListWidgetItem * const item = lyxObjectsLW->item(row);
+               Qt::ItemFlags const flags = item->flags();
 
+               if (disable)
+                       item->setFlags(flags & ~Qt::ItemIsEnabled);
+               else
+                       item->setFlags(flags | Qt::ItemIsEnabled);
+       }
 }
 
 void PrefColors::changeLyxObjectsSelection()
@@ -1679,8 +1684,6 @@ PrefConverters::PrefConverters(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(needauthForbiddenCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
-       connect(needauthCB, SIGNAL(toggled(bool)),
-               this, SIGNAL(changed()));
 
        converterED->setValidator(new NoNewLineValidator(converterED));
        converterFlagED->setValidator(new NoNewLineValidator(converterFlagED));
@@ -1698,11 +1701,18 @@ void PrefConverters::applyRC(LyXRC & rc) const
 }
 
 
+static void setCheckboxBlockSignals(QCheckBox *cb, bool checked) {
+       cb->blockSignals(true);
+       cb->setChecked(checked);
+       cb->blockSignals(false);
+}
+
+
 void PrefConverters::updateRC(LyXRC const & rc)
 {
        cacheCB->setChecked(rc.use_converter_cache);
        needauthForbiddenCB->setChecked(rc.use_converter_needauth_forbidden);
-       needauthCB->setChecked(rc.use_converter_needauth);
+       setCheckboxBlockSignals(needauthCB, rc.use_converter_needauth);
        QString max_age;
        doubleToWidget(maxAgeLE, (double(rc.converter_cache_maxage) / 86400.0), 'g', 6);
        updateGui();
@@ -1869,6 +1879,23 @@ void PrefConverters::on_needauthForbiddenCB_toggled(bool checked)
 }
 
 
+void PrefConverters::on_needauthCB_toggled(bool checked)
+{
+       if (checked) {
+               changed();
+               return;
+       }
+
+       int ret = frontend::Alert::prompt(
+               _("SECURITY WARNING!"), _("Unchecking this option has the effect that potentially harmful converters would be run without asking your permission first. This is UNSAFE and NOT recommended, unless you know what you are doing. Are you sure you would like to proceed ? The recommended and safe answer is NO!"),
+               0, 0, _("&No"), _("&Yes"));
+       if (ret == 1)
+               changed();
+       else
+               setCheckboxBlockSignals(needauthCB, true);
+}
+
+
 /////////////////////////////////////////////////////////////////////
 //
 // FormatValidator
@@ -2006,6 +2033,8 @@ PrefFileformats::PrefFileformats(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(defaultOTFFormatCB, SIGNAL(activated(QString)),
                this, SIGNAL(changed()));
+       connect(defaultPlatexFormatCB, SIGNAL(activated(QString)),
+               this, SIGNAL(changed()));
        connect(viewerCO, SIGNAL(activated(int)),
                this, SIGNAL(changed()));
        connect(editorCO, SIGNAL(activated(int)),
@@ -2025,7 +2054,7 @@ string const l10n_shortcut(docstring const & prettyname, string const & shortcut
        return split(l10n_format, '|');
 }
 
-} // namespace anon
+} // namespace
 
 
 void PrefFileformats::applyRC(LyXRC & rc) const
@@ -2036,6 +2065,9 @@ void PrefFileformats::applyRC(LyXRC & rc) const
        QString const default_otf_format = defaultOTFFormatCB->itemData(
                defaultOTFFormatCB->currentIndex()).toString();
        rc.default_otf_view_format = fromqstr(default_otf_format);
+       QString const default_platex_format = defaultPlatexFormatCB->itemData(
+               defaultPlatexFormatCB->currentIndex()).toString();
+       rc.default_platex_view_format = fromqstr(default_platex_format);
 }
 
 
@@ -2052,6 +2084,9 @@ void PrefFileformats::updateRC(LyXRC const & rc)
                pos = defaultOTFFormatCB->findData(toqstr(rc.default_otf_view_format));
                                defaultOTFFormatCB->setCurrentIndex(pos);
                defaultOTFFormatCB->setCurrentIndex(pos);
+               pos = defaultPlatexFormatCB->findData(toqstr(rc.default_platex_view_format));
+                               defaultPlatexFormatCB->setCurrentIndex(pos);
+               defaultPlatexFormatCB->setCurrentIndex(pos);
        }
 }
 
@@ -2061,14 +2096,17 @@ void PrefFileformats::updateView()
        QString const current = formatsCB->currentText();
        QString const current_def = defaultFormatCB->currentText();
        QString const current_def_otf = defaultOTFFormatCB->currentText();
+       QString const current_def_platex = defaultPlatexFormatCB->currentText();
 
        // update comboboxes with formats
        formatsCB->blockSignals(true);
        defaultFormatCB->blockSignals(true);
        defaultOTFFormatCB->blockSignals(true);
+       defaultPlatexFormatCB->blockSignals(true);
        formatsCB->clear();
        defaultFormatCB->clear();
        defaultOTFFormatCB->clear();
+       defaultPlatexFormatCB->clear();
        form_->formats().sort();
        for (Format const & f : form_->formats()) {
                QString const prettyname = toqstr(translateIfPossible(f.prettyname()));
@@ -2084,10 +2122,15 @@ void PrefFileformats::updateView()
                                        QVariant(toqstr(f.name())));
                        defaultOTFFormatCB->addItem(prettyname,
                                        QVariant(toqstr(f.name())));
-               } else if (form_->converters().isReachable("latex", f.name())
-                          || form_->converters().isReachable("pdflatex", f.name()))
-                       defaultFormatCB->addItem(prettyname,
+               } else {
+                       if (form_->converters().isReachable("latex", f.name())
+                           || form_->converters().isReachable("pdflatex", f.name()))
+                               defaultFormatCB->addItem(prettyname,
                                        QVariant(toqstr(f.name())));
+                       if (form_->converters().isReachable("platex", f.name()))
+                                       defaultPlatexFormatCB->addItem(prettyname,
+                                               QVariant(toqstr(f.name())));
+               }
        }
 
        // restore selections
@@ -2098,9 +2141,12 @@ void PrefFileformats::updateView()
        defaultFormatCB->setCurrentIndex(item < 0 ? 0 : item);
        item = defaultOTFFormatCB->findText(current_def_otf, Qt::MatchExactly);
        defaultOTFFormatCB->setCurrentIndex(item < 0 ? 0 : item);
+       item = defaultPlatexFormatCB->findText(current_def_platex, Qt::MatchExactly);
+       defaultPlatexFormatCB->setCurrentIndex(item < 0 ? 0 : item);
        formatsCB->blockSignals(false);
        defaultFormatCB->blockSignals(false);
        defaultOTFFormatCB->blockSignals(false);
+       defaultPlatexFormatCB->blockSignals(false);
 }
 
 
@@ -2257,7 +2303,7 @@ namespace {
                        }
                }
        }
-}
+} // namespace
 
 
 void PrefFileformats::updateViewers()
@@ -3394,7 +3440,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
 
        QDialog::setModal(false);
 
-       connect(savePB, SIGNAL(clicked()), this, SLOT(slotOK()));
+       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
        connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
@@ -3439,7 +3485,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
 #endif
 
        bc().setPolicy(ButtonPolicy::PreferencesPolicy);
-       bc().setOK(savePB);
+       bc().setOK(okPB);
        bc().setApply(applyPB);
        bc().setCancel(closePB);
        bc().setRestore(restorePB);
@@ -3529,7 +3575,7 @@ void GuiPreferences::dispatchParams()
        theConverters().update(formats_);
        theConverters().buildGraph();
        theBufferList().invalidateConverterCache();
-       
+
        theMovers() = movers_;
 
        vector<string>::const_iterator it = colors_.begin();
@@ -3550,8 +3596,8 @@ void GuiPreferences::dispatchParams()
                update_previews_ = false;
        }
 
-       // The Save button has been pressed
-       if (isClosing())
+       // Save permanently
+       if (!tempSaveCB->isChecked())
                dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
 }