commit 16e6a15bdd61659474cc241a413cb09f61371fdf
parent 963deac42029ab54e14f72800e324bf6e3be5ccf
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sat, 9 Apr 2016 00:25:59 -0400
browser: add selection-wide actions to the context menu when >1 package are selected
Diffstat:
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -125,7 +125,7 @@ void Browser::onCommand(const int id, const int event)
SetFocus(m_list->handle());
break;
case IDC_ACTION:
- selectionMenu();
+ actionButton();
break;
case ACTION_LATEST:
installLatest(m_currentIndex);
@@ -204,6 +204,10 @@ void Browser::onContextMenu(HWND target, const int x, const int y)
menu.show(x, y, handle());
return;
}
+ else if(m_list->selectionSize() > 1) {
+ selectionMenu(menu);
+ menu.addSeparator();
+ }
if(entry->test(InstalledFlag)) {
if(entry->test(OutOfDateFlag)) {
@@ -278,7 +282,15 @@ void Browser::onContextMenu(HWND target, const int x, const int y)
menu.show(x, y, handle());
}
-void Browser::selectionMenu()
+void Browser::selectionMenu(Menu &menu) const
+{
+ menu.addAction(AUTO_STR("&Install/update selection"), ACTION_LATEST_ALL);
+ menu.addAction(AUTO_STR("&Reinstall selection"), ACTION_REINSTALL_ALL);
+ menu.addAction(AUTO_STR("&Uninstall selection"), ACTION_UNINSTALL_ALL);
+ menu.addAction(AUTO_STR("&Clear queued action"), ACTION_RESET_ALL);
+}
+
+void Browser::actionButton()
{
RECT rect;
GetWindowRect(m_action, &rect);
@@ -288,11 +300,7 @@ void Browser::selectionMenu()
entry = getEntry(m_list->currentIndex());
Menu menu;
-
- menu.addAction(AUTO_STR("&Install/update selection"), ACTION_LATEST_ALL);
- menu.addAction(AUTO_STR("&Reinstall selection"), ACTION_REINSTALL_ALL);
- menu.addAction(AUTO_STR("&Uninstall selection"), ACTION_UNINSTALL_ALL);
- menu.addAction(AUTO_STR("&Clear queued action"), ACTION_RESET_ALL);
+ selectionMenu(menu);
if(!m_list->hasSelection())
menu.disableAll();
diff --git a/src/browser.hpp b/src/browser.hpp
@@ -32,6 +32,7 @@
class Index;
class ListView;
+class Menu;
class ReaPack;
class Version;
@@ -97,7 +98,8 @@ private:
std::string getValue(Column, const Entry &entry) const;
ListView::Row makeRow(const Entry &) const;
const Entry *getEntry(int) const;
- void selectionMenu();
+ void selectionMenu(Menu &) const;
+ void actionButton();
bool hasAction(const Entry *e) const { return m_actions.count(e) > 0; }
bool isTarget(const Entry *, const Version *) const;
void setAction(const int index, const Version *, bool toggle = true);