diff --git a/src/frontends/qt/DialogFactory.cpp b/src/frontends/qt/DialogFactory.cpp new file mode 100644 index 0000000000..e3848417ac --- /dev/null +++ b/src/frontends/qt/DialogFactory.cpp @@ -0,0 +1,227 @@ +/** + * \file DialogFactory.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Yuriy Skalko + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "DialogFactory.h" +#include "FindAndReplace.h" +#include "GuiAbout.h" +#include "GuiBibitem.h" +#include "GuiBibtex.h" +#include "GuiBox.h" +#include "GuiBranch.h" +#include "GuiChanges.h" +#include "GuiCharacter.h" +#include "GuiCitation.h" +#include "GuiCompare.h" +#include "GuiCompareHistory.h" +#include "GuiCounter.h" +#include "GuiDelimiter.h" +#include "GuiDocument.h" +#include "GuiErrorList.h" +#include "GuiERT.h" +#include "GuiExternal.h" +#include "FloatPlacement.h" +#include "GuiGraphics.h" +#include "GuiHSpace.h" +#include "GuiHyperlink.h" +#include "GuiInclude.h" +#include "GuiIndex.h" +#include "GuiInfo.h" +#include "GuiLabel.h" +#include "GuiLine.h" +#include "GuiListings.h" +#include "GuiLog.h" +#include "GuiLyXFiles.h" +#include "GuiMathMatrix.h" +#include "GuiNomenclature.h" +#include "GuiNote.h" +#include "GuiParagraph.h" +#include "GuiPhantom.h" +#include "GuiPrefs.h" +#include "GuiPrintindex.h" +#include "GuiPrintNomencl.h" +#include "GuiProgressView.h" +#include "GuiRef.h" +#include "GuiSearch.h" +#include "GuiSendto.h" +#include "GuiShowFile.h" +#include "GuiSpellchecker.h" +#include "GuiSymbols.h" +#include "GuiTabular.h" +#include "GuiTabularCreate.h" +#include "GuiTexinfo.h" +#include "GuiThesaurus.h" +#include "GuiToc.h" +#include "GuiViewSource.h" +#include "GuiVSpace.h" +#include "GuiWrap.h" + +#include "insets/Inset.h" +#include "InsetParamsDialog.h" +#include "InsetParamsWidget.h" + +using namespace std; + +namespace lyx { +namespace frontend { + + +Dialog * createDialog(GuiView & gv, string const & name) +{ + InsetParamsWidget * widget; + switch (insetCode(name)) { + case ERT_CODE: + widget = new GuiERT; + break; + case FLOAT_CODE: + widget = new FloatPlacement(true); + break; + case BIBITEM_CODE: + widget = new GuiBibitem; + break; + case BRANCH_CODE: + widget = new GuiBranch; + break; + case BOX_CODE: + widget = new GuiBox; + break; + case HYPERLINK_CODE: + widget = new GuiHyperlink; + break; + case COUNTER_CODE: + widget = new GuiCounter(gv, nullptr); + break; + case INFO_CODE: + widget = new GuiInfo; + break; + case LABEL_CODE: + widget = new GuiLabel; + break; + case LINE_CODE: + widget = new GuiLine; + break; + case MATH_SPACE_CODE: + widget = new GuiHSpace(true); + break; + case NOMENCL_CODE: + widget = new GuiNomenclature; + break; + case NOMENCL_PRINT_CODE: + widget = new GuiPrintNomencl; + break; + case SPACE_CODE: + widget = new GuiHSpace(false); + break; + case TABULAR_CODE: + widget = new GuiTabular; + break; + case VSPACE_CODE: + widget = new GuiVSpace; + break; + default: + widget = nullptr; + } + if (widget) + return new InsetParamsDialog(gv, widget); + + if (name == "aboutlyx") + return new GuiAbout(gv); + if (name == "bibtex") + return new GuiBibtex(gv); + if (name == "changes") + return new GuiChanges(gv); + if (name == "character") + return new GuiCharacter(gv); + if (name == "citation") + return new GuiCitation(gv); + if (name == "compare") + return new GuiCompare(gv); + if (name == "comparehistory") + return new GuiCompareHistory(gv); + if (name == "document") + return new GuiDocument(gv); + if (name == "errorlist") + return new GuiErrorList(gv); + if (name == "external") + return new GuiExternal(gv); + if (name == "file") + return new GuiShowFile(gv); + if (name == "findreplace") + return new GuiSearch(gv); + if (name == "findreplaceadv") { + FindAndReplace * gui = new FindAndReplace(gv, Qt::RightDockWidgetArea); +#ifdef Q_OS_MAC + // On Mac show and floating + gui->setFloating(true); +#endif + return gui; + } + if (name == "graphics") + return new GuiGraphics(gv); + if (name == "include") + return new GuiInclude(gv); + if (name == "index") + return new GuiIndex(gv); + if (name == "index_print") + return new GuiPrintindex(gv); + if (name == "listings") + return new GuiListings(gv); + if (name == "log") + return new GuiLog(gv); + if (name == "lyxfiles") + return new GuiLyXFiles(gv); + if (name == "mathdelimiter") + return new GuiDelimiter(gv); + if (name == "mathmatrix") + return new GuiMathMatrix(gv); + if (name == "note") + return new GuiNote(gv); + if (name == "paragraph") + return new GuiParagraph(gv); + if (name == "phantom") + return new GuiPhantom(gv); + if (name == "prefs") + return new GuiPreferences(gv); + if (name == "ref") + return new GuiRef(gv); + if (name == "sendto") + return new GuiSendTo(gv); + if (name == "spellchecker") { + GuiSpellchecker * gui = new GuiSpellchecker(gv, Qt::RightDockWidgetArea); +#ifdef Q_OS_MAC + // On Mac show and floating + gui->setFloating(true); +#endif + return gui; + } + if (name == "symbols") + return new GuiSymbols(gv); + if (name == "tabularcreate") + return new GuiTabularCreate(gv); + if (name == "texinfo") + return new GuiTexInfo(gv); + if (name == "thesaurus") + return new GuiThesaurus(gv); + if (name == "toc") + return new GuiToc(gv); + if (name == "view-source") + return new GuiViewSource(gv); + if (name == "wrap") + return new GuiWrap(gv); + if (name == "progress") + return new GuiProgressView(gv, Qt::BottomDockWidgetArea); + + return nullptr; +} + + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/qt/DialogFactory.h b/src/frontends/qt/DialogFactory.h new file mode 100644 index 0000000000..1342dc3c50 --- /dev/null +++ b/src/frontends/qt/DialogFactory.h @@ -0,0 +1,30 @@ +// -*- C++ -*- +/** + * \file DialogFactory.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Yuriy Skalko + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef DIALOG_FACTORY_H +#define DIALOG_FACTORY_H + +#include + +namespace lyx { +namespace frontend { + +class Dialog; +class GuiView; + + +Dialog * createDialog(GuiView & gv, std::string const & name); + + +} // namespace frontend +} // namespace lyx + +#endif // DIALOG_FACTORY_H diff --git a/src/frontends/qt/FindAndReplace.cpp b/src/frontends/qt/FindAndReplace.cpp index bd3edcf3c9..942bbf1442 100644 --- a/src/frontends/qt/FindAndReplace.cpp +++ b/src/frontends/qt/FindAndReplace.cpp @@ -633,17 +633,6 @@ void FindAndReplaceWidget::updateGUI() } -Dialog * createGuiSearchAdv(GuiView & lv) -{ - FindAndReplace * gui = new FindAndReplace(lv, Qt::RightDockWidgetArea); -#ifdef Q_OS_MAC - // On Mac show and floating - gui->setFloating(true); -#endif - return gui; -} - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiAbout.cpp b/src/frontends/qt/GuiAbout.cpp index a76b087d87..35dd3bff30 100644 --- a/src/frontends/qt/GuiAbout.cpp +++ b/src/frontends/qt/GuiAbout.cpp @@ -355,9 +355,6 @@ void GuiAbout::on_buttonBox_rejected() } -Dialog * createGuiAbout(GuiView & lv) { return new GuiAbout(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiBibtex.cpp b/src/frontends/qt/GuiBibtex.cpp index 8c561ccf85..66cff69bda 100644 --- a/src/frontends/qt/GuiBibtex.cpp +++ b/src/frontends/qt/GuiBibtex.cpp @@ -642,9 +642,6 @@ void GuiBibtex::dispatchParams() } -Dialog * createGuiBibtex(GuiView & lv) { return new GuiBibtex(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiChanges.cpp b/src/frontends/qt/GuiChanges.cpp index 812888f635..7be8e7ef0e 100644 --- a/src/frontends/qt/GuiChanges.cpp +++ b/src/frontends/qt/GuiChanges.cpp @@ -123,9 +123,6 @@ void GuiChanges::rejectChange() } -Dialog * createGuiChanges(GuiView & lv) { return new GuiChanges(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiCharacter.cpp b/src/frontends/qt/GuiCharacter.cpp index b6b672c69a..dadae88c33 100644 --- a/src/frontends/qt/GuiCharacter.cpp +++ b/src/frontends/qt/GuiCharacter.cpp @@ -696,9 +696,6 @@ void GuiCharacter::restoreSession() } -Dialog * createGuiCharacter(GuiView & lv) { return new GuiCharacter(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiCitation.cpp b/src/frontends/qt/GuiCitation.cpp index 4f34a0fa1a..20b4c34dc0 100644 --- a/src/frontends/qt/GuiCitation.cpp +++ b/src/frontends/qt/GuiCitation.cpp @@ -1101,9 +1101,6 @@ void GuiCitation::restoreSession() } -Dialog * createGuiCitation(GuiView & lv) { return new GuiCitation(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiCompare.cpp b/src/frontends/qt/GuiCompare.cpp index 2edc8c8cac..e48be86f22 100644 --- a/src/frontends/qt/GuiCompare.cpp +++ b/src/frontends/qt/GuiCompare.cpp @@ -378,8 +378,6 @@ bool GuiCompare::initialiseParams(std::string const &par) return true; } -Dialog * createGuiCompare(GuiView & lv) { return new GuiCompare(lv); } - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiCompareHistory.cpp b/src/frontends/qt/GuiCompareHistory.cpp index 4586eabad9..fbc17b741a 100644 --- a/src/frontends/qt/GuiCompareHistory.cpp +++ b/src/frontends/qt/GuiCompareHistory.cpp @@ -154,9 +154,6 @@ void GuiCompareHistory::slotButtonBox(QAbstractButton * button) } -Dialog * createGuiCompareHistory(GuiView & lv) { return new GuiCompareHistory(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiDelimiter.cpp b/src/frontends/qt/GuiDelimiter.cpp index 4e2eff7d0d..476cd20ed7 100644 --- a/src/frontends/qt/GuiDelimiter.cpp +++ b/src/frontends/qt/GuiDelimiter.cpp @@ -468,9 +468,6 @@ void GuiDelimiter::on_swapPB_clicked() } -Dialog * createGuiDelimiter(GuiView & lv) { return new GuiDelimiter(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp index 3025a2691f..c21c3a00a0 100644 --- a/src/frontends/qt/GuiDocument.cpp +++ b/src/frontends/qt/GuiDocument.cpp @@ -5207,10 +5207,6 @@ void GuiDocument::setOutputSync(bool on) } - -Dialog * createGuiDocument(GuiView & lv) { return new GuiDocument(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiErrorList.cpp b/src/frontends/qt/GuiErrorList.cpp index c60dbf11bf..e7dc3766f5 100644 --- a/src/frontends/qt/GuiErrorList.cpp +++ b/src/frontends/qt/GuiErrorList.cpp @@ -178,8 +178,6 @@ bool GuiErrorList::goTo(int item) } -Dialog * createGuiErrorList(GuiView & lv) { return new GuiErrorList(lv); } - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiExternal.cpp b/src/frontends/qt/GuiExternal.cpp index 3a4ab2c91e..55688c54e4 100644 --- a/src/frontends/qt/GuiExternal.cpp +++ b/src/frontends/qt/GuiExternal.cpp @@ -680,9 +680,6 @@ QString GuiExternal::browse(QString const & input, } -Dialog * createGuiExternal(GuiView & lv) { return new GuiExternal(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiGraphics.cpp b/src/frontends/qt/GuiGraphics.cpp index b20fed7d01..b8a5af95f6 100644 --- a/src/frontends/qt/GuiGraphics.cpp +++ b/src/frontends/qt/GuiGraphics.cpp @@ -827,9 +827,6 @@ bool GuiGraphics::isFileNameValid(string const & fname) const } -Dialog * createGuiGraphics(GuiView & lv) { return new GuiGraphics(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiInclude.cpp b/src/frontends/qt/GuiInclude.cpp index 770c2ac214..ad95b9f95d 100644 --- a/src/frontends/qt/GuiInclude.cpp +++ b/src/frontends/qt/GuiInclude.cpp @@ -393,9 +393,6 @@ void GuiInclude::dispatchParams() } -Dialog * createGuiInclude(GuiView & lv) { return new GuiInclude(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiIndex.cpp b/src/frontends/qt/GuiIndex.cpp index a59ac3953f..6264d6a101 100644 --- a/src/frontends/qt/GuiIndex.cpp +++ b/src/frontends/qt/GuiIndex.cpp @@ -96,9 +96,6 @@ void GuiIndex::dispatchParams() } -Dialog * createGuiIndex(GuiView & lv) { return new GuiIndex(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiListings.cpp b/src/frontends/qt/GuiListings.cpp index c957cb0b75..0b3cb24b3b 100644 --- a/src/frontends/qt/GuiListings.cpp +++ b/src/frontends/qt/GuiListings.cpp @@ -702,9 +702,6 @@ void GuiListings::setParams(InsetListingsParams const & params) } -Dialog * createGuiListings(GuiView & lv) { return new GuiListings(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiLog.cpp b/src/frontends/qt/GuiLog.cpp index 16979138d8..aab671a91e 100644 --- a/src/frontends/qt/GuiLog.cpp +++ b/src/frontends/qt/GuiLog.cpp @@ -324,9 +324,6 @@ void GuiLog::getContents(ostream & ss) const } -Dialog * createGuiLog(GuiView & lv) { return new GuiLog(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiLyXFiles.cpp b/src/frontends/qt/GuiLyXFiles.cpp index 9e1caf9295..f14369a5a9 100644 --- a/src/frontends/qt/GuiLyXFiles.cpp +++ b/src/frontends/qt/GuiLyXFiles.cpp @@ -620,8 +620,6 @@ FuncCode GuiLyXFiles::getLfun() const return LFUN_NOACTION; } -Dialog * createGuiLyXFiles(GuiView & lv) { return new GuiLyXFiles(lv); } - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiMathMatrix.cpp b/src/frontends/qt/GuiMathMatrix.cpp index 92ba6fc09c..d339e2c976 100644 --- a/src/frontends/qt/GuiMathMatrix.cpp +++ b/src/frontends/qt/GuiMathMatrix.cpp @@ -181,9 +181,6 @@ void GuiMathMatrix::slotClose() } -Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiNote.cpp b/src/frontends/qt/GuiNote.cpp index a70a809dfa..59c771d55c 100644 --- a/src/frontends/qt/GuiNote.cpp +++ b/src/frontends/qt/GuiNote.cpp @@ -90,9 +90,6 @@ void GuiNote::dispatchParams() } -Dialog * createGuiNote(GuiView & lv) { return new GuiNote(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiParagraph.cpp b/src/frontends/qt/GuiParagraph.cpp index 3f1e64f219..9990dda623 100644 --- a/src/frontends/qt/GuiParagraph.cpp +++ b/src/frontends/qt/GuiParagraph.cpp @@ -396,12 +396,6 @@ void GuiParagraph::restoreSession() } -Dialog * createGuiParagraph(GuiView & lv) -{ - return new GuiParagraph(lv); -} - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiPhantom.cpp b/src/frontends/qt/GuiPhantom.cpp index 1aff3afd3c..62fc99036c 100644 --- a/src/frontends/qt/GuiPhantom.cpp +++ b/src/frontends/qt/GuiPhantom.cpp @@ -89,9 +89,6 @@ void GuiPhantom::dispatchParams() } -Dialog * createGuiPhantom(GuiView & lv) { return new GuiPhantom(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp index f0ccb52308..beb424f387 100644 --- a/src/frontends/qt/GuiPrefs.cpp +++ b/src/frontends/qt/GuiPrefs.cpp @@ -3686,9 +3686,6 @@ QString GuiPreferences::browse(QString const & file, } -Dialog * createGuiPreferences(GuiView & lv) { return new GuiPreferences(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiPrintindex.cpp b/src/frontends/qt/GuiPrintindex.cpp index 1244c62e49..b618287ae1 100644 --- a/src/frontends/qt/GuiPrintindex.cpp +++ b/src/frontends/qt/GuiPrintindex.cpp @@ -131,9 +131,6 @@ void GuiPrintindex::dispatchParams() } -Dialog * createGuiPrintindex(GuiView & lv) { return new GuiPrintindex(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiProgressView.cpp b/src/frontends/qt/GuiProgressView.cpp index 486fdaf54e..6c5f939f4b 100644 --- a/src/frontends/qt/GuiProgressView.cpp +++ b/src/frontends/qt/GuiProgressView.cpp @@ -265,13 +265,6 @@ void GuiProgressView::hideEvent(QHideEvent*) } -Dialog * createGuiProgressView(GuiView & guiview) -{ - return new GuiProgressView(guiview, Qt::BottomDockWidgetArea); -} - - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp index 5884ac4009..f16c6565a6 100644 --- a/src/frontends/qt/GuiRef.cpp +++ b/src/frontends/qt/GuiRef.cpp @@ -618,10 +618,6 @@ void GuiRef::dispatchParams() } - -Dialog * createGuiRef(GuiView & lv) { return new GuiRef(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp index e582126123..c70e328562 100644 --- a/src/frontends/qt/GuiSearch.cpp +++ b/src/frontends/qt/GuiSearch.cpp @@ -146,9 +146,6 @@ void GuiSearch::replace(docstring const & search, docstring const & replace, } -Dialog * createGuiSearch(GuiView & lv) { return new GuiSearch(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiSendto.cpp b/src/frontends/qt/GuiSendto.cpp index b14db45304..ec40ff3dcb 100644 --- a/src/frontends/qt/GuiSendto.cpp +++ b/src/frontends/qt/GuiSendto.cpp @@ -152,8 +152,6 @@ void GuiSendTo::dispatchParams() dispatch(FuncRequest(lfun, sdata)); } -Dialog * createGuiSendTo(GuiView & lv) { return new GuiSendTo(lv); } - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiShowFile.cpp b/src/frontends/qt/GuiShowFile.cpp index 4126045410..526eacee43 100644 --- a/src/frontends/qt/GuiShowFile.cpp +++ b/src/frontends/qt/GuiShowFile.cpp @@ -64,9 +64,6 @@ void GuiShowFile::clearParams() } -Dialog * createGuiShowFile(GuiView & lv) { return new GuiShowFile(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiSpellchecker.cpp b/src/frontends/qt/GuiSpellchecker.cpp index ec3bbf2568..7fc1155b1f 100644 --- a/src/frontends/qt/GuiSpellchecker.cpp +++ b/src/frontends/qt/GuiSpellchecker.cpp @@ -614,16 +614,6 @@ void GuiSpellchecker::updateView() } -Dialog * createGuiSpellchecker(GuiView & lv) -{ - GuiSpellchecker * gui = new GuiSpellchecker(lv, Qt::RightDockWidgetArea); -#ifdef Q_OS_MAC - gui->setFloating(true); -#endif - return gui; -} - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiSymbols.cpp b/src/frontends/qt/GuiSymbols.cpp index 99d1fc0215..0e5d4ced4f 100644 --- a/src/frontends/qt/GuiSymbols.cpp +++ b/src/frontends/qt/GuiSymbols.cpp @@ -504,12 +504,6 @@ void GuiSymbols::dispatchParams() } -Dialog * createGuiSymbols(GuiView & lv) -{ - return new GuiSymbols(lv); -} - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiTabularCreate.cpp b/src/frontends/qt/GuiTabularCreate.cpp index e0e93afad9..d9eba4871b 100644 --- a/src/frontends/qt/GuiTabularCreate.cpp +++ b/src/frontends/qt/GuiTabularCreate.cpp @@ -171,12 +171,6 @@ FuncCode GuiTabularCreate::getLfun() const } -Dialog * createGuiTabularCreate(GuiView & lv) -{ - return new GuiTabularCreate(lv); -} - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiTexinfo.cpp b/src/frontends/qt/GuiTexinfo.cpp index d8f079f999..d2cb065d28 100644 --- a/src/frontends/qt/GuiTexinfo.cpp +++ b/src/frontends/qt/GuiTexinfo.cpp @@ -186,9 +186,6 @@ string GuiTexInfo::classOptions(string const & classname) const */ -Dialog * createGuiTexInfo(GuiView & lv) { return new GuiTexInfo(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiThesaurus.cpp b/src/frontends/qt/GuiThesaurus.cpp index eef37ebfa5..d748d295a6 100644 --- a/src/frontends/qt/GuiThesaurus.cpp +++ b/src/frontends/qt/GuiThesaurus.cpp @@ -279,9 +279,6 @@ Thesaurus::Meanings const & GuiThesaurus::getMeanings(WordLangTuple const & wl) } -Dialog * createGuiThesaurus(GuiView & lv) { return new GuiThesaurus(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiToc.cpp b/src/frontends/qt/GuiToc.cpp index e9ee840fd8..c10ba605ac 100644 --- a/src/frontends/qt/GuiToc.cpp +++ b/src/frontends/qt/GuiToc.cpp @@ -89,12 +89,6 @@ bool GuiToc::getStatus(Cursor & cur, FuncRequest const & cmd, } -Dialog * createGuiToc(GuiView & lv) -{ - return new GuiToc(lv); -} - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index 31c8f88dc7..c4a406c30e 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -15,6 +15,7 @@ #include "GuiView.h" +#include "DialogFactory.h" #include "DispatchResult.h" #include "FileDialog.h" #include "FontLoader.h" @@ -4924,134 +4925,10 @@ void GuiView::updateDialogs() updateLayoutList(); } -Dialog * createDialog(GuiView & lv, string const & name); - -// will be replaced by a proper factory... -Dialog * createGuiAbout(GuiView & lv); -Dialog * createGuiBibtex(GuiView & lv); -Dialog * createGuiChanges(GuiView & lv); -Dialog * createGuiCharacter(GuiView & lv); -Dialog * createGuiCitation(GuiView & lv); -Dialog * createGuiCompare(GuiView & lv); -Dialog * createGuiCompareHistory(GuiView & lv); -Dialog * createGuiDelimiter(GuiView & lv); -Dialog * createGuiDocument(GuiView & lv); -Dialog * createGuiErrorList(GuiView & lv); -Dialog * createGuiExternal(GuiView & lv); -Dialog * createGuiGraphics(GuiView & lv); -Dialog * createGuiInclude(GuiView & lv); -Dialog * createGuiIndex(GuiView & lv); -Dialog * createGuiListings(GuiView & lv); -Dialog * createGuiLog(GuiView & lv); -Dialog * createGuiLyXFiles(GuiView & lv); -Dialog * createGuiMathMatrix(GuiView & lv); -Dialog * createGuiNote(GuiView & lv); -Dialog * createGuiParagraph(GuiView & lv); -Dialog * createGuiPhantom(GuiView & lv); -Dialog * createGuiPreferences(GuiView & lv); -Dialog * createGuiPrint(GuiView & lv); -Dialog * createGuiPrintindex(GuiView & lv); -Dialog * createGuiRef(GuiView & lv); -Dialog * createGuiSearch(GuiView & lv); -Dialog * createGuiSearchAdv(GuiView & lv); -Dialog * createGuiSendTo(GuiView & lv); -Dialog * createGuiShowFile(GuiView & lv); -Dialog * createGuiSpellchecker(GuiView & lv); -Dialog * createGuiSymbols(GuiView & lv); -Dialog * createGuiTabularCreate(GuiView & lv); -Dialog * createGuiTexInfo(GuiView & lv); -Dialog * createGuiToc(GuiView & lv); -Dialog * createGuiThesaurus(GuiView & lv); -Dialog * createGuiViewSource(GuiView & lv); -Dialog * createGuiWrap(GuiView & lv); -Dialog * createGuiProgressView(GuiView & lv); - - Dialog * GuiView::build(string const & name) { - LASSERT(isValidName(name), return nullptr); - - Dialog * dialog = createDialog(*this, name); - if (dialog) - return dialog; - - if (name == "aboutlyx") - return createGuiAbout(*this); - if (name == "bibtex") - return createGuiBibtex(*this); - if (name == "changes") - return createGuiChanges(*this); - if (name == "character") - return createGuiCharacter(*this); - if (name == "citation") - return createGuiCitation(*this); - if (name == "compare") - return createGuiCompare(*this); - if (name == "comparehistory") - return createGuiCompareHistory(*this); - if (name == "document") - return createGuiDocument(*this); - if (name == "errorlist") - return createGuiErrorList(*this); - if (name == "external") - return createGuiExternal(*this); - if (name == "file") - return createGuiShowFile(*this); - if (name == "findreplace") - return createGuiSearch(*this); - if (name == "findreplaceadv") - return createGuiSearchAdv(*this); - if (name == "graphics") - return createGuiGraphics(*this); - if (name == "include") - return createGuiInclude(*this); - if (name == "index") - return createGuiIndex(*this); - if (name == "index_print") - return createGuiPrintindex(*this); - if (name == "listings") - return createGuiListings(*this); - if (name == "log") - return createGuiLog(*this); - if (name == "lyxfiles") - return createGuiLyXFiles(*this); - if (name == "mathdelimiter") - return createGuiDelimiter(*this); - if (name == "mathmatrix") - return createGuiMathMatrix(*this); - if (name == "note") - return createGuiNote(*this); - if (name == "paragraph") - return createGuiParagraph(*this); - if (name == "phantom") - return createGuiPhantom(*this); - if (name == "prefs") - return createGuiPreferences(*this); - if (name == "ref") - return createGuiRef(*this); - if (name == "sendto") - return createGuiSendTo(*this); - if (name == "spellchecker") - return createGuiSpellchecker(*this); - if (name == "symbols") - return createGuiSymbols(*this); - if (name == "tabularcreate") - return createGuiTabularCreate(*this); - if (name == "texinfo") - return createGuiTexInfo(*this); - if (name == "thesaurus") - return createGuiThesaurus(*this); - if (name == "toc") - return createGuiToc(*this); - if (name == "view-source") - return createGuiViewSource(*this); - if (name == "wrap") - return createGuiWrap(*this); - if (name == "progress") - return createGuiProgressView(*this); - - return nullptr; + return createDialog(*this, name); } diff --git a/src/frontends/qt/GuiViewSource.cpp b/src/frontends/qt/GuiViewSource.cpp index 1a7a36cdd1..d26a55cccb 100644 --- a/src/frontends/qt/GuiViewSource.cpp +++ b/src/frontends/qt/GuiViewSource.cpp @@ -474,12 +474,6 @@ void GuiViewSource::restoreSession() } -Dialog * createGuiViewSource(GuiView & lv) -{ - return new GuiViewSource(lv); -} - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/GuiWrap.cpp b/src/frontends/qt/GuiWrap.cpp index e22be0898c..0f66cf0758 100644 --- a/src/frontends/qt/GuiWrap.cpp +++ b/src/frontends/qt/GuiWrap.cpp @@ -206,9 +206,6 @@ void GuiWrap::dispatchParams() } -Dialog * createGuiWrap(GuiView & lv) { return new GuiWrap(lv); } - - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/InsetParamsDialog.cpp b/src/frontends/qt/InsetParamsDialog.cpp index 3bccd2235e..ebac60b721 100644 --- a/src/frontends/qt/InsetParamsDialog.cpp +++ b/src/frontends/qt/InsetParamsDialog.cpp @@ -259,72 +259,6 @@ void InsetParamsDialog::updateView() buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); } - -Dialog * createDialog(GuiView & lv, InsetCode code) -{ - InsetParamsWidget * widget; - switch (code) { - case ERT_CODE: - widget = new GuiERT; - break; - case FLOAT_CODE: - widget = new FloatPlacement(true); - break; - case BIBITEM_CODE: - widget = new GuiBibitem; - break; - case BRANCH_CODE: - widget = new GuiBranch; - break; - case BOX_CODE: - widget = new GuiBox; - break; - case HYPERLINK_CODE: - widget = new GuiHyperlink; - break; - case COUNTER_CODE: - widget = new GuiCounter(lv, nullptr); - break; - case INFO_CODE: - widget = new GuiInfo; - break; - case LABEL_CODE: - widget = new GuiLabel; - break; - case LINE_CODE: - widget = new GuiLine; - break; - case MATH_SPACE_CODE: - widget = new GuiHSpace(true); - break; - case NOMENCL_CODE: - widget = new GuiNomenclature; - break; - case NOMENCL_PRINT_CODE: - widget = new GuiPrintNomencl; - break; - case SPACE_CODE: - widget = new GuiHSpace(false); - break; - case TABULAR_CODE: - widget = new GuiTabular; - break; - case VSPACE_CODE: - widget = new GuiVSpace; - break; - default: - return nullptr; - } - InsetParamsDialog * dialog = new InsetParamsDialog(lv, widget); - return dialog; -} - - -Dialog * createDialog(GuiView & lv, string const & name) -{ - return createDialog(lv, insetCode(name)); -} - } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt/Makefile.am b/src/frontends/qt/Makefile.am index e01f8ddba8..2a497af887 100644 --- a/src/frontends/qt/Makefile.am +++ b/src/frontends/qt/Makefile.am @@ -43,7 +43,7 @@ SOURCEFILES = \ ButtonPolicy.cpp \ ButtonPolicy.h \ Dialog.cpp \ - Dialog.h \ + DialogFactory.cpp \ Action.cpp \ BulletsModule.cpp \ ButtonController.cpp \ @@ -171,6 +171,8 @@ MOCHEADER = \ BulletsModule.h \ CategorizedCombo.h \ CustomizedWidgets.h \ + Dialog.h \ + DialogFactory.h \ DialogView.h \ DockView.h \ EmptyTable.h \