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_ChangeTrackingUi.h"
24 #include "ui_DocumentUi.h"
25 #include "ui_FontUi.h"
26 #include "ui_LanguageUi.h"
27 #include "ui_LaTeXUi.h"
28 #include "ui_ListingsSettingsUi.h"
29 #include "ui_LocalLayoutUi.h"
30 #include "ui_MarginsUi.h"
31 #include "ui_MasterChildUi.h"
32 #include "ui_MathsUi.h"
33 #include "ui_ModulesUi.h"
34 #include "ui_NumberingUi.h"
35 #include "ui_OutputUi.h"
36 #include "ui_PageLayoutUi.h"
37 #include "ui_PDFSupportUi.h"
38 #include "ui_PreambleUi.h"
39 #include "ui_TextLayoutUi.h"
41 #include <QStandardItemModel>
45 class LayoutModuleList;
57 class ModuleSelectionManager;
63 typedef Buffer const * BufferId;
66 class UiWidget : public QWidget, public UI
69 UiWidget(QWidget * parent) : QWidget(parent) { UI::setupUi(this); }
73 class GuiDocument : public GuiDialog, public Ui::DocumentUi
77 GuiDocument(GuiView & lv);
79 void paramsToDialog();
80 void updateFontsize(std::string const &, std::string const &);
81 void updateFontlist();
82 void updateDefaultFormat();
83 void updateCiteStyles(std::vector<std::string> const &,
84 CiteEngineType const & sel = ENGINE_TYPE_AUTHORYEAR);
85 void updateEngineType(std::string const &, CiteEngineType const &);
86 void updatePagestyle(std::string const &, std::string const &);
87 bool isChildIncluded(std::string const &);
90 BufferParams const & params() const { return bp_; }
93 void onBufferViewChanged() override;
96 // Apply button clicked
98 void slotButtonBox(QAbstractButton *);
101 void updateNumbering();
102 void change_adaptor();
103 void shellescapeChanged();
104 void includeonlyClicked(QTreeWidgetItem * item, int);
105 void setListingsMessage();
106 void listingsPackageChanged(int);
107 void saveDefaultClicked();
108 void useDefaultsClicked();
109 void setLSpacing(int);
111 void papersizeChanged(int);
113 void setCustomMargins(bool);
114 void fontencChanged(int);
115 void romanChanged(int);
116 void sansChanged(int);
118 void fontOsfToggled(bool state);
119 void fontScToggled(bool state);
121 void enableIndent(bool);
123 void enableSkip(bool);
124 void allowMathIndent();
125 void enableMathIndent(int);
129 void classChanged_adaptor();
130 void languagePackageChanged(int);
131 void biblioChanged();
132 void rescanBibFiles();
133 void resetDefaultBibfile(std::string const & which = std::string());
134 void resetDefaultBbxBibfile();
135 void resetDefaultCbxBibfile();
136 void citeEngineChanged(int);
137 void citeStyleChanged();
138 void bibtexChanged(int);
139 void updateResetDefaultBiblio();
140 void matchBiblatexStyles();
141 void updateEngineDependends();
142 void updateModuleInfo();
143 void modulesChanged();
144 void changeBackgroundColor();
145 void deleteBackgroundColor();
146 void changeFontColor();
147 void deleteFontColor();
148 void changeNoteFontColor();
149 void deleteNoteFontColor();
150 void changeBoxBackgroundColor();
151 void deleteBoxBackgroundColor();
152 void languageChanged(int);
153 void osFontsChanged(bool);
154 void encodingSwitched(int);
155 void inputencodingToDialog();
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);
165 void outputChangesToggled(bool);
166 void setOutputSync(bool);
167 void bookmarksopenChanged(bool);
169 /// validate listings parameters and return an error message, if any
170 QString validateListingsParameters();
172 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
173 UiWidget<Ui::MasterChildUi> *masterChildModule;
174 FontModule *fontModule;
175 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
176 UiWidget<Ui::MarginsUi> *marginsModule;
177 UiWidget<Ui::LanguageUi> *langModule;
178 UiWidget<Ui::ColorUi> *colorModule;
179 UiWidget<Ui::ChangeTrackingUi> *changesModule;
180 UiWidget<Ui::NumberingUi> *numberingModule;
181 UiWidget<Ui::BiblioUi> *biblioModule;
182 UiWidget<Ui::MathsUi> *mathsModule;
183 UiWidget<Ui::LaTeXUi> *latexModule;
184 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
185 UiWidget<Ui::ModulesUi> *modulesModule;
186 UiWidget<Ui::OutputUi> *outputModule;
187 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
188 PreambleModule * preambleModule;
189 LocalLayout * localLayout;
191 GuiBranches * branchesModule;
192 GuiIndices * indicesModule;
194 BulletsModule * bulletsModule;
195 FloatPlacement * floatModule;
197 ModuleSelectionManager * selectionManager;
199 /// Available modules
200 QStandardItemModel * availableModel() { return &modules_av_model_; }
202 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
205 void applyView() override;
207 void updateContents() override;
209 void updateAvailableModules();
211 void updateSelectedModules();
213 void updateIncludeonlyDisplay();
215 void updateIncludeonlys();
217 void updateDefaultBiblio(std::string const & style,
218 std::string const & which = std::string());
219 /// save as default template
220 void saveDocDefault();
221 /// reset to default params
222 void useClassDefaults();
224 void setLayoutComboByIDString(std::string const & idString);
225 /// Update quotes styles combo, indicating the current language's default
226 void updateQuoteStyles(bool const set = false);
228 void getTableStyles();
230 /// available modules
231 QStandardItemModel modules_av_model_;
233 GuiIdListModel modules_sel_model_;
236 FancyLineEdit * filter_;
238 /// return false if validate_listings_params returns error
239 bool isValid() override;
241 /// font family names for BufferParams::fonts_default_family
242 static char const * const fontfamilies[5];
243 /// GUI names corresponding fontfamilies
244 static char const * fontfamilies_gui[5];
246 bool initialiseParams(std::string const & data) override;
248 void clearParams() override;
250 void dispatchParams() override;
252 void modulesToParams(BufferParams &);
254 bool isBufferDependent() const override { return true; }
255 /// always true since we don't manipulate document contents
256 bool canApply() const override { return true; }
258 DocumentClass const & documentClass() const;
260 BufferParams & params() { return bp_; }
264 struct modInfoStruct {
273 static modInfoStruct modInfo(LyXModule const & mod);
274 /// List of available modules
275 std::list<modInfoStruct> const & getModuleInfo();
276 /// Modules in use in current buffer
277 std::list<modInfoStruct> const getSelectedModules();
279 std::list<modInfoStruct> const getProvidedModules();
281 std::list<modInfoStruct> const
282 makeModuleInfo(LayoutModuleList const & mods);
284 void setLanguage() const;
286 void saveAsDefault() const;
287 /// does this font provide Old Style figures?
288 bool providesOSF(QString const & font) const;
289 /// does this font provide true Small Caps?
290 bool providesSC(QString const & font) const;
291 /** does this font provide OSF and Small Caps only via
292 * a single, undifferentiated expert option?
294 bool hasMonolithicExpertSet(QString const & font) const;
295 /// does this font provide size adjustment?
296 bool providesScale(QString const & font) const;
297 /// does this font provide extra options?
298 bool providesExtraOpts(QString const & font) const;
299 /// does this font provide an alternative without math?
300 bool providesNoMath(QString const & font) const;
302 void executeBranchRenaming() const;
304 void setCustomPapersize(bool custom);
307 void loadModuleInfo();
309 void updateUnknownBranches();
311 void updateTexFonts();
313 void updateMathFonts(QString const & rm);
315 void updateExtraOpts();
317 void updateFontOptions();
321 bool completeFontset() const;
323 bool noMathFont() const;
325 void allPackages(int);
327 bool isBiblatex() const;
329 void checkPossibleCiteEngines();
331 void filterModules(QString const & string);
334 /// List of names of available modules
335 std::list<modInfoStruct> moduleNames_;
337 std::map<docstring, docstring> changedBranches_;
339 std::list<std::string> includeonlys_;
342 /// Track if a non-module document param changed
343 bool nonModuleChanged_;
344 /// Track if used modules changed
345 bool modulesChanged_;
346 /// Track if the shellescape param changed
347 bool shellescapeChanged_;
351 class PreambleModule : public UiWidget<Ui::PreambleUi>
355 PreambleModule(QWidget * parent);
356 void update(BufferParams const & params, BufferId id);
357 void apply(BufferParams & params);
358 bool editing() const { return (bool)tempfile_; }
361 /// signal that something's changed in the Widget.
365 void closeEvent(QCloseEvent *) override;
366 void on_preambleTE_textChanged() { changed(); }
368 typedef std::map<BufferId, std::pair<int,int> > Coords;
369 Coords preamble_coords_;
370 BufferId current_id_;
371 unique_ptr<support::TempFile> tempfile_;
375 void checkFindButton();
381 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
385 LocalLayout(QWidget * parent);
386 void update(BufferParams const & params, BufferId id);
387 void apply(BufferParams & params);
388 bool isValid() const { return validated_; }
389 bool editing() const { return (bool)tempfile_; }
392 /// signal that something's changed in the Widget.
401 void validatePressed();
402 void convertPressed();
406 BufferId current_id_;
408 unique_ptr<support::TempFile> tempfile_;
412 class FontModule : public UiWidget<Ui::FontUi>
416 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
417 font_sf_scale(100), font_tt_scale(100) {}
418 /// The roman font currently not selected by osFontsCB->isChecked()
420 /// The sans font currently not selected by osFontsCB->isChecked()
422 /// The typewriter font currently not selected by osFontsCB->isChecked()
423 QString font_typewriter;
424 /// The math font currently not selected by osFontsCB->isChecked()
426 /// The sans font scale currently not selected by osFontsCB->isChecked()
428 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
433 } // namespace frontend
436 #endif // GUIDOCUMENT_H