]> git.lyx.org Git - features.git/blob - src/frontends/qt4/Dialogs.cpp
2fdd7c6857515f3bbd1c29c2b4604ade19cb80b9
[features.git] / src / frontends / qt4 / Dialogs.cpp
1 /**
2  * \file qt4/Dialogs.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Dialogs.h"
14 #include "GuiDialog.h"
15
16 #include "ButtonController.h"
17 #include "DialogView.h"
18 #include "DockView.h"
19 #include "GuiAbout.h"
20 #include "GuiBibitem.h"
21 #include "GuiBibtex.h"
22 #include "GuiBox.h"
23 #include "GuiBranch.h"
24 #include "GuiChanges.h"
25 #include "GuiCharacter.h"
26 #include "GuiCitation.h"
27 #include "GuiDelimiter.h"
28 #include "GuiDocument.h"
29 #include "GuiEmbeddedFiles.h"
30 #include "GuiErrorList.h"
31 #include "GuiERT.h"
32 #include "GuiExternal.h"
33 #include "GuiFloat.h"
34 #include "GuiGraphics.h"
35 #include "GuiInclude.h"
36 #include "GuiIndex.h"
37 #include "GuiMathMatrix.h"
38 #include "GuiNomencl.h"
39 #include "GuiListings.h"
40 #include "GuiLog.h"
41 #include "GuiNote.h"
42 #include "GuiParagraph.h"
43 #include "GuiPrefs.h"
44 #include "GuiPrint.h"
45 #include "GuiRef.h"
46 #include "GuiSearch.h"
47 #include "GuiSendto.h"
48 #include "GuiShowFile.h"
49 #include "GuiSpellchecker.h"
50 #include "GuiTabular.h"
51 #include "GuiTabularCreate.h"
52 #include "GuiTexinfo.h"
53 #include "GuiToc.h"
54 #include "GuiView.h"
55 #include "GuiViewSource.h"
56 #include "TocWidget.h"
57 #include "GuiURL.h"
58 #include "GuiVSpace.h"
59 #include "GuiWrap.h"
60
61 #ifdef HAVE_LIBAIKSAURUS
62 #include "ControlThesaurus.h"
63 #include "GuiThesaurus.h"
64 #endif
65
66 // Uncomment this if you prefer dock widget
67 //#define USE_DOCK_WIDGET
68
69 #include "qt_helpers.h"
70
71 #include <boost/assert.hpp>
72
73 using std::string;
74
75 namespace lyx {
76 namespace frontend {
77
78 namespace {
79
80 char const * const dialognames[] = {
81 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
82 "citation", "document", "embedding", "errorlist", "ert", "external", "file",
83 "findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log",
84 "mathdelimiter", "mathmatrix", "note", "paragraph",
85 "prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
86
87 #ifdef HAVE_LIBAIKSAURUS
88 "thesaurus",
89 #endif
90
91 "texinfo", "toc", "url", "view-source", "vspace", "wrap", "listings" };
92
93 char const * const * const end_dialognames =
94         dialognames + (sizeof(dialognames) / sizeof(char *));
95
96 class cmpCStr {
97 public:
98         cmpCStr(char const * name) : name_(name) {}
99         bool operator()(char const * other) {
100                 return strcmp(other, name_) == 0;
101         }
102 private:
103         char const * name_;
104 };
105
106
107 } // namespace anon
108
109
110 bool Dialogs::isValidName(string const & name) const
111 {
112         return std::find_if(dialognames, end_dialognames,
113                             cmpCStr(name.c_str())) != end_dialognames;
114 }
115
116
117 Dialog * Dialogs::build(string const & name)
118 {
119         BOOST_ASSERT(isValidName(name));
120
121         Dialog * dialog = 0;
122         GuiViewBase & guiview = static_cast<GuiViewBase &>(lyxview_);
123
124         if (name == "aboutlyx") {
125                 dialog = new GuiAboutDialog(lyxview_);
126         } else if (name == "bibitem") {
127                 dialog = new GuiBibitemDialog(lyxview_);
128         } else if (name == "bibtex") {
129                 dialog = new GuiBibtexDialog(lyxview_);
130         } else if (name == "box") {
131                 dialog = new GuiBoxDialog(lyxview_);
132         } else if (name == "branch") {
133                 dialog = new GuiBranchDialog(lyxview_);
134         } else if (name == "changes") {
135                 dialog = new GuiChangesDialog(lyxview_);
136         } else if (name == "character") {
137                 dialog = new GuiCharacterDialog(lyxview_);
138         } else if (name == "citation") {
139                 dialog = new GuiCitationDialog(lyxview_);
140         } else if (name == "document") {
141                 dialog = new GuiDocumentDialog(lyxview_);
142         } else if (name == "embedding") {
143                 dialog = new DockView<ControlEmbeddedFiles, GuiEmbeddedFilesDialog>(
144                         guiview, name, Qt::RightDockWidgetArea);
145         } else if (name == "errorlist") {
146                 dialog = new GuiErrorListDialog(lyxview_);
147         } else if (name == "ert") {
148                 dialog = new GuiERTDialog(lyxview_);
149         } else if (name == "external") {
150                 dialog = new GuiExternalDialog(lyxview_);
151         } else if (name == "file") {
152                 dialog = new GuiShowFileDialog(lyxview_);
153         } else if (name == "findreplace") {
154                 dialog = new GuiSearchDialog(lyxview_);
155         } else if (name == "float") {
156                 dialog = new GuiFloatDialog(lyxview_);
157         } else if (name == "graphics") {
158                 dialog = new GuiGraphicsDialog(lyxview_);
159         } else if (name == "include") {
160                 dialog = new GuiIncludeDialog(lyxview_);
161         } else if (name == "index") {
162                 dialog = new GuiIndexDialog(lyxview_);
163         } else if (name == "nomenclature") {
164                 dialog = new GuiNomenclDialog(lyxview_);
165         } else if (name == "label") {
166                 dialog = new GuiLabelDialog(lyxview_);
167         } else if (name == "log") {
168                 dialog = new GuiLogDialog(lyxview_);
169         } else if (name == "view-source") {
170                 dialog = new DockView<ControlViewSource, GuiViewSourceDialog>(
171                         guiview, name, Qt::BottomDockWidgetArea);
172         } else if (name == "mathdelimiter") {
173                 dialog = new GuiDelimiterDialog(lyxview_);
174         } else if (name == "mathmatrix") {
175                 dialog = new GuiMathMatrixDialog(lyxview_);
176         } else if (name == "note") {
177                 dialog = new GuiNoteDialog(lyxview_);
178         } else if (name == "paragraph") {
179 #ifdef USE_DOCK_WIDGET
180                 DockView<ControlParagraph, GuiParagraph> * dv =
181                         new DockView<ControlParagraph, GuiParagraph>(guiview, name,
182                                 Qt::TopDockWidgetArea);
183 #else
184                 DialogView<ControlParagraph, GuiParagraph> * dv =
185                         new DialogView<ControlParagraph, GuiParagraph>(guiview, name);
186 #endif
187                 dialog = dv;
188         } else if (name == "prefs") {
189                 dialog = new GuiPrefsDialog(lyxview_);
190         } else if (name == "print") {
191                 dialog = new GuiPrintDialog(lyxview_);
192         } else if (name == "ref") {
193                 dialog = new GuiRefDialog(lyxview_);
194         } else if (name == "sendto") {
195                 dialog = new GuiSendtoDialog(lyxview_);
196         } else if (name == "spellchecker") {
197                 dialog = new GuiSpellcheckerDialog(lyxview_);
198         } else if (name == "tabular") {
199                 dialog = new GuiTabularDialog(lyxview_);
200         } else if (name == "tabularcreate") {
201                 dialog = new GuiTabularCreateDialog(lyxview_);
202         } else if (name == "texinfo") {
203                 dialog = new GuiTexinfoDialog(lyxview_);
204 #ifdef HAVE_LIBAIKSAURUS
205         } else if (name == "thesaurus") {
206                 dialog = new GuiThesaurusDialog(lyxview_);
207 #endif
208         } else if (name == "toc") {
209 #ifdef Q_WS_MACX
210                 // On Mac show as a drawer at the right
211                 dialog = new DockView<GuiToc, TocWidget>(guiview, name,
212                         Qt::RightDockWidgetArea, Qt::Drawer);
213 #else
214                 dialog = new DockView<GuiToc, TocWidget>(guiview, name);
215 #endif
216         } else if (name == "url") {
217                 dialog = new GuiURLDialog(lyxview_);
218         } else if (name == "vspace") {
219                 dialog = new GuiVSpaceDialog(lyxview_);
220         } else if (name == "wrap") {
221                 dialog = new GuiWrapDialog(lyxview_);
222         } else if (name == "listings") {
223                 dialog = new GuiListingsDialog(lyxview_);
224         }
225
226         return dialog;
227 }
228
229
230 /// Are the tooltips on or off?
231 bool Dialogs::tooltipsEnabled()
232 {
233         return false;
234 }
235
236 } // namespace frontend
237 } // namespace lyx