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>
46 class LayoutModuleList;
59 class ModuleSelectionManager;
65 typedef Buffer const * BufferId;
68 class UiWidget : public QWidget, public UI
71 UiWidget(QWidget * parent) : QWidget(parent) { UI::setupUi(this); }
75 class GuiDocument : public GuiDialog, public Ui::DocumentUi
79 GuiDocument(GuiView & lv);
81 void paramsToDialog();
82 void updateFontsize(std::string const &, std::string const &);
83 void updateFontlist();
84 void updateDefaultFormat();
85 void updateCiteStyles(std::vector<std::string> const &,
86 CiteEngineType const & sel = ENGINE_TYPE_AUTHORYEAR);
87 void updateEngineType(std::string const &, CiteEngineType const &);
88 void updatePagestyle(std::string const &, std::string const &);
89 bool isChildIncluded(std::string const &);
92 BufferParams const & params() const { return bp_; }
95 void onBufferViewChanged();//override
98 // Apply button clicked
100 void slotButtonBox(QAbstractButton *);
103 void updateNumbering();
104 void change_adaptor();
105 void shellescapeChanged();
106 void includeonlyClicked(QTreeWidgetItem * item, int);
107 void setListingsMessage();
108 void listingsPackageChanged(int);
109 void saveDefaultClicked();
110 void useDefaultsClicked();
111 void setLSpacing(int);
113 void papersizeChanged(int);
115 void setCustomMargins(bool);
116 void fontencChanged(int);
117 void romanChanged(int);
118 void sansChanged(int);
120 void fontOsfToggled(bool state);
121 void fontScToggled(bool state);
123 void enableIndent(bool);
125 void enableSkip(bool);
126 void allowMathIndent();
127 void enableMathIndent(int);
131 void classChanged_adaptor();
132 void languagePackageChanged(int);
133 void biblioChanged();
134 void rescanBibFiles();
135 void resetDefaultBibfile(std::string const & which = std::string());
136 void resetDefaultBbxBibfile();
137 void resetDefaultCbxBibfile();
138 void citeEngineChanged(int);
139 void citeStyleChanged();
140 void bibtexChanged(int);
141 void updateResetDefaultBiblio();
142 void matchBiblatexStyles();
143 void updateEngineDependends();
144 void updateModuleInfo();
145 void modulesChanged();
146 void changeBackgroundColor();
147 void deleteBackgroundColor();
148 void changeFontColor();
149 void deleteFontColor();
150 void changeNoteFontColor();
151 void deleteNoteFontColor();
152 void changeBoxBackgroundColor();
153 void deleteBoxBackgroundColor();
154 void languageChanged(int);
155 void osFontsChanged(bool);
156 void encodingSwitched(int);
157 void inputencodingToDialog();
158 void mathFontChanged(int);
159 void branchesRename(docstring const &, docstring const &);
160 void allPackagesAuto();
161 void allPackagesAlways();
162 void allPackagesNot();
163 void moduleFilterPressed();
164 void moduleFilterChanged(const QString & text);
165 void resetModuleFilter();
166 void linenoToggled(bool);
167 void outputChangesToggled(bool);
168 void setOutputSync(bool);
170 /// validate listings parameters and return an error message, if any
171 QString validateListingsParameters();
173 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
174 UiWidget<Ui::MasterChildUi> *masterChildModule;
175 FontModule *fontModule;
176 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
177 UiWidget<Ui::MarginsUi> *marginsModule;
178 UiWidget<Ui::LanguageUi> *langModule;
179 UiWidget<Ui::ColorUi> *colorModule;
180 UiWidget<Ui::ChangeTrackingUi> *changesModule;
181 UiWidget<Ui::NumberingUi> *numberingModule;
182 UiWidget<Ui::BiblioUi> *biblioModule;
183 UiWidget<Ui::MathsUi> *mathsModule;
184 UiWidget<Ui::LaTeXUi> *latexModule;
185 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
186 UiWidget<Ui::ModulesUi> *modulesModule;
187 UiWidget<Ui::OutputUi> *outputModule;
188 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
189 PreambleModule * preambleModule;
190 LocalLayout * localLayout;
192 GuiBranches * branchesModule;
193 GuiIndices * indicesModule;
195 BulletsModule * bulletsModule;
196 FloatPlacement * floatModule;
198 ModuleSelectionManager * selectionManager;
200 /// Available modules
201 QStandardItemModel * availableModel() { return &modules_av_model_; }
203 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
208 void updateContents();
210 void updateAvailableModules();
212 void updateSelectedModules();
214 void updateIncludeonlyDisplay();
216 void updateIncludeonlys();
218 void updateDefaultBiblio(std::string const & style,
219 std::string const & which = std::string());
220 /// save as default template
221 void saveDocDefault();
222 /// reset to default params
223 void useClassDefaults();
225 void setLayoutComboByIDString(std::string const & idString);
226 /// Update quotes styles combo, indicating the current language's default
227 void updateQuoteStyles(bool const set = false);
229 void getTableStyles();
231 /// available modules
232 QStandardItemModel modules_av_model_;
234 GuiIdListModel modules_sel_model_;
237 FancyLineEdit * filter_;
239 /// return false if validate_listings_params returns error
242 /// font family names for BufferParams::fonts_default_family
243 static char const * const fontfamilies[5];
244 /// GUI names corresponding fontfamilies
245 static char const * fontfamilies_gui[5];
247 bool initialiseParams(std::string const & data);
251 void dispatchParams();
253 void modulesToParams(BufferParams &);
255 bool isBufferDependent() const { return true; }
256 /// always true since we don't manipulate document contents
257 bool canApply() const { return true; }
259 DocumentClass const & documentClass() const;
261 BufferParams & params() { return bp_; }
265 struct modInfoStruct {
274 static modInfoStruct modInfo(LyXModule const & mod);
275 /// List of available modules
276 std::list<modInfoStruct> const & getModuleInfo();
277 /// Modules in use in current buffer
278 std::list<modInfoStruct> const getSelectedModules();
280 std::list<modInfoStruct> const getProvidedModules();
282 std::list<modInfoStruct> const
283 makeModuleInfo(LayoutModuleList const & mods);
285 void setLanguage() const;
287 void saveAsDefault() const;
288 /// does this font provide Old Style figures?
289 bool providesOSF(QString const & font) const;
290 /// does this font provide true Small Caps?
291 bool providesSC(QString const & font) const;
292 /** does this font provide OSF and Small Caps only via
293 * a single, undifferentiated expert option?
295 bool hasMonolithicExpertSet(QString const & font) const;
296 /// does this font provide size adjustment?
297 bool providesScale(QString const & font) const;
298 /// does this font provide extra options?
299 bool providesExtraOpts(QString const & font) const;
300 /// does this font provide an alternative without math?
301 bool providesNoMath(QString const & font) const;
303 void executeBranchRenaming() const;
305 void setCustomPapersize(bool custom);
308 void loadModuleInfo();
310 void updateUnknownBranches();
312 void updateTexFonts();
314 void updateMathFonts(QString const & rm);
316 void updateExtraOpts();
318 void updateFontOptions();
322 bool completeFontset() const;
324 bool noMathFont() const;
326 void allPackages(int);
328 bool isBiblatex() const;
330 void checkPossibleCiteEngines();
332 void filterModules(QString const & string);
335 /// List of names of available modules
336 std::list<modInfoStruct> moduleNames_;
338 std::map<docstring, docstring> changedBranches_;
340 std::list<std::string> includeonlys_;
343 /// Track if a non-module document param changed
344 bool nonModuleChanged_;
345 /// Track if used modules changed
346 bool modulesChanged_;
347 /// Track if the shellescape param changed
348 bool shellescapeChanged_;
352 class PreambleModule : public UiWidget<Ui::PreambleUi>
356 PreambleModule(QWidget * parent);
357 void update(BufferParams const & params, BufferId id);
358 void apply(BufferParams & params);
359 bool editing() const { return (bool)tempfile_; }
362 /// signal that something's changed in the Widget.
366 void closeEvent(QCloseEvent *);
367 void on_preambleTE_textChanged() { changed(); }
369 typedef std::map<BufferId, std::pair<int,int> > Coords;
370 Coords preamble_coords_;
371 BufferId current_id_;
372 unique_ptr<support::TempFile> tempfile_;
376 void checkFindButton();
382 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
386 LocalLayout(QWidget * parent);
387 void update(BufferParams const & params, BufferId id);
388 void apply(BufferParams & params);
389 bool isValid() const { return validated_; }
390 bool editing() const { return (bool)tempfile_; }
393 /// signal that something's changed in the Widget.
402 void validatePressed();
403 void convertPressed();
407 BufferId current_id_;
409 unique_ptr<support::TempFile> tempfile_;
413 class FontModule : public UiWidget<Ui::FontUi>
417 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
418 font_sf_scale(100), font_tt_scale(100) {}
419 /// The roman font currently not selected by osFontsCB->isChecked()
421 /// The sans font currently not selected by osFontsCB->isChecked()
423 /// The typewriter font currently not selected by osFontsCB->isChecked()
424 QString font_typewriter;
425 /// The math font currently not selected by osFontsCB->isChecked()
427 /// The sans font scale currently not selected by osFontsCB->isChecked()
429 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
434 } // namespace frontend
437 #endif // GUIDOCUMENT_H