4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Richard Heck (modules)
10 * Full author contact details are available in file CREDITS.
16 #include "BufferParams.h"
17 #include "BulletsModule.h"
18 #include "GuiDialog.h"
19 #include "GuiIdListModel.h"
21 #include "ui_BiblioUi.h"
22 #include "ui_ColorUi.h"
23 #include "ui_DocumentUi.h"
24 #include "ui_FontUi.h"
25 #include "ui_LanguageUi.h"
26 #include "ui_LaTeXUi.h"
27 #include "ui_ListingsSettingsUi.h"
28 #include "ui_LocalLayoutUi.h"
29 #include "ui_MarginsUi.h"
30 #include "ui_MasterChildUi.h"
31 #include "ui_MathsUi.h"
32 #include "ui_ModulesUi.h"
33 #include "ui_NumberingUi.h"
34 #include "ui_OutputUi.h"
35 #include "ui_PageLayoutUi.h"
36 #include "ui_PDFSupportUi.h"
37 #include "ui_PreambleUi.h"
38 #include "ui_TextLayoutUi.h"
40 #include <QStandardItemModel>
45 class LayoutModuleList;
58 class ModuleSelectionManager;
64 typedef Buffer const * BufferId;
67 class UiWidget : public QWidget, public UI
70 UiWidget(QWidget * parent) : QWidget(parent) { UI::setupUi(this); }
74 class GuiDocument : public GuiDialog, public Ui::DocumentUi
78 GuiDocument(GuiView & lv);
80 void paramsToDialog();
81 void updateFontsize(std::string const &, std::string const &);
82 void updateFontlist();
83 void updateDefaultFormat();
84 void updateCiteStyles(std::vector<std::string> const &,
85 CiteEngineType const & sel = ENGINE_TYPE_AUTHORYEAR);
86 void updateEngineType(std::string const &, CiteEngineType const &);
87 void updatePagestyle(std::string const &, std::string const &);
88 bool isChildIncluded(std::string const &);
91 BufferParams const & params() const { return bp_; }
94 void onBufferViewChanged();//override
97 // Apply button clicked
99 void slotButtonBox(QAbstractButton *);
102 void updateNumbering();
103 void change_adaptor();
104 void shellescapeChanged();
105 void includeonlyClicked(QTreeWidgetItem * item, int);
106 void setListingsMessage();
107 void listingsPackageChanged(int);
108 void saveDefaultClicked();
109 void useDefaultsClicked();
110 void setLSpacing(int);
112 void papersizeChanged(int);
114 void setCustomMargins(bool);
115 void fontencChanged(int);
116 void romanChanged(int);
117 void sansChanged(int);
119 void fontOsfToggled(bool state);
120 void fontScToggled(bool state);
122 void enableIndent(bool);
124 void enableSkip(bool);
125 void allowMathIndent();
126 void enableMathIndent(int);
130 void classChanged_adaptor();
131 void languagePackageChanged(int);
132 void biblioChanged();
133 void rescanBibFiles();
134 void resetDefaultBibfile(std::string const & which = std::string());
135 void resetDefaultBbxBibfile();
136 void resetDefaultCbxBibfile();
137 void citeEngineChanged(int);
138 void citeStyleChanged();
139 void bibtexChanged(int);
140 void updateResetDefaultBiblio();
141 void matchBiblatexStyles();
142 void updateEngineDependends();
143 void updateModuleInfo();
144 void modulesChanged();
145 void changeBackgroundColor();
146 void deleteBackgroundColor();
147 void changeFontColor();
148 void deleteFontColor();
149 void changeNoteFontColor();
150 void deleteNoteFontColor();
151 void changeBoxBackgroundColor();
152 void deleteBoxBackgroundColor();
153 void languageChanged(int);
154 void osFontsChanged(bool);
155 void mathFontChanged(int);
156 void branchesRename(docstring const &, docstring const &);
157 void allPackagesAuto();
158 void allPackagesAlways();
159 void allPackagesNot();
160 void moduleFilterPressed();
161 void moduleFilterChanged(const QString & text);
162 void resetModuleFilter();
164 /// validate listings parameters and return an error message, if any
165 QString validateListingsParameters();
167 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
168 UiWidget<Ui::MasterChildUi> *masterChildModule;
169 FontModule *fontModule;
170 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
171 UiWidget<Ui::MarginsUi> *marginsModule;
172 UiWidget<Ui::LanguageUi> *langModule;
173 UiWidget<Ui::ColorUi> *colorModule;
174 UiWidget<Ui::NumberingUi> *numberingModule;
175 UiWidget<Ui::BiblioUi> *biblioModule;
176 UiWidget<Ui::MathsUi> *mathsModule;
177 UiWidget<Ui::LaTeXUi> *latexModule;
178 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
179 UiWidget<Ui::ModulesUi> *modulesModule;
180 UiWidget<Ui::OutputUi> *outputModule;
181 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
182 PreambleModule * preambleModule;
183 LocalLayout * localLayout;
185 GuiBranches * branchesModule;
186 GuiIndices * indicesModule;
188 BulletsModule * bulletsModule;
189 FloatPlacement * floatModule;
191 ModuleSelectionManager * selectionManager;
193 /// Available modules
194 QStandardItemModel * availableModel() { return &modules_av_model_; }
196 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
201 void updateContents();
203 void updateAvailableModules();
205 void updateSelectedModules();
207 void updateIncludeonlys();
209 void updateDefaultBiblio(std::string const & style,
210 std::string const & which = std::string());
211 /// save as default template
212 void saveDocDefault();
213 /// reset to default params
214 void useClassDefaults();
216 void setLayoutComboByIDString(std::string const & idString);
217 /// Update quotes styles combo, indicating the current language's default
218 void updateQuoteStyles(bool const set = false);
220 void getTableStyles();
222 /// available modules
223 QStandardItemModel modules_av_model_;
225 GuiIdListModel modules_sel_model_;
228 FancyLineEdit * filter_;
230 /// return false if validate_listings_params returns error
233 /// font family names for BufferParams::fonts_default_family
234 static char const * const fontfamilies[5];
235 /// GUI names corresponding fontfamilies
236 static char const * fontfamilies_gui[5];
238 bool initialiseParams(std::string const & data);
242 void dispatchParams();
244 void modulesToParams(BufferParams &);
246 bool isBufferDependent() const { return true; }
247 /// always true since we don't manipulate document contents
248 bool canApply() const { return true; }
250 DocumentClass const & documentClass() const;
252 BufferParams & params() { return bp_; }
256 struct modInfoStruct {
265 static modInfoStruct modInfo(LyXModule const & mod);
266 /// List of available modules
267 std::list<modInfoStruct> const & getModuleInfo();
268 /// Modules in use in current buffer
269 std::list<modInfoStruct> const getSelectedModules();
271 std::list<modInfoStruct> const getProvidedModules();
273 std::list<modInfoStruct> const
274 makeModuleInfo(LayoutModuleList const & mods);
276 void setLanguage() const;
278 void saveAsDefault() const;
279 /// does this font provide Old Style figures?
280 bool providesOSF(QString const & font) const;
281 /// does this font provide true Small Caps?
282 bool providesSC(QString const & font) const;
283 /** does this font provide OSF and Small Caps only via
284 * a single, undifferentiated expert option?
286 bool hasMonolithicExpertSet(QString const & font) const;
287 /// does this font provide size adjustment?
288 bool providesScale(QString const & font) const;
289 /// does this font provide an alternative without math?
290 bool providesNoMath(QString const & font) const;
292 void executeBranchRenaming() const;
294 void setCustomPapersize(bool custom);
297 void loadModuleInfo();
299 void updateUnknownBranches();
301 void updateTexFonts();
303 void updateMathFonts(QString const & rm);
305 void updateFontOptions();
309 bool completeFontset() const;
311 bool noMathFont() const;
313 void allPackages(int);
315 bool isBiblatex() const;
317 void checkPossibleCiteEngines();
319 void filterModules(QString const & string);
322 /// List of names of available modules
323 std::list<modInfoStruct> moduleNames_;
325 std::map<docstring, docstring> changedBranches_;
327 std::list<std::string> includeonlys_;
330 /// Track if a non-module document param changed
331 bool nonModuleChanged_;
332 /// Track if used modules changed
333 bool modulesChanged_;
334 /// Track if the shellescape param changed
335 bool shellescapeChanged_;
339 class PreambleModule : public UiWidget<Ui::PreambleUi>
343 PreambleModule(QWidget * parent);
344 void update(BufferParams const & params, BufferId id);
345 void apply(BufferParams & params);
346 bool editing() const { return (bool)tempfile_; }
349 /// signal that something's changed in the Widget.
353 void closeEvent(QCloseEvent *);
354 void on_preambleTE_textChanged() { changed(); }
356 typedef std::map<BufferId, std::pair<int,int> > Coords;
357 Coords preamble_coords_;
358 BufferId current_id_;
359 unique_ptr<support::TempFile> tempfile_;
363 void checkFindButton();
369 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
373 LocalLayout(QWidget * parent);
374 void update(BufferParams const & params, BufferId id);
375 void apply(BufferParams & params);
376 bool isValid() const { return validated_; }
377 bool editing() const { return (bool)tempfile_; }
380 /// signal that something's changed in the Widget.
389 void validatePressed();
390 void convertPressed();
394 BufferId current_id_;
396 unique_ptr<support::TempFile> tempfile_;
400 class FontModule : public UiWidget<Ui::FontUi>
404 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
405 font_sf_scale(100), font_tt_scale(100) {}
406 /// The roman font currently not selected by osFontsCB->isChecked()
408 /// The sans font currently not selected by osFontsCB->isChecked()
410 /// The typewriter font currently not selected by osFontsCB->isChecked()
411 QString font_typewriter;
412 /// The math font currently not selected by osFontsCB->isChecked()
414 /// The sans font scale currently not selected by osFontsCB->isChecked()
416 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
421 } // namespace frontend
424 #endif // GUIDOCUMENT_H