]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPrefs.cpp
Use QFontMetrics information for underlines (and friends) width and position
[lyx.git] / src / frontends / qt4 / GuiPrefs.cpp
index 9e806c4733dad034669fe2da781fc3886d18eaa9..54b308c48d05b77c3bcd2fa0db7ea4bca514507b 100644 (file)
@@ -35,7 +35,6 @@
 #include "LyXAction.h"
 #include "LyX.h"
 #include "PanelStack.h"
-#include "paper.h"
 #include "Session.h"
 #include "SpellChecker.h"
 
@@ -404,6 +403,17 @@ PrefOutput::PrefOutput(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(pdfCB, SIGNAL(editTextChanged(QString)),
                this, SIGNAL(changed()));
+       connect(printerPaperTypeED, SIGNAL(textChanged(QString)),
+               this, SIGNAL(changed()));
+       connect(printerLandscapeED, SIGNAL(textChanged(QString)),
+               this, SIGNAL(changed()));
+       connect(printerPaperSizeED, SIGNAL(textChanged(QString)),
+               this, SIGNAL(changed()));
+
+       printerPaperTypeED->setValidator(new NoNewLineValidator(printerPaperTypeED));
+       printerLandscapeED->setValidator(new NoNewLineValidator(printerLandscapeED));
+       printerPaperSizeED->setValidator(new NoNewLineValidator(printerPaperSizeED));
+
        dviCB->addItem("");
        dviCB->addItem("xdvi -sourceposition '$$n:\\ $$t' $$o");
        dviCB->addItem("yap -1 -s \"$$n $$t\" $$o");
@@ -448,6 +458,10 @@ void PrefOutput::applyRC(LyXRC & rc) const
                rc.export_overwrite = ALL_FILES;
                break;
        }
+
+       rc.print_paper_flag = fromqstr(printerPaperTypeED->text());
+       rc.print_landscape_flag = fromqstr(printerLandscapeED->text());
+       rc.print_paper_dimension_flag = fromqstr(printerPaperSizeED->text());
 }
 
 
@@ -469,6 +483,10 @@ void PrefOutput::updateRC(LyXRC const & rc)
                overwriteCO->setCurrentIndex(2);
                break;
        }
+
+       printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
+       printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
+       printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
 }
 
 
@@ -497,6 +515,8 @@ PrefInput::PrefInput(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(dontswapCB, SIGNAL(toggled(bool)),
                this, SIGNAL(changed()));
+       connect(mmPasteCB, SIGNAL(toggled(bool)),
+               this, SIGNAL(changed()));
 
        // reveal checkbox for switching Ctrl and Meta on Mac:
        bool swapcb = false;
@@ -532,6 +552,7 @@ void PrefInput::applyRC(LyXRC & rc) const
                rc.scroll_wheel_zoom = LyXRC::SCROLL_WHEEL_ZOOM_OFF;
        }
        rc.mac_dontswap_ctrl_meta  = dontswapCB->isChecked();
+       rc.mouse_middlebutton_paste = mmPasteCB->isChecked();
 }
 
 
@@ -560,6 +581,7 @@ void PrefInput::updateRC(LyXRC const & rc)
                break;
        }
        dontswapCB->setChecked(rc.mac_dontswap_ctrl_meta);
+       mmPasteCB->setChecked(rc.mouse_middlebutton_paste);
 }
 
 
@@ -686,7 +708,7 @@ void PrefCompletion::updateRC(LyXRC const & rc)
        popupTextCB->setChecked(rc.completion_popup_text);
        cursorTextCB->setChecked(rc.completion_cursor_text);
        popupAfterCompleteCB->setChecked(rc.completion_popup_after_complete);
-        enableCB();
+       enableCB();
        minlengthSB->setValue(rc.completion_minlength);
 }
 
@@ -1046,7 +1068,7 @@ void PrefScreenFonts::updateRC(LyXRC const & rc)
        updateScreenFontSizes(rc);
 
        pixmapCacheCB->setChecked(rc.use_pixmap_cache);
