]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiCharacter.cpp
fix completion painting for RTL (inline completion and completion list)
[lyx.git] / src / frontends / qt4 / GuiCharacter.cpp
index 1c4acf076351706b26da14689873c874cc1cb5d7..f2885b1fc102a7c3f7b2989ea406b6539911dde1 100644 (file)
@@ -14,7 +14,9 @@
 
 #include "GuiCharacter.h"
 
+#include "GuiApplication.h"
 #include "qt_helpers.h"
+
 #include "Font.h"
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "Language.h"
 #include "Paragraph.h"
 
+#include <QAbstractItemModel>
+#include <QModelIndex>
+#include <QSettings>
+#include <QVariant>
 
 using namespace std;
 
@@ -120,10 +126,18 @@ static QList<FamilyPair> familyData()
 static QList<LanguagePair> languageData()
 {
        QList<LanguagePair> list;
-       Languages::const_iterator it = languages.begin();
-       for (; it != languages.end(); ++it) {
-               list << LanguagePair(
-                       qt_(it->second.display()), toqstr(it->second.lang()));
+       // FIXME (Abdel 14/05/2008): it would be nice if we could use this model
+       // directly in the language combo; but, as we need also the 'No Change' and
+       // 'Reset' items, this is not possible right now. Separating those two
+       // entries in radio buttons would be a better GUI IMHO.
+       QAbstractItemModel * language_model = guiApp->languageModel();
+       // Make sure the items are sorted.
+       language_model->sort(0);
+
+       for (int i = 0; i != language_model->rowCount(); ++i) {
+               QModelIndex index = language_model->index(i, 0);
+               list << LanguagePair(index.data(Qt::DisplayRole).toString(),
+                       index.data(Qt::UserRole).toString());
        }
        return list;
 }
@@ -162,13 +176,6 @@ GuiCharacter::GuiCharacter(GuiView & lv)
        connect(autoapplyCB, SIGNAL(stateChanged(int)), this,
                SLOT(change_adaptor()));
 
-#ifdef Q_WS_MACX
-       // On Mac it's common to have tool windows which are always in the
-       // foreground and are hidden when the main window is not focused.
-       setWindowFlags(Qt::Tool);
-       autoapplyCB->setChecked(true);
-#endif
-
        family = familyData();
        series = seriesData();
        shape  = shapeData();
@@ -202,6 +209,13 @@ GuiCharacter::GuiCharacter(GuiView & lv)
        bc().addReadOnly(toggleallCB);
        bc().addReadOnly(autoapplyCB);
 
+#ifdef Q_WS_MACX
+       // On Mac it's common to have tool windows which are always in the
+       // foreground and are hidden when the main window is not focused.
+       setWindowFlags(Qt::Tool);
+       autoapplyCB->setChecked(true);
+#endif
+
 // FIXME: hack to work around resizing bug in Qt >= 4.2
 // bug verified with Qt 4.2.{0-3} (JSpitzm)
 #if QT_VERSION >= 0x040200
@@ -365,6 +379,26 @@ void GuiCharacter::dispatchParams()
 }
 
 
+void GuiCharacter::saveSession() const
+{
+       Dialog::saveSession();
+       QSettings settings;
+       settings.setValue(sessionKey() + "/toggleall", toggleallCB->isChecked());
+       settings.setValue(sessionKey() + "/autoapply", autoapplyCB->isChecked());
+}
+
+
+void GuiCharacter::restoreSession()
+{
+       Dialog::restoreSession();
+       QSettings settings;
+       toggleallCB->setChecked(
+               settings.value(sessionKey() + "/toggleall").toBool());
+       autoapplyCB->setChecked(
+               settings.value(sessionKey() + "/autoapply").toBool());
+}
+
+
 Dialog * createGuiCharacter(GuiView & lv) { return new GuiCharacter(lv); }