]> git.lyx.org Git - lyx.git/commitdiff
Make "paste recent" accessible from toolbar
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 26 Dec 2018 16:11:24 +0000 (17:11 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 26 Dec 2018 16:11:24 +0000 (17:11 +0100)
via button menu

lib/ui/stdtoolbars.inc
src/frontends/qt4/GuiToolbar.cpp
src/frontends/qt4/GuiToolbar.h

index 412d5647f8577d70ff86fa67015529ea3a4285ab..4d862d8387bbc4eb641274c5d9309d1e999ce2bd 100644 (file)
@@ -79,7 +79,7 @@ ToolbarSet
                Item "Redo" "redo"
                Item "Cut" "cut"
                Item "Copy" "copy"
-               Item "Paste" "paste"
+               DynamicMenu "paste" "Paste"
                Item "Find and replace" "dialog-show findreplace"
                Item "Find and replace (advanced)" "dialog-toggle findreplaceadv"
                Item "Navigate back" "bookmark-goto 0"
index ea2683b371ca6102b4566ae60579952112d3bae5..8966bcfdebbcca24eded1577472f185427a9c7b3 100644 (file)
@@ -22,6 +22,7 @@
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "Cursor.h"
+#include "CutAndPaste.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "GuiApplication.h"
@@ -43,6 +44,7 @@
 
 #include "support/convert.h"
 #include "support/debug.h"
+#include "support/docstring_list.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
@@ -321,7 +323,8 @@ bool DynamicMenuButton::isMenuType(string const & s)
 {
        return s == "dynamic-custom-insets"
                || s == "dynamic-char-styles"
-               || s == "dynamic-freefonts";
+               || s == "dynamic-freefonts"
+               || s == "paste";
 }
 
 
@@ -385,6 +388,32 @@ void DynamicMenuButton::updateTriggered()
                }
                setPopupMode(QToolButton::DelayedPopup);
                setEnabled(lyx::getStatus(FuncRequest(LFUN_TEXTSTYLE_APPLY)).enabled());
+       } else if (menutype == "paste") {
+               m->clear();
+               docstring_list const sel = cap::availableSelections(&bv->buffer());
+
+               docstring_list::const_iterator cit = sel.begin();
+               docstring_list::const_iterator end = sel.end();
+
+               Action * default_act = nullptr;
+               for (unsigned int index = 0; cit != end; ++cit, ++index) {
+                       docstring const s = *cit;
+                       FuncRequest func(LFUN_PASTE, convert<docstring>(index),
+                                        FuncRequest::TOOLBAR);
+                       docstring const lb = char_type('&') + convert<docstring>(index)
+                               + from_ascii(". ") + s ;
+                       Action * act = new Action(func, QIcon(), toqstr(lb), toqstr(s), this);
+                       m->addAction(act);
+                       // The most recent one is the default
+                       if (index == 0)
+                               default_act = act;
+               }
+               Action * default_action = new Action(FuncRequest(LFUN_PASTE),
+                                                    getIcon(FuncRequest(LFUN_PASTE), false),
+                                                    qt_("Paste"), qt_("Paste"), this);
+               QToolButton::setDefaultAction(default_action);
+               setPopupMode(QToolButton::DelayedPopup);
+               setEnabled(lyx::getStatus(FuncRequest(LFUN_PASTE)).enabled());
        }
 }
 
index da09bbfbbff5f52ae456674a30cafde27aee6059..8d82f538e337288f703ce2d2a52db5ec23a3e495 100644 (file)
@@ -87,6 +87,7 @@ protected Q_SLOTS:
 ///            dynamic-custom-insets
 ///            dynamic-char-styles
 ///            dynamic-freefonts
+///            paste
 /// To add a new one of these, you must add a routine, like 
 /// loadFlexInsets, that will populate the menu, and call it from
 /// updateTriggered. Make sure to add the new type to isMenuType().