InsetParamsDialog bug fixing:

* OK button now creates an inset if none is present
* Fix some enabling/disabling of buttons.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33484 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2010-02-16 09:39:14 +00:00
parent 06e19de13b
commit c775690b58
3 changed files with 32 additions and 13 deletions

View File

@ -33,7 +33,7 @@ private Q_SLOTS:
void enableCustom(int); void enableCustom(int);
private: private:
/// \name DialogView inherited methods /// \name InsetParamsWidget inherited methods
//@{ //@{
InsetCode insetCode() { return VSPACE_CODE; } InsetCode insetCode() { return VSPACE_CODE; }
FuncCode creationCode() { return LFUN_INSET_INSERT; } FuncCode creationCode() { return LFUN_INSET_INSERT; }

View File

@ -15,6 +15,7 @@
#include "GuiBox.h" #include "GuiBox.h"
#include "GuiERT.h" #include "GuiERT.h"
#include "GuiInfo.h" #include "GuiInfo.h"
#include "GuiTabular.h"
#include "GuiVSpace.h" #include "GuiVSpace.h"
#include "FloatPlacement.h" #include "FloatPlacement.h"
@ -89,19 +90,28 @@ void InsetParamsDialog::on_restorePB_clicked()
void InsetParamsDialog::on_okPB_clicked() void InsetParamsDialog::on_okPB_clicked()
{ {
applyView(); Inset const * i = inset(d->widget_->insetCode());
if (i)
applyView();
else
newInset();
hide(); hide();
} }
void InsetParamsDialog::newInset()
{
docstring const argument = d->widget_->dialogToParams();
dispatch(FuncRequest(d->widget_->creationCode(), argument));
}
void InsetParamsDialog::on_applyPB_clicked() void InsetParamsDialog::on_applyPB_clicked()
{ {
if (synchronizedViewCB->isChecked()) { if (synchronizedViewCB->isChecked())
docstring const argument = d->widget_->dialogToParams(); newInset();
dispatch(FuncRequest(d->widget_->creationCode(), argument)); else
} else {
applyView(); applyView();
}
} }
@ -116,12 +126,15 @@ void InsetParamsDialog::on_synchronizedViewCB_stateChanged(int state)
bool const sync = (state == Qt::Checked); bool const sync = (state == Qt::Checked);
QString const label = sync ? qt_("&New") : qt_("&Apply"); QString const label = sync ? qt_("&New") : qt_("&Apply");
applyPB->setText(label); applyPB->setText(label);
okPB->setEnabled(!sync); okPB->setEnabled(!sync && d->widget_->checkWidgets());
restorePB->setEnabled(!sync); restorePB->setEnabled(!sync);
if (sync) if (sync)
connect(d->widget_, SIGNAL(changed()), this, SLOT(applyView())); connect(d->widget_, SIGNAL(changed()), this, SLOT(applyView()));
else else {
applyPB->setEnabled(d->widget_->checkWidgets());
d->widget_->setEnabled(!buffer().isReadonly());
QObject::disconnect(d->widget_, SIGNAL(changed()), this, SLOT(applyView())); QObject::disconnect(d->widget_, SIGNAL(changed()), this, SLOT(applyView()));
}
} }
@ -137,12 +150,10 @@ void InsetParamsDialog::applyView()
docstring const argument = d->widget_->dialogToParams(); docstring const argument = d->widget_->dialogToParams();
if (argument.empty() || !i->validateModifyArgument(argument)) { if (argument.empty() || !i->validateModifyArgument(argument)) {
//FIXME: newPB is not accessible applyPB->setEnabled(false);
//newPB->setEnabled(false);
return; return;
} }
//FIXME: newPB is not accessible applyPB->setEnabled(true);
//newPB->setEnabled(true);
dispatch(FuncRequest(LFUN_INSET_MODIFY, argument)); dispatch(FuncRequest(LFUN_INSET_MODIFY, argument));
} }
@ -179,6 +190,12 @@ Dialog * createDialog(GuiView & lv, InsetCode code)
case INFO_CODE: case INFO_CODE:
widget = new GuiInfo; widget = new GuiInfo;
break; break;
//FIXME: not ready yet.
/*
case TABULAR_CODE:
widget = new GuiTabular;
break;
*/
case VSPACE_CODE: case VSPACE_CODE:
widget = new GuiVSpace; widget = new GuiVSpace;
break; break;

View File

@ -51,6 +51,8 @@ private:
bool isBufferDependent() const { return true; } bool isBufferDependent() const { return true; }
bool canApply() const { return true; } bool canApply() const { return true; }
//@} //@}
///
void newInset();
/// pimpl /// pimpl
struct Private; struct Private;
Private * d; Private * d;