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 inputencodingToDialog();
157 void mathFontChanged(int);
158 void branchesRename(docstring const &, docstring const &);
159 void allPackagesAuto();
160 void allPackagesAlways();
161 void allPackagesNot();
162 void moduleFilterPressed();
163 void moduleFilterChanged(const QString & text);
164 void resetModuleFilter();
165 void linenoToggled(bool);
167 /// validate listings parameters and return an error message, if any
168 QString validateListingsParameters();
170 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
171 UiWidget<Ui::MasterChildUi> *masterChildModule;
172 FontModule *fontModule;
173 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
174 UiWidget<Ui::MarginsUi> *marginsModule;
175 UiWidget<Ui::LanguageUi> *langModule;
176 UiWidget<Ui::ColorUi> *colorModule;
177 UiWidget<Ui::NumberingUi> *numberingModule;
178 UiWidget<Ui::BiblioUi> *biblioModule;
179 UiWidget<Ui::MathsUi> *mathsModule;
180 UiWidget<Ui::LaTeXUi> *latexModule;
181 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
182 UiWidget<Ui::ModulesUi> *modulesModule;
183 UiWidget<Ui::OutputUi> *outputModule;
184 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
185 PreambleModule * preambleModule;
186 LocalLayout * localLayout;
188 GuiBranches * branchesModule;
189 GuiIndices * indicesModule;
191 BulletsModule * bulletsModule;
192 FloatPlacement * floatModule;
194 ModuleSelectionManager * selectionManager;
196 /// Available modules
197 QStandardItemModel * availableModel() { return &modules_av_model_; }
199 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
204 void updateContents();
206 void updateAvailableModules();
208 void updateSelectedModules();
210 void updateIncludeonlys();
212 void updateDefaultBiblio(std::string const & style,
213 std::string const & which = std::string());
214 /// save as default template
215 void saveDocDefault();
216 /// reset to default params
217 void useClassDefaults();
219 void setLayoutComboByIDString(std::string const & idString);
220 /// Update quotes styles combo, indicating the current language's default
221 void updateQuoteStyles(bool const set = false);
223 void getTableStyles();
225 /// available modules
226 QStandardItemModel modules_av_model_;
228 GuiIdListModel modules_sel_model_;
231 FancyLineEdit * filter_;
233 /// return false if validate_listings_params returns error
236 /// font family names for BufferParams::fonts_default_family
237 static char const * const fontfamilies[5];
238 /// GUI names corresponding fontfamilies
239 static char const * fontfamilies_gui[5];
241 bool initialiseParams(std::string const & data);
245 void dispatchParams();
247 void modulesToParams(BufferParams &);
249 bool isBufferDependent() const { return true; }
250 /// always true since we don't manipulate document contents
251 bool canApply() const { return true; }
253 DocumentClass const & documentClass() const;
255 BufferParams & params() { return bp_; }
259 struct modInfoStruct {
268 static modInfoStruct modInfo(LyXModule const & mod);
269 /// List of available modules
270 std::list<modInfoStruct> const & getModuleInfo();
271 /// Modules in use in current buffer
272 std::list<modInfoStruct> const getSelectedModules();
274 std::list<modInfoStruct> const getProvidedModules();
276 std::list<modInfoStruct> const
277 makeModuleInfo(LayoutModuleList const & mods);
279 void setLanguage() const;
281 void saveAsDefault() const;
282 /// does this font provide Old Style figures?
283 bool providesOSF(QString const & font) const;
284 /// does this font provide true Small Caps?
285 bool providesSC(QString const & font) const;
286 /** does this font provide OSF and Small Caps only via
287 * a single, undifferentiated expert option?
289 bool hasMonolithicExpertSet(QString const & font) const;
290 /// does this font provide size adjustment?
291 bool providesScale(QString const & font) const;
292 /// does this font provide extra options?
293 bool providesExtraOpts(QString const & font) const;
294 /// does this font provide an alternative without math?
295 bool providesNoMath(QString const & font) const;
297 void executeBranchRenaming() const;
299 void setCustomPapersize(bool custom);
302 void loadModuleInfo();
304 void updateUnknownBranches();
306 void updateTexFonts();
308 void updateMathFonts(QString const & rm);
310 void updateExtraOpts();
312 void updateFontOptions();
316 bool completeFontset() const;
318 bool noMathFont() const;
320 void allPackages(int);
322 bool isBiblatex() const;
324 void checkPossibleCiteEngines();
326 void filterModules(QString const & string);
329 /// List of names of available modules
330 std::list<modInfoStruct> moduleNames_;
332 std::map<docstring, docstring> changedBranches_;
334 std::list<std::string> includeonlys_;
337 /// Track if a non-module document param changed
338 bool nonModuleChanged_;
339 /// Track if used modules changed
340 bool modulesChanged_;
341 /// Track if the shellescape param changed
342 bool shellescapeChanged_;
346 class PreambleModule : public UiWidget<Ui::PreambleUi>
350 PreambleModule(QWidget * parent);
351 void update(BufferParams const & params, BufferId id);
352 void apply(BufferParams & params);
353 bool editing() const { return (bool)tempfile_; }
356 /// signal that something's changed in the Widget.
360 void closeEvent(QCloseEvent *);
361 void on_preambleTE_textChanged() { changed(); }
363 typedef std::map<BufferId, std::pair<int,int> > Coords;
364 Coords preamble_coords_;
365 BufferId current_id_;
366 unique_ptr<support::TempFile> tempfile_;
370 void checkFindButton();
376 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
380 LocalLayout(QWidget * parent);
381 void update(BufferParams const & params, BufferId id);
382 void apply(BufferParams & params);
383 bool isValid() const { return validated_; }
384 bool editing() const { return (bool)tempfile_; }
387 /// signal that something's changed in the Widget.
396 void validatePressed();
397 void convertPressed();
401 BufferId current_id_;
403 unique_ptr<support::TempFile> tempfile_;
407 class FontModule : public UiWidget<Ui::FontUi>
411 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
412 font_sf_scale(100), font_tt_scale(100) {}
413 /// The roman font currently not selected by osFontsCB->isChecked()
415 /// The sans font currently not selected by osFontsCB->isChecked()
417 /// The typewriter font currently not selected by osFontsCB->isChecked()
418 QString font_typewriter;
419 /// The math font currently not selected by osFontsCB->isChecked()
421 /// The sans font scale currently not selected by osFontsCB->isChecked()
423 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
428 } // namespace frontend
431 #endif // GUIDOCUMENT_H