From 6e9a59841ece275b5ffb03ef245fa85fb236ef85 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Mon, 31 Jan 2011 14:48:16 +0000 Subject: [PATCH] InsetParamsDialog: update the dialog settings on context change (on user request). Fixes bug 7271. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37388 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/InsetParamsDialog.cpp | 36 ++++++++++++++++--------- src/frontends/qt4/InsetParamsDialog.h | 5 ++-- src/frontends/qt4/ui/InsetParamsUi.ui | 35 +++++++++++++++++------- 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/src/frontends/qt4/InsetParamsDialog.cpp b/src/frontends/qt4/InsetParamsDialog.cpp index 00aa01c9d5..f76427d68d 100644 --- a/src/frontends/qt4/InsetParamsDialog.cpp +++ b/src/frontends/qt4/InsetParamsDialog.cpp @@ -78,8 +78,9 @@ InsetParamsDialog::InsetParamsDialog(GuiView & lv, InsetParamsWidget * widget) { setupUi(this); setInsetParamsWidget(widget); - synchronizedViewCB->setChecked(false); - on_synchronizedViewCB_stateChanged(false); + immediateApplyCB->setChecked(false); + synchronizedCB->setChecked(true); + on_immediateApplyCB_stateChanged(false); setFocusProxy(widget); } @@ -151,13 +152,19 @@ void InsetParamsDialog::on_closePB_clicked() } -void InsetParamsDialog::on_synchronizedViewCB_stateChanged(int state) +void InsetParamsDialog::on_immediateApplyCB_stateChanged(int state) { checkWidgets(state == Qt::Checked); } -docstring InsetParamsDialog::checkWidgets(bool synchronized_view) +void InsetParamsDialog::on_synchronizedCB_stateChanged(int) +{ + checkWidgets(false); +} + + +docstring InsetParamsDialog::checkWidgets(bool immediate) { bool const widget_ok = d->widget_->checkWidgets(); Inset const * ins = inset(d->widget_->insetCode()); @@ -165,17 +172,18 @@ docstring InsetParamsDialog::checkWidgets(bool synchronized_view) bool valid_argument = !argument.empty(); if (ins) valid_argument &= ins->validateModifyArgument(argument); - FuncCode const code = synchronized_view + FuncCode const code = immediate ? d->widget_->creationCode() : LFUN_INSET_MODIFY; bool const lfun_ok = lyx::getStatus(FuncRequest(code, argument)).enabled(); bool const read_only = buffer().isReadonly(); - okPB->setEnabled(!synchronized_view && widget_ok && !read_only && valid_argument); - bool const can_be_restored = !synchronized_view && !read_only + okPB->setEnabled(!immediate && widget_ok && !read_only && valid_argument); + bool const can_be_restored = !immediate && !read_only && ins && (ins != d->inset_ || d->changed_); restorePB->setEnabled(can_be_restored); - applyPB->setEnabled(lfun_ok && widget_ok && !read_only && valid_argument); + applyPB->setEnabled(!immediate && lfun_ok && widget_ok && !read_only && valid_argument); d->widget_->setEnabled(!read_only); + synchronizedCB->setEnabled(!immediate); return argument; } @@ -183,15 +191,15 @@ docstring InsetParamsDialog::checkWidgets(bool synchronized_view) void InsetParamsDialog::onWidget_changed() { d->changed_ = true; - docstring const argument = checkWidgets(synchronizedViewCB->isChecked()); - if (synchronizedViewCB->isChecked()) + docstring const argument = checkWidgets(immediateApplyCB->isChecked()); + if (immediateApplyCB->isChecked()) dispatch(FuncRequest(LFUN_INSET_MODIFY, argument)); } void InsetParamsDialog::applyView() { - docstring const argument = checkWidgets(synchronizedViewCB->isChecked()); + docstring const argument = checkWidgets(immediateApplyCB->isChecked()); dispatch(FuncRequest(LFUN_INSET_MODIFY, argument)); d->changed_ = false; d->inset_ = inset(d->widget_->insetCode()); @@ -209,13 +217,15 @@ void InsetParamsDialog::updateView(bool update_widget) d->widget_->blockSignals(false); } } - checkWidgets(synchronizedViewCB->isChecked()); + checkWidgets(immediateApplyCB->isChecked()); } void InsetParamsDialog::updateView() { - updateView(synchronizedViewCB->isChecked()); + bool const update_widget = + (synchronizedCB->isChecked() || immediateApplyCB->isChecked()); + updateView(update_widget); } diff --git a/src/frontends/qt4/InsetParamsDialog.h b/src/frontends/qt4/InsetParamsDialog.h index 0d6e784d71..571aa50781 100644 --- a/src/frontends/qt4/InsetParamsDialog.h +++ b/src/frontends/qt4/InsetParamsDialog.h @@ -43,7 +43,8 @@ protected Q_SLOTS: void on_okPB_clicked(); void on_applyPB_clicked(); void on_closePB_clicked(); - void on_synchronizedViewCB_stateChanged(int state); + void on_immediateApplyCB_stateChanged(int state); + void on_synchronizedCB_stateChanged(int state); private: /// \name DialogView inherited methods @@ -59,7 +60,7 @@ private: /// void updateView(bool update_widget); /// - docstring checkWidgets(bool synchronized_view); + docstring checkWidgets(bool immediate); /// pimpl struct Private; Private * d; diff --git a/src/frontends/qt4/ui/InsetParamsUi.ui b/src/frontends/qt4/ui/InsetParamsUi.ui index bb6f8d9a4d..7fee4ece57 100644 --- a/src/frontends/qt4/ui/InsetParamsUi.ui +++ b/src/frontends/qt4/ui/InsetParamsUi.ui @@ -39,14 +39,31 @@ - - - Qt::LeftToRight - - - I&mmediate Apply - - + + + + + Update dialog when moving context + + + S&ynchronize Dialog + + + + + + + Apply settings immediately + + + Qt::LeftToRight + + + I&mmediate Apply + + + + @@ -124,7 +141,7 @@ - synchronizedViewCB + immediateApplyCB restorePB okPB applyPB -- 2.39.5