mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Allow selection of a local layout file from the document->settings dialog.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23652 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
297f68bc52
commit
14eeac2e1c
@ -223,9 +223,8 @@ LayoutFileIndex
|
|||||||
BOOST_ASSERT(sub.size() == 4);
|
BOOST_ASSERT(sub.size() == 4);
|
||||||
// now, create a TextClass with description containing path information
|
// now, create a TextClass with description containing path information
|
||||||
string className(sub.str(2) == "" ? textclass : sub.str(2));
|
string className(sub.str(2) == "" ? textclass : sub.str(2));
|
||||||
string description(sub.str(3) + " <" + path + ">");
|
|
||||||
LayoutFile * tmpl =
|
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
|
// This textclass is added on request so it will definitely be
|
||||||
// used. Load it now because other load() calls may fail if they
|
// used. Load it now because other load() calls may fail if they
|
||||||
// are called in a context without buffer path information.
|
// are called in a context without buffer path information.
|
||||||
|
@ -870,6 +870,8 @@ GuiDocument::GuiDocument(GuiView & lv)
|
|||||||
this, SLOT(classChanged()));
|
this, SLOT(classChanged()));
|
||||||
connect(latexModule->classCO, SIGNAL(activated(int)),
|
connect(latexModule->classCO, SIGNAL(activated(int)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SLOT(change_adaptor()));
|
||||||
|
connect(latexModule->layoutPB, SIGNAL(clicked()),
|
||||||
|
this, SLOT(browseLayout()));
|
||||||
|
|
||||||
selectionManager =
|
selectionManager =
|
||||||
new ModuleSelMan(latexModule->availableLV, latexModule->selectedLV,
|
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()
|
void GuiDocument::classChanged()
|
||||||
{
|
{
|
||||||
int idx = latexModule->classCO->currentIndex();
|
int idx = latexModule->classCO->currentIndex();
|
||||||
|
@ -135,6 +135,7 @@ private Q_SLOTS:
|
|||||||
void setSkip(int);
|
void setSkip(int);
|
||||||
void enableSkip(bool);
|
void enableSkip(bool);
|
||||||
void portraitChanged();
|
void portraitChanged();
|
||||||
|
void browseLayout();
|
||||||
void classChanged();
|
void classChanged();
|
||||||
void updateModuleInfo();
|
void updateModuleInfo();
|
||||||
void setExtraEmbeddedFileList();
|
void setExtraEmbeddedFileList();
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="3" column="0" colspan="3" >
|
<item row="3" column="0" colspan="4" >
|
||||||
<widget class="QGroupBox" name="modulesGB" >
|
<widget class="QGroupBox" name="modulesGB" >
|
||||||
<property name="title" >
|
<property name="title" >
|
||||||
<string>Modules</string>
|
<string>Modules</string>
|
||||||
@ -129,7 +129,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2" >
|
<item row="2" column="2" colspan="2">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -167,6 +167,29 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" colspan="2" >
|
<item row="0" column="1" colspan="2" >
|
||||||
<widget class="QComboBox" name="classCO" />
|
<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&rowse...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" >
|
<item row="1" column="0" >
|
||||||
<widget class="QLabel" name="optionsL" >
|
<widget class="QLabel" name="optionsL" >
|
||||||
@ -178,7 +201,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" colspan="2" >
|
<item row="1" column="1" colspan="3" >
|
||||||
<widget class="QLineEdit" name="optionsLE" />
|
<widget class="QLineEdit" name="optionsLE" />
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user