]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiRef.cpp
Mention style-dependency of of features in the tooltips, part 2
[lyx.git] / src / frontends / qt4 / GuiRef.cpp
index aa98550734815d1fda1a98f9562cd347ded75135..58aa435efaa5ab4d039fe49522cce2e910a8db28 100644 (file)
@@ -16,6 +16,7 @@
 #include "GuiApplication.h"
 
 #include "Buffer.h"
+#include "BufferParams.h"
 #include "BufferList.h"
 #include "FuncRequest.h"
 
@@ -105,6 +106,14 @@ GuiRef::GuiRef(GuiView & lv)
                this, SLOT(updateClicked()));
        connect(bufferCO, SIGNAL(activated(int)),
                this, SLOT(updateClicked()));
+       connect(pluralCB, SIGNAL(clicked()),
+               this, SLOT(changed_adaptor()));
+       connect(capsCB, SIGNAL(clicked()),
+               this, SLOT(changed_adaptor()));
+       connect(noprefixCB, SIGNAL(clicked()),
+               this, SLOT(changed_adaptor()));
+
+       enableBoxes();
 
        bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
        bc().setOK(okPB);
@@ -126,9 +135,23 @@ void GuiRef::enableView(bool enable)
 }
 
 
+void GuiRef::enableBoxes()
+{
+       bool const isFormatted = 
+           (InsetRef::getName(typeCO->currentIndex()) == "formatted");
+       bool const isLabelOnly = 
+           (InsetRef::getName(typeCO->currentIndex()) == "labelonly");
+       bool const usingRefStyle = buffer().params().use_refstyle;
+       pluralCB->setEnabled(isFormatted && usingRefStyle);
+       capsCB->setEnabled(isFormatted && usingRefStyle);
+       noprefixCB->setEnabled(isLabelOnly);
+}
+
+
 void GuiRef::changed_adaptor()
 {
        changed();
+       enableBoxes();
 }
 
 
@@ -281,6 +304,10 @@ void GuiRef::updateContents()
        if (!typeAllowed())
                typeCO->setCurrentIndex(0);
 
+       pluralCB->setChecked(params_["plural"] == "true");
+       capsCB->setChecked(params_["caps"] == "true");
+       noprefixCB->setChecked(params_["noprefix"] == "true");
+
        // insert buffer list
        bufferCO->clear();
        FileNameList const buffers(theBufferList().fileNames());
@@ -303,6 +330,7 @@ void GuiRef::updateContents()
        active_buffer_ = thebuffer;
 
        updateRefs();
+       enableBoxes();
        // Activate OK/Apply buttons if the users inserts a new ref
        // and we have a valid pre-setting.
        bc().setValid(isValid() && new_inset);
@@ -316,7 +344,12 @@ void GuiRef::applyView()
        params_.setCmdName(InsetRef::getName(typeCO->currentIndex()));
        params_["reference"] = qstring_to_ucs4(last_reference_);
        params_["name"] = qstring_to_ucs4(nameED->text());
-
+       params_["plural"] = pluralCB->isChecked() ? 
+             from_ascii("true") : from_ascii("false");
+       params_["caps"] = capsCB->isChecked() ? 
+             from_ascii("true") : from_ascii("false");
+       params_["noprefix"] = noprefixCB->isChecked() ? 
+             from_ascii("true") : from_ascii("false");
        restored_buffer_ = bufferCO->currentIndex();
 }