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 change_encoding();
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();
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 an alternative without math?
293 bool providesNoMath(QString const & font) const;
295 void executeBranchRenaming() const;
297 void setCustomPapersize(bool custom);
300 void loadModuleInfo();
302 void updateUnknownBranches();
304 void updateTexFonts();
306 void updateMathFonts(QString const & rm);
308 void updateFontOptions();
312 bool completeFontset() const;
314 bool noMathFont() const;
316 void allPackages(int);
318 bool isBiblatex() const;
320 void checkPossibleCiteEngines();
322 void filterModules(QString const & string);
325 /// List of names of available modules
326 std::list<modInfoStruct> moduleNames_;
328 std::map<docstring, docstring> changedBranches_;
330 std::list<std::string> includeonlys_;
333 /// Track if a non-module document param changed
334 bool nonModuleChanged_;
335 /// Track if used modules changed
336 bool modulesChanged_;
337 /// Track if the shellescape param changed
338 bool shellescapeChanged_;
342 class PreambleModule : public UiWidget<Ui::PreambleUi>
346 PreambleModule(QWidget * parent);
347 void update(BufferParams const & params, BufferId id);
348 void apply(BufferParams & params);
349 bool editing() const { return (bool)tempfile_; }
352 /// signal that something's changed in the Widget.
356 void closeEvent(QCloseEvent *);
357 void on_preambleTE_textChanged() { changed(); }
359 typedef std::map<BufferId, std::pair<int,int> > Coords;
360 Coords preamble_coords_;
361 BufferId current_id_;
362 unique_ptr<support::TempFile> tempfile_;
366 void checkFindButton();
372 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
376 LocalLayout(QWidget * parent);
377 void update(BufferParams const & params, BufferId id);
378 void apply(BufferParams & params);
379 bool isValid() const { return validated_; }
380 bool editing() const { return (bool)tempfile_; }
383 /// signal that something's changed in the Widget.
392 void validatePressed();
393 void convertPressed();
397 BufferId current_id_;
399 unique_ptr<support::TempFile> tempfile_;
403 class FontModule : public UiWidget<Ui::FontUi>
407 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
408 font_sf_scale(100), font_tt_scale(100) {}
409 /// The roman font currently not selected by osFontsCB->isChecked()
411 /// The sans font currently not selected by osFontsCB->isChecked()
413 /// The typewriter font currently not selected by osFontsCB->isChecked()
414 QString font_typewriter;
415 /// The math font currently not selected by osFontsCB->isChecked()
417 /// The sans font scale currently not selected by osFontsCB->isChecked()
419 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
424 } // namespace frontend
427 #endif // GUIDOCUMENT_H