]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt/Menus.cpp
Fix broken Apple speller interface
[features.git] / src / frontends / qt / Menus.cpp
index 6d77c2e373d3181372299aaea98a8d6896e27f43..c69ba5f0bcdc7dacf88c7740b861b0ecbae0b5fc 100644 (file)
@@ -197,7 +197,9 @@ public:
                /** Commands to separate environments (context menu version). */
                EnvironmentSeparatorsContext,
                /** This is the list of quotation marks available */
-               SwitchQuotes
+               SwitchQuotes,
+               /** Options in the Zoom menu **/
+               ZoomOptions
        };
 
        explicit MenuItem(Kind kind) : kind_(kind), optional_(false) {}
@@ -374,6 +376,7 @@ public:
        void expandCaptions(Buffer const * buf, bool switchcap = false);
        void expandEnvironmentSeparators(BufferView const *, bool contextmenu = false);
        void expandQuotes(BufferView const *);
+       void expandZoomOptions(BufferView const *);
        ///
        ItemList items_;
        ///
@@ -489,7 +492,8 @@ void MenuDefinition::read(Lexer & lex)
                md_switchcaptions,
                md_env_separators,
                md_env_separatorscontext,
-               md_switchquotes
+               md_switchquotes,
+               md_zoomoptions
        };
 
        LexerKeyword menutags[] = {
@@ -530,7 +534,8 @@ void MenuDefinition::read(Lexer & lex)
                { "toc", md_toc },
                { "toolbars", md_toolbars },
                { "updateformats", md_updateformats },
-               { "viewformats", md_viewformats }
+               { "viewformats", md_viewformats },
+               { "zoomoptions", md_zoomoptions }
        };
 
        lex.pushTable(menutags);
@@ -687,6 +692,10 @@ void MenuDefinition::read(Lexer & lex)
                        add(MenuItem(MenuItem::SwitchQuotes));
                        break;
 
+               case md_zoomoptions:
+                       add(MenuItem(MenuItem::ZoomOptions));
+                       break;
+
                case md_optsubmenu:
                case md_submenu: {
                        lex.next(true);
@@ -848,7 +857,8 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
                                                                false,    // all words
                                                                true,     // forward
                                                                false,    // find next
-                                                               false))); // auto-wrap
+                                                               false,    // auto-wrap
+                                                               false))); // only selection
                                        if (i < m)
                                                add(w);
                                        else
@@ -861,26 +871,42 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
                                docstring const arg = wl.word() + " " + from_ascii(wl.lang()->lang());
                                add(MenuItem(MenuItem::Command, qt_("Add to personal dictionary|n"),
                                                FuncRequest(LFUN_SPELLING_ADD, arg)));
-                               add(MenuItem(MenuItem::Command, qt_("Ignore all|I"),
+                               add(MenuItem(MenuItem::Command, qt_("Ignore this occurrence|g"),
+                                               FuncRequest(LFUN_FONT_NO_SPELLCHECK, arg)));
+                               add(MenuItem(MenuItem::Command, qt_("Ignore all for this session|I"),
                                                FuncRequest(LFUN_SPELLING_IGNORE, arg)));
+                               add(MenuItem(MenuItem::Command, qt_("Ignore all in this document|d"),
+                                               FuncRequest(LFUN_SPELLING_ADD_LOCAL, arg)));
                        }
                }
                break;
+       case SpellChecker::WORD_OK: {
+                       if (wl.word().empty())
+                               break;
+                       SpellChecker * speller = theSpellChecker();
+                       if (speller && speller->canCheckParagraph())
+                               break;
+                       LYXERR(Debug::GUI, "Valid Word.");
+               }
+               // FALLTHROUGH
        case SpellChecker::LEARNED_WORD: {
-                       LYXERR(Debug::GUI, "Learned Word.");
+                       if (res == SpellChecker::LEARNED_WORD)
+                               LYXERR(Debug::GUI, "Learned Word.");
                        docstring const arg = wl.word() + " " + from_ascii(wl.lang()->lang());
                        add(MenuItem(MenuItem::Command, qt_("Remove from personal dictionary|r"),
                                        FuncRequest(LFUN_SPELLING_REMOVE, arg)));
                }
                break;
