]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt/GuiView.cpp
Use real minus char
[features.git] / src / frontends / qt / GuiView.cpp
index 4298fd1d8147d1ac9c8806d43be76973b82b7475..3fafd20e87980eb2242ffc8f5e2023f2b3e7feea 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "GuiView.h"
 
+#include "DialogFactory.h"
 #include "DispatchResult.h"
 #include "FileDialog.h"
 #include "FontLoader.h"
 #include <QPoint>
 #include <QSettings>
 #include <QShowEvent>
+#include <QSlider>
 #include <QSplitter>
 #include <QStackedWidget>
 #include <QStatusBar>
@@ -490,7 +492,7 @@ public:
                                   Buffer::ExportStatus (*asyncFunc)(Buffer const *, Buffer *, string const &),
                                   Buffer::ExportStatus (Buffer::*syncFunc)(string const &, bool) const,
                                   Buffer::ExportStatus (Buffer::*previewFunc)(string const &) const,
-                                  bool allow_async);
+                                  bool allow_async, bool use_tmpdir = false);
 
        QVector<GuiWorkArea*> guiWorkAreas();
 
@@ -601,6 +603,11 @@ GuiView::GuiView(int id)
        // (such as "source" and "messages")
        setDockOptions(QMainWindow::ForceTabbedDocks);
 
+#ifdef Q_OS_MAC
+       // use document mode tabs on docks
+       setDocumentMode(true);
+#endif
+
        // For Drag&Drop.
        setAcceptDrops(true);
 
@@ -621,6 +628,62 @@ GuiView::GuiView(int id)
        connect(busylabel, SIGNAL(clicked()), this, SLOT(checkCancelBackground()));
 
        QFontMetrics const fm(statusBar()->fontMetrics());
+
+       zoom_slider_ = new QSlider(Qt::Horizontal, statusBar());
+       // Small size slider for macOS to prevent the status bar from enlarging
+       zoom_slider_->setAttribute(Qt::WA_MacSmallSize);
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
+       zoom_slider_->setFixedWidth(fm.horizontalAdvance('x') * 15);
+#else
+       zoom_slider_->setFixedWidth(fm.width('x') * 15);
+#endif
+       // Make the defaultZoom center
+       zoom_slider_->setRange(10, (lyxrc.defaultZoom * 2) - 10);
+       // Initialize proper zoom value
+       QSettings settings;
+       zoom_ratio_ = settings.value("zoom_ratio", 1.0).toDouble();
+       // Actual zoom value: default zoom + fractional offset
+       int zoom = (int)(lyxrc.defaultZoom * zoom_ratio_);
+       if (zoom < static_cast<int>(zoom_min_))
+               zoom = zoom_min_;
+       zoom_slider_->setValue(zoom);
+       zoom_slider_->setToolTip(qt_("Workarea zoom level. Drag, use Ctrl-+/- or Shift-Mousewheel to adjust."));
+       zoom_slider_->setTickPosition(QSlider::TicksBelow);
+       zoom_slider_->setTickInterval(lyxrc.defaultZoom - 10);
+
+       // Buttons to change zoom stepwise
+       zoom_in_ = new QPushButton(statusBar());
+       zoom_in_->setText("+");
+       zoom_in_->setFlat(true);
+       zoom_in_->setFixedSize(QSize(fm.height(), fm.height()));
+       zoom_out_ = new QPushButton(statusBar());
+       zoom_out_->setText(QString(0x2212));
+       zoom_out_->setFixedSize(QSize(fm.height(), fm.height()));
+       zoom_out_->setFlat(true);
+
+       statusBar()->addPermanentWidget(zoom_out_);
+       zoom_out_->setEnabled(currentBufferView());
+       statusBar()->addPermanentWidget(zoom_slider_);
+       zoom_slider_->setEnabled(currentBufferView());
+       zoom_out_->setEnabled(currentBufferView());
+       statusBar()->addPermanentWidget(zoom_in_);
+
+       connect(zoom_slider_, SIGNAL(sliderMoved(int)), this, SLOT(zoomSliderMoved(int)));
+       connect(zoom_slider_, SIGNAL(valueChanged(int)), this, SLOT(zoomValueChanged(int)));
+       connect(this, SIGNAL(currentZoomChanged(int)), zoom_slider_, SLOT(setValue(int)));
+       connect(zoom_in_, SIGNAL(clicked()), this, SLOT(zoomInPressed()));
+       connect(zoom_out_, SIGNAL(clicked()), this, SLOT(zoomOutPressed()));
+
+       zoom_value_ = new QLabel(statusBar());
+       zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), zoom)));
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
+       zoom_value_->setMinimumWidth(fm.horizontalAdvance("000%"));
+#else
+       zoom_value_->setMinimumWidth(fm.width("000%"));
+#endif
+       statusBar()->addPermanentWidget(zoom_value_);
+       zoom_value_->setEnabled(currentBufferView());
+
        int const iconheight = max(int(d.normalIconSize), fm.height());
        QSize const iconsize(iconheight, iconheight);
 
