]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/GuiDocument.h
Disable bookmarksopenlevel SL when bookmarksopen is false
[lyx.git] / src / frontends / qt / GuiDocument.h
1 // -*- C++ -*-
2 /**
3  * \file GuiDocument.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  * \author Richard Heck (modules)
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef GUIDOCUMENT_H
14 #define GUIDOCUMENT_H
15
16 #include "BufferParams.h"
17 #include "BulletsModule.h"
18 #include "GuiDialog.h"
19 #include "GuiIdListModel.h"
20
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"
40
41 #include <QStandardItemModel>
42
43 namespace lyx {
44
45 class BufferParams;
46 class LayoutModuleList;
47 class LyXModule;
48 class TextClass;
49
50 namespace support {
51         class TempFile;
52 }
53
54 namespace frontend {
55
56 class FloatPlacement;
57 class GuiBranches;
58 class GuiIndices;
59 class ModuleSelectionManager;
60 class PreambleModule;
61 class LocalLayout;
62 class FontModule;
63
64 ///
65 typedef Buffer const * BufferId;
66
67 template<class UI>
68 class UiWidget : public QWidget, public UI
69 {
70 public:
71         UiWidget(QWidget * parent) : QWidget(parent) { UI::setupUi(this); }
72 };
73
74
75 class GuiDocument : public GuiDialog, public Ui::DocumentUi
76 {
77         Q_OBJECT
78 public:
79         GuiDocument(GuiView & lv);
80
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 &);
90
91         ///
92         BufferParams const & params() const { return bp_; }
93
94 public Q_SLOTS:
95         void onBufferViewChanged();//override
96         // OK button clicked
97         void slotOK();
98         // Apply button clicked
99         void slotApply();
100         void slotButtonBox(QAbstractButton *);
101
102 private Q_SLOTS:
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);
112         void setMargins();
113         void papersizeChanged(int);
114         void setColSep();
115         void setCustomMargins(bool);
116         void fontencChanged(int);
117         void romanChanged(int);
118         void sansChanged(int);
119         void ttChanged(int);
120         void fontOsfToggled(bool state);
121         void fontScToggled(bool state);
122         void setIndent(int);
123         void enableIndent(bool);
124         void setSkip(int);
125         void enableSkip(bool);
126         void allowMathIndent();
127         void enableMathIndent(int);
128         void browseLayout();
129         void browseMaster();
130         void classChanged();
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);
169         void bookmarksopenChanged(bool);
170 private:
171         /// validate listings parameters and return an error message, if any
172         QString validateListingsParameters();
173
174         UiWidget<Ui::TextLayoutUi> *textLayoutModule;
175         UiWidget<Ui::MasterChildUi> *masterChildModule;
176         FontModule *fontModule;
177         UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
178         UiWidget<Ui::MarginsUi> *marginsModule;
179         UiWidget<Ui::LanguageUi> *langModule;
180         UiWidget<Ui::ColorUi> *colorModule;
181         UiWidget<Ui::ChangeTrackingUi> *changesModule;
182         UiWidget<Ui::NumberingUi> *numberingModule;
183         UiWidget<Ui::BiblioUi> *biblioModule;
184         UiWidget<Ui::MathsUi> *mathsModule;
185         UiWidget<Ui::LaTeXUi> *latexModule;
186         UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
187         UiWidget<Ui::ModulesUi> *modulesModule;
188         UiWidget<Ui::OutputUi> *outputModule;
189         UiWidget<Ui::ListingsSettingsUi> *listingsModule;
190         PreambleModule * preambleModule;
191         LocalLayout * localLayout;
192
193         GuiBranches * branchesModule;
194         GuiIndices * indicesModule;
195
196         BulletsModule * bulletsModule;
197         FloatPlacement * floatModule;
198
199         ModuleSelectionManager * selectionManager;
200
201         /// Available modules
202         QStandardItemModel * availableModel() { return &modules_av_model_; }
203         /// Selected modules
204         GuiIdListModel * selectedModel() { return &modules_sel_model_; }
205
206         /// Apply changes
207         void applyView();
208         /// update
209         void updateContents();
210         ///
211         void updateAvailableModules();
212         ///
213         void updateSelectedModules();
214         ///
215         void updateIncludeonlyDisplay();
216         ///
217         void updateIncludeonlys();
218         ///
219         void updateDefaultBiblio(std::string const & style,
220                                  std::string const & which = std::string());
221         /// save as default template
222         void saveDocDefault();
223         /// reset to default params
224         void useClassDefaults();
225         ///
226         void setLayoutComboByIDString(std::string const & idString);
227         /// Update quotes styles combo, indicating the current language's default
228         void updateQuoteStyles(bool const set = false);
229         ///
230         void getTableStyles();
231
232         /// available modules
233         QStandardItemModel modules_av_model_;
234         /// selected modules
235         GuiIdListModel modules_sel_model_;
236
237         /// Module filter
238         FancyLineEdit * filter_;
239
240         /// return false if validate_listings_params returns error
241         bool isValid();
242
243         /// font family names for BufferParams::fonts_default_family
244         static char const * const fontfamilies[5];
245         /// GUI names corresponding fontfamilies
246         static char const * fontfamilies_gui[5];
247         ///
248         bool initialiseParams(std::string const & data);
249         ///
250         void clearParams();
251         ///
252         void dispatchParams();
253         ///
254         void modulesToParams(BufferParams &);
255         ///
256         bool isBufferDependent() const { return true; }
257         /// always true since we don't manipulate document contents
258         bool canApply() const { return true; }
259         ///
260         DocumentClass const & documentClass() const;
261         ///
262         BufferParams & params() { return bp_; }
263         ///
264         BufferId id() const;
265         ///
266         struct modInfoStruct {
267                 QString name;
268                 std::string id;
269                 QString description;
270                 QString category;
271                 bool local;
272                 bool missingreqs;
273         };
274         ///
275         static modInfoStruct modInfo(LyXModule const & mod);
276         /// List of available modules
277         std::list<modInfoStruct> const & getModuleInfo();
278         /// Modules in use in current buffer
279         std::list<modInfoStruct> const getSelectedModules();
280         ///
281         std::list<modInfoStruct> const getProvidedModules();
282         ///
283         std::list<modInfoStruct> const
284                         makeModuleInfo(LayoutModuleList const & mods);
285         ///
286         void setLanguage() const;
287         ///
288         void saveAsDefault() const;
289         /// does this font provide Old Style figures?
290         bool providesOSF(QString const & font) const;
291         /// does this font provide true Small Caps?
292         bool providesSC(QString const & font) const;
293         /** does this font provide OSF and Small Caps only via
294          * a single, undifferentiated expert option?
295          */
296         bool hasMonolithicExpertSet(QString const & font) const;
297         /// does this font provide size adjustment?
298         bool providesScale(QString const & font) const;
299         /// does this font provide extra options?
300         bool providesExtraOpts(QString const & font) const;
301         /// does this font provide an alternative without math?
302         bool providesNoMath(QString const & font) const;
303         ///
304         void executeBranchRenaming() const;
305         ///
306         void setCustomPapersize(bool custom);
307 private:
308         ///
309         void loadModuleInfo();
310         ///
311         void updateUnknownBranches();
312         ///
313         void updateTexFonts();
314         ///
315         void updateMathFonts(QString const & rm);
316         ///
317         void updateExtraOpts();
318         ///
319         void updateFontOptions();
320         ///
321         bool ot1() const;
322         ///
323         bool completeFontset() const;
324         ///
325         bool noMathFont() const;
326         ///
327         void allPackages(int);
328         ///
329         bool isBiblatex() const;
330         ///
331         void checkPossibleCiteEngines();
332         ///
333         void filterModules(QString const & string);
334         ///
335         BufferParams bp_;
336         /// List of names of available modules
337         std::list<modInfoStruct> moduleNames_;
338         ///
339         std::map<docstring, docstring> changedBranches_;
340         ///
341         std::list<std::string> includeonlys_;
342         ///
343         bool biblioChanged_;
344         /// Track if a non-module document param changed
345         bool nonModuleChanged_;
346         /// Track if used modules changed
347         bool modulesChanged_;
348         /// Track if the shellescape param changed
349         bool shellescapeChanged_;
350 };
351
352
353 class PreambleModule : public UiWidget<Ui::PreambleUi>
354 {
355         Q_OBJECT
356 public:
357         PreambleModule(QWidget * parent);
358         void update(BufferParams const & params, BufferId id);
359         void apply(BufferParams & params);
360         bool editing() const { return (bool)tempfile_; }
361
362 Q_SIGNALS:
363         /// signal that something's changed in the Widget.
364         void changed();
365
366 private:
367         void closeEvent(QCloseEvent *);
368         void on_preambleTE_textChanged() { changed(); }
369
370         typedef std::map<BufferId, std::pair<int,int> > Coords;
371         Coords preamble_coords_;
372         BufferId current_id_;
373         unique_ptr<support::TempFile> tempfile_;
374
375 private Q_SLOTS:
376         ///
377         void checkFindButton();
378         void findText();
379         void editExternal();
380 };
381
382
383 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
384 {
385         Q_OBJECT
386 public:
387         LocalLayout(QWidget * parent);
388         void update(BufferParams const & params, BufferId id);
389         void apply(BufferParams & params);
390         bool isValid() const { return validated_; }
391         bool editing() const { return (bool)tempfile_; }
392
393 Q_SIGNALS:
394         /// signal that something's changed in the Widget.
395         void changed();
396
397 private:
398         void validate();
399         void convert();
400         void hideConvert();
401 private Q_SLOTS:
402         void textChanged();
403         void validatePressed();
404         void convertPressed();
405         void editExternal();
406
407 private:
408         BufferId current_id_;
409         bool validated_;
410         unique_ptr<support::TempFile> tempfile_;
411 };
412
413
414 class FontModule : public UiWidget<Ui::FontUi>
415 {
416         Q_OBJECT
417 public:
418         FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
419            font_sf_scale(100), font_tt_scale(100) {}
420         /// The roman font currently not selected by osFontsCB->isChecked()
421         QString font_roman;
422         /// The sans font currently not selected by osFontsCB->isChecked()
423         QString font_sans;
424         /// The typewriter font currently not selected by osFontsCB->isChecked()
425         QString font_typewriter;
426         /// The math font currently not selected by osFontsCB->isChecked()
427         QString font_math;
428         /// The sans font scale currently not selected by osFontsCB->isChecked()
429         int font_sf_scale;
430         /// The typewriter font scale currently not selected by osFontsCB->isChecked()
431         int font_tt_scale;
432 };
433
434
435 } // namespace frontend
436 } // namespace lyx
437
438 #endif // GUIDOCUMENT_H