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 encodingSwitched(int);
156 void mathFontChanged(int);
157 void branchesRename(docstring const &, docstring const &);
158 void allPackagesAuto();
159 void allPackagesAlways();
160 void allPackagesNot();
161 void moduleFilterPressed();
162 void moduleFilterChanged(const QString & text);
163 void resetModuleFilter();
164 void linenoToggled(bool);
166 /// validate listings parameters and return an error message, if any
167 QString validateListingsParameters();
169 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
170 UiWidget<Ui::MasterChildUi> *masterChildModule;
171 FontModule *fontModule;
172 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
173 UiWidget<Ui::MarginsUi> *marginsModule;
174 UiWidget<Ui::LanguageUi> *langModule;
175 UiWidget<Ui::ColorUi> *colorModule;
176 UiWidget<Ui::NumberingUi> *numberingModule;
177 UiWidget<Ui::BiblioUi> *biblioModule;
178 UiWidget<Ui::MathsUi> *mathsModule;
179 UiWidget<Ui::LaTeXUi> *latexModule;
180 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
181 UiWidget<Ui::ModulesUi> *modulesModule;
182 UiWidget<Ui::OutputUi> *outputModule;
183 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
184 PreambleModule * preambleModule;
185 LocalLayout * localLayout;
187 GuiBranches * branchesModule;
188 GuiIndices * indicesModule;
190 BulletsModule * bulletsModule;
191 FloatPlacement * floatModule;
193 ModuleSelectionManager * selectionManager;
195 /// Available modules
196 QStandardItemModel * availableModel() { return &modules_av_model_; }
198 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
203 void updateContents();
205 void updateAvailableModules();
207 void updateSelectedModules();
209 void updateIncludeonlys();
211 void updateDefaultBiblio(std::string const & style,
212 std::string const & which = std::string());
213 /// save as default template
214 void saveDocDefault();
215 /// reset to default params
216 void useClassDefaults();
218 void setLayoutComboByIDString(std::string const & idString);
219 /// Update quotes styles combo, indicating the current language's default
220 void updateQuoteStyles(bool const set = false);
222 void getTableStyles();
224 /// available modules
225 QStandardItemModel modules_av_model_;
227 GuiIdListModel modules_sel_model_;
230 FancyLineEdit * filter_;
232 /// return false if validate_listings_params returns error
235 /// font family names for BufferParams::fonts_default_family
236 static char const * const fontfamilies[5];
237 /// GUI names corresponding fontfamilies
238 static char const * fontfamilies_gui[5];
240 bool initialiseParams(std::string const & data);
244 void dispatchParams();
246 void modulesToParams(BufferParams &);
248 bool isBufferDependent() const { return true; }
249 /// always true since we don't manipulate document contents
250 bool canApply() const { return true; }
252 DocumentClass const & documentClass() const;
254 BufferParams & params() { return bp_; }
258 struct modInfoStruct {
267 static modInfoStruct modInfo(LyXModule const & mod);
268 /// List of available modules
269 std::list<modInfoStruct> const & getModuleInfo();
270 /// Modules in use in current buffer
271 std::list<modInfoStruct> const getSelectedModules();
273 std::list<modInfoStruct> const getProvidedModules();
275 std::list<modInfoStruct> const
276 makeModuleInfo(LayoutModuleList const & mods);
278 void setLanguage() const;
280 void saveAsDefault() const;
281 /// does this font provide Old Style figures?
282 bool providesOSF(QString const & font) const;
283 /// does this font provide true Small Caps?
284 bool providesSC(QString const & font) const;
285 /** does this font provide OSF and Small Caps only via
286 * a single, undifferentiated expert option?
288 bool hasMonolithicExpertSet(QString const & font) const;
289 /// does this font provide size adjustment?
290 bool providesScale(QString const & font) const;
291 /// does this font provide an alternative without math?
292 bool providesNoMath(QString const & font) const;
294 void executeBranchRenaming() const;
296 void setCustomPapersize(bool custom);
299 void loadModuleInfo();
301 void updateUnknownBranches();
303 void updateTexFonts();
305 void updateMathFonts(QString const & rm);
307 void updateFontOptions();
311 bool completeFontset() const;
313 bool noMathFont() const;
315 void allPackages(int);
317 bool isBiblatex() const;
319 void checkPossibleCiteEngines();
321 void filterModules(QString const & string);
324 /// List of names of available modules
325 std::list<modInfoStruct> moduleNames_;
327 std::map<docstring, docstring> changedBranches_;
329 std::list<std::string> includeonlys_;
332 /// Track if a non-module document param changed
333 bool nonModuleChanged_;
334 /// Track if used modules changed
335 bool modulesChanged_;
336 /// Track if the shellescape param changed
337 bool shellescapeChanged_;
341 class PreambleModule : public UiWidget<Ui::PreambleUi>
345 PreambleModule(QWidget * parent);
346 void update(BufferParams const & params, BufferId id);
347 void apply(BufferParams & params);
348 bool editing() const { return (bool)tempfile_; }
351 /// signal that something's changed in the Widget.
355 void closeEvent(QCloseEvent *);
356 void on_preambleTE_textChanged() { changed(); }
358 typedef std::map<BufferId, std::pair<int,int> > Coords;
359 Coords preamble_coords_;
360 BufferId current_id_;
361 unique_ptr<support::TempFile> tempfile_;
365 void checkFindButton();
371 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
375 LocalLayout(QWidget * parent);
376 void update(BufferParams const & params, BufferId id);
377 void apply(BufferParams & params);
378 bool isValid() const { return validated_; }
379 bool editing() const { return (bool)tempfile_; }
382 /// signal that something's changed in the Widget.
391 void validatePressed();
392 void convertPressed();
396 BufferId current_id_;
398 unique_ptr<support::TempFile> tempfile_;
402 class FontModule : public UiWidget<Ui::FontUi>
406 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
407 font_sf_scale(100), font_tt_scale(100) {}
408 /// The roman font currently not selected by osFontsCB->isChecked()
410 /// The sans font currently not selected by osFontsCB->isChecked()
412 /// The typewriter font currently not selected by osFontsCB->isChecked()
413 QString font_typewriter;
414 /// The math font currently not selected by osFontsCB->isChecked()
416 /// The sans font scale currently not selected by osFontsCB->isChecked()
418 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
423 } // namespace frontend
426 #endif // GUIDOCUMENT_H