]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Toolbars.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / Toolbars.cpp
index f83b57055756aada01822e9b1c18951ee539e0f3..f395e52a0a65b147859a54b7f698ceb1ad4a34de 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"
@@ -31,10 +33,6 @@ using namespace lyx::support;
 namespace lyx {
 namespace frontend {
 
-namespace {
-
-} // namespace anon
-
 
 /////////////////////////////////////////////////////////////////////////
 //
@@ -71,18 +69,28 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                TO_MINIBUFFER,
                TO_TABLEINSERT,
                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 },
-               { "tableinsert", TO_TABLEINSERT }
+               { "stickypopupmenu", TO_STICKYPOPUPMENU },
+               { "tableinsert", TO_TABLEINSERT },
+               { "updateformats", TO_UPDATEFORMATS },
+               { "viewformats", TO_VIEWFORMATS },
        };
 
        //consistency check
@@ -112,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());
@@ -146,6 +155,15 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                        }
                        break;
 
+               case TO_STICKYPOPUPMENU:
+                       if (lex.next(true)) {
+                               string const name = lex.getString();
+                               lex.next(true);
+                               docstring const label = lex.getDocString();
+                               add(ToolbarItem(ToolbarItem::STICKYPOPUPMENU, name, label));
+                       }
+                       break;
+
                case TO_ICONPALETTE:
                        if (lex.next(true)) {
                                string const name = lex.getString();
@@ -172,6 +190,53 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
                        quit = true;
                        break;
 
+               case TO_EXPORTFORMATS:
+               case TO_IMPORTFORMATS:
+               case TO_UPDATEFORMATS:
+               case TO_VIEWFORMATS: {
+                       vector<Format const *> formats = (code == TO_IMPORTFORMATS) ?
+                               theConverters().importableFormats() :
+                               theConverters().exportableFormats(code != TO_EXPORTFORMATS);
+                       sort(formats.begin(), formats.end());
+                       vector<Format const *>::const_iterator fit = formats.begin();
+                       vector<Format const *>::const_iterator end = formats.end();
+                       for (; fit != end ; ++fit) {
+                               if ((*fit)->dummy())
+                                       continue;
+                               if (code != TO_IMPORTFORMATS &&
+                                   !(*fit)->documentFormat())
+                                       continue;
+
+                               docstring const prettyname =
+                                       from_utf8((*fit)->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, (*fit)->name(),
+                                               FuncRequest::TOOLBAR);
+                               add(ToolbarItem(ToolbarItem::COMMAND, func,
+                                               bformat(tooltip, prettyname)));
+                       }
+                       break;
+               }
+
                default:
                        lex.printError("ToolbarInfo::read: "
                                       "Unknown toolbar tag: `$$Token'");
@@ -293,6 +358,8 @@ 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 {
                                LYXERR(Debug::ANY,
                                        "Toolbars::readToolbarSettings: unrecognised token:`"