X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FInsetParamsDialog.cpp;h=698cf899bf77711e294e4340807255a9436018e0;hb=8e7d7e42952f0119db1c192386a63d1d9ede3b7f;hp=e6ee1d09ec8a19c339e5b715b52ff7550f9292ef;hpb=379eba512b27089676a24293657b94831f3f4933;p=lyx.git diff --git a/src/frontends/qt4/InsetParamsDialog.cpp b/src/frontends/qt4/InsetParamsDialog.cpp index e6ee1d09ec..698cf899bf 100644 --- a/src/frontends/qt4/InsetParamsDialog.cpp +++ b/src/frontends/qt4/InsetParamsDialog.cpp @@ -16,9 +16,13 @@ #include "GuiBranch.h" #include "GuiBibitem.h" #include "GuiERT.h" +#include "GuiHSpace.h" +#include "GuiHyperlink.h" #include "GuiInfo.h" +#include "GuiLabel.h" #include "GuiLine.h" -#include "GuiHSpace.h" +#include "GuiNomenclature.h" +#include "GuiPrintNomencl.h" #include "GuiTabular.h" #include "GuiVSpace.h" #include "FloatPlacement.h" @@ -52,8 +56,14 @@ namespace frontend { struct InsetParamsDialog::Private { + Private() : widget_(0), inset_(0), changed_(false) {} /// InsetParamsWidget * widget_; + /// The inset that was used at last Restore or Apply operation. + Inset const * inset_; + /// Set to true whenever the dialog is changed and set back to + /// false when the dialog is applied or restored. + bool changed_; }; ///////////////////////////////////////////////////////////////// @@ -79,12 +89,14 @@ InsetParamsDialog::~InsetParamsDialog() } -bool InsetParamsDialog::initialiseParams(std::string const &) +bool InsetParamsDialog::initialiseParams(std::string const & data) { - on_restorePB_clicked(); + if (!d->widget_->initialiseParams(data)) + on_restorePB_clicked(); return true; } + void InsetParamsDialog::setInsetParamsWidget(InsetParamsWidget * widget) { d->widget_ = widget; @@ -98,6 +110,8 @@ void InsetParamsDialog::on_restorePB_clicked() { updateView(true); restorePB->setEnabled(false); + d->changed_ = false; + d->inset_ = inset(d->widget_->insetCode()); } @@ -157,7 +171,9 @@ docstring InsetParamsDialog::checkWidgets(bool synchronized_view) bool const read_only = buffer().isReadonly(); okPB->setEnabled(!synchronized_view && widget_ok && !read_only && valid_argument); - restorePB->setEnabled(!synchronized_view && ins && !read_only); + bool const can_be_restored = !synchronized_view && !read_only + && ins && (ins != d->inset_ || d->changed_); + restorePB->setEnabled(can_be_restored); applyPB->setEnabled(lfun_ok && widget_ok && !read_only && valid_argument); d->widget_->setEnabled(!read_only); return argument; @@ -166,6 +182,7 @@ docstring InsetParamsDialog::checkWidgets(bool synchronized_view) void InsetParamsDialog::onWidget_changed() { + d->changed_ = true; docstring const argument = checkWidgets(synchronizedViewCB->isChecked()); if (synchronizedViewCB->isChecked()) dispatch(FuncRequest(LFUN_INSET_MODIFY, argument)); @@ -176,6 +193,9 @@ void InsetParamsDialog::applyView() { docstring const argument = checkWidgets(synchronizedViewCB->isChecked()); dispatch(FuncRequest(LFUN_INSET_MODIFY, argument)); + d->changed_ = false; + d->inset_ = inset(d->widget_->insetCode()); + updateView(true); } @@ -218,15 +238,27 @@ Dialog * createDialog(GuiView & lv, InsetCode code) case BOX_CODE: widget = new GuiBox; break; + case HYPERLINK_CODE: + widget = new GuiHyperlink; + break; case INFO_CODE: widget = new GuiInfo; break; + case LABEL_CODE: + widget = new GuiLabel; + break; case LINE_CODE: widget = new GuiLine; break; case MATH_SPACE_CODE: widget = new GuiHSpace(true); break; + case NOMENCL_CODE: + widget = new GuiNomenclature; + break; + case NOMENCL_PRINT_CODE: + widget = new GuiPrintNomencl; + break; case SPACE_CODE: widget = new GuiHSpace(false); break;