Speed Dial: replace tile monograms with native SVG icons

Tiles previously rendered a colored monogram (title/source initials plus an ordinal) with a per-id hue. Show the matching native SVG icon instead:

- AppAction/NativeCommand gain an `icon` field; commands get a curated key->icon table and settings inherit their group header's icon.
- Notebook tracks each page's resource icon name and reports it in tab_options(), so the tab picker can show it too.
- Searcher records the group icon so settings keep it through search.
- Web tile rendering swaps monogramFor/hue for an <img>; drop the now-unused hue/text CSS vars. Add a test asserting every non-empty icon resolves to a shipped SVG.
This commit is contained in:
Lam Wei Lun
2026-09-11 11:36:24 +08:00
parent 792ab183e4
commit 42bee12481
15 changed files with 231 additions and 82 deletions
+43
View File
@@ -3,6 +3,8 @@
#include "slic3r/GUI/ActionRegistry.hpp"
#include "slic3r/GUI/NativeCommands.hpp"
#include <boost/filesystem.hpp>
#include <memory>
#include <set>
#include <string>
@@ -113,6 +115,47 @@ TEST_CASE("Native command catalog has unique keys and present titles", "[speeddi
}
}
// Every command's tile pictogram is the SVG the matching GUI control already uses; an absent icon
// means a blank tile (like the tab picker). Guard representative names and that every non-empty
// value resolves to a shipped file, so a rename/typo cannot leave broken images in the palette.
TEST_CASE("Native command icons resolve to shipped SVGs", "[speeddial][actions]")
{
const std::vector<Slic3r::GUI::NativeCommand>& commands = Slic3r::GUI::NativeCommands::catalog();
auto icon_of = [&commands](const std::string& key) -> const std::string* {
for (const auto& c : commands)
if (c.key == key)
return &c.icon;
return nullptr;
};
struct Expected
{
const char* key;
const char* icon;
};
for (const Expected& e : {Expected{"load_project", "menu_open"},
Expected{"save_project", "menu_save"},
Expected{"sync_ams", "ams_fila_sync"},
Expected{"mode_simple", "advanced"},
Expected{"calib_temperature", "calib_sf"},
Expected{"plate_add", "toolbar_add_plate"},
Expected{"add_primitive_cube", "menu_obj_cube"},
Expected{"go_to_tab", ""}}) {
const std::string* icon = icon_of(e.key);
INFO(e.key);
REQUIRE(icon != nullptr);
CHECK(*icon == e.icon);
}
const boost::filesystem::path images = boost::filesystem::path(PROFILES_DIR).parent_path() / "images";
for (const auto& c : commands) {
if (c.icon.empty())
continue;
INFO(c.key << " -> " << c.icon);
CHECK(boost::filesystem::exists(images / (c.icon + ".svg")));
}
}
// The Help-menu commands, wiki/YouTube links and the developer-mode toggle are part of the palette.
// Guard their presence and that they stay grouped with their peers, so a catalog edit cannot drop
// or scatter them. Groups are compared to the peer's own group to stay independent of translation.