]> git.lyx.org Git - features.git/commitdiff
Allow selection of a local layout file from the document->settings dialog.
authorBo Peng <bpeng@lyx.org>
Mon, 10 Mar 2008 21:31:22 +0000 (21:31 +0000)
committerBo Peng <bpeng@lyx.org>
Mon, 10 Mar 2008 21:31:22 +0000 (21:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23652 a592a061-630c-0410-9148-cb99ea01b6c8

src/LayoutFile.cpp
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h
src/frontends/qt4/ui/LaTeXUi.ui

index 7096cf402f8ee510661da4d5c49597ab1ff22351..e2d7653454907dd15fa5417ad957a8b2942df4d5 100644 (file)
@@ -223,9 +223,8 @@ LayoutFileIndex
                                BOOST_ASSERT(sub.size() == 4);
                                // now, create a TextClass with description containing path information
                                string className(sub.str(2) == "" ? textclass : sub.str(2));
-                               string description(sub.str(3) + " <" + path + ">");
                                LayoutFile * tmpl = 
-                                       new LayoutFile(textclass, className, description, true);
+                                       new LayoutFile(textclass, className, localIndex, true);
                                // This textclass is added on request so it will definitely be
                                // used. Load it now because other load() calls may fail if they
                                // are called in a context without buffer path information.
index 61fbdf8255f3945042129866fedec16c308fbaf5..d8d96144faa12bd878c09c0a3deb0e33b9c81e00 100644 (file)
@@ -870,6 +870,8 @@ GuiDocument::GuiDocument(GuiView & lv)
                this, SLOT(classChanged()));
        connect(latexModule->classCO, SIGNAL(activated(int)),
                this, SLOT(change_adaptor()));
+       connect(latexModule->layoutPB, SIGNAL(clicked()),
+               this, SLOT(browseLayout()));
        
        selectionManager = 
                new ModuleSelMan(latexModule->availableLV, latexModule->selectedLV, 
@@ -1220,6 +1222,49 @@ void GuiDocument::updatePagestyle(string const & items, string const & sel)
 }
 
 
+void GuiDocument::browseLayout()
+{
+       QString const label1 = qt_("Layouts|#o#O");
+       QString const dir1 = toqstr(lyxrc.document_path);
+       FileFilterList const filter(_("LyX Layout (*.layout)"));
+       QString file = browseRelFile(QString(), bufferFilepath(),
+               qt_("Local layout file"), filter, false,
+               label1, dir1);
+
+       if (!suffixIs(fromqstr(file), ".layout"))
+               return;
+
+       FileName layoutFile = makeAbsPath(fromqstr(file),
+               fromqstr(bufferFilepath()));
+       
+       // load the layout file
+       LayoutFileList & bcl = LayoutFileList::get();
+       string classname = layoutFile.onlyFileName();
+       LayoutFileIndex name = bcl.addLayoutFile(
+               classname.substr(0, classname.size() - 7),
+               layoutFile.onlyPath().absFilename());
+
+       if (name.empty()) {
+               Alert::error(_("Error"),
+                       _("Unable to read local layout file."));                
+               return;
+       }
+
+       // do not trigger classChanged if there is no change.
+       if (latexModule->classCO->currentText() == toqstr(name))
+               return;
+               
+       // add to combo box
+       int idx = latexModule->classCO->findText(toqstr(name));
+       if (idx == -1) {
+               classes_model_.insertRow(0, toqstr(name), name);
+               latexModule->classCO->setCurrentIndex(0);
+       } else
+               latexModule->classCO->setCurrentIndex(idx);
+       classChanged();
+}
+
+
 void GuiDocument::classChanged()
 {
        int idx = latexModule->classCO->currentIndex();
index 489cc1efd48ac00c81032e6e8b5a6fa51187748a..e846f90ac5cc446ba4be53ea113b2adcf392082b 100644 (file)
@@ -135,6 +135,7 @@ private Q_SLOTS:
        void setSkip(int);
        void enableSkip(bool);
        void portraitChanged();
+       void browseLayout();
        void classChanged();
        void updateModuleInfo();
        void setExtraEmbeddedFileList();
index ee08c1dc9b0c0a42a586a5661e40ca3013459dd0..7d3e7e9b96b1410b435769a15412b3c7da9521f3 100644 (file)
@@ -19,7 +19,7 @@
    <property name="spacing" >
     <number>6</number>
    </property>
-   <item row="3" column="0" colspan="3" >
+   <item row="3" column="0" colspan="4" >
     <widget class="QGroupBox" name="modulesGB" >
      <property name="title" >
       <string>Modules</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="2" >
+   <item row="2" column="2" colspan="2">
     <spacer>
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
    </item>
    <item row="0" column="1" colspan="2" >
     <widget class="QComboBox" name="classCO" />
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>7</hsizetype>
+       <vsizetype>0</vsizetype>
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+   </item>
+   <item row="0" column="3" >
+    <widget class="QPushButton" name="layoutPB" >
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>1</hsizetype>
+       <vsizetype>0</vsizetype>
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="text" >
+      <string>B&amp;rowse...</string>
+     </property>
+    </widget>
    </item>
    <item row="1" column="0" >
     <widget class="QLabel" name="optionsL" >
      </property>
     </widget>
    </item>
-   <item row="1" column="1" colspan="2" >
+   <item row="1" column="1" colspan="3" >
     <widget class="QLineEdit" name="optionsLE" />
    </item>
   </layout>