@@ -687,7 +750,6 @@ GuiView::GuiView(int id)
        initToolbars();
 
        // clear session data if any.
-       QSettings settings;
        settings.remove("views");
 }
 
@@ -721,6 +783,38 @@ void GuiView::checkCancelBackground()
 }
 
 
+void GuiView::zoomSliderMoved(int value)
+{
+       DispatchResult dr;
+       dispatch(FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(value)), dr);
+       currentWorkArea()->scheduleRedraw(true);
+       zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), value)));
+}
+
+
+void GuiView::zoomValueChanged(int value)
+{
+       if (value != lyxrc.currentZoom)
+               zoomSliderMoved(value);
+}
+
+
+void GuiView::zoomInPressed()
+{
+       DispatchResult dr;
+       dispatch(FuncRequest(LFUN_BUFFER_ZOOM_IN), dr);
+       currentWorkArea()->scheduleRedraw(true);
+}
+
+
+void GuiView::zoomOutPressed()
+{
+       DispatchResult dr;
+       dispatch(FuncRequest(LFUN_BUFFER_ZOOM_OUT), dr);
+       currentWorkArea()->scheduleRedraw(true);
+}
+
+
 QVector<GuiWorkArea*> GuiView::GuiViewPrivate::guiWorkAreas()
 {
        QVector<GuiWorkArea*> areas;
@@ -839,6 +933,14 @@ void GuiView::saveUISettings() const
 }
 
 
+void GuiView::setCurrentZoom(const int v)
+{
+       lyxrc.currentZoom = v;
+       zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), v)));
+       Q_EMIT currentZoomChanged(v);
+}
+
+
 bool GuiView::restoreLayout()
 {
        QSettings settings;
@@ -847,7 +949,7 @@ bool GuiView::restoreLayout()
        int zoom = (int)(lyxrc.defaultZoom * zoom_ratio_);
        if (zoom < static_cast<int>(zoom_min_))
                zoom = zoom_min_;
-       lyxrc.currentZoom = zoom;
+       setCurrentZoom(zoom);
        devel_mode_ = settings.value("devel_mode", devel_mode_).toBool();
        settings.beginGroup("views");
        settings.beginGroup(QString::number(id_));
@@ -1298,6 +1400,10 @@ void GuiView::onBufferViewChanged()
        // Buffer-dependent dialogs must be updated. This is done here because
        // some dialogs require buffer()->text.
        updateDialogs();
+       zoom_slider_->setEnabled(currentBufferView());
+       zoom_value_->setEnabled(currentBufferView());
+       zoom_in_->setEnabled(currentBufferView());
+       zoom_out_->setEnabled(currentBufferView());
 }
 
 
@@ -1399,6 +1505,10 @@ bool GuiView::event(QEvent * e)
                        }
                        for (int i = 0; i != d.splitter_->count(); ++i)
                                d.tabWorkArea(i)->setFullScreen(true);
