]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiRef.cpp
Make a string translatable
[lyx.git] / src / frontends / qt4 / GuiRef.cpp
index aa98550734815d1fda1a98f9562cd347ded75135..6ef6be5b29e48c2d518ccb72a15311d0e16b075b 100644 (file)
@@ -16,6 +16,7 @@
 #include "GuiApplication.h"
 
 #include "Buffer.h"
+#include "BufferParams.h"
 #include "BufferList.h"
 #include "FuncRequest.h"
 
@@ -58,6 +59,13 @@ GuiRef::GuiRef(GuiView & lv)
        filter_->setAutoHideButton(FancyLineEdit::Right, true);
        filter_->setPlaceholderText(qt_("All available labels"));
        filter_->setToolTip(qt_("Enter string to filter the list of available labels"));
+#if (QT_VERSION < 0x050000)
+       connect(filter_, SIGNAL(downPressed()),
+               refsTW, SLOT(setFocus()));
+#else
+       connect(filter_, &FancyLineEdit::downPressed,
+               refsTW, [=](){ focusAndHighlight(refsTW); });
+#endif
 
        filterBarL->addWidget(filter_, 0);
        findKeysLA->setBuddy(filter_);
@@ -105,6 +113,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);
@@ -114,6 +130,8 @@ GuiRef::GuiRef(GuiView & lv)
 
        restored_buffer_ = -1;
        active_buffer_ = -1;
+
+       setFocusProxy(filter_);
 }
 
 
@@ -126,9 +144,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 +313,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 +339,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 +353,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();
 }
 
@@ -499,8 +541,6 @@ void GuiRef::updateRefs()
        sortingCO->setEnabled(!refs_.empty());
        refsTW->setEnabled(!refs_.empty());
        groupCB->setEnabled(!refs_.empty());
-       // refsTW should only be the focus proxy when it is enabled
-       setFocusProxy(refs_.empty() ? 0 : refsTW);
        redoRefs();
 }