-#if defined(Q_WS_X11)
+#if defined(Q_WS_X11) || defined(QPA_XCB)
        pixmapCacheCB->setEnabled(false);
 #endif
 
@@ -1092,6 +1114,7 @@ void PrefScreenFonts::selectTypewriter(const QString & name)
 //
 /////////////////////////////////////////////////////////////////////
 
+
 namespace {
 
 struct ColorSorter
@@ -1104,6 +1127,7 @@ struct ColorSorter
 
 } // namespace anon
 
+
 PrefColors::PrefColors(GuiPreferences * form)
        : PrefModule(catLookAndFeel, N_("Colors"), form)
 {
@@ -1118,11 +1142,22 @@ PrefColors::PrefColors(GuiPreferences * form)
                if (lc == Color_none
                    || lc == Color_black
                    || lc == Color_white
-                   || lc == Color_red
-                   || lc == Color_green
                    || lc == Color_blue
+                   || lc == Color_brown
                    || lc == Color_cyan
+                   || lc == Color_darkgray
+                   || lc == Color_gray
+                   || lc == Color_green
+                   || lc == Color_lightgray
+                   || lc == Color_lime
                    || lc == Color_magenta
+                   || lc == Color_olive
+                   || lc == Color_orange
+                   || lc == Color_pink
+                   || lc == Color_purple
+                   || lc == Color_red
+                   || lc == Color_teal
+                   || lc == Color_violet
                    || lc == Color_yellow
                    || lc == Color_inherit
                    || lc == Color_ignore)
@@ -2293,19 +2328,16 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
        startCommandED->setValidator(new NoNewLineValidator(startCommandED));
        endCommandED->setValidator(new NoNewLineValidator(endCommandED));
 
-       uiLanguageCO->clear();
-
-       QAbstractItemModel * language_model = guiApp->languageModel();
-       // FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
-       language_model->sort(0);
        defaultDecimalPointLE->setInputMask("X; ");
        defaultDecimalPointLE->setMaxLength(1);
 
        defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);
        defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::IN]), Length::IN);
 
-       set<string> added;
+       QAbstractItemModel * language_model = guiApp->languageModel();
+       language_model->sort(0);
        uiLanguageCO->blockSignals(true);
+       uiLanguageCO->clear();
        uiLanguageCO->addItem(qt_("Default"), toqstr("auto"));
        for (int i = 0; i != language_model->rowCount(); ++i) {
                QModelIndex index = language_model->index(i, 0);
@@ -2319,11 +2351,10 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
                if (name != form->rc().gui_language
                    && name != lyxrc.gui_language
                    && (!Messages::available(lang->code())
-                       || added.find(lang->code()) != added.end()))
-                               continue;
-               added.insert(lang->code());
+                       || !lang->hasGuiSupport()))
+                       continue;
                uiLanguageCO->addItem(index.data(Qt::DisplayRole).toString(),
-                       index.data(Qt::UserRole).toString());
+                                     index.data(Qt::UserRole).toString());
        }
        uiLanguageCO->blockSignals(false);
 }
@@ -2395,122 +2426,6 @@ void PrefLanguage::updateRC(LyXRC const & rc)
 }
 
 