+#if QT_VERSION > 0x050903
+                       //Qt's 5.9.4 ba44cdae38406c safe area measures won't allow us to go negative in margins
+                       setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false);
+#endif
                        setContentsMargins(-2, -2, -2, -2);
                        // bug 5274
                        hideDialogs("prefs", nullptr);
@@ -1417,6 +1527,9 @@ bool GuiView::event(QEvent * e)
                        }
                        for (int i = 0; i != d.splitter_->count(); ++i)
                                d.tabWorkArea(i)->setFullScreen(false);
+#if QT_VERSION > 0x050903
+                       setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, true);
+#endif
                        setContentsMargins(0, 0, 0, 0);
                }
                return result;
@@ -1457,6 +1570,12 @@ bool GuiView::event(QEvent * e)
                return QMainWindow::event(e);
        }
 
+       case QEvent::ApplicationPaletteChange: {
+               // runtime switch from/to dark mode
+               refillToolbars();
+               return QMainWindow::event(e);
+       }
+
        default:
                return QMainWindow::event(e);
        }
@@ -1726,6 +1845,13 @@ void GuiView::updateToolbars()
 }
 
 
+void GuiView::refillToolbars()
+{
+       for (auto const & tb_p : d.toolbars_)
+               tb_p.second->refill();
+}
+
+
 void GuiView::setBuffer(Buffer * newBuffer, bool switch_to)
 {
        LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << endl);
@@ -2109,6 +2235,41 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                flag.setOnOff(devel_mode_);
                break;
 
+       case LFUN_TOOLBAR_SET: {
+               string const name = cmd.getArg(0);
+               string const state = cmd.getArg(1);
+               if (name.empty() || state.empty()) {
+                       enable = false;
+                       docstring const msg =
+                               _("Function toolbar-set requires two arguments!");
+                       flag.message(msg);
+                       break;
+               }
+               if (state != "on" && state != "off" && state != "auto") {
+                       enable = false;
+                       docstring const msg =
+                               bformat(_("Invalid argument \"%1$s\" to function toolbar-set!"),
+                                       from_utf8(state));
+                       flag.message(msg);
+                       break;
+               }
+               if (GuiToolbar * t = toolbar(name)) {
+                       bool const autovis = t->visibility() & Toolbars::AUTO;
+                       if (state == "on")
+                               flag.setOnOff(t->isVisible() && !autovis);
+                       else if (state == "off")
+                               flag.setOnOff(!t->isVisible() && !autovis);
+                       else if (state == "auto")
+                               flag.setOnOff(autovis);
+               } else {
+                       enable = false;
+                       docstring const msg =
+                               bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name));
+                       flag.message(msg);
+               }
+               break;
+       }
+
        case LFUN_TOOLBAR_TOGGLE: {
                string const name = cmd.getArg(0);
                if (GuiToolbar * t = toolbar(name))
@@ -2185,7 +2346,6 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                        enable = FileName(doc_buffer->logName()).isReadableFile();
                else if (name == "spellchecker")
                        enable = theSpellChecker()
-                               && !doc_buffer->isReadonly()
                                && !doc_buffer->text().empty();
                else if (name == "vclog")
                        enable = doc_buffer->lyxvc().inUse();
@@ -2493,19 +2653,17 @@ static bool import(GuiView * lv, FileName const & filename,
        string loader_format;
        vector<string> loaders = theConverters().loaders();
        if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
-               vector<string>::const_iterator it = loaders.begin();
-               vector<string>::const_iterator en = loaders.end();
                for (string const & loader : loaders) {
                        if (!theConverters().isReachable(format, loader))
                                continue;
 
                        string const tofile =
                                support::changeExtension(filename.absFileName(),
-                               theFormats().extension(*it));
+                               theFormats().extension(loader));
                        if (theConverters().convert(nullptr, filename, FileName(tofile),
-                               filename, format, *it, errorList) != Converters::SUCCESS)
+                               filename, format, loader, errorList) != Converters::SUCCESS)
                                return false;
