]> git.lyx.org Git - lyx.git/commitdiff
InsetParamsDialog: update the dialog settings on context change (on user request).
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 31 Jan 2011 14:48:16 +0000 (14:48 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 31 Jan 2011 14:48:16 +0000 (14:48 +0000)
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
src/frontends/qt4/InsetParamsDialog.h
src/frontends/qt4/ui/InsetParamsUi.ui

index 00aa01c9d5a507b139f9b80c2f00fea5fbcd5563..f76427d68d7c56d810d00fe4763d133305e12f8b 100644 (file)
@@ -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);
 }
 
 
index 0d6e784d71dd278fdb5d6e891660360b9e82b2b1..571aa50781faf8bb36dd6f0338b043c97e57553f 100644 (file)
@@ -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;
index bb6f8d9a4d571ac3b1fc4cb466060ae4f5d1ca10..7fee4ece570cbac0c2545034ad0284640c7bf274 100644 (file)
     </spacer>
    </item>
    <item row="1" column="1">
-    <widget class="QCheckBox" name="synchronizedViewCB">
-     <property name="layoutDirection">
-      <enum>Qt::LeftToRight</enum>
-     </property>
-     <property name="text">
-      <string>I&amp;mmediate Apply</string>
-     </property>
-    </widget>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QCheckBox" name="synchronizedCB">
+       <property name="toolTip">
+        <string>Update dialog when moving context</string>
+       </property>
+       <property name="text">
+        <string>S&amp;ynchronize Dialog</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="immediateApplyCB">
+       <property name="toolTip">
+        <string>Apply settings immediately</string>
+       </property>
+       <property name="layoutDirection">
+        <enum>Qt::LeftToRight</enum>
+       </property>
+       <property name="text">
+        <string>I&amp;mmediate Apply</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
    </item>
    <item row="2" column="0" colspan="2">
     <layout class="QHBoxLayout">
   </layout>
  </widget>
  <tabstops>
-  <tabstop>synchronizedViewCB</tabstop>
+  <tabstop>immediateApplyCB</tabstop>
   <tabstop>restorePB</tabstop>
   <tabstop>okPB</tabstop>
   <tabstop>applyPB</tabstop>