-/////////////////////////////////////////////////////////////////////
-//
-// PrefPrinter
-//
-/////////////////////////////////////////////////////////////////////
-
-PrefPrinter::PrefPrinter(GuiPreferences * form)
-       : PrefModule(catOutput, N_("Printer"), form)
-{
-       setupUi(this);
-
-       connect(printerAdaptCB, SIGNAL(clicked()),
-               this, SIGNAL(changed()));
-       connect(printerCommandED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerNameED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerPageRangeED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerCopiesED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerReverseED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerToPrinterED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerExtensionED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerSpoolCommandED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerPaperTypeED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerEvenED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerOddED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerCollatedED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerLandscapeED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerToFileED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerExtraED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerSpoolPrefixED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-       connect(printerPaperSizeED, SIGNAL(textChanged(QString)),
-               this, SIGNAL(changed()));
-
-       printerNameED->setValidator(new NoNewLineValidator(printerNameED));
-       printerCommandED->setValidator(new NoNewLineValidator(printerCommandED));
-       printerEvenED->setValidator(new NoNewLineValidator(printerEvenED));
-       printerPageRangeED->setValidator(new NoNewLineValidator(printerPageRangeED));
-       printerCopiesED->setValidator(new NoNewLineValidator(printerCopiesED));
-       printerReverseED->setValidator(new NoNewLineValidator(printerReverseED));
-       printerToFileED->setValidator(new NoNewLineValidator(printerToFileED));
-       printerPaperTypeED->setValidator(new NoNewLineValidator(printerPaperTypeED));
-       printerExtraED->setValidator(new NoNewLineValidator(printerExtraED));
-       printerOddED->setValidator(new NoNewLineValidator(printerOddED));
-       printerCollatedED->setValidator(new NoNewLineValidator(printerCollatedED));
-       printerLandscapeED->setValidator(new NoNewLineValidator(printerLandscapeED));
-       printerToPrinterED->setValidator(new NoNewLineValidator(printerToPrinterED));
-       printerExtensionED->setValidator(new NoNewLineValidator(printerExtensionED));
-       printerPaperSizeED->setValidator(new NoNewLineValidator(printerPaperSizeED));
-       printerSpoolCommandED->setValidator(new NoNewLineValidator(printerSpoolCommandED));
-       printerSpoolPrefixED->setValidator(new NoNewLineValidator(printerSpoolPrefixED));
-}
-
-
-void PrefPrinter::applyRC(LyXRC & rc) const
-{
-       rc.print_adapt_output = printerAdaptCB->isChecked();
-       rc.print_command = fromqstr(printerCommandED->text());
-       rc.printer = fromqstr(printerNameED->text());
-
-       rc.print_pagerange_flag = fromqstr(printerPageRangeED->text());
-       rc.print_copies_flag = fromqstr(printerCopiesED->text());
-       rc.print_reverse_flag = fromqstr(printerReverseED->text());
-       rc.print_to_printer = fromqstr(printerToPrinterED->text());
-       rc.print_file_extension = fromqstr(printerExtensionED->text());
-       rc.print_spool_command = fromqstr(printerSpoolCommandED->text());
-       rc.print_paper_flag = fromqstr(printerPaperTypeED->text());
-       rc.print_evenpage_flag = fromqstr(printerEvenED->text());
-       rc.print_oddpage_flag = fromqstr(printerOddED->text());
-       rc.print_collcopies_flag = fromqstr(printerCollatedED->text());
-       rc.print_landscape_flag = fromqstr(printerLandscapeED->text());
-       rc.print_to_file = internal_path(fromqstr(printerToFileED->text()));
-       rc.print_extra_options = fromqstr(printerExtraED->text());
-       rc.print_spool_printerprefix = fromqstr(printerSpoolPrefixED->text());
-       rc.print_paper_dimension_flag = fromqstr(printerPaperSizeED->text());
-}
-
-
-void PrefPrinter::updateRC(LyXRC const & rc)
-{
-       printerAdaptCB->setChecked(rc.print_adapt_output);
-       printerCommandED->setText(toqstr(rc.print_command));
-       printerNameED->setText(toqstr(rc.printer));
-
-       printerPageRangeED->setText(toqstr(rc.print_pagerange_flag));
-       printerCopiesED->setText(toqstr(rc.print_copies_flag));
-       printerReverseED->setText(toqstr(rc.print_reverse_flag));
-       printerToPrinterED->setText(toqstr(rc.print_to_printer));
-       printerExtensionED->setText(toqstr(rc.print_file_extension));
-       printerSpoolCommandED->setText(toqstr(rc.print_spool_command));
-       printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
-       printerEvenED->setText(toqstr(rc.print_evenpage_flag));
-       printerOddED->setText(toqstr(rc.print_oddpage_flag));
-       printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
-       printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
-       printerToFileED->setText(toqstr(external_path(rc.print_to_file)));
-       printerExtraED->setText(toqstr(rc.print_extra_options));
-       printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
-       printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
-}
-
-
 /////////////////////////////////////////////////////////////////////
 //
 // PrefUserInterface
@@ -2540,7 +2455,7 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form)
        iconSetCO->addItem(qt_("Classic"), "classic");
        iconSetCO->addItem(qt_("Oxygen"), "oxygen");
 
