]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Toolbars.cpp
rename buffer parameter math_number_before to math_numbering_side
[lyx.git] / src / frontends / qt4 / Toolbars.cpp
index 834c9ab3941a3b6b16e84e900110bc6f2751604d..2c0d2ab1a3a0a1abbc1191132cf8e53b1ff386aa 100644 (file)
@@ -12,6 +12,8 @@
 #include <config.h>
 
 #include "Toolbars.h"
+#include "Converter.h"
+#include "Format.h"
 #include "FuncRequest.h"
 #include "Lexer.h"
 #include "LyXAction.h"
@@ -21,8 +23,6 @@
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
-#include <boost/bind.hpp>
-
 #include <algorithm>
 
 using namespace std;
@@ -31,10 +31,6 @@ using namespace lyx::support;
 namespace lyx {
 namespace frontend {
 
-namespace {
-
-} // namespace anon
-
 
 /////////////////////////////////////////////////////////////////////////
 //
@@ -42,14 +38,16 @@ namespace {
 //
 /////////////////////////////////////////////////////////////////////////
 
-ToolbarItem::ToolbarItem(Type type, FuncRequest const & func, docstring const & label)
-       : type_(type), func_(func), label_(label)
+ToolbarItem::ToolbarItem(Type type, FuncRequest const & func,
+                         docstring const & label)
+       : type_(type), func_(make_shared<FuncRequest>(func)), label_(label)
 {
 }
 
 
-ToolbarItem::ToolbarItem(Type type, string const & name, docstring const & label)
-       : type_(type), label_(label), name_(name)
+ToolbarItem::ToolbarItem(Type type, string const & name,
+                         docstring const & label)
+       : type_(type), func_(make_shared<FuncRequest>()), label_(label), name_(name)
 {
 }
 
@@ -57,7 +55,7 @@ ToolbarItem::ToolbarItem(Type type, string const & name, docstring const & label
 void ToolbarInfo::add(ToolbarItem const & item)
 {
        items.push_back(item);
-       items.back().func_.origin = FuncRequest::TOOLBAR;
+       items.back().func_->setOrigin(FuncRequest::TOOLBAR);
 }
 
 
@@ -73,18 +71,26 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                TO_POPUPMENU,
                TO_STICKYPOPUPMENU,
                TO_ICONPALETTE,
+               TO_EXPORTFORMATS,
+               TO_IMPORTFORMATS,
+               TO_UPDATEFORMATS,
+               TO_VIEWFORMATS
        };
 
        struct LexerKeyword toolTags[] = {
                { "end", TO_ENDTOOLBAR },
+               { "exportformats", TO_EXPORTFORMATS },
                { "iconpalette", TO_ICONPALETTE },
+               { "importformats", TO_IMPORTFORMATS },
                { "item", TO_COMMAND },
                { "layouts", TO_LAYOUTS },
                { "minibuffer", TO_MINIBUFFER },
                { "popupmenu", TO_POPUPMENU },
                { "separator", TO_SEPARATOR },
                { "stickypopupmenu", TO_STICKYPOPUPMENU },
-               { "tableinsert", TO_TABLEINSERT }
+               { "tableinsert", TO_TABLEINSERT },
+               { "updateformats", TO_UPDATEFORMATS },
+               { "viewformats", TO_VIEWFORMATS },
        };
 
        //consistency check
@@ -114,7 +120,8 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                lex.printTable(lyxerr);
 
        while (lex.isOK() && !quit) {
-               switch (lex.lex()) {
+               int const code = lex.lex();
+               switch (code) {
                case TO_COMMAND:
                        if (lex.next(true)) {
                                docstring const tooltip = translateIfPossible(lex.getDocString());
@@ -147,7 +154,7 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                                add(ToolbarItem(ToolbarItem::POPUPMENU, name, label));
                        }
                        break;
-               
+
                case TO_STICKYPOPUPMENU:
                        if (lex.next(true)) {
                                string const name = lex.getString();
@@ -183,6 +190,50 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                        quit = true;
                        break;
 
+               case TO_EXPORTFORMATS:
+               case TO_IMPORTFORMATS:
+               case TO_UPDATEFORMATS:
+               case TO_VIEWFORMATS: {
+                       FormatList formats = (code == TO_IMPORTFORMATS) ?
+                               theConverters().importableFormats() :
+                               theConverters().exportableFormats(true);
+                       sort(formats.begin(), formats.end());
+                       for (Format const * f : formats) {
+                               if (f->dummy())
+                                       continue;
+                               if (code != TO_IMPORTFORMATS &&
+                                   !f->documentFormat())
+                                       continue;
+
+                               docstring const prettyname = f->prettyname();
+                               docstring tooltip;
+                               FuncCode lfun = LFUN_NOACTION;
+                               switch (code) {
+                               case TO_EXPORTFORMATS:
+                                       lfun = LFUN_BUFFER_EXPORT;
+                                       tooltip = _("Export %1$s");
+                                       break;
+                               case TO_IMPORTFORMATS:
+                                       lfun = LFUN_BUFFER_IMPORT;
+                                       tooltip = _("Import %1$s");
+                                       break;
+                               case TO_UPDATEFORMATS:
+                                       lfun = LFUN_BUFFER_UPDATE;
+                                       tooltip = _("Update %1$s");
+                                       break;
+                               case TO_VIEWFORMATS:
+                                       lfun = LFUN_BUFFER_VIEW;
+                                       tooltip = _("View %1$s");
+                                       break;
+                               }
+                               FuncRequest func(lfun, f->name(),
+                                               FuncRequest::TOOLBAR);
+                               add(ToolbarItem(ToolbarItem::COMMAND, func,
+                                               bformat(tooltip, prettyname)));
+                       }
+                       break;
+               }
+
                default:
                        lex.printError("ToolbarInfo::read: "
                                       "Unknown toolbar tag: `$$Token'");
@@ -213,7 +264,7 @@ void Toolbars::readToolbars(Lexer & lex)
 {
        enum {
                TO_TOOLBAR = 1,
-               TO_ENDTOOLBARSET,
+               TO_ENDTOOLBARSET
        };
 
        struct LexerKeyword toolTags[] = {
@@ -294,6 +345,8 @@ void Toolbars::readToolbarSettings(Lexer & lex)
                                flag = MATHMACROTEMPLATE;
                        else if (!compare_ascii_no_case(*cit, "review"))
                                flag = REVIEW;
+                       else if (!compare_ascii_no_case(*cit, "minibuffer"))
+                               flag = MINIBUFFER;
                        else if (!compare_ascii_no_case(*cit, "top"))
                                flag = TOP;
                        else if (!compare_ascii_no_case(*cit, "bottom"))
@@ -304,6 +357,10 @@ void Toolbars::readToolbarSettings(Lexer & lex)
                                flag = RIGHT;
                        else if (!compare_ascii_no_case(*cit, "auto"))
                                flag = AUTO;
+                       else if (!compare_ascii_no_case(*cit, "samerow"))
+                               flag = SAMEROW;
+                       else if (!compare_ascii_no_case(*cit, "ipa"))
+                               flag = IPA;
                        else {
                                LYXERR(Debug::ANY,
                                        "Toolbars::readToolbarSettings: unrecognised token:`"
@@ -314,7 +371,7 @@ void Toolbars::readToolbarSettings(Lexer & lex)
                }
                toolbar_visibility_[name] = visibility;
 
-               if (visibility >= MATH) {
+               if (visibility & ALLOWAUTO) {
                        if (ToolbarInfo const * ti = info(name))
                                const_cast<ToolbarInfo *>(ti)->gui_name +=
                                        " (" + _("auto") + ")";