]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Menus.cpp
Add items to toggle "Force uppercase" and "Full author list" to the context menu
[lyx.git] / src / frontends / qt4 / Menus.cpp
index fd2d0f39e7bc9d96bb96c9bc90c40a82d103c5cf..e38441a8cec5d38457ed8cb95bf3667ac806a47d 100644 (file)
@@ -1529,10 +1529,11 @@ void MenuDefinition::expandCiteStyles(BufferView const * bv)
                                    FuncRequest(LFUN_NOACTION)));
                return;
        }
-       InsetCommand const * citinset =
-                               static_cast<InsetCommand const *>(inset);
+       InsetCitation const * citinset =
+                               static_cast<InsetCitation const *>(inset);
 
        Buffer const * buf = &bv->buffer();
+       BufferParams const & bp = buf->params();
        string const cmd = citinset->params().getCmdName();
 
        docstring const & key = citinset->getParam("key");
@@ -1572,6 +1573,45 @@ void MenuDefinition::expandCiteStyles(BufferView const * bv)
                                    FuncRequest(LFUN_INSET_MODIFY,
                                                "changetype " + from_utf8(citationStyleToString(cs)))));
        }
+
+       // Extra features of the citation styles
+       CitationStyle cs = citinset->getCitationStyle(bp, cmd, citeStyleList);
+
+       if (cs.hasStarredVersion) {
+               docstring starred = _("All authors|h");
+               // Check if we have a custom string/tooltip for the starred version
+               if (!cs.stardesc.empty()) {
+                       string val =
+                               bp.documentClass().getCiteMacro(buf->params().citeEngineType(), cs.stardesc);
+                       if (!val.empty())
+                               starred = translateIfPossible(from_utf8(val));
+                       // Transform qt-style accelerators to menu-style
+                       int const amps = count_char(starred, '&');
+                       if (amps > 0) {
+                               if (amps > 1)
+                                       starred = subst(starred, from_ascii("&&"), from_ascii("<:amp:>"));
+                               size_t n = starred.find('&');
+                               char_type accel = char_type();
+                               if (n != docstring::npos && n < starred.size() - 1)
+                                       accel = starred[n + 1];
+                               starred = subst(starred, from_ascii("&"), from_ascii(""));
+                               if (amps > 1)
+                                       starred = subst(starred, from_ascii("<:amp:>"), from_ascii("&&"));
+                               if (accel != char_type())
+                                       starred = starred + '|' + accel;
+                       }
+               }
+               add(MenuItem(MenuItem::Separator));
+               addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(starred),
+                                   FuncRequest(LFUN_INSET_MODIFY, "toggleparam star")));
+       }
+
+       if (cs.forceUpperCase) {
+               if (!cs.hasStarredVersion)
+                       add(MenuItem(MenuItem::Separator));
+               addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(_("Force upper case|u")),
+                                   FuncRequest(LFUN_INSET_MODIFY, "toggleparam casing")));
+       }
 }