]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDocument.h
Mention style-dependency of of features in the tooltips, part 2
[lyx.git] / src / frontends / qt4 / 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_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"
39
40 namespace lyx {
41
42 class BufferParams;
43 class LayoutModuleList;
44 class LyXModule;
45 class TextClass;
46
47 namespace frontend {
48
49 class FloatPlacement;
50 class GuiBranches;
51 class GuiIndices;
52 class ModuleSelectionManager;
53 class PreambleModule;
54 class LocalLayout;
55 class FontModule;
56
57 ///
58 typedef void const * BufferId;
59
60 template<class UI>
61 class UiWidget : public QWidget, public UI
62 {
63 public:
64         UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
65 };
66
67
68 class GuiDocument : public GuiDialog, public Ui::DocumentUi
69 {
70         Q_OBJECT
71 public:
72         GuiDocument(GuiView & lv);
73
74         void paramsToDialog();
75         void updateFontsize(std::string const &, std::string const &);
76         void updateFontlist();
77         void updateDefaultFormat();
78         void updateCiteStyles(std::vector<std::string> const &,
79                               CiteEngineType const & sel = ENGINE_TYPE_AUTHORYEAR);
80         void updateEngineType(std::string const &, CiteEngineType const &);
81         void updatePagestyle(std::string const &, std::string const &);
82         bool isChildIncluded(std::string const &);
83
84         ///
85         BufferParams const & params() const { return bp_; }
86
87 public Q_SLOTS:
88         void onBufferViewChanged();//override
89
90 private Q_SLOTS:
91         void updateNumbering();
92         void change_adaptor();
93         void includeonlyClicked(QTreeWidgetItem * item, int);
94         void setListingsMessage();
95         void saveDefaultClicked();
96         void useDefaultsClicked();
97         void setLSpacing(int);
98         void setMargins();
99         void papersizeChanged(int);
100         void setColSep();
101         void setCustomMargins(bool);
102         void fontencChanged(int);
103         void romanChanged(int);
104         void sansChanged(int);
105         void ttChanged(int);
106         void fontOsfToggled(bool state);
107         void fontScToggled(bool state);
108         void setIndent(int);
109         void enableIndent(bool);
110         void setSkip(int);
111         void enableSkip(bool);
112         void browseLayout();
113         void browseMaster();
114         void classChanged();
115         void classChanged_adaptor();
116         void languagePackageChanged(int);
117         void biblioChanged();
118         void rescanBibFiles();
119         void resetDefaultBibfile(std::string const & which = std::string());
120         void resetDefaultBbxBibfile();
121         void resetDefaultCbxBibfile();
122         void citeEngineChanged(int);
123         void citeStyleChanged();
124         void bibtexChanged(int);
125         void updateResetDefaultBiblio();
126         void matchBiblatexStyles();
127         void updateEngineDependends();
128         void updateModuleInfo();
129         void modulesChanged();
130         void changeBackgroundColor();
131         void deleteBackgroundColor();
132         void changeFontColor();
133         void deleteFontColor();
134         void changeNoteFontColor();
135         void deleteNoteFontColor();
136         void changeBoxBackgroundColor();
137         void deleteBoxBackgroundColor();
138         void languageChanged(int);
139         void osFontsChanged(bool);
140         void mathFontChanged(int);
141         void branchesRename(docstring const &, docstring const &);
142         void allPackagesAuto();
143         void allPackagesAlways();
144         void allPackagesNot();
145 private:
146         /// validate listings parameters and return an error message, if any
147         QString validateListingsParameters();
148
149         UiWidget<Ui::TextLayoutUi> *textLayoutModule;
150         UiWidget<Ui::MasterChildUi> *masterChildModule;
151         FontModule *fontModule;
152         UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
153         UiWidget<Ui::MarginsUi> *marginsModule;
154         UiWidget<Ui::LanguageUi> *langModule;
155         UiWidget<Ui::ColorUi> *colorModule;
156         UiWidget<Ui::NumberingUi> *numberingModule;
157         UiWidget<Ui::BiblioUi> *biblioModule;
158         UiWidget<Ui::MathsUi> *mathsModule;
159         UiWidget<Ui::LaTeXUi> *latexModule;
160         UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
161         UiWidget<Ui::ModulesUi> *modulesModule;
162         UiWidget<Ui::OutputUi> *outputModule;
163         UiWidget<Ui::ListingsSettingsUi> *listingsModule;
164         PreambleModule * preambleModule;
165         LocalLayout * localLayout;
166
167         GuiBranches * branchesModule;
168         GuiIndices * indicesModule;
169
170         BulletsModule * bulletsModule;
171         FloatPlacement * floatModule;
172
173         ModuleSelectionManager * selectionManager;
174
175         /// Available modules
176         GuiIdListModel * availableModel() { return &modules_av_model_; }
177         /// Selected modules
178         GuiIdListModel * selectedModel() { return &modules_sel_model_; }
179
180         /// Apply changes
181         void applyView();
182         /// update
183         void updateContents();
184         ///
185         void updateAvailableModules();
186         ///
187         void updateSelectedModules();
188         ///
189         void updateIncludeonlys();
190         ///
191         void updateDefaultBiblio(std::string const & style,
192                                  std::string const & which = std::string());
193         /// save as default template
194         void saveDocDefault();
195         /// reset to default params
196         void useClassDefaults();
197         ///
198         void setLayoutComboByIDString(std::string const & idString);
199         /// Update quotes styles combo, indicating the current language's default
200         void updateQuoteStyles(bool const set = false);
201
202         /// available modules
203         GuiIdListModel modules_av_model_;
204         /// selected modules
205         GuiIdListModel modules_sel_model_;
206
207         /// return false if validate_listings_params returns error
208         bool isValid();
209
210         /// font family names for BufferParams::fonts_default_family
211         static char const * const fontfamilies[5];
212         /// GUI names corresponding fontfamilies
213         static char const * fontfamilies_gui[5];
214         ///
215         bool initialiseParams(std::string const & data);
216         ///
217         void clearParams();
218         ///
219         void dispatchParams();
220         ///
221         void modulesToParams(BufferParams &);
222         ///
223         bool isBufferDependent() const { return true; }
224         /// always true since we don't manipulate document contents
225         bool canApply() const { return true; }
226         ///
227         DocumentClass const & documentClass() const;
228         ///
229         BufferParams & params() { return bp_; }
230         ///
231         BufferId id() const;
232         ///
233         struct modInfoStruct {
234                 QString name;
235                 std::string id;
236                 QString description;
237         };
238         ///
239         static modInfoStruct modInfo(LyXModule const & mod);
240         /// List of available modules
241         std::list<modInfoStruct> const & getModuleInfo();
242         /// Modules in use in current buffer
243         std::list<modInfoStruct> const getSelectedModules();
244         ///
245         std::list<modInfoStruct> const getProvidedModules();
246         ///
247         std::list<modInfoStruct> const
248                         makeModuleInfo(LayoutModuleList const & mods);
249         ///
250         void setLanguage() const;
251         ///
252         void saveAsDefault() const;
253         /// does this font provide Old Style figures?
254         bool providesOSF(QString const & font) const;
255         /// does this font provide true Small Caps?
256         bool providesSC(QString const & font) const;
257         /** does this font provide OSF and Small Caps only via 
258          * a single, undifferentiated expert option?
259          */
260         bool hasMonolithicExpertSet(QString const & font) const;
261         /// does this font provide size adjustment?
262         bool providesScale(QString const & font) const;
263         /// does this font provide an alternative without math?
264         bool providesNoMath(QString const & font) const;
265         ///
266         void executeBranchRenaming() const;
267         ///
268         void setCustomPapersize(bool custom);
269 private:
270         ///
271         void loadModuleInfo();
272         ///
273         void updateUnknownBranches();
274         ///
275         void updateTexFonts();
276         ///
277         void updateMathFonts(QString const & rm);
278         ///
279         void updateFontOptions();
280         ///
281         bool ot1() const;
282         ///
283         bool completeFontset() const;
284         ///
285         bool noMathFont() const;
286         ///
287         void allPackages(int);
288         ///
289         bool isBiblatex() const;
290         ///
291         BufferParams bp_;
292         /// List of names of available modules
293         std::list<modInfoStruct> moduleNames_;
294         ///
295         std::map<docstring, docstring> changedBranches_;
296         ///
297         std::list<std::string> includeonlys_;
298         ///
299         bool biblioChanged_;
300         /// Track if a non-module document param changed
301         bool nonModuleChanged_;
302 };
303
304
305 class PreambleModule : public UiWidget<Ui::PreambleUi>
306 {
307         Q_OBJECT
308 public:
309         PreambleModule();
310         void update(BufferParams const & params, BufferId id);
311         void apply(BufferParams & params);
312
313 Q_SIGNALS:
314         /// signal that something's changed in the Widget.
315         void changed();
316
317 private:
318         void closeEvent(QCloseEvent *);
319         void on_preambleTE_textChanged() { changed(); }
320
321 private:
322         typedef std::map<BufferId, std::pair<int,int> > Coords;
323         Coords preamble_coords_;
324         BufferId current_id_;
325 };
326
327
328 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
329 {
330         Q_OBJECT
331 public:
332         LocalLayout();
333         void update(BufferParams const & params, BufferId id);
334         void apply(BufferParams & params);
335         bool isValid() const { return validated_; }
336
337 Q_SIGNALS:
338         /// signal that something's changed in the Widget.
339         void changed();
340
341 private:
342         void validate();
343         void convert();
344         void hideConvert();
345 private Q_SLOTS:
346         void textChanged();
347         void validatePressed();
348         void convertPressed();
349
350 private:
351         BufferId current_id_;
352         bool validated_;
353 };
354
355
356 class FontModule : public UiWidget<Ui::FontUi>
357 {
358         Q_OBJECT
359 public:
360         /// The roman font currently not selected by osFontsCB->isChecked()
361         QString font_roman;
362         /// The sans font currently not selected by osFontsCB->isChecked()
363         QString font_sans;
364         /// The typewriter font currently not selected by osFontsCB->isChecked()
365         QString font_typewriter;
366         /// The math font currently not selected by osFontsCB->isChecked()
367         QString font_math;
368         /// The sans font scale currently not selected by osFontsCB->isChecked()
369         int font_sf_scale;
370         /// The typewriter font scale currently not selected by osFontsCB->isChecked()
371         int font_tt_scale;
372 };
373
374
375 } // namespace frontend
376 } // namespace lyx
377
378 #endif // GUIDOCUMENT_H