+       case SpellChecker::DOCUMENT_LEARNED_WORD: {
+                       LYXERR(Debug::GUI, "Document-Learned Word.");
+                       docstring const arg = wl.word() + " " + from_ascii(wl.lang()->lang());
+                       add(MenuItem(MenuItem::Command, qt_("Remove from document dictionary|r"),
+                                       FuncRequest(LFUN_SPELLING_REMOVE_LOCAL, arg)));
+               }
+               break;
        case SpellChecker::NO_DICTIONARY:
                LYXERR(Debug::GUI, "No dictionary for language " + from_ascii(wl.lang()->lang()));
                // FALLTHROUGH
-       case SpellChecker::WORD_OK:
-       case SpellChecker::COMPOUND_WORD:
-       case SpellChecker::ROOT_FOUND:
-       case SpellChecker::IGNORED_WORD:
-               break;
        }
 }
 
@@ -1281,8 +1307,7 @@ void MenuDefinition::expandToc2(Toc const & toc_list,
                                                label += QString::number(++shortcut_count);
                                }
                        }
-                       add(MenuItem(MenuItem::Command, label,
-                                           FuncRequest(toc_list[i].action())));
+                       add(MenuItem(MenuItem::Command, label, toc_list[i].action()));
                        // separator after the menu heading
                        if (toc_list[i].depth() < depth)
                                add(MenuItem(MenuItem::Separator));
@@ -1310,8 +1335,7 @@ void MenuDefinition::expandToc2(Toc const & toc_list,
                                break;
                        }
                        if (new_pos == pos + 1) {
-                               add(MenuItem(MenuItem::Command,
-                                                   label, FuncRequest(toc_list[pos].action())));
+                               add(MenuItem(MenuItem::Command, label, toc_list[pos].action()));
                        } else {
                                MenuDefinition sub;
                                sub.expandToc2(toc_list, pos, new_pos, depth + 1, toc_type);
@@ -1803,6 +1827,48 @@ void MenuDefinition::expandCaptions(Buffer const * buf, bool switchcap)
 }
 
 
+void MenuDefinition::expandZoomOptions(BufferView const * bv)
+{
+       if (!bv)
+               return;
+
+       add(MenuItem(MenuItem::Command,
+                    toqstr(bformat(_("Reset to Default (%1$d%)|R"),
+                                   lyxrc.defaultZoom)),
+                    FuncRequest(LFUN_BUFFER_ZOOM)));
+       add(MenuItem(MenuItem::Command, qt_("Zoom In|I"),
+                    FuncRequest(LFUN_BUFFER_ZOOM_IN)));
+       add(MenuItem(MenuItem::Command, qt_("Zoom Out|O"),
+                    FuncRequest(LFUN_BUFFER_ZOOM_OUT)));
+       add(MenuItem(MenuItem::Separator));
+       // Offer some fractional values of the default
+       int z = lyxrc.defaultZoom * 1.75;
+       add(MenuItem(MenuItem::Command,
+                    toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+                    FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+       z = lyxrc.defaultZoom * 1.5;
+       add(MenuItem(MenuItem::Command,
+                    toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+                    FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+       z = lyxrc.defaultZoom * 1.25;
+       add(MenuItem(MenuItem::Command,
+                    toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+                    FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+       z = lyxrc.defaultZoom * 0.75;
+       add(MenuItem(MenuItem::Command,
+                    toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+                    FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+       z = lyxrc.defaultZoom * 0.5;
+       add(MenuItem(MenuItem::Command,
+                    toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+                    FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+       z = lyxrc.defaultZoom * 0.25;
+       add(MenuItem(MenuItem::Command,
+                    toqstr(bformat(_("[[ZOOM]]%1$d%"), z)),
+                    FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(z))));
+}
+
+
 void MenuDefinition::expandQuotes(BufferView const * bv)
 {
        if (!bv)
@@ -2420,6 +2486,10 @@ void Menus::Impl::expand(MenuDefinition const & frommenu,
                        tomenu.expandQuotes(bv);
                        break;
 
+               case MenuItem::ZoomOptions:
+                       tomenu.expandZoomOptions(bv);
+                       break;
+
                case MenuItem::Submenu: {
                        MenuItem item(*cit);
                        item.setSubmenu(MenuDefinition(cit->submenuname()));