]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiDocument.cpp
Improve the local layout feature by better handling of unknown textclass, unknown...
[lyx.git] / src / frontends / qt4 / GuiDocument.cpp
index ab3b065cab5cb5a8d5283095f9c5016850283676..1a7780cbddb43de51d40680c03278c54e458834b 100644 (file)
@@ -876,6 +876,8 @@ GuiDocument::GuiDocument(GuiView & lv)
                this, SLOT(change_adaptor()));
        connect(latexModule->layoutPB, SIGNAL(clicked()),
                this, SLOT(browseLayout()));
+       connect(latexModule->layoutPB, SIGNAL(clicked()),
+               this, SLOT(change_adaptor()));
        connect(latexModule->childDocGB, SIGNAL(clicked()),
                this, SLOT(change_adaptor()));
        connect(latexModule->childDocLE, SIGNAL(textChanged(const QString &)),
@@ -933,7 +935,7 @@ GuiDocument::GuiDocument(GuiView & lv)
        pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
 
        connect(pdfSupportModule->use_hyperrefGB, SIGNAL(toggled(bool)),
-               this, SLOT(useHyperrefClicked()));
+               this, SLOT(change_adaptor()));
        connect(pdfSupportModule->titleLE, SIGNAL(textChanged(const QString &)),
                this, SLOT(change_adaptor()));
        connect(pdfSupportModule->authorLE, SIGNAL(textChanged(const QString &)),
@@ -1013,15 +1015,6 @@ void GuiDocument::useDefaultsClicked()
 }
 
 
-void GuiDocument::useHyperrefClicked()
-{
-       // strange as it is, Qt seems to be unable to handle this by itself
-       pdfSupportModule->bookmarksopenlevelLA->setEnabled(
-               pdfSupportModule->bookmarksopenlevelSB->isEnabled());
-       change_adaptor();
-}
-
-
 void GuiDocument::change_adaptor()
 {
        changed();
@@ -1248,13 +1241,22 @@ void GuiDocument::browseLayout()
        FileName layoutFile = support::makeAbsPath(fromqstr(file),
                fromqstr(bufferFilepath()));
        
+       int const ret = Alert::prompt(_("Local layout file"),
+               _("The layout file you have selected is a local layout\n"
+                 "file, not one in the system or user directory. Your\n"
+                 "document may not work with this layout if you do not\n"
+                 "keep the layout file in the document directory."),
+                 1, 1, _("&Set Layout"), _("&Cancel"));
+       if (ret == 1)
+               return;
+
        // load the layout file
        LayoutFileList & bcl = LayoutFileList::get();
        string classname = layoutFile.onlyFileName();
-       LayoutFileIndex name = bcl.addLayoutFile(
+       // this will update an existing layout if that layout has been loaded before.
+       LayoutFileIndex name = bcl.addLocalLayout(
                classname.substr(0, classname.size() - 7),
-               layoutFile.onlyPath().absFilename(),
-               LayoutFileList::Local);
+               layoutFile.onlyPath().absFilename());
 
        if (name.empty()) {
                Alert::error(_("Error"),
@@ -1273,6 +1275,7 @@ void GuiDocument::browseLayout()
                latexModule->classCO->setCurrentIndex(0);
        } else
                latexModule->classCO->setCurrentIndex(idx);
+       
        classChanged();
 }
 
@@ -1297,20 +1300,7 @@ void GuiDocument::classChanged()
        if (idx < 0) 
                return;
        string const classname = classes_model_.getIDString(idx);
-       // check if this is a local layout file
-       if (prefixIs(classname, LayoutFileList::localPrefix)) {
-               int const ret = Alert::prompt(_("Local layout file"),
-                               _("The layout file you have selected is a local layout\n"
-                                 "file, not one in the system or user directory. Your\n"
-                                 "document may not work with this layout if you do not\n"
-                                 "keep the layout file in the same directory."),
-                                 1, 1, _("&Set Layout"), _("&Cancel"));
-               if (ret == 1) {
-                       // try to reset the layout combo
-                       setLayoutComboByIDString(bp_.baseClassID());
-                       return;
-               }
-       }
+
        // FIXME Note that by doing things this way, we load the TextClass
        // as soon as it is selected. So, if you use the scroll wheel when
        // sitting on the combo box, we'll load a lot of TextClass objects