mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-24 11:22:07 +00:00
Add right-click menu to reorder or unpin favs
Right-clicking a fav tile now opens a small context menu with Move left, Move right, and Unpin, instead of relying on drag-only reorder. - speeddial.js: oncontextmenu handler, the menu build/position/dismiss logic, and an Escape-key close. - style.css: .ctx-menu/.ctx-item styling. - ActionRegistry: reorder_favourites persists the new bar order to AppConfig. - SpeedDialDialog: routes the new reorder_favourites command from the page.
This commit is contained in:
@@ -254,6 +254,23 @@ void ActionRegistry::set_favourite(const std::string& id, bool on)
|
||||
live->favourite = on;
|
||||
}
|
||||
|
||||
void ActionRegistry::reorder_favourites(const std::vector<std::string>& ids)
|
||||
{
|
||||
assert(wxThread::IsMain());
|
||||
auto cur = read_string_array("favourite_actions");
|
||||
std::vector<std::string> next;
|
||||
// keep the requested order, but only ids that are actually favourites (guard a bad payload)
|
||||
for (const auto& id : ids)
|
||||
if (std::find(cur.begin(), cur.end(), id) != cur.end() &&
|
||||
std::find(next.begin(), next.end(), id) == next.end())
|
||||
next.push_back(id);
|
||||
// why: don't drop favourites the page omitted (e.g. pins with no live action hidden from the bar)
|
||||
for (const auto& id : cur)
|
||||
if (std::find(next.begin(), next.end(), id) == next.end())
|
||||
next.push_back(id);
|
||||
write_section("favourite_actions", nlohmann::json(next));
|
||||
}
|
||||
|
||||
bool ActionRegistry::should_ask(const std::string& plugin_key) const
|
||||
{
|
||||
assert(wxThread::IsMain());
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
// Dispatch + write-through (registry is the only thing that touches AppConfig).
|
||||
ScriptRunOutcome run(const std::string& id); // runs + bumps stats
|
||||
void set_favourite(const std::string& id, bool on);
|
||||
void reorder_favourites(const std::vector<std::string>& ids); // persist a new bar order
|
||||
|
||||
bool should_ask(const std::string& plugin_key) const; // run-confirm gate
|
||||
void suppress_ask(const std::string& plugin_key);
|
||||
|
||||
@@ -189,6 +189,12 @@ private:
|
||||
send_actions();
|
||||
}
|
||||
else if (cmd == "toggle_favourite") wxGetApp().action_registry().set_favourite(p.value("id", ""), p.value("fav", false));
|
||||
else if (cmd == "reorder_favourites") {
|
||||
std::vector<std::string> ids;
|
||||
if (p.contains("ids") && p["ids"].is_array())
|
||||
for (auto& e : p["ids"]) if (e.is_string()) ids.push_back(e.get<std::string>());
|
||||
wxGetApp().action_registry().reorder_favourites(ids);
|
||||
}
|
||||
else if (cmd == "run_action") run_action(p.value("id", ""), p.value("title", ""));
|
||||
else if (cmd == "resize") resize_to_content(json_int_or(p, "height", 0));
|
||||
else if (cmd == "close_page") Dismiss();
|
||||
|
||||
Reference in New Issue
Block a user