mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
apply Juergen Spitzmueller's changes to qt document dialog. save doc defaults and buffer update on apply now work.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5596 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3f8d73282c
commit
b8008acbf1
@ -1,3 +1,8 @@
|
||||
2002-11-07 Juergen Spitzmueller <j.spitzmueller@gmx.de>
|
||||
|
||||
* ControlDocument.C: (SaveAsDefault) make it work.
|
||||
fix buffer update on class change
|
||||
|
||||
2002-11-06 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* biblio.C (searchKeys and helper functions): rewritten entirely
|
||||
|
@ -72,14 +72,15 @@ void ControlDocument::apply()
|
||||
|
||||
// FIXME: do we need to use return value from classApply() here? (Lgb)
|
||||
classApply();
|
||||
lv_.view()->redoCurrentBuffer();
|
||||
|
||||
view().apply();
|
||||
buffer()->params = *bp_;
|
||||
|
||||
lv_.view()->redoCurrentBuffer();
|
||||
|
||||
buffer()->markDirty();
|
||||
|
||||
lv_.message(_("Document Settings Applied"));
|
||||
lv_.message(_("Document settings applied"));
|
||||
}
|
||||
|
||||
|
||||
@ -107,14 +108,17 @@ void ControlDocument::setLanguage()
|
||||
|
||||
bool ControlDocument::classApply()
|
||||
{
|
||||
BufferParams & params = lv_.buffer()->params;
|
||||
unsigned int const old_class = bp_->textclass;
|
||||
BufferParams & params = buffer()->params;
|
||||
unsigned int const old_class = params.textclass;
|
||||
unsigned int const new_class = bp_->textclass;
|
||||
|
||||
// exit if nothing changes
|
||||
if (params.textclass == old_class)
|
||||
return true;
|
||||
if (new_class == old_class) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// try to load new_class
|
||||
if (!textclasslist[params.textclass].load()) {
|
||||
if (!textclasslist[new_class].load()) {
|
||||
// problem changing class
|
||||
// -- warn user (to retain old style)
|
||||
Alert::alert(_("Conversion Errors!"),
|
||||
@ -124,9 +128,11 @@ bool ControlDocument::classApply()
|
||||
}
|
||||
|
||||
// successfully loaded
|
||||
view().apply();
|
||||
buffer()->params = *bp_;
|
||||
lv_.message(_("Converting document to new document class..."));
|
||||
int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
|
||||
old_class, params.textclass,
|
||||
old_class, new_class,
|
||||
&*(lv_.buffer()->paragraphs.begin()),
|
||||
lv_.buffer()->params);
|
||||
if (ret) {
|
||||
@ -140,13 +146,17 @@ bool ControlDocument::classApply()
|
||||
Alert::alert(_("Conversion Errors!"),s,
|
||||
_("into chosen document class"));
|
||||
}
|
||||
//lv_.view()->redoCurrentBuffer();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ControlDocument::saveAsDefault()
|
||||
{
|
||||
if (!Alert::askQuestion(_("Do you want to save the current settings"),
|
||||
_("for the document layout as default?"),
|
||||
_("(they will be valid for any new document)")))
|
||||
return;
|
||||
|
||||
lv_.buffer()->params.preamble = bp_->preamble;
|
||||
|
||||
string const fname = AddName(AddPath(user_lyxdir, "templates/"),
|
||||
|
@ -1,3 +1,13 @@
|
||||
2002-11-27 Juergen Spitzmueller <j.spitzmueller@gmx.de>
|
||||
|
||||
* ui/QDocument.ui:
|
||||
* QDocumentDialog.C:
|
||||
* QDocument.[Ch]:
|
||||
Implement "Save as default" and "Use class defaults"
|
||||
|
||||
* QDocumentDialog.C: Fix dialog update on class change
|
||||
implement lyxrc.auto_reset_options
|
||||
|
||||
2002-11-07 John Levon <levon@movementarian.org>
|
||||
|
||||
* QGraphics.[Ch]:
|
||||
|
@ -594,3 +594,21 @@ void QDocument::update_contents()
|
||||
dialog_->marginsModule->footskipLE->setText(
|
||||
tostr(LyXLength(params.footskip).value()).c_str());
|
||||
}
|
||||
|
||||
|
||||
void QDocument::saveDocDefault()
|
||||
{
|
||||
// we have to apply the params first
|
||||
apply();
|
||||
controller().saveAsDefault();
|
||||
}
|
||||
|
||||
void QDocument::useClassDefaults()
|
||||
{
|
||||
BufferParams & params = controller().params();
|
||||
|
||||
params.textclass = dialog_->layoutModule->classCO->currentItem();
|
||||
params.useClassDefaults();
|
||||
update_contents();
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,10 @@ private:
|
||||
void update_contents();
|
||||
/// build the dialog
|
||||
void build_dialog();
|
||||
/// save as default template
|
||||
void saveDocDefault();
|
||||
/// reset to default params
|
||||
void useClassDefaults();
|
||||
///
|
||||
std::vector<string> lang_;
|
||||
};
|
||||
|
@ -310,8 +310,10 @@ void QDocumentDialog::setTitle(int item)
|
||||
/*
|
||||
* public slot
|
||||
*/
|
||||
void QDocumentDialog::saveDocDefault()
|
||||
{}
|
||||
void QDocumentDialog::saveDefaultClicked()
|
||||
{
|
||||
form_->saveDocDefault();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -326,9 +328,9 @@ void QDocumentDialog::restore()
|
||||
/*
|
||||
* public slot
|
||||
*/
|
||||
void QDocumentDialog::useClassDefaults()
|
||||
void QDocumentDialog::useDefaultsClicked()
|
||||
{
|
||||
qWarning( "DocumentDialog::useClassDefaults() not yet implemented!" );
|
||||
form_->useClassDefaults();
|
||||
}
|
||||
|
||||
|
||||
@ -475,10 +477,23 @@ void QDocumentDialog::updatePagestyle(string const & items, string const & sel)
|
||||
|
||||
void QDocumentDialog::classChanged()
|
||||
{
|
||||
updateFontsize(form_->controller().textClass().opt_fontsize(),
|
||||
form_->controller().params().fontsize);
|
||||
unsigned int tc = layoutModule->classCO->currentItem();
|
||||
|
||||
updatePagestyle(form_->controller().textClass().opt_pagestyle(),
|
||||
form_->controller().params().pagestyle);
|
||||
BufferParams & params = form_->controller().params();
|
||||
params.textclass = layoutModule->classCO->currentItem();
|
||||
|
||||
if (lyxrc.auto_reset_options) {
|
||||
params.textclass = tc;
|
||||
params.useClassDefaults();
|
||||
form_->update_contents();
|
||||
} else {
|
||||
// update the params which are needed in any case
|
||||
// (fontsizes, pagestyle)
|
||||
params.textclass = tc;
|
||||
updateFontsize(form_->controller().textClass().opt_fontsize(),
|
||||
params.fontsize);
|
||||
|
||||
updatePagestyle(form_->controller().textClass().opt_pagestyle(),
|
||||
params.pagestyle);
|
||||
}
|
||||
}
|
||||
|
@ -50,9 +50,9 @@ public:
|
||||
public slots:
|
||||
void setTitle(int);
|
||||
void change_adaptor();
|
||||
void saveDocDefault();
|
||||
void saveDefaultClicked();
|
||||
void restore();
|
||||
void useClassDefaults();
|
||||
void useDefaultsClicked();
|
||||
protected slots:
|
||||
void setLSpacing(int);
|
||||
void setMargins(int);
|
||||
|
@ -13,7 +13,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>468</width>
|
||||
<width>465</width>
|
||||
<height>363</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -66,6 +66,10 @@
|
||||
<name>text</name>
|
||||
<string>Use Class Defaults</string>
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string>Reset default params of the current class</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QPushButton</class>
|
||||
@ -84,6 +88,10 @@
|
||||
<name>text</name>
|
||||
<string>Save as Document Defaults</string>
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string>Save settings as LyX's default template</string>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
@ -265,7 +273,7 @@
|
||||
<images>
|
||||
<image>
|
||||
<name>image0</name>
|
||||
<data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
|
||||
<data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
|
||||
</image>
|
||||
</images>
|
||||
<connections>
|
||||
@ -281,7 +289,21 @@
|
||||
<receiver>QDocumentDialogBase</receiver>
|
||||
<slot>setTitle(int)</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>savePB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QDocumentDialogBase</receiver>
|
||||
<slot>saveDefaultClicked()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>defaultPB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QDocumentDialogBase</receiver>
|
||||
<slot>useDefaultsClicked()</slot>
|
||||
</connection>
|
||||
<slot access="public">change_adaptor()</slot>
|
||||
<slot access="protected">useDefaultsClicked()</slot>
|
||||
<slot access="protected">saveDefaultClicked()</slot>
|
||||
<slot access="public">setTitle(int)</slot>
|
||||
</connections>
|
||||
</UI>
|
||||
|
Loading…
Reference in New Issue
Block a user