4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Richard Kimberly Heck (modules)
10 * Full author contact details are available in file CREDITS.
16 #include "BufferParams.h"
17 #include "GuiDialog.h"
18 #include "GuiIdListModel.h"
20 #include "LaTeXHighlighter.h"
22 #include "ui_BiblioUi.h"
23 #include "ui_ColorUi.h"
24 #include "ui_ChangeTrackingUi.h"
25 #include "ui_DocumentUi.h"
26 #include "ui_FontUi.h"
27 #include "ui_LanguageUi.h"
28 #include "ui_LaTeXUi.h"
29 #include "ui_ListingsSettingsUi.h"
30 #include "ui_LocalLayoutUi.h"
31 #include "ui_MarginsUi.h"
32 #include "ui_MasterChildUi.h"
33 #include "ui_MathsUi.h"
34 #include "ui_ModulesUi.h"
35 #include "ui_NumberingUi.h"
36 #include "ui_OutputUi.h"
37 #include "ui_PageLayoutUi.h"
38 #include "ui_PDFSupportUi.h"
39 #include "ui_PreambleUi.h"
40 #include "ui_TextLayoutUi.h"
42 #include "support/unique_ptr.h"
44 #include <QStandardItemModel>
48 class LayoutModuleList;
62 class ModuleSelectionManager;
68 typedef Buffer const * BufferId;
71 class UiWidget : public QWidget, public UI
74 UiWidget(QWidget * parent) : QWidget(parent) { UI::setupUi(this); }
78 class GuiDocument : public GuiDialog, public Ui::DocumentUi
82 GuiDocument(GuiView & lv);
84 void paramsToDialog();
85 void updateFontsize(std::string const &, std::string const &);
86 void updateFontlist();
87 void updateDefaultFormat();
88 void updateCiteStyles(std::vector<std::string> const &,
89 CiteEngineType const & sel = ENGINE_TYPE_AUTHORYEAR);
90 void updateEngineType(std::string const &, CiteEngineType const &);
91 void updatePagestyle(std::string const &, std::string const &);
92 bool isChildIncluded(std::string const &);
95 BufferParams const & params() const { return bp_; }
98 void onBufferViewChanged() override;
101 // Apply button clicked
103 void slotButtonBox(QAbstractButton *);
106 void updateNumbering();
107 void change_adaptor();
108 void shellescapeChanged();
109 void includeonlyClicked(QTreeWidgetItem * item, int);
110 void setListingsMessage();
111 void listingsPackageChanged(int);
112 void saveDefaultClicked();
113 void useDefaultsClicked();
114 void setLSpacing(int);
116 void papersizeChanged(int);
118 void setCustomMargins(bool);
119 void fontencChanged(int);
120 void romanChanged(int);
121 void sansChanged(int);
123 void fontOsfToggled(bool state);
124 void fontScToggled(bool state);
126 void enableIndent(bool);
128 void enableSkip(bool);
129 void allowMathIndent();
130 void enableMathIndent(int);
134 void classChanged_adaptor();
135 void languagePackageChanged(int);
136 void biblioChanged();
137 void rescanBibFiles();
138 void resetDefaultBibfile(std::string const & which = std::string());
139 void resetDefaultBbxBibfile();
140 void resetDefaultCbxBibfile();
141 void citeEngineChanged(int);
142 void citeStyleChanged();
143 void bibtexChanged(int);
144 void updateResetDefaultBiblio();
145 void matchBiblatexStyles();
146 void updateEngineDependends();
147 void updateModuleInfo();
148 void modulesChanged();
149 void changeBackgroundColor();
150 void deleteBackgroundColor();
151 void changeFontColor();
152 void deleteFontColor();
153 void changeNoteFontColor();
154 void deleteNoteFontColor();
155 void changeBoxBackgroundColor();
156 void deleteBoxBackgroundColor();
157 void languageChanged(int);
158 void osFontsChanged(bool);
159 void encodingSwitched(int);
160 void inputencodingToDialog();
161 void mathFontChanged(int);
162 void branchesRename(docstring const &, docstring const &);
163 void allPackagesAuto();
164 void allPackagesAlways();
165 void allPackagesNot();
166 void moduleFilterPressed();
167 void moduleFilterChanged(const QString & text);
168 void resetModuleFilter();
169 void linenoToggled(bool);
170 void outputChangesToggled(bool);
171 void setOutputSync(bool);
172 void bookmarksopenChanged(bool);
173 void changeTrackingChanged(bool);
175 /// validate listings parameters and return an error message, if any
176 QString validateListingsParameters();
178 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
179 UiWidget<Ui::MasterChildUi> *masterChildModule;
180 FontModule *fontModule;
181 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
182 UiWidget<Ui::MarginsUi> *marginsModule;
183 UiWidget<Ui::LanguageUi> *langModule;
184 UiWidget<Ui::ColorUi> *colorModule;
185 UiWidget<Ui::ChangeTrackingUi> *changesModule;
186 UiWidget<Ui::NumberingUi> *numberingModule;
187 UiWidget<Ui::BiblioUi> *biblioModule;
188 UiWidget<Ui::MathsUi> *mathsModule;
189 UiWidget<Ui::LaTeXUi> *latexModule;
190 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
191 UiWidget<Ui::ModulesUi> *modulesModule;
192 UiWidget<Ui::OutputUi> *outputModule;
193 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
194 PreambleModule * preambleModule;
195 LocalLayout * localLayout;
197 GuiBranches * branchesModule;
198 GuiIndices * indicesModule;
200 BulletsModule * bulletsModule;
201 FloatPlacement * floatModule;
203 ModuleSelectionManager * selectionManager;
205 /// Available modules
206 QStandardItemModel * availableModel() { return &modules_av_model_; }
208 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
211 void applyView() override;
213 void updateContents() override;
215 void updateAvailableModules();
217 void updateSelectedModules();
219 void updateIncludeonlyDisplay();
221 void updateIncludeonlys(bool const cleanup = true);
223 void updateDefaultBiblio(std::string const & style,
224 std::string const & which = std::string());
225 /// save as default template
226 void saveDocDefault();
227 /// reset to default params
228 void useClassDefaults();
230 void setLayoutComboByIDString(std::string const & idString);
231 /// Update quotes styles combo, indicating the current language's default
232 void updateQuoteStyles(bool const set = false);
234 void getTableStyles();
236 /// available modules
237 QStandardItemModel modules_av_model_;
239 GuiIdListModel modules_sel_model_;
242 FancyLineEdit * filter_;
244 /// return false if validate_listings_params returns error
245 bool isValid() override;
247 /// font family names for BufferParams::fonts_default_family
248 static char const * const fontfamilies[5];
249 /// GUI names corresponding fontfamilies
250 static char const * fontfamilies_gui[5];
252 bool initialiseParams(std::string const & data) override;
254 void clearParams() override;
256 void dispatchParams() override;
258 void modulesToParams(BufferParams &);
260 bool isBufferDependent() const override { return true; }
261 /// always true since we don't manipulate document contents
262 bool canApply() const override { return true; }
264 DocumentClass const & documentClass() const;
266 BufferParams & params() { return bp_; }
270 struct modInfoStruct {
279 static modInfoStruct modInfo(LyXModule const & mod);
280 /// List of available modules
281 std::list<modInfoStruct> const & getModuleInfo();
282 /// Modules in use in current buffer
283 std::list<modInfoStruct> const getSelectedModules();
285 std::list<modInfoStruct> const getProvidedModules();
287 std::list<modInfoStruct> const
288 makeModuleInfo(LayoutModuleList const & mods);
290 void setLanguage() const;
292 void saveAsDefault() const;
293 /// does this font provide Old Style figures?
294 bool providesOSF(QString const & font) const;
295 /// does this font provide true Small Caps?
296 bool providesSC(QString const & font) const;
297 /** does this font provide OSF and Small Caps only via
298 * a single, undifferentiated expert option?
300 bool hasMonolithicExpertSet(QString const & font) const;
301 /// does this font provide size adjustment?
302 bool providesScale(QString const & font) const;
303 /// does this font provide extra options?
304 bool providesExtraOpts(QString const & font) const;
305 /// does this font provide an alternative without math?
306 bool providesNoMath(QString const & font) const;
308 void executeBranchRenaming() const;
310 void setCustomPapersize(bool custom);
313 void loadModuleInfo();
315 void updateUnknownBranches();
317 void updateTexFonts();
319 void updateMathFonts(QString const & rm);
321 void updateExtraOpts();
323 void updateFontOptions();
327 bool completeFontset() const;
329 bool noMathFont() const;
331 void allPackages(int);
333 bool isBiblatex() const;
335 void checkPossibleCiteEngines();
337 void filterModules(QString const & string);
340 /// Store buffer filename for the case we switch with
341 /// unapplied changes.
342 std::string prev_buffer_filename_;
343 /// List of names of available modules
344 std::list<modInfoStruct> moduleNames_;
346 std::map<docstring, docstring> changedBranches_;
348 std::list<std::string> includeonlys_;
351 /// Track if a non-module document param changed
352 bool nonModuleChanged_;
353 /// Track if used modules changed
354 bool modulesChanged_;
355 /// Track if the shellescape param changed
356 bool shellescapeChanged_;
357 /// Track if we switch back to a buffer due to unapplied
360 /// Track whether we prompted the user about unapplied
364 /// LaTeX syntax highlighter
365 LaTeXHighlighter * pdf_options_highlighter_;
366 LaTeXHighlighter * pdf_metadata_highlighter_;
368 bool eventFilter(QObject * sender, QEvent * event) override;
372 class PreambleModule : public UiWidget<Ui::PreambleUi>
376 PreambleModule(QWidget * parent);
377 void update(BufferParams const & params, BufferId id);
378 void apply(BufferParams & params);
379 bool editing() const { return (bool)tempfile_; }
382 /// signal that something's changed in the Widget.
386 bool eventFilter(QObject * sender, QEvent * event) override;
389 void closeEvent(QCloseEvent *) override;
390 void on_preambleTE_textChanged() { changed(); }
392 typedef std::map<BufferId, std::pair<int,int> > Coords;
393 Coords preamble_coords_;
394 BufferId current_id_;
395 unique_ptr<support::TempFile> tempfile_;
396 /// LaTeX syntax highlighter
397 LaTeXHighlighter * highlighter_;
401 void checkFindButton();
407 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
411 LocalLayout(QWidget * parent);
412 void update(BufferParams const & params, BufferId id);
413 void apply(BufferParams & params);
415 bool isValid() const { return validated_; }
416 bool editing() const { return (bool)tempfile_; }
419 /// signal that something's changed in the Widget.
427 void validatePressed();
428 void convertPressed();
432 BufferId current_id_;
434 unique_ptr<support::TempFile> tempfile_;
438 class FontModule : public UiWidget<Ui::FontUi>
442 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
443 font_sf_scale(100), font_tt_scale(100) {}
444 /// The roman font currently not selected by osFontsCB->isChecked()
446 /// The sans font currently not selected by osFontsCB->isChecked()
448 /// The typewriter font currently not selected by osFontsCB->isChecked()
449 QString font_typewriter;
450 /// The math font currently not selected by osFontsCB->isChecked()
452 /// The sans font scale currently not selected by osFontsCB->isChecked()
454 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
459 } // namespace frontend
462 #endif // GUIDOCUMENT_H