-                       loader_format = *it;
+                       loader_format = loader;
                        break;
                }
                if (loader_format.empty()) {
@@ -2676,11 +2834,11 @@ void GuiView::newDocument(string const & filename, string templatefile,
 }
 
 
-void GuiView::insertLyXFile(docstring const & fname, bool ignorelang)
+bool GuiView::insertLyXFile(docstring const & fname, bool ignorelang)
 {
        BufferView * bv = documentBufferView();
        if (!bv)
-               return;
+               return false;
 
        // FIXME UNICODE
        FileName filename(to_utf8(fname));
@@ -2702,7 +2860,7 @@ void GuiView::insertLyXFile(docstring const & fname, bool ignorelang)
                                         QStringList(qt_("LyX Documents (*.lyx)")));
 
                if (result.first == FileDialog::Later)
-                       return;
+                       return false;
 
                // FIXME UNICODE
                filename.set(fromqstr(result.second));
@@ -2711,12 +2869,13 @@ void GuiView::insertLyXFile(docstring const & fname, bool ignorelang)
                if (filename.empty()) {
                        // emit message signal.
                        message(_("Canceled."));
-                       return;
+                       return false;
                }
        }
 
        bv->insertLyXFile(filename, ignorelang);
        bv->buffer().errors("Parse");
+       return true;
 }
 
 
@@ -3257,9 +3416,10 @@ bool GuiView::closeBuffer(Buffer & buf)
        if (success) {
                // goto bookmark to update bookmark pit.
                // FIXME: we should update only the bookmarks related to this buffer!
+               // FIXME: this is done also in LFUN_WINDOW_CLOSE!
                LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
-               for (unsigned int i = 0; i < theSession().bookmarks().size(); ++i)
-                       guiApp->gotoBookmark(i + 1, false, false);
+               for (unsigned int i = 1; i < theSession().bookmarks().size(); ++i)
+                       guiApp->gotoBookmark(i, false, false);
 
                if (saveBufferIfNeeded(buf, false)) {
                        buf.removeAutosaveFile();
@@ -3805,14 +3965,13 @@ Buffer::ExportStatus GuiView::GuiViewPrivate::previewAndDestroy(
 }
 
 
-bool GuiView::GuiViewPrivate::asyncBufferProcessing(
-                          string const & argument,
+bool GuiView::GuiViewPrivate::asyncBufferProcessing(string const & argument,
                           Buffer const * used_buffer,
                           docstring const & msg,
                           Buffer::ExportStatus (*asyncFunc)(Buffer const *, Buffer *, string const &),
                           Buffer::ExportStatus (Buffer::*syncFunc)(string const &, bool) const,
                           Buffer::ExportStatus (Buffer::*previewFunc)(string const &) const,
-                          bool allow_async)
+                          bool allow_async, bool use_tmpdir)
 {
        if (!used_buffer)
                return false;
@@ -3848,7 +4007,7 @@ bool GuiView::GuiViewPrivate::asyncBufferProcessing(
        } else {
                Buffer::ExportStatus status;
                if (syncFunc) {
-                       status = (used_buffer->*syncFunc)(format, false);
+                       status = (used_buffer->*syncFunc)(format, use_tmpdir);
                } else if (previewFunc) {
                        status = (used_buffer->*previewFunc)(format);
                } else
@@ -4005,7 +4164,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                                _("Exporting ..."),
                                                &GuiViewPrivate::compileAndDestroy,
                                                &Buffer::doExport,
-                                               nullptr, cmd.allowAsync());
+                                               nullptr, cmd.allowAsync(), true);
                        break;
                }
                case LFUN_BUFFER_VIEW: {
@@ -4023,7 +4182,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                                docstring(),
                                                &GuiViewPrivate::compileAndDestroy,
                                                &Buffer::doExport,
-                                               nullptr, cmd.allowAsync());
+                                               nullptr, cmd.allowAsync(), true);
                        break;
                }
                case LFUN_MASTER_BUFFER_VIEW: {
@@ -4118,10 +4277,11 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        break;
 
                case LFUN_FILE_INSERT: {
-                       if (cmd.getArg(1) == "ignorelang")
-                               insertLyXFile(from_utf8(cmd.getArg(0)), true);
-                       else
-                               insertLyXFile(cmd.argument());
+                       bool const ignore_lang = cmd.getArg(1) == "ignorelang";
+                       if (insertLyXFile(from_utf8(cmd.getArg(0)), ignore_lang)) {
+                               dr.forceBufferUpdate();
+                               dr.screenUpdate(Update::Force);
+                       }
                        break;
                }
 
@@ -4270,6 +4430,14 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                dr.setMessage(_("Developer mode is now disabled."));
                        break;
 
+               case LFUN_TOOLBAR_SET: {
+                       string const name = cmd.getArg(0);
+                       string const state = cmd.getArg(1);
+                       if (GuiToolbar * t = toolbar(name))
+                               t->setState(state);
+                       break;
+               }
+
                case LFUN_TOOLBAR_TOGGLE: {
                        string const name = cmd.getArg(0);
                        if (GuiToolbar * t = toolbar(name))
@@ -4376,6 +4544,9 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                sdata = bv->cursor().getEncoding()->name();
                                if (!sdata.empty())
                                        showDialog("symbols", sdata);
+                       } else if (name == "findreplace") {
+                               sdata = to_utf8(bv->cursor().selectionAsString(false));
+                               showDialog(name, sdata);
                        // bug 5274
                        } else if (name == "prefs" && isFullScreen()) {
                                lfunUiToggle("fullscreen");
@@ -4494,13 +4665,13 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        if (zoom < static_cast<int>(zoom_min_))
                                zoom = zoom_min_;
 
-                       lyxrc.currentZoom = zoom;
+                       setCurrentZoom(zoom);
 
                        dr.setMessage(bformat(_("Zoom level is now %1$d% (default value: %2$d%)"),
                                              lyxrc.currentZoom, lyxrc.defaultZoom));
 
                        guiApp->fontLoader().update();
-                       dr.screenUpdate(Update::Force | Update::FitCursor);
+                       dr.screenUpdate(Update::ForceAll | Update::FitCursor);
                        break;
                }
 
@@ -4609,12 +4780,6 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        break;
        }
 