-#if (!defined Q_WS_X11 || QT_VERSION < 0x040600)
+#if (!(defined Q_WS_X11 || defined(QPA_XCB)) || QT_VERSION < 0x040600)
        useSystemThemeIconsCB->hide();
 #endif
 }
@@ -2616,6 +2531,8 @@ PrefDocHandling::PrefDocHandling(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(saveCompressedCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
+       connect(saveOriginCB, SIGNAL(clicked()),
+               this, SIGNAL(changed()));
 }
 
 
@@ -2627,6 +2544,7 @@ void PrefDocHandling::applyRC(LyXRC & rc) const
        rc.autosave = autoSaveCB->isChecked() ?  autoSaveSB->value() * 60 : 0;
        rc.make_backup = backupCB->isChecked();
        rc.save_compressed = saveCompressedCB->isChecked();
+       rc.save_origin = saveOriginCB->isChecked();
        rc.open_buffers_in_tabs = openDocumentsInTabsCB->isChecked();
        rc.single_instance = singleInstanceCB->isChecked();
        rc.single_close_tab_button = singleCloseTabButtonCB->isChecked();
@@ -2662,6 +2580,7 @@ void PrefDocHandling::updateRC(LyXRC const & rc)
        autoSaveSB->setEnabled(autosave);
        backupCB->setChecked(rc.make_backup);
        saveCompressedCB->setChecked(rc.save_compressed);
+       saveOriginCB->setChecked(rc.save_origin);
        openDocumentsInTabsCB->setChecked(rc.open_buffers_in_tabs);
        singleInstanceCB->setChecked(rc.single_instance && !rc.lyxpipes.empty());
        singleInstanceCB->setEnabled(!rc.lyxpipes.empty());
@@ -2757,7 +2676,7 @@ void PrefEdit::updateRC(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);
+       toggleStatusbarCB->setChecked(rc.full_screen_statusbar);
        toggleToolbarsCB->setChecked(rc.full_screen_toolbars);
        toggleTabbarCB->setChecked(rc.full_screen_tabbar);
        toggleMenubarCB->setChecked(rc.full_screen_menubar);
@@ -3144,7 +3063,7 @@ void PrefShortcuts::on_searchLE_textEdited()
        // show matched items
        for (int i = 0; i < matched.size(); ++i) {
                shortcutsTW->setItemHidden(matched[i], false);
-        shortcutsTW->setItemExpanded(matched[i]->parent(), true);
+               shortcutsTW->setItemExpanded(matched[i]->parent(), true);
        }
 }
 
@@ -3305,7 +3224,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
        QDialog::setModal(false);
 
        connect(savePB, SIGNAL(clicked()), this, SLOT(slotOK()));
-       connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApplyRC()));
+       connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
        connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
 
@@ -3332,7 +3251,6 @@ GuiPreferences::GuiPreferences(GuiView & lv)
        //for strftime validator
        PrefOutput * output = new PrefOutput(this);
        addModule(output);
-       addModule(new PrefPrinter(this));
        addModule(new PrefLatex(this));
 
        PrefConverters * converters = new PrefConverters(this);
@@ -3452,6 +3370,8 @@ void GuiPreferences::dispatchParams()
                update_screen_font_ = false;
        }
 
+       theBufferList().updatePreviews();
+
        // The Save button has been pressed
        if (isClosing())
                dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));