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);
171 void changeTrackingChanged(bool);
173 /// validate listings parameters and return an error message, if any
174 QString validateListingsParameters();
176 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
177 UiWidget<Ui::MasterChildUi> *masterChildModule;
178 FontModule *fontModule;
179 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
180 UiWidget<Ui::MarginsUi> *marginsModule;
181 UiWidget<Ui::LanguageUi> *langModule;
182 UiWidget<Ui::ColorUi> *colorModule;
183 UiWidget<Ui::ChangeTrackingUi> *changesModule;
184 UiWidget<Ui::NumberingUi> *numberingModule;
185 UiWidget<Ui::BiblioUi> *biblioModule;
186 UiWidget<Ui::MathsUi> *mathsModule;
187 UiWidget<Ui::LaTeXUi> *latexModule;
188 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
189 UiWidget<Ui::ModulesUi> *modulesModule;
190 UiWidget<Ui::OutputUi> *outputModule;
191 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
192 PreambleModule * preambleModule;
193 LocalLayout * localLayout;
195 GuiBranches * branchesModule;
196 GuiIndices * indicesModule;
198 BulletsModule * bulletsModule;
199 FloatPlacement * floatModule;
201 ModuleSelectionManager * selectionManager;
203 /// Available modules
204 QStandardItemModel * availableModel() { return &modules_av_model_; }
206 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
209 void applyView() override;
211 void updateContents() override;
213 void updateAvailableModules();
215 void updateSelectedModules();
217 void updateIncludeonlyDisplay();
219 void updateIncludeonlys(bool const cleanup = true);
221 void updateDefaultBiblio(std::string const & style,
222 std::string const & which = std::string());
223 /// save as default template
224 void saveDocDefault();
225 /// reset to default params
226 void useClassDefaults();
228 void setLayoutComboByIDString(std::string const & idString);
229 /// Update quotes styles combo, indicating the current language's default
230 void updateQuoteStyles(bool const set = false);
232 void getTableStyles();
234 /// available modules
235 QStandardItemModel modules_av_model_;
237 GuiIdListModel modules_sel_model_;
240 FancyLineEdit * filter_;
242 /// return false if validate_listings_params returns error
243 bool isValid() override;
245 /// font family names for BufferParams::fonts_default_family
246 static char const * const fontfamilies[5];
247 /// GUI names corresponding fontfamilies
248 static char const * fontfamilies_gui[5];
250 bool initialiseParams(std::string const & data) override;
252 void clearParams() override;
254 void dispatchParams() override;
256 void modulesToParams(BufferParams &);
258 bool isBufferDependent() const override { return true; }
259 /// always true since we don't manipulate document contents
260 bool canApply() const override { return true; }
262 DocumentClass const & documentClass() const;
264 BufferParams & params() { return bp_; }
268 struct modInfoStruct {
277 static modInfoStruct modInfo(LyXModule const & mod);
278 /// List of available modules
279 std::list<modInfoStruct> const & getModuleInfo();
280 /// Modules in use in current buffer
281 std::list<modInfoStruct> const getSelectedModules();
283 std::list<modInfoStruct> const getProvidedModules();
285 std::list<modInfoStruct> const
286 makeModuleInfo(LayoutModuleList const & mods);
288 void setLanguage() const;
290 void saveAsDefault() const;
291 /// does this font provide Old Style figures?
292 bool providesOSF(QString const & font) const;
293 /// does this font provide true Small Caps?
294 bool providesSC(QString const & font) const;
295 /** does this font provide OSF and Small Caps only via
296 * a single, undifferentiated expert option?
298 bool hasMonolithicExpertSet(QString const & font) const;
299 /// does this font provide size adjustment?
300 bool providesScale(QString const & font) const;
301 /// does this font provide extra options?
302 bool providesExtraOpts(QString const & font) const;
303 /// does this font provide an alternative without math?
304 bool providesNoMath(QString const & font) const;
306 void executeBranchRenaming() const;
308 void setCustomPapersize(bool custom);
311 void loadModuleInfo();
313 void updateUnknownBranches();
315 void updateTexFonts();
317 void updateMathFonts(QString const & rm);
319 void updateExtraOpts();
321 void updateFontOptions();
325 bool completeFontset() const;
327 bool noMathFont() const;
329 void allPackages(int);
331 bool isBiblatex() const;
333 void checkPossibleCiteEngines();
335 void filterModules(QString const & string);
338 /// Store buffer filename for the case we switch with
339 /// unapplied changes.
340 std::string prev_buffer_filename_;
341 /// List of names of available modules
342 std::list<modInfoStruct> moduleNames_;
344 std::map<docstring, docstring> changedBranches_;
346 std::list<std::string> includeonlys_;
349 /// Track if a non-module document param changed
350 bool nonModuleChanged_;
351 /// Track if used modules changed
352 bool modulesChanged_;
353 /// Track if the shellescape param changed
354 bool shellescapeChanged_;
355 /// Track if we switch back to a buffer due to unapplied
358 /// Track whether we prompted the user about unapplied
364 class PreambleModule : public UiWidget<Ui::PreambleUi>
368 PreambleModule(QWidget * parent);
369 void update(BufferParams const & params, BufferId id);
370 void apply(BufferParams & params);
371 bool editing() const { return (bool)tempfile_; }
374 /// signal that something's changed in the Widget.
378 bool eventFilter(QObject * sender, QEvent * event) override;
381 void closeEvent(QCloseEvent *) override;
382 void on_preambleTE_textChanged() { changed(); }
384 typedef std::map<BufferId, std::pair<int,int> > Coords;
385 Coords preamble_coords_;
386 BufferId current_id_;
387 unique_ptr<support::TempFile> tempfile_;
391 void checkFindButton();
397 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
401 LocalLayout(QWidget * parent);
402 void update(BufferParams const & params, BufferId id);
403 void apply(BufferParams & params);
405 bool isValid() const { return validated_; }
406 bool editing() const { return (bool)tempfile_; }
409 /// signal that something's changed in the Widget.
417 void validatePressed();
418 void convertPressed();
422 BufferId current_id_;
424 unique_ptr<support::TempFile> tempfile_;
428 class FontModule : public UiWidget<Ui::FontUi>
432 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
433 font_sf_scale(100), font_tt_scale(100) {}
434 /// The roman font currently not selected by osFontsCB->isChecked()
436 /// The sans font currently not selected by osFontsCB->isChecked()
438 /// The typewriter font currently not selected by osFontsCB->isChecked()
439 QString font_typewriter;
440 /// The math font currently not selected by osFontsCB->isChecked()
442 /// The sans font scale currently not selected by osFontsCB->isChecked()
444 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
449 } // namespace frontend
452 #endif // GUIDOCUMENT_H