-       // Part of automatic menu appearance feature.
-       if (isFullScreen()) {
-               if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
-                       menuBar()->hide();
-       }
-
        // Need to update bv because many LFUNs here might have destroyed it
        bv = currentBufferView();
 
@@ -4652,8 +4817,14 @@ bool GuiView::lfunUiToggle(string const & ui_component)
                //are the frames in default state?
                d.current_work_area_->setFrameStyle(QFrame::NoFrame);
                if (l == 0) {
+#if QT_VERSION >  0x050903
+                       setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false);
+#endif
                        setContentsMargins(-2, -2, -2, -2);
                } else {
+#if QT_VERSION >  0x050903
+                       setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, true);
+#endif
                        setContentsMargins(0, 0, 0, 0);
                }
        } else
@@ -4840,7 +5011,8 @@ void GuiView::doShowDialog(QString const & qname, QString const & qdata,
                                // activateWindow is needed for floating dockviews
                                dialog->asQWidget()->raise();
                                dialog->asQWidget()->activateWindow();
-                               dialog->asQWidget()->setFocus();
+                               if (dialog->wantInitialFocus())
+                                       dialog->asQWidget()->setFocus();
                        }
                }
        }
@@ -4900,7 +5072,7 @@ void GuiView::hideAll() const
 
 void GuiView::updateDialogs()
 {
-       for(auto const & dlg_p : d.dialogs_)
+       for(auto const & dlg_p : d.dialogs_) {
                Dialog * dialog = dlg_p.second.get();
                if (dialog) {
                        if (dialog->needBufferOpen() && !documentBufferView())
@@ -4913,134 +5085,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);
 }