]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt2/QPrefs.C
Replace LString.h with support/std_string.h,
[features.git] / src / frontends / qt2 / QPrefs.C
index 77ce4bc0a26e978e6542c0f7dd429e01b5e6f420..895dde11cce50f84addcee9d9f438971530536c1 100644 (file)
@@ -5,14 +5,14 @@
  *
  * \author John Levon
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
 #include "support/lstrings.h"
 #include "support/tostr.h"
-#include "Lsstream.h"
+#include "support/std_sstream.h"
 #include <iomanip>
 
 #include "ControlPrefs.h"
@@ -26,8 +26,6 @@
 #include "ui/QPrefDisplayModule.h"
 #include "ui/QPrefPathsModule.h"
 #include "ui/QPrefSpellcheckerModule.h"
-#include "ui/QPrefConvertersModule.h"
-#include "ui/QPrefFileformatsModule.h"
 #include "ui/QPrefLanguageModule.h"
 #include "ui/QPrefPrinterModule.h"
 #include "ui/QPrefUIModule.h"
 #include "lyx_gui.h"
 #include "QPrefs.h"
 #include "Qt2BC.h"
-#include "lyxrc.h"
+#include "lyxfont.h"
 #include "frnt_lang.h"
 #include "helper_funcs.h"
 #include "qt_helpers.h"
 #include "lcolorcache.h"
-#include "debug.h"
 
 #include <boost/tuple/tuple.hpp>
 
@@ -49,9 +46,7 @@
 #include <qlineedit.h>
 #include <qspinbox.h>
 #include <qcombobox.h>
-#include <qlistbox.h>
 #include <qlabel.h>
-#include <qfontinfo.h>
 #include "qcoloritem.h"
 
 using namespace lyx::support;
@@ -63,6 +58,7 @@ using std::setfill;
 using std::setw;
 using std::endl;
 
+
 typedef Qt2CB<ControlPrefs, Qt2DB<QPrefsDialog> > base_class;
 
 
@@ -163,20 +159,19 @@ void QPrefs::apply()
        rc.auto_reset_options = latexmod->latexAutoresetCB->isChecked();
        rc.view_dvi_paper_option = fromqstr(latexmod->latexDviPaperED->text());
        rc.default_papersize =
-               static_cast<BufferParams::PAPER_SIZE>(latexmod->latexPaperSizeCO->currentItem());
-
+               static_cast<PAPER_SIZE>(latexmod->latexPaperSizeCO->currentItem());
 
        QPrefDisplayModule * displaymod(dialog_->displayModule);
 
        rc.preview = displaymod->previewCB->isChecked();
 
-       grfx::DisplayType dtype(grfx::ColorDisplay);
+       lyx::graphics::DisplayType dtype(lyx::graphics::ColorDisplay);
 
        switch (displaymod->displayGraphicsCO->currentItem()) {
-               case 3: dtype = grfx::NoDisplay; break;
-               case 2: dtype = grfx::ColorDisplay; break;
-               case 1: dtype = grfx::GrayscaleDisplay; break;
-               case 0: dtype = grfx::MonochromeDisplay; break;
+               case 3: dtype = lyx::graphics::NoDisplay; break;
+               case 2: dtype = lyx::graphics::ColorDisplay; break;
+               case 1: dtype = lyx::graphics::GrayscaleDisplay;        break;
+               case 0: dtype = lyx::graphics::MonochromeDisplay; break;
        }
        rc.display_graphics = dtype;
 
@@ -185,7 +180,7 @@ void QPrefs::apply()
 #endif
 #if 0
        if (old_value != rc.display_graphics) {
-               grfx::GCache & gc = grfx::GCache::get();
+               lyx::graphics::GCache & gc = lyx::graphics::GCache::get();
                gc.changeDisplay();
        }
 #endif
@@ -341,7 +336,7 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry
                }
        }
 
-       // Try matching without foundary name
+       // Try matching without foundry name
 
        // We count in reverse in order to prefer the Xft foundry
        for (int i = cb->count() - 1; i >= 0; --i) {
@@ -352,6 +347,18 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry
                }
        }
 
+       // family alone can contain e.g. "Helvetica [Adobe]"
+       pair<string, string> tmpfam = parseFontName(family);
+
+       // We count in reverse in order to prefer the Xft foundry
+       for (int i = cb->count() - 1; i >= 0; --i) {
+               pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
+               if (compare_no_case(tmp.first, tmpfam.first) == 0) {
+                       cb->setCurrentItem(i);
+                       return;
+               }
+       }
+
        // Bleh, default fonts, and the names couldn't be found. Hack
        // for bug 1063. Qt makes baby Jesus cry.
 
@@ -472,10 +479,10 @@ void QPrefs::update_contents()
        int item = 2;
 
        switch (rc.display_graphics) {
-               case grfx::NoDisplay:           item = 3; break;
-               case grfx::ColorDisplay:        item = 2; break;
-               case grfx::GrayscaleDisplay:    item = 1; break;
-               case grfx::MonochromeDisplay:   item = 0; break;
+               case lyx::graphics::NoDisplay:          item = 3; break;
+               case lyx::graphics::ColorDisplay:       item = 2; break;
+               case lyx::graphics::GrayscaleDisplay:   item = 1; break;
+               case lyx::graphics::MonochromeDisplay:  item = 0; break;
                default: break;
        }
        displaymod->displayGraphicsCO->setCurrentItem(item);