reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 624d8f085d718a1ffcd46853e7862c520aca7fc9
parent 7d89929c1ca0e2154767681965fa7965a28e0fcb
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Fri, 15 Sep 2017 20:21:56 -0400

browser: add "Copy package name" action to context menu (equivalent to Ctrl+C)

Diffstat:
Msrc/browser.cpp | 24++++++++++++++++--------
Msrc/browser.hpp | 2++
2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/browser.cpp b/src/browser.cpp @@ -163,6 +163,9 @@ void Browser::onCommand(const int id, const int event) case ACTION_RESET_ALL: selectionDo(bind(&Browser::resetActions, this, _1)); break; + case ACTION_COPY: + copy(); + break; case ACTION_REFRESH: refresh(true); break; @@ -207,14 +210,8 @@ bool Browser::onKeyDown(const int key, const int mods) m_list->selectAll(); else if(mods == (CtrlModifier | ShiftModifier) && key == 'A') m_list->unselectAll(); - else if(mods == CtrlModifier && key == 'C') { - vector<string> values; - - for(const int index : m_list->selection(false)) - values.push_back(getEntry(index)->displayName()); - - setClipboard(values); - } + else if(mods == CtrlModifier && key == 'C') + copy(); else if(!mods && key == VK_F5) refresh(true); else @@ -249,6 +246,7 @@ bool Browser::fillContextMenu(Menu &menu, const int index) if(!menu.empty()) menu.addSeparator(); + menu.addAction("&Copy package name", ACTION_COPY); menu.addAction("&Select all", IDC_SELECT); menu.addAction("&Unselect all", IDC_UNSELECT); @@ -782,6 +780,16 @@ auto Browser::currentView() const -> View return (View)SendMessage(m_view, CB_GETCURSEL, 0, 0); } +void Browser::copy() +{ + vector<string> values; + + for(const int index : m_list->selection(false)) + values.push_back(getEntry(index)->displayName()); + + setClipboard(values); +} + bool Browser::confirm() const { // count uninstallation actions diff --git a/src/browser.hpp b/src/browser.hpp @@ -53,6 +53,7 @@ public: ACTION_ABOUT_PKG, ACTION_ABOUT_REMOTE, ACTION_RESET_ALL, + ACTION_COPY, ACTION_REFRESH, ACTION_MANAGE, }; @@ -108,6 +109,7 @@ private: void updateAction(const int index); void selectionDo(const std::function<void (int)> &); View currentView() const; + void copy(); bool confirm() const; bool apply();