#include "GuiDocument.h"
+#include "GuiApplication.h"
+#include "GuiBranches.h"
+#include "LaTeXHighlighter.h"
+#include "LengthCombo.h"
+#include "PanelStack.h"
+#include "Validator.h"
+
#include "LayoutFile.h"
#include "BranchList.h"
#include "buffer_funcs.h"
#include "Encoding.h"
#include "FloatPlacement.h"
#include "FuncRequest.h"
-#include "support/gettext.h"
-#include "GuiBranches.h"
#include "Language.h"
#include "LaTeXFeatures.h"
-#include "LaTeXHighlighter.h"
#include "Layout.h"
-#include "LengthCombo.h"
#include "LyXRC.h" // defaultUnit
#include "ModuleList.h"
#include "OutputParams.h"
-#include "PanelStack.h"
#include "PDFOptions.h"
#include "qt_helpers.h"
#include "Spacing.h"
-#include "Validator.h"
#include "insets/InsetListingsParams.h"
#include "support/debug.h"
#include "support/FileName.h"
#include "support/filetools.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
#include "frontends/alert.h"
+#include <QAbstractItemModel>
#include <QCloseEvent>
#include <QScrollBar>
#include <QTextCursor>
GuiDocument::GuiDocument(GuiView & lv)
- : GuiDialog(lv, "document", qt_("Document Settings")), current_id_(0)
+ : GuiDialog(lv, "document", qt_("Document Settings"))
{
setupUi(this);
this, SLOT(change_adaptor()));
connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
+ connect(fontModule->cjkFontLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
this, SLOT(change_adaptor()));
connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
// language & quotes
-
- Languages::const_iterator lit = languages.begin();
- Languages::const_iterator lend = languages.end();
- for (; lit != lend; ++lit) {
- lang_.append(toqstr(lit->second.lang()));
- langModule->languageCO->addItem(qt_(lit->second.display()));
- }
+ QAbstractItemModel * language_model = guiApp->languageModel();
+ // FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
+ language_model->sort(0);
+ langModule->languageCO->setModel(language_model);
// Always put the default encoding in the first position.
// It is special because the displayed text is translated.
applyView();
}
bp_.useClassDefaults();
- forceUpdate();
+ paramsToDialog(bp_);
}
}
}
params.quotes_language = lga;
- int const pos = langModule->languageCO->currentIndex();
- params.language = lyx::languages.getLanguage(fromqstr(lang_[pos]));
+ QString const lang = langModule->languageCO->itemData(
+ langModule->languageCO->currentIndex()).toString();
+ params.language = lyx::languages.getLanguage(fromqstr(lang));
// numbering
if (params.documentClass().hasTocLevels()) {
params.fontsTypewriter =
tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
+ params.fontsCJK =
+ fromqstr(fontModule->cjkFontLE->text());
+
params.fontsSansScale = fontModule->scaleSansSB->value();
params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
}
-static int findPos(QStringList const & vec, QString const & val)
-{
- for (int i = 0; i != vec.size(); ++i)
- if (vec[i] == val)
- return i;
- return 0;
-}
-
-
-void GuiDocument::updateParams()
-{
- updateParams(bp_);
-}
-
-
-void GuiDocument::updateParams(BufferParams const & params)
+void GuiDocument::paramsToDialog(BufferParams const & params)
{
// set the default unit
Length::UNIT defaultUnit = Length::CM;
params.use_bibtopic);
// language & quotes
- int const pos = findPos(lang_, toqstr(params.language->lang()));
+ int const pos = langModule->languageCO->findData(toqstr(
+ params.language->lang()));
langModule->languageCO->setCurrentIndex(pos);
langModule->quoteStyleCO->setCurrentIndex(
ttChanged(n);
}
+ if (!params.fontsCJK.empty())
+ fontModule->cjkFontLE->setText(
+ toqstr(params.fontsCJK));
+ else
+ fontModule->cjkFontLE->setText(QString());
+
fontModule->fontScCB->setChecked(params.fontsSC);
fontModule->fontOsfCB->setChecked(params.fontsOSF);
fontModule->scaleSansSB->setValue(params.fontsSansScale);
void GuiDocument::updateContents()
{
- if (id() == current_id_)
- return;
-
- updateAvailableModules();
- updateSelectedModules();
-
- //FIXME It'd be nice to make sure here that the selected
- //modules are consistent: That required modules are actually
- //selected, and that we don't have conflicts. If so, we could
- //at least pop up a warning.
- updateParams(bp_);
- current_id_ = id();
-}
-
-
-void GuiDocument::forceUpdate()
-{
- // reset to force dialog update
- current_id_ = 0;
- updateContents();
+ // Nothing to do here as the document settings is not cursor dependant.
+ return;
}
return;
}
bp_.useClassDefaults();
- forceUpdate();
+ paramsToDialog(bp_);
}
bool GuiDocument::initialiseParams(string const &)
{
- bp_ = buffer().params();
- // Force update on next updateContent() round.
- current_id_ = 0;
+ BufferView * view = bufferview();
+ if (!view) {
+ bp_ = BufferParams();
+ paramsToDialog(bp_);
+ return true;
+ }
+ bp_ = view->buffer().params();
loadModuleInfo();
+ updateAvailableModules();
+ updateSelectedModules();
+ //FIXME It'd be nice to make sure here that the selected
+ //modules are consistent: That required modules are actually
+ //selected, and that we don't have conflicts. If so, we could
+ //at least pop up a warning.
+ paramsToDialog(bp_);
return true;
}
BufferId GuiDocument::id() const
{
- return &buffer();
+ BufferView const * const view = bufferview();
+ return view? &view->buffer() : 0;
}