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 "ui_BiblioUi.h"
21 #include "ui_ColorUi.h"
22 #include "ui_ChangeTrackingUi.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 "support/unique_ptr.h"
42 #include <QStandardItemModel>
46 class LayoutModuleList;
60 class ModuleSelectionManager;
66 typedef Buffer const * BufferId;
69 class UiWidget : public QWidget, public UI
72 UiWidget(QWidget * parent) : QWidget(parent) { UI::setupUi(this); }
76 class GuiDocument : public GuiDialog, public Ui::DocumentUi
80 GuiDocument(GuiView & lv);
82 void paramsToDialog();
83 void updateFontsize(std::string const &, std::string const &);
84 void updateFontlist();
85 void updateDefaultFormat();
86 void updateCiteStyles(std::vector<std::string> const &,
87 CiteEngineType const & sel = ENGINE_TYPE_AUTHORYEAR);
88 void updateEngineType(std::string const &, CiteEngineType const &);
89 void updatePagestyle(std::string const &, std::string const &);
90 bool isChildIncluded(std::string const &);
93 BufferParams const & params() const { return bp_; }
96 void onBufferViewChanged() override;
99 // Apply button clicked
101 void slotButtonBox(QAbstractButton *);
104 void updateNumbering();
105 void change_adaptor();
106 void shellescapeChanged();
107 void includeonlyClicked(QTreeWidgetItem * item, int);
108 void setListingsMessage();
109 void listingsPackageChanged(int);
110 void saveDefaultClicked();
111 void useDefaultsClicked();
112 void setLSpacing(int);
114 void papersizeChanged(int);
116 void setCustomMargins(bool);
117 void fontencChanged(int);
118 void romanChanged(int);
119 void sansChanged(int);
121 void fontOsfToggled(bool state);
122 void fontScToggled(bool state);
124 void enableIndent(bool);
126 void enableSkip(bool);
127 void allowMathIndent();
128 void enableMathIndent(int);
132 void classChanged_adaptor();
133 void languagePackageChanged(int);
134 void biblioChanged();
135 void rescanBibFiles();
136 void resetDefaultBibfile(std::string const & which = std::string());
137 void resetDefaultBbxBibfile();
138 void resetDefaultCbxBibfile();
139 void citeEngineChanged(int);
140 void citeStyleChanged();
141 void bibtexChanged(int);
142 void updateResetDefaultBiblio();
143 void matchBiblatexStyles();
144 void updateEngineDependends();
145 void updateModuleInfo();
146 void modulesChanged();
147 void changeBackgroundColor();
148 void deleteBackgroundColor();
149 void changeFontColor();
150 void deleteFontColor();
151 void changeNoteFontColor();
152 void deleteNoteFontColor();
153 void changeBoxBackgroundColor();
154 void deleteBoxBackgroundColor();
155 void languageChanged(int);
156 void osFontsChanged(bool);
157 void encodingSwitched(int);
158 void inputencodingToDialog();
159 void mathFontChanged(int);
160 void branchesRename(docstring const &, docstring const &);
161 void allPackagesAuto();
162 void allPackagesAlways();
163 void allPackagesNot();
164 void moduleFilterPressed();
165 void moduleFilterChanged(const QString & text);
166 void resetModuleFilter();
167 void linenoToggled(bool);
168 void outputChangesToggled(bool);
169 void setOutputSync(bool);
170 void bookmarksopenChanged(bool);
172 /// validate listings parameters and return an error message, if any
173 QString validateListingsParameters();
175 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
176 UiWidget<Ui::MasterChildUi> *masterChildModule;
177 FontModule *fontModule;
178 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
179 UiWidget<Ui::MarginsUi> *marginsModule;
180 UiWidget<Ui::LanguageUi> *langModule;
181 UiWidget<Ui::ColorUi> *colorModule;
182 UiWidget<Ui::ChangeTrackingUi> *changesModule;
183 UiWidget<Ui::NumberingUi> *numberingModule;
184 UiWidget<Ui::BiblioUi> *biblioModule;
185 UiWidget<Ui::MathsUi> *mathsModule;
186 UiWidget<Ui::LaTeXUi> *latexModule;
187 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
188 UiWidget<Ui::ModulesUi> *modulesModule;
189 UiWidget<Ui::OutputUi> *outputModule;
190 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
191 PreambleModule * preambleModule;
192 LocalLayout * localLayout;
194 GuiBranches * branchesModule;
195 GuiIndices * indicesModule;
197 BulletsModule * bulletsModule;
198 FloatPlacement * floatModule;
200 ModuleSelectionManager * selectionManager;
202 /// Available modules
203 QStandardItemModel * availableModel() { return &modules_av_model_; }
205 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
208 void applyView() override;
210 void updateContents() override;
212 void updateAvailableModules();
214 void updateSelectedModules();
216 void updateIncludeonlyDisplay();
218 void updateIncludeonlys(bool const cleanup = true);
220 void updateDefaultBiblio(std::string const & style,
221 std::string const & which = std::string());
222 /// save as default template
223 void saveDocDefault();
224 /// reset to default params
225 void useClassDefaults();
227 void setLayoutComboByIDString(std::string const & idString);
228 /// Update quotes styles combo, indicating the current language's default
229 void updateQuoteStyles(bool const set = false);
231 void getTableStyles();
233 /// available modules
234 QStandardItemModel modules_av_model_;
236 GuiIdListModel modules_sel_model_;
239 FancyLineEdit * filter_;
241 /// return false if validate_listings_params returns error
242 bool isValid() override;
244 /// font family names for BufferParams::fonts_default_family
245 static char const * const fontfamilies[5];
246 /// GUI names corresponding fontfamilies
247 static char const * fontfamilies_gui[5];
249 bool initialiseParams(std::string const & data) override;
251 void clearParams() override;
253 void dispatchParams() override;
255 void modulesToParams(BufferParams &);
257 bool isBufferDependent() const override { return true; }
258 /// always true since we don't manipulate document contents
259 bool canApply() const override { return true; }
261 DocumentClass const & documentClass() const;
263 BufferParams & params() { return bp_; }
267 struct modInfoStruct {
276 static modInfoStruct modInfo(LyXModule const & mod);
277 /// List of available modules
278 std::list<modInfoStruct> const & getModuleInfo();
279 /// Modules in use in current buffer
280 std::list<modInfoStruct> const getSelectedModules();
282 std::list<modInfoStruct> const getProvidedModules();
284 std::list<modInfoStruct> const
285 makeModuleInfo(LayoutModuleList const & mods);
287 void setLanguage() const;
289 void saveAsDefault() const;
290 /// does this font provide Old Style figures?
291 bool providesOSF(QString const & font) const;
292 /// does this font provide true Small Caps?
293 bool providesSC(QString const & font) const;
294 /** does this font provide OSF and Small Caps only via
295 * a single, undifferentiated expert option?
297 bool hasMonolithicExpertSet(QString const & font) const;
298 /// does this font provide size adjustment?
299 bool providesScale(QString const & font) const;
300 /// does this font provide extra options?
301 bool providesExtraOpts(QString const & font) const;
302 /// does this font provide an alternative without math?
303 bool providesNoMath(QString const & font) const;
305 void executeBranchRenaming() const;
307 void setCustomPapersize(bool custom);
310 void loadModuleInfo();
312 void updateUnknownBranches();
314 void updateTexFonts();
316 void updateMathFonts(QString const & rm);
318 void updateExtraOpts();
320 void updateFontOptions();
324 bool completeFontset() const;
326 bool noMathFont() const;
328 void allPackages(int);
330 bool isBiblatex() const;
332 void checkPossibleCiteEngines();
334 void filterModules(QString const & string);
337 /// Store buffer filename for the case we switch with
338 /// unapplied changes.
339 std::string prev_buffer_filename_;
340 /// List of names of available modules
341 std::list<modInfoStruct> moduleNames_;
343 std::map<docstring, docstring> changedBranches_;
345 std::list<std::string> includeonlys_;
348 /// Track if a non-module document param changed
349 bool nonModuleChanged_;
350 /// Track if used modules changed
351 bool modulesChanged_;
352 /// Track if the shellescape param changed
353 bool shellescapeChanged_;
354 /// Track if we switch back to a buffer due to unapplied
357 /// Track whether we prompted the user about unapplied
363 class PreambleModule : public UiWidget<Ui::PreambleUi>
367 PreambleModule(QWidget * parent);
368 void update(BufferParams const & params, BufferId id);
369 void apply(BufferParams & params);
370 bool editing() const { return (bool)tempfile_; }
373 /// signal that something's changed in the Widget.
377 bool eventFilter(QObject * sender, QEvent * event) override;
380 void closeEvent(QCloseEvent *) override;
381 void on_preambleTE_textChanged() { changed(); }
383 typedef std::map<BufferId, std::pair<int,int> > Coords;
384 Coords preamble_coords_;
385 BufferId current_id_;
386 unique_ptr<support::TempFile> tempfile_;
390 void checkFindButton();
396 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
400 LocalLayout(QWidget * parent);
401 void update(BufferParams const & params, BufferId id);
402 void apply(BufferParams & params);
404 bool isValid() const { return validated_; }
405 bool editing() const { return (bool)tempfile_; }
408 /// signal that something's changed in the Widget.
416 void validatePressed();
417 void convertPressed();
421 BufferId current_id_;
423 unique_ptr<support::TempFile> tempfile_;
427 class FontModule : public UiWidget<Ui::FontUi>
431 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
432 font_sf_scale(100), font_tt_scale(100) {}
433 /// The roman font currently not selected by osFontsCB->isChecked()
435 /// The sans font currently not selected by osFontsCB->isChecked()
437 /// The typewriter font currently not selected by osFontsCB->isChecked()
438 QString font_typewriter;
439 /// The math font currently not selected by osFontsCB->isChecked()
441 /// The sans font scale currently not selected by osFontsCB->isChecked()
443 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
448 } // namespace frontend
451 #endif // GUIDOCUMENT_H