mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-16 12:21:11 +00:00
* Add orca-translations Claude skill and PO tool
Add a .claude skill that guides translation passes over the localization/i18n gettext catalogs. It covers the workflow: run gettext, settle new glossary terms, translate in batches, verify, and report.
Includes translation-rules.md, which condenses the placeholder, line-break and glossary rules plus the guidance on review notes.
Also adds scripts/po_tool.py (standard library only). It lists pending entries with glossary hints, validates and applies translations, adding '# AI Translated' and '# Needs human review' comments, and rewrites only the entries it changes. It can also check catalogs, look up existing translations, suggest glossary candidates and update the wiki glossary TSV.
* Let po_tool apply translations by entry id
pending now gives each entry a short id, so a translation file can name
entries by id instead of repeating the English msgid. apply accepts either.
A "review": "" item clears an earlier review note when overwriting an
entry, and check gives each msgfmt run its own temporary output file so
parallel checks do not collide.
* Fill all empty translations
Regenerate the template with run_gettext --full and translate every empty
entry in the 22 catalogs (7,089 entries) with the orca-translations skill,
following the localization glossary, including the new belt printer,
IDEX/IQEX and plugin terms. Every new entry is marked "# AI Translated";
122 also carry "# Needs human review" with what to check.
* Show entry ids in po_tool lookup and search translations
lookup now prints each entry's id, so an entry found there can be
rewritten with apply --overwrite without repeating the English, and
--msgstr searches the translations instead of the msgids, which finds
every entry that still uses a term being changed.
SKILL.md describes how to change an established term: check the
catalog's usage first, update the glossary cell, then rewrite only the
entries where the term has that meaning.
* Fix mistranslated terms and align catalogs with the glossary
Correct labels that the glossary had copied, and the entries that used
them:
- ca: Raft was rendered as the Brim term; it is now "Rai". Exhaust fan,
Monotonic line, Unretract, Slice, Lateral Honeycomb and PA Tower
labels fixed.
- cs: Lightning infill is "Blesk", not "Osvětlení" (illumination).
- sv: Retraction is "Retraktion", not "Reduktion"; Unretract,
Lagerhöjd, Delkylningsfläkt, Utsugsfläkt, Aligned Rectilinear and the
Preset label fixed.
- de: Brim is "Rand" and Skirt is "Umrandung", as most entries already
had them.
- lt: brim entries used the Skirt word "apvadas"; they now use "kraštas".
- es: Sparse infill is "relleno de baja densidad", the catalog majority.
- eu: nozzle wipe is "garbiketa", not purge.
- th: the project plate is "เพลต", distinct from the bed.
- uk: Quarter Cubic, Latin "PA" in PA Tower, and Belt purge tower.
- pl: Cross Hatch, Tri-hexagon, Volumetric speed and Raft labels.
- zh_TW: Brim stays "Brim", as the existing labels have it.
- tr: "Prime Tower" read "Prime Minister Tower".
- ko: the plugin "Capabilities" label read "performance".
- Build Volume labels fixed in tr, de, cs and eu.
All 242 rewritten entries are marked "# AI Translated".
* Make more UI text translatable and fix pluralization and context
Audit the sources for text that translators could not translate
correctly and fix it.
Mark text that reached users in English only: IDEX/IQEX role names,
plugin permission prompts and errors, 3MF/preset loading errors, G-code
placeholder parser errors, calibration and device messages, notification
texts, file dialog filters, and the config validation messages.
Replace sentences built from translated fragments, such as the prime
tower warnings, "left"/"right" nozzle names, and "Filament " + number,
with single msgids that have placeholders, so translators can reorder
and inflect them.
Use plural forms for texts with a count ("%1% mixed filaments",
"%d objects", "%1% triangles") instead of "(s)" and mismatched verbs.
Fix the swapped singular/plural pair in "The following presets inherit
this preset".
Add translation contexts where one English word has several meanings
(Subscribed/Local, Standard, Pause, View, Step, Model, Camera, Flow,
Filter, Others, Prepare, the Design tools). Show "Size" instead of
"Build Volume" in the Cut tool, which displays the object size.
Fix code that compared translated text with English (the Edit G-code
dialog group, the plugin registration failure check), and add the
bundled web pages' missing string-table entries. Use the single
character for degrees Celsius, say "G-code", and describe the head
filament map without internal jargon.
Install the libslic3r translate callback before the presets load, so
their load errors are translated, and list the 28 source files that had
marked strings but were never extracted into localization/i18n/list.txt.
* Suggest earlier translations and list fuzzy entries in po_tool pending
pending now attaches the closest earlier translation of a similar
English text (from obsolete or translated entries), so a reworded or
split string keeps its wording, and it lists fuzzy entries by default,
since users never see them. A fuzzy entry also carries its stale
translation as previous_translation.
* Fix wording of the non-boolean operands error
The logical operation error said "operators" where it means the
operands the operation was applied to.
* Translate the newly translatable strings in all languages
Regenerate the template after the translatability changes and fill every
new or changed entry in the 22 catalogs (about 12,800 entries): the
strings that became translatable, the plural forms, the entries split by
context, and the previously fuzzy singular entries that became plurals.
Every new entry is marked "# AI Translated", and about 360 also carry a
"# Needs human review" note saying what to check. Terms follow the
localization glossary. Earlier translations of reworded strings were
reused where the meaning was unchanged. Existing entries were not
changed, and obsolete entries are kept.
* Document the source translatability audit in the orca-translations skill
Add a reference describing how strings reach translators, what to look
for (untranslated text, spliced sentences, missing plurals, ambiguous
words), what not to translate, where a context cannot be carried, and
what to do after the edits, plus a scanner that lists untranslated
user-facing string literals.
* Document how to write translatable strings in AGENTS.md
Tell developers to keep each message complete in one msgid: use
placeholders instead of concatenating translated fragments, plural forms
for counts, and contexts for ambiguous words, and to list new source
files in localization/i18n/list.txt. Add a matching code review item.
* Translate the strings added since the rebase
Regenerate the template against the current main and translate the 26
new entries per language: the Fix Model commands and messages, and the
texture displacement image adjustment panel. Each new entry is marked
"# AI Translated"; existing entries are unchanged.
* tidy
444 lines
18 KiB
C++
444 lines
18 KiB
C++
#include "SpeedDialDialog.hpp"
|
|
|
|
#include "ActionRegistry.hpp"
|
|
#include "GUI.hpp"
|
|
#include "GUI_App.hpp"
|
|
#include "I18N.hpp"
|
|
#include "MainFrame.hpp"
|
|
#include "MsgDialog.hpp"
|
|
#include "NotificationManager.hpp"
|
|
#include "Plater.hpp"
|
|
#include "Widgets/WebViewHostDialog.hpp"
|
|
|
|
#include "slic3r/Utils/MacDarkMode.hpp"
|
|
|
|
#include <algorithm>
|
|
|
|
#include "libslic3r/Config.hpp"
|
|
#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp"
|
|
#include <string>
|
|
#include <wx/chartype.h>
|
|
#include <atomic>
|
|
#include <vector>
|
|
#include <utility>
|
|
#include <wx/dcmemory.h>
|
|
#include <wx/display.h>
|
|
#include <wx/event.h>
|
|
#include <wx/gdicmn.h>
|
|
#include <wx/frame.h>
|
|
#include <wx/nonownedwnd.h>
|
|
#include <wx/region.h>
|
|
#include <wx/sizer.h>
|
|
#include <wx/stattext.h>
|
|
#include <wx/string.h>
|
|
#include <wx/utils.h>
|
|
#include <wx/webview.h>
|
|
|
|
#ifdef __linux__
|
|
#include <gtk/gtk.h>
|
|
#endif
|
|
|
|
namespace Slic3r { namespace GUI {
|
|
|
|
namespace {
|
|
|
|
// ADJUST WIDTH HERE (DIP px). Fixed dialog width; was 360, now 1.5x. Height is not set here -
|
|
// the dialog auto-resizes to the page content (see resize_to_content + the list max-height in style.css).
|
|
constexpr int kPopupWidth = 540;
|
|
constexpr int kPopupMinHeight = 60; // just above the bare search-bar height, so the dialog hugs content
|
|
constexpr int kPopupMaxHeight = 282;
|
|
|
|
int json_int_or(const nlohmann::json& j, const char* key, int fallback)
|
|
{
|
|
auto it = j.find(key);
|
|
return it != j.end() && it->is_number() ? it->get<int>() : fallback;
|
|
}
|
|
|
|
// Display name of a settings mode, for the mode-switch confirmation.
|
|
wxString mode_label(ConfigOptionMode mode)
|
|
{
|
|
switch (mode) {
|
|
case comAdvanced: return _L_CONTEXT("Advanced", "Settings Mode");
|
|
case comExpert: return _L_CONTEXT("Expert", "Settings Mode");
|
|
case comDevelop: return _L_CONTEXT("Developer", "Settings Mode");
|
|
default: return _L_CONTEXT("Simple", "Settings Mode");
|
|
}
|
|
}
|
|
|
|
wxColour bg_color() { return wxGetApp().get_window_default_clr(); }
|
|
|
|
// Give the WebKitGTK widget itself input focus, not its GtkScrolledWindow container.
|
|
// (browser()->SetFocus() grabs focus on the container and doesn't reach the web content,
|
|
// so typing only works after the user clicks.) On Linux the native backend is the
|
|
// WebKitWebView widget; grab focus there directly. Elsewhere SetFocus() is correct.
|
|
void focus_webview(wxWebView* browser, bool page_ready)
|
|
{
|
|
if (!browser)
|
|
return;
|
|
#ifdef __linux__
|
|
if (void* nb = browser->GetNativeBackend())
|
|
gtk_widget_grab_focus((GtkWidget*) nb);
|
|
#else
|
|
browser->SetFocus();
|
|
#endif
|
|
if (page_ready)
|
|
browser->RunScript("focusInput();");
|
|
}
|
|
|
|
// Localized strings for the Speed Dial page (see WebViewHostDialog::localized_strings). The page's own T()
|
|
// reads them; its JS literals are only a fallback before the script runs / in the node vm test.
|
|
// %% is a literal '%': T() collapses it after substituting %s. Keep the shortcut tokens out of the
|
|
// translated text so the platform prefix (Alt+/⌥+, Ctrl+/⌘+) stays correct.
|
|
nlohmann::json speed_dial_ui_strings()
|
|
{
|
|
const std::string alt = GUI::shortkey_alt_prefix();
|
|
const std::string ctrl = GUI::shortkey_ctrl_prefix();
|
|
return {
|
|
// TRN Screen-reader label of a Speed Dial action: the first %s is the action name, the second where it comes from (a menu, tab or settings group). Keep the two %s in this order.
|
|
{"sd_action_from", _u8L("%s from %s")},
|
|
{"shortcut_alt", alt},
|
|
{"shortcut_ctrl", ctrl},
|
|
|
|
{"sd_search", _u8L("Search actions")},
|
|
{"sd_clear", _u8L("Clear")},
|
|
{"sd_recent", _u8L("Recent")},
|
|
{"sd_plugins", _u8L("Plugins")},
|
|
{"sd_other", _u8L("Other")},
|
|
{"sd_no_match_total", _u8L("No actions match (Total: %s)")},
|
|
{"sd_no_actions", _u8L("No actions yet")},
|
|
{"sd_no_tabs_match", _u8L("No tabs match")},
|
|
{"sd_no_tabs", _u8L("No tabs")},
|
|
{"sd_result_count", _u8L("Matching actions: %s")},
|
|
{"sd_result_count_all", _u8L("Actions: %s")},
|
|
{"sd_tab_count", _u8L("Tabs: %s")},
|
|
{"sd_tab_match_count", _u8L("Matching tabs: %s")},
|
|
{"sd_favs_full", _u8L("Favorites are full (%s max)")},
|
|
{"sd_go_to_pct", _u8L("Go to %s%% of the layer range")},
|
|
{"sd_enter_pct", _u8L("Enter a layer percentage (0-100)")},
|
|
{"sd_go_layer_ph", _u8L("Go to layer %% (0-100)")},
|
|
{"sd_go_tab_ph", _u8L("Go to tab")},
|
|
{"sd_fav_slot", _u8L("Favorite %s (%s)")},
|
|
{"sd_pin_fav", _u8L("Pin to favorites (%s)")},
|
|
{"sd_unpin_fav", _u8L("Unpin from favorites (%s)")},
|
|
{"sd_remove_fav", _u8L("Remove from favorites")},
|
|
{"sd_move_left", _u8L("Move left")},
|
|
{"sd_move_right", _u8L("Move right")},
|
|
{"sd_unpin", _u8L("Unpin")},
|
|
{"sd_mode_advanced", _u8L_CONTEXT("Advanced", "Settings Mode")},
|
|
{"sd_mode_expert", _u8L_CONTEXT("Expert", "Settings Mode")},
|
|
{"sd_mode_develop", _u8L_CONTEXT("Developer", "Settings Mode")},
|
|
{"sd_wiki_f1", _u8L("Wiki (F1)")},
|
|
{"sd_no_wiki", _u8L("No wiki page for this action")},
|
|
{"sd_show_details", _u8L("Show details")},
|
|
{"sd_hide_details", _u8L("Hide details")},
|
|
};
|
|
}
|
|
|
|
} // namespace
|
|
|
|
SpeedDialWebDialog::SpeedDialWebDialog(wxWindow* parent)
|
|
: WebViewHostDialog(parent,
|
|
wxID_ANY,
|
|
wxEmptyString,
|
|
wxDefaultPosition,
|
|
wxDefaultSize,
|
|
wxBORDER_NONE | wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT | wxFRAME_SHAPED)
|
|
{
|
|
SetBackgroundColour(bg_color());
|
|
Bind(wxEVT_ACTIVATE, [this](wxActivateEvent& event) {
|
|
// Focus the WebKit widget exactly when the WM makes the popup the active window
|
|
// (modeless focus is granted asynchronously, so a focus request made right after
|
|
// Show() is dropped). Also re-corrects focus on every re-open.
|
|
if (event.GetActive() && IsShown())
|
|
focus_webview(browser(), m_page_ready);
|
|
else if (!event.GetActive() && IsShown())
|
|
Hide();
|
|
event.Skip();
|
|
});
|
|
if (!create_webview("web/dialog/SpeedDial/index.html", wxEmptyString, wxSize(kPopupWidth, kPopupMaxHeight),
|
|
wxSize(kPopupWidth, kPopupMinHeight))) {
|
|
auto* sizer = new wxBoxSizer(wxVERTICAL);
|
|
sizer->Add(new wxStaticText(this, wxID_ANY, _L("Web view is unavailable.")), wxSizerFlags().Border(wxALL, 20));
|
|
SetSizer(sizer);
|
|
SetClientSize(FromDIP(wxSize(kPopupWidth, kPopupMinHeight)));
|
|
}
|
|
// WebView2's browser accelerator keys include Ctrl +/-/0 and Ctrl+wheel zoom, which would resize
|
|
// the page inside the fixed-size popup. No-op on the other backends (wxWidgets 3.3 base virtual).
|
|
if (wxWebView* wv = browser())
|
|
wv->EnableBrowserAcceleratorKeys(false);
|
|
// Re-cut the shape whenever layout changes the client size. wxOSX SetShape resizes the
|
|
// NSWindow, which fires this synchronously; apply_rounded_shape() guards re-entry.
|
|
Bind(wxEVT_SIZE, [this](wxSizeEvent& event) {
|
|
event.Skip();
|
|
apply_rounded_shape();
|
|
});
|
|
apply_rounded_shape();
|
|
}
|
|
|
|
SpeedDialWebDialog::~SpeedDialWebDialog() { m_alive->store(false, std::memory_order_release); }
|
|
|
|
nlohmann::json SpeedDialWebDialog::localized_strings() const { return speed_dial_ui_strings(); }
|
|
|
|
void SpeedDialWebDialog::request_show()
|
|
{
|
|
if (IsShown()) {
|
|
Raise();
|
|
focus_webview(browser(), m_page_ready);
|
|
repaint_webview();
|
|
return;
|
|
}
|
|
|
|
Show();
|
|
Raise();
|
|
apply_rounded_shape();
|
|
if (m_page_ready)
|
|
send_actions();
|
|
// Grab focus now and again on wxEVT_ACTIVATE; grabbing directly on the WebKit widget is
|
|
// what makes typing reach the search field immediately on open.
|
|
focus_webview(browser(), m_page_ready);
|
|
repaint_webview();
|
|
}
|
|
|
|
void SpeedDialWebDialog::on_script_message(const nlohmann::json& payload)
|
|
{
|
|
if (handle_common_script_command(payload))
|
|
return;
|
|
|
|
// Defer command handling out of the webview script-message callback: GTK and macOS deliver
|
|
// it synchronously inside the native webview callback, and window work on that stack is the
|
|
// crash class fixed in b779a7bfed/f2ccbfc8b5 (see PluginsDialog::on_script_message).
|
|
// run_action puts a modal confirm on that stack, which is the same bug.
|
|
wxGetApp().CallAfter([this, alive = m_alive, payload]() {
|
|
if (alive->load(std::memory_order_acquire))
|
|
handle_web_command(payload);
|
|
});
|
|
}
|
|
|
|
void SpeedDialWebDialog::handle_web_command(const nlohmann::json& payload)
|
|
{
|
|
const std::string command = payload.value("command", "");
|
|
if (command == "request_actions") {
|
|
m_page_ready = true;
|
|
send_actions();
|
|
} else if (command == "toggle_favourite") {
|
|
// set_favourite() refuses once the bar hits kFavLimit; tell the page so it can undo the
|
|
// pin and show a "favourites are full" hint instead of silently losing the favourite.
|
|
const std::string fav_id = payload.value("id", "");
|
|
const bool ok = wxGetApp().action_registry().set_favourite(fav_id, payload.value("fav", false));
|
|
if (!ok)
|
|
call_web_handler({{"command", "favourite_full"}, {"limit", (int) ActionRegistry::kFavLimit}, {"id", fav_id}});
|
|
} else if (command == "reorder_favourites") {
|
|
std::vector<std::string> ids;
|
|
if (payload.contains("ids") && payload["ids"].is_array())
|
|
for (const auto& id : payload["ids"])
|
|
if (id.is_string())
|
|
ids.push_back(id.get<std::string>());
|
|
wxGetApp().action_registry().reorder_favourites(ids);
|
|
} else if (command == "set_tooltip_expanded")
|
|
wxGetApp().action_registry().set_tooltip_expanded(payload.value("expanded", true));
|
|
else if (command == "run_action")
|
|
run_action(payload.value("id", ""), payload.value("title", ""), payload.value("param", ""));
|
|
else if (command == "open_wiki")
|
|
open_wiki(payload.value("id", ""));
|
|
else if (command == "search_tabs")
|
|
search_tabs();
|
|
else if (command == "resize")
|
|
resize_to_content(json_int_or(payload, "height", 0));
|
|
}
|
|
|
|
void SpeedDialWebDialog::search_tabs()
|
|
{
|
|
// Round-trip is async because the webview delivers script messages synchronously on the
|
|
// GTK/macOS stack; defer the (cheap) enumeration and push the result back to the page.
|
|
wxGetApp().CallAfter([this, alive = m_alive]() {
|
|
if (!alive->load(std::memory_order_acquire))
|
|
return;
|
|
auto tabs = wxGetApp().action_registry().tab_options();
|
|
call_web_handler({{"command", "tab_results"}, {"tabs", std::move(tabs)}});
|
|
});
|
|
}
|
|
|
|
void SpeedDialWebDialog::resize_to_content(int height)
|
|
{
|
|
if (height <= 0)
|
|
return;
|
|
|
|
int display_index = wxDisplay::GetFromWindow(this);
|
|
if (display_index == wxNOT_FOUND)
|
|
display_index = 0;
|
|
const int screen_dip = ToDIP(wxDisplay(display_index).GetClientArea().GetHeight());
|
|
const int max_dip = std::max(kPopupMinHeight, screen_dip * 85 / 100);
|
|
const int height_dip = std::max(kPopupMinHeight, std::min(height, max_dip));
|
|
SetClientSize(FromDIP(wxSize(kPopupWidth, height_dip)));
|
|
Layout();
|
|
#ifdef __WXOSX__
|
|
// WKWebView can lag the dialog's new client size; force the viewport to match so the page is
|
|
// never painted (and clipped by the rounded layer) below the footer. Unconditional: on a
|
|
// re-open the size is often unchanged, and skipping the sync leaves the fresh render unpainted.
|
|
if (wxWebView* wv = browser())
|
|
wv->SetSize(GetClientSize());
|
|
#endif
|
|
apply_rounded_shape();
|
|
// A re-open re-renders at (usually) the same size, so nothing above may generate damage.
|
|
// Repaint explicitly so the newly rendered list is shown without needing user input.
|
|
repaint_webview();
|
|
}
|
|
|
|
void SpeedDialWebDialog::repaint_webview()
|
|
{
|
|
wxWebView* wv = browser();
|
|
if (!wv)
|
|
return;
|
|
// Portable invalidate; the platform blocks below reach the widget/layer that actually paints.
|
|
wv->Refresh();
|
|
#ifdef __WXOSX__
|
|
if (void* nb = wv->GetNativeBackend())
|
|
WKWebView_force_display(nb);
|
|
wv->Update();
|
|
#elif defined(__linux__)
|
|
// WebKitGTK's WebKitWebView owns its own GdkWindow, so invalidating the wxWebView wrapper
|
|
// (the GtkScrolledWindow) does not redraw it.
|
|
if (void* nb = wv->GetNativeBackend())
|
|
gtk_widget_queue_draw((GtkWidget*) nb);
|
|
#else
|
|
wv->Update();
|
|
#endif
|
|
}
|
|
|
|
// Rounded corners: the webview paints an opaque rectangle, so round the whole top-level window.
|
|
// GTK/MSW use a shape region (same mask trick as FilamentPickerDialog, binary edges, no
|
|
// anti-aliasing); macOS clips the native view layer instead, since SetShape cannot shape there.
|
|
void SpeedDialWebDialog::apply_rounded_shape()
|
|
{
|
|
// wxOSX SetShape resizes the NSWindow (setContentSize 10x10 then back), which synchronously
|
|
// fires wxEVT_SIZE -> apply_rounded_shape() -> SetShape() and recurses until the stack
|
|
// overflows. GTK/MSW set a region without resizing, so they are unaffected.
|
|
if (m_applying_shape)
|
|
return;
|
|
|
|
// BORDER_NONE means the window is all client area, so the client size is the shape size.
|
|
const wxSize size = GetClientSize();
|
|
if (size.GetWidth() <= 0 || size.GetHeight() <= 0)
|
|
return;
|
|
|
|
m_applying_shape = true;
|
|
|
|
#ifdef __WXOSX__
|
|
// wxOSX ignores the region (it only clears the window background), so round the native view.
|
|
set_window_corner_radius(this, FromDIP(m_corner_radius));
|
|
#else
|
|
m_shape_bmp.Create(size.GetWidth(), size.GetHeight(), 32);
|
|
if (m_shape_bmp.IsOk()) {
|
|
wxMemoryDC dc;
|
|
dc.SelectObject(m_shape_bmp);
|
|
dc.SetBackground(wxBrush(wxColour(0, 0, 0)));
|
|
dc.Clear();
|
|
dc.SetBrush(wxBrush(wxColour(255, 255, 255, 255)));
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
dc.DrawRoundedRectangle(0, 0, size.GetWidth(), size.GetHeight(), FromDIP(m_corner_radius));
|
|
dc.SelectObject(wxNullBitmap);
|
|
|
|
wxRegion region(m_shape_bmp, wxColour(0, 0, 0));
|
|
if (region.IsOk())
|
|
SetShape(region);
|
|
}
|
|
#endif
|
|
|
|
m_applying_shape = false;
|
|
}
|
|
|
|
void SpeedDialWebDialog::on_dpi_changed(const wxRect&)
|
|
{
|
|
apply_rounded_shape();
|
|
Refresh();
|
|
}
|
|
|
|
void SpeedDialWebDialog::run_action(const std::string& id, const std::string& title, const std::string& param)
|
|
{
|
|
ActionRegistry& reg = wxGetApp().action_registry();
|
|
const AppAction* a = reg.by_id(id);
|
|
if (!a)
|
|
return;
|
|
|
|
// Only plugin actions get the "Run plugin?" confirm. Built-in commands act immediately.
|
|
const bool ask = a->kind == AppActionKind::Plugin && reg.should_ask(id);
|
|
const std::string atitle = a->title();
|
|
const ConfigOptionMode required = a->required_mode;
|
|
|
|
// Settings the current mode hides require a switch first. Ask while the dial is still up; a
|
|
// cancel dismisses both (the dial also auto-hides when the modal takes activation).
|
|
if (requires_mode_switch(required, wxGetApp().get_mode())) {
|
|
const wxString setting = title.empty() ? from_u8(atitle) : from_u8(title);
|
|
if (required == comDevelop) {
|
|
RichMessageDialog dlg(wxGetApp().mainframe,
|
|
wxString::Format(_L("\"%s\" is a Developer setting. Enable Developer mode to edit it?"), setting),
|
|
_L("Developer setting"), wxOK | wxCANCEL);
|
|
if (dlg.ShowModal() != wxID_OK)
|
|
return;
|
|
wxGetApp().enable_developer_mode();
|
|
} else {
|
|
RichMessageDialog dlg(wxGetApp().mainframe,
|
|
wxString::Format(_L("\"%s\" is a %s setting. Switch from %s mode to %s mode to edit it?"), setting,
|
|
mode_label(required), mode_label(wxGetApp().get_mode()), mode_label(required)),
|
|
_L("Switch settings mode"), wxOK | wxCANCEL);
|
|
if (dlg.ShowModal() != wxID_OK)
|
|
return;
|
|
wxGetApp().save_mode(required);
|
|
}
|
|
}
|
|
|
|
if (IsModal())
|
|
EndModal(wxID_CANCEL);
|
|
else
|
|
Hide();
|
|
|
|
if (ask) {
|
|
const wxString label = title.empty() ? from_u8(atitle) : from_u8(title);
|
|
RichMessageDialog dlg(wxGetApp().mainframe, wxString::Format(_L("Run \"%s\"?"), label), _L("Run plugin"), wxOK | wxCANCEL);
|
|
dlg.ShowCheckBox(_L("Don't ask again for this action"));
|
|
if (dlg.ShowModal() != wxID_OK)
|
|
return;
|
|
if (dlg.IsCheckBoxChecked())
|
|
wxGetApp().action_registry().suppress_ask(id);
|
|
}
|
|
|
|
wxGetApp().CallAfter([id, param] {
|
|
if (wxGetApp().is_closing())
|
|
return;
|
|
AppActionRunResult result = wxGetApp().action_registry().run(id, param);
|
|
if (result.level == AppActionRunResult::Level::Busy)
|
|
return;
|
|
if (!result.message.IsEmpty() && wxGetApp().plater())
|
|
wxGetApp()
|
|
.plater()
|
|
->get_notification_manager()
|
|
->push_notification(NotificationType::CustomNotification,
|
|
result.level == AppActionRunResult::Level::Error ?
|
|
NotificationManager::NotificationLevel::ErrorNotificationLevel :
|
|
NotificationManager::NotificationLevel::RegularNotificationLevel,
|
|
into_u8(result.message));
|
|
});
|
|
}
|
|
|
|
void SpeedDialWebDialog::open_wiki(const std::string& id)
|
|
{
|
|
const AppAction* a = wxGetApp().action_registry().by_id(id);
|
|
if (!a || a->help_url.empty())
|
|
return;
|
|
Hide();
|
|
wxLaunchDefaultBrowser(from_u8(a->help_url));
|
|
}
|
|
|
|
void SpeedDialWebDialog::send_actions()
|
|
{
|
|
nlohmann::json snap = wxGetApp().action_registry().snapshot();
|
|
call_web_handler({{"command", "list_actions"},
|
|
{"actions", std::move(snap["actions"])},
|
|
{"favourites", std::move(snap["favourites"])},
|
|
{"recent", std::move(snap["recent"])},
|
|
{"user_mode", std::move(snap["user_mode"])},
|
|
{"tooltip_expanded", std::move(snap["tooltip_expanded"])}});
|
|
}
|
|
|
|
}} // namespace Slic3r::GUI
|