OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::PresetBundleDialog Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/PresetBundleDialog.hpp>

Inheritance diagram for Slic3r::GUI::PresetBundleDialog:
Collaboration diagram for Slic3r::GUI::PresetBundleDialog:

Public Member Functions

 PresetBundleDialog (wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxT(""), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX)
 ~PresetBundleDialog ()
void create ()
bool DeleteBundleById (const wxString &id)
bool UnsubscribeBundleById (const std::string &id)
bool seq_top_layer_only_changed () const
bool recreate_GUI () const
void ListBundles ()
void OpenFolder (const std::string &id)
void DeleteBundle (const std::string &id)
void UnsubscribeBundle (const std::string &id)
void OpenBundleOnCloud (const std::string &id)
void OnPresetBundlePage ()
void on_script_message (const nlohmann::json &payload) override
nlohmann::json localized_strings () const override
void StartDialogWorker ()
void StopDialogWorker ()
void RefreshBundleMap ()
bool CheckUpdateCloud ()
void OnBundleUpdate (wxCommandEvent &evt)
bool CompareVer (const std::string &a, const std::string &b)
bool create_webview (const std::string &resource_path, const wxString &title, const wxSize &dialog_size=wxSize(820, 660), const wxSize &min_size=wxSize(640, 640))
void load_url (const wxString &url)
bool run_script (const wxString &script)
void call_web_handler (const nlohmann::json &payload, const wxString &handler=wxT("HandleStudio"))
void EndModal (int retCode) override
float scale_factor () const
float prev_scale_factor () const
void set_scale_factor (float v)
void set_prev_scale_factor (float v)
void set_em_unit (int v)
bool force_rescale () const
int em_unit () const
const wxFont & normal_font () const
void enable_force_rescale ()
int ShowModal ()

Static Public Member Functions

static std::string document_start_injector (const std::string &markup, const char *dom_id, const char *position, const std::string &prelude={}, const std::string &on_inject={})
static std::string theme_user_script ()
static std::string element_defaults_user_script ()
static std::string theme_apply_script ()
static std::string localized_strings_script (const nlohmann::json &strings)

Protected Member Functions

void OnFSWatch (wxFileSystemWatcherEvent &e)
wxWebView * browser () const
wxString build_resource_url (const std::string &resource_path) const
bool handle_common_script_command (const nlohmann::json &payload, int close_return_code=wxID_CANCEL)
void on_dpi_changed (const wxRect &suggested_rect) override
virtual void on_script_message_parse_error (const wxString &payload, const std::exception &error)
virtual bool append_language_to_url () const
void register_theme_user_scripts ()
virtual void add_user_scripts ()
void apply_theme_live ()
virtual void on_sys_color_changed ()

Protected Attributes

wxFileSystemWatcher * m_watcher = nullptr
bool m_seq_top_layer_only_changed {false}
bool m_recreate_GUI {false}
std::unordered_map< std::string, BundleMetadata > bundle_copy
boost::thread m_dialog_worker_thread
std::shared_ptr< int > m_dialog_worker_token
std::atomic< bool > m_check_update_pending {false}
std::atomic< bool > m_update_bundles {false}

Private Member Functions

void on_script_message_event (wxWebViewEvent &event)
void on_webview_recreated (wxCommandEvent &event)
void update_em_unit ()
bool is_new_scale_factor () const
void rescale (const wxRect &suggested_rect)

Private Attributes

Slic3r::AppConfig * app_config
wxWebView * m_browser {nullptr}
float m_scale_factor
int m_em_unit
wxFont m_normal_font
float m_prev_scale_factor
bool m_can_rescale
bool m_force_rescale
int m_new_font_point_size

Detailed Description

Constructor & Destructor Documentation

◆ PresetBundleDialog()

Slic3r::GUI::PresetBundleDialog::PresetBundleDialog ( wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxString & title = wxT(""),
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxMAXIMIZE_BOX )
41 : WebViewHostDialog(parent, id, _L("PresetBundle"), pos, size, style)
42{
43 wxGetApp().preset_bundle->bundles.PauseRead(); // for the entirety of the preset bundle dialog, we want the update thread to yield.
44 create();
45 wxGetApp().UpdateDlgDarkUI(this);
46
47 m_watcher = new wxFileSystemWatcher();
48 m_watcher->SetOwner(this);
49
50 Bind(wxEVT_FSWATCHER, &PresetBundleDialog::OnFSWatch, this);
51 Bind(EVT_UPDATE_BUNDLE_COMPLETE, &PresetBundleDialog::OnBundleUpdate, this);
52
53 m_watcher->Add(wxFileName(wxGetApp().preset_bundle->dir_user_presets_local.c_str())); // _local
54 m_watcher->Add(wxFileName(wxGetApp().preset_bundle->dir_user_presets_subscribed.c_str())); // _subscribed
55
57
58 StartDialogWorker(); // start worker thread;
59}
#define _L(s)
Definition OBJ.cpp:34
#define style
Definition WipeTowerDialog.cpp:101
wxFileSystemWatcher * m_watcher
Definition PresetBundleDialog.hpp:82
void create()
Definition PresetBundleDialog.cpp:204
void RefreshBundleMap()
Definition PresetBundleDialog.cpp:197
void StartDialogWorker()
Definition PresetBundleDialog.cpp:81
void OnFSWatch(wxFileSystemWatcherEvent &e)
Definition PresetBundleDialog.cpp:71
void OnBundleUpdate(wxCommandEvent &evt)
Definition PresetBundleDialog.cpp:191
WebViewHostDialog(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxT(""), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxRESIZE_BORDER)
Definition WebViewHostDialog.cpp:161

References Slic3r::GUI::WebViewHostDialog::WebViewHostDialog(), _L, create(), m_watcher, OnBundleUpdate(), OnFSWatch(), RefreshBundleMap(), StartDialogWorker(), and style.

Here is the call graph for this function:

◆ ~PresetBundleDialog()

Slic3r::GUI::PresetBundleDialog::~PresetBundleDialog ( )
62{
64 wxGetApp().preset_bundle->bundles.UnpauseRead(); // yield for update thread
65 if (m_watcher) {
66 m_watcher->RemoveAll();
67 delete m_watcher;
68 }
69}
void StopDialogWorker()
Definition PresetBundleDialog.cpp:178

References m_watcher, and StopDialogWorker().

Here is the call graph for this function:

Member Function Documentation

◆ add_user_scripts()

virtual void Slic3r::GUI::WebViewHostDialog::add_user_scripts ( )
inlineprotectedvirtualinherited

Reimplemented in Slic3r::GUI::ColorPickerDialog, and Slic3r::GUI::WebDialog.

95{}

Referenced by register_theme_user_scripts().

Here is the caller graph for this function:

◆ append_language_to_url()

virtual bool Slic3r::GUI::WebViewHostDialog::append_language_to_url ( ) const
inlineprotectedvirtualinherited

Reimplemented in Slic3r::GUI::WebDialog.

84{ return true; }

Referenced by build_resource_url().

Here is the caller graph for this function:

◆ apply_theme_live()

void Slic3r::GUI::WebViewHostDialog::apply_theme_live ( )
protectedinherited
300{
301 if (!m_browser)
302 return;
303 // Update the already-loaded document in place (no reload, no flash) by rewriting the
304 // injected :root variables + data-orca-theme; the whole cascade re-flows from these.
305 // The document-start script keeps the creation-time theme for any later reload, and
306 // these dialogs are not reloaded on a theme toggle (see WebView::RecreateAll).
307 run_script(wxString::FromUTF8(host_theme_apply_js()));
308}
bool run_script(const wxString &script)
Definition WebViewHostDialog.cpp:234
wxWebView * m_browser
Definition WebViewHostDialog.hpp:109
std::string host_theme_apply_js()
Definition WebViewHostDialog.cpp:73

References m_browser, and run_script().

Referenced by on_webview_recreated().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser()

◆ build_resource_url()

wxString Slic3r::GUI::WebViewHostDialog::build_resource_url ( const std::string & resource_path) const
protectedinherited
210{
211 wxString target_url = file_url_from_path(boost::filesystem::path(resources_dir()) / resource_path);
212
214 const wxString lang = wxGetApp().current_language_code_safe();
215 if (!lang.empty()) {
216 target_url += wxT("?lang=");
217 target_url += lang;
218 }
219 }
220
221 return target_url;
222}
virtual bool append_language_to_url() const
Definition WebViewHostDialog.hpp:84
wxString file_url_from_path(const boost::filesystem::path &path)
Definition GUI.cpp:569
const std::string & resources_dir()
Definition utils.cpp:296

References append_language_to_url(), Slic3r::GUI::file_url_from_path(), and Slic3r::resources_dir().

Referenced by create_webview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ call_web_handler()

void Slic3r::GUI::WebViewHostDialog::call_web_handler ( const nlohmann::json & payload,
const wxString & handler = wxT("HandleStudio") )
inherited
243{
244 const wxString payload_text = wxString::FromUTF8(payload.dump(-1, ' ', false, nlohmann::json::error_handler_t::ignore));
245 const wxString script = handler + wxT("(") + payload_text + wxT(")");
246
247 wxGetApp().CallAfter([this, script] { run_script(script); });
248}

References run_script().

Referenced by Slic3r::GUI::SpeedDialWebDialog::handle_web_command(), Slic3r::GUI::PresetBundleDialog::ListBundles(), Slic3r::GUI::ExportPresetBundleDialog::OnRequestPresets(), Slic3r::GUI::WebDialog::push_message(), Slic3r::GUI::TerminalDialog::resolve_and_run(), Slic3r::GUI::PluginsDialog::restore_capability_config(), Slic3r::GUI::PluginsDialog::save_capability_config(), Slic3r::GUI::SpeedDialWebDialog::search_tabs(), Slic3r::GUI::SpeedDialWebDialog::send_actions(), Slic3r::GUI::PluginsConfigDialog::send_capabilities(), Slic3r::GUI::PluginsConfigDialog::send_capability_config(), Slic3r::GUI::PluginsDialog::send_capability_config(), Slic3r::GUI::PluginsDialog::send_plugins(), Slic3r::GUI::PluginsConfigDialog::send_save_error(), Slic3r::GUI::PluginsConfigDialog::show_status(), and Slic3r::GUI::PluginsDialog::show_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckUpdateCloud()

bool Slic3r::GUI::PresetBundleDialog::CheckUpdateCloud ( )
127{
128 bool has_update = false;
129 if (!wxGetApp().getAgent() || !wxGetApp().getAgent()->is_user_login())
130 return false;
131 auto orca_agent = std::dynamic_pointer_cast<OrcaCloudServiceAgent>(wxGetApp().getAgent()->get_cloud_agent());
132 if (!orca_agent)
133 return false;
134
135 BOOST_LOG_TRIVIAL(info) << "Preset Bundle Dialog: checking for bundle updates";
136
137 // Fetch all subscribed bundles from cloud
138 std::vector<std::pair<std::string, std::string>> subscribed_bundles;
139 std::vector<std::string> notfound;
140 std::vector<std::string> unauthorized;
141 int result = orca_agent->get_subscribed_bundles(&subscribed_bundles, notfound, unauthorized);
142
143 if (result != 0) {
144 BOOST_LOG_TRIVIAL(warning) << "Preset Bundle Dialog: failed to fetch subscribed bundles, result=" << result;
145 return false;
146 }
147
148 // if unauthorized or not found it should be a warning icon to the ui shit
149
150 // check bundle copy with the subscribed bundles
151 for (auto& b : subscribed_bundles) {
152 if (bundle_copy.find(b.first) != bundle_copy.end()) {
153 if (CompareVer(bundle_copy[b.first].version, b.second)) {
154 bundle_copy[b.first].update_available = true;
155 bundle_copy[b.first].unauthorized = false;
156 has_update = true;
157
158 } else {
159 // we count it as an update to the UI if we need to update the unauthorized state
160 if (bundle_copy[b.first].unauthorized) {
161 bundle_copy[b.first].unauthorized = false;
162 has_update = true;
163 }
164 bundle_copy[b.first].update_available = false;
165 }
166 }
167 }
168
169 for (auto& a : unauthorized) {
170 if (bundle_copy.find(a) != bundle_copy.end()) {
171 bundle_copy[a].unauthorized = true;
172 has_update = true;
173 }
174 }
175 return has_update;
176}
std::unordered_map< std::string, BundleMetadata > bundle_copy
Definition PresetBundleDialog.hpp:90
bool CompareVer(const std::string &a, const std::string &b)
Definition PresetBundleDialog.cpp:109

References bundle_copy, and CompareVer().

Referenced by StartDialogWorker().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompareVer()

bool Slic3r::GUI::PresetBundleDialog::CompareVer ( const std::string & a,
const std::string & b )
110{
111 // Compare versions using Semver
112 auto local_version = Semver::parse(a);
113 auto remote_version = Semver::parse(b);
114
115 if (!local_version || !remote_version) {
116 return false;
117 }
118
119 if (local_version < remote_version) {
120 return true;
121 }
122
123 return false;
124}
static boost::optional< Semver > parse(const std::string &str)
Definition Semver.hpp:63

References Slic3r::Semver::parse().

Referenced by CheckUpdateCloud().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create()

void Slic3r::GUI::PresetBundleDialog::create ( )
205{
207 create_webview("web/dialog/PresetBundleDialog/index.html", _L("Preset Bundle"),
208 wxSize(820, 660), wxSize(640, 640));
209}
Slic3r::AppConfig * app_config
Definition PresetBundleDialog.hpp:98
bool create_webview(const std::string &resource_path, const wxString &title, const wxSize &dialog_size=wxSize(820, 660), const wxSize &min_size=wxSize(640, 640))
Definition WebViewHostDialog.cpp:172
AppConfig * get_app_config()
Definition GUI.cpp:539

References _L, app_config, Slic3r::GUI::WebViewHostDialog::create_webview(), and Slic3r::GUI::get_app_config().

Referenced by PresetBundleDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_webview()

bool Slic3r::GUI::WebViewHostDialog::create_webview ( const std::string & resource_path,
const wxString & title,
const wxSize & dialog_size = wxSize(820, 660),
const wxSize & min_size = wxSize(640, 640) )
inherited
176{
177 SetTitle(title);
178 SetMinSize(FromDIP(min_size));
179
180 const wxString target_url = build_resource_url(resource_path);
181 wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
182
183 // Created empty and loaded below, after the user scripts are added, so the first load already has them.
184 m_browser = WebView::CreateWebView(this, wxEmptyString);
185 if (m_browser == nullptr) {
186 wxLogError("Could not init m_browser");
187 delete topsizer;
188 return false;
189 }
190
191 SetSizer(topsizer);
192 topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
193
194 SetSize(FromDIP(dialog_size));
195 CenterOnParent();
196
197 Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &WebViewHostDialog::on_script_message_event, this, m_browser->GetId());
198
199 // Inject the shared host theme contract BEFORE the first load so the page paints in
200 // the app theme with no flash, and re-theme live when the app theme toggles.
202 m_browser->Bind(EVT_WEBVIEW_RECREATED, &WebViewHostDialog::on_webview_recreated, this);
203
204 load_url(target_url);
205 wxGetApp().UpdateDlgDarkUI(this);
206 return true;
207}
void on_webview_recreated(wxCommandEvent &event)
Definition WebViewHostDialog.cpp:310
wxString build_resource_url(const std::string &resource_path) const
Definition WebViewHostDialog.cpp:209
void register_theme_user_scripts()
Definition WebViewHostDialog.cpp:285
void on_script_message_event(wxWebViewEvent &event)
Definition WebViewHostDialog.cpp:274
void load_url(const wxString &url)
Definition WebViewHostDialog.cpp:224
static wxWebView * CreateWebView(wxWindow *parent, wxString const &url)
Definition WebView.cpp:313

References build_resource_url(), WebView::CreateWebView(), load_url(), m_browser, on_script_message_event(), on_webview_recreated(), and register_theme_user_scripts().

Referenced by Slic3r::GUI::ColorPickerDialog::ColorPickerDialog(), Slic3r::GUI::PluginsConfigDialog::PluginsConfigDialog(), Slic3r::GUI::PluginsDialog::PluginsDialog(), Slic3r::GUI::SpeedDialWebDialog::SpeedDialWebDialog(), Slic3r::GUI::TerminalDialog::TerminalDialog(), Slic3r::GUI::WebDialog::WebDialog(), Slic3r::GUI::PresetBundleDialog::create(), and Slic3r::GUI::ExportPresetBundleDialog::Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteBundle()

void Slic3r::GUI::PresetBundleDialog::DeleteBundle ( const std::string & id)
391{
392 if (id.empty())
393 return;
394
395 const int rc = wxMessageBox(_L("Delete selected bundle from folder and all presets loaded from it?"), _L("Delete Bundle"),
396 wxYES_NO | wxNO_DEFAULT | wxICON_WARNING, this);
397
398 if (rc != wxYES)
399 return;
400
401 if (!DeleteBundleById(id)) {
402 wxMessageBox(_L("Failed to remove bundle."), _L("Remove Bundle"), wxOK | wxICON_ERROR, this);
403 return;
404 }
405 wxGetApp().mainframe->update_side_preset_ui();
406}
bool DeleteBundleById(const wxString &id)
Definition PresetBundleDialog.cpp:236
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:273

References _L, DeleteBundleById(), and Slic3r::empty().

Referenced by on_script_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteBundleById()

bool Slic3r::GUI::PresetBundleDialog::DeleteBundleById ( const wxString & id)
237{
238 auto* b = wxGetApp().preset_bundle;
239 if (id.empty()) {
240 return false;
241 }
242
243 const std::string bundle_id = id.ToStdString();
244
245 wxGetApp().preset_bundle->bundles.ReadLock();
246 auto it = b->bundles.m_bundles.find(bundle_id);
247 if (it == b->bundles.m_bundles.end()) {
248 wxGetApp().preset_bundle->bundles.ReadUnlock();
249 return false;
250 }
251
252 const std::string metadata_path = it->second.path;
253 const boost::filesystem::path bundle_dir = boost::filesystem::path(metadata_path).parent_path();
254
255 const BundleType bundle_type = it->second.bundle_type;
256 wxGetApp().preset_bundle->bundles.ReadUnlock();
257
258 if (bundle_type == BundleType::Subscribed) {
259 // do unsubscribe before deleting locally
260 }
261
262 wxGetApp().preset_bundle->bundles.WriteLock();
263 b->bundles.m_bundles.erase(it);
264 wxGetApp().preset_bundle->bundles.WriteUnlock();
265
266 auto remove_from_collection = [&](PresetCollection& c) {
267 std::vector<std::string> to_delete;
268 for (const auto& p : c.get_presets()) {
269 if (p.bundle_id == bundle_id)
270 to_delete.push_back(p.name);
271 }
272 for (const auto& name : to_delete)
273 c.delete_preset(name);
274 };
275
276 remove_from_collection(b->prints);
277 remove_from_collection(b->filaments);
278 remove_from_collection(b->printers);
279
280 boost::system::error_code ec;
281 if (!bundle_dir.empty() && boost::filesystem::exists(bundle_dir))
282 boost::filesystem::remove_all(bundle_dir, ec);
283
284 wxGetApp().preset_bundle->update_compatible(PresetSelectCompatibleType::Always);
285
286 return true;
287}
BundleType
Definition PresetBundle.hpp:111
@ Subscribed
Definition PresetBundle.hpp:114
@ Always
Definition Preset.hpp:527

References Slic3r::Always, Slic3r::empty(), and Slic3r::Subscribed.

Referenced by DeleteBundle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ document_start_injector()

std::string Slic3r::GUI::WebViewHostDialog::document_start_injector ( const std::string & markup,
const char * dom_id,
const char * position,
const std::string & prelude = {},
const std::string & on_inject = {} )
staticinherited
135{
136 const std::string literal = nlohmann::json(markup).dump();
137 std::string s;
138 s += "(function(){";
139 // wxWebView's AddUserScript runs in child frames too (including cross-origin
140 // frames on WebView2). Host theme state belongs only to the top-level page.
141 s += "if(window.top!==window.self)return;";
142 s += prelude;
143 s += "var css=" + literal + ";";
144 s += "function inject(){";
145 s += "var root=document.head||document.documentElement;if(!root)return false;";
146 s += "if(!document.getElementById('" + std::string(dom_id) + "'))root.insertAdjacentHTML('" +
147 std::string(position) + "',css);";
148 s += on_inject;
149 s += "return true;}";
150 s += "if(inject())return;";
151 s += "var obs=new MutationObserver(function(){if(inject())obs.disconnect();});";
152 s += "obs.observe(document,{childList:true});})();";
153 return s;
154}

Referenced by element_defaults_user_script(), and theme_user_script().

Here is the caller graph for this function:

◆ element_defaults_user_script()

std::string Slic3r::GUI::WebViewHostDialog::element_defaults_user_script ( )
staticinherited
103{
104 std::string css;
105 css += "<style id=\"orca-plugin-defaults\">";
106 css += "html,body{background:var(--orca-bg);color:var(--orca-fg);"
107 "font-family:var(--orca-font);font-size:13px;}";
108 css += "body{margin:0;}";
109 css += "h1,h2,h3,h4,h5,h6{color:var(--orca-fg);font-weight:600;}";
110 css += "a{color:var(--orca-accent);}";
111 css += "hr{border:0;border-top:1px solid var(--orca-border);}";
112 css += "button{font:inherit;color:var(--orca-accent-fg);background:var(--orca-accent);"
113 "border:1px solid var(--orca-accent);border-radius:4px;padding:5px 14px;cursor:pointer;}";
114 css += "button:hover{filter:brightness(1.1);}";
115 css += "button:disabled{opacity:.5;cursor:default;}";
116 css += "input,select,textarea{font:inherit;color:var(--orca-fg);"
117 "background:var(--orca-bg);border:1px solid var(--orca-border);"
118 "border-radius:4px;padding:4px 8px;}";
119 css += "input:focus,select:focus,textarea:focus{outline:none;border-color:var(--orca-accent);}";
120 css += "table{border-collapse:collapse;}";
121 css += "th,td{text-align:left;padding:6px 10px;border-bottom:1px solid var(--orca-border);}";
122 css += "th{color:var(--orca-muted);font-weight:600;}";
123 css += "::-webkit-scrollbar{width:12px;height:12px;}";
124 css += "::-webkit-scrollbar-thumb{background:var(--orca-border);border-radius:6px;}";
125 css += "::-webkit-scrollbar-track{background:transparent;}";
126 css += "</style>";
127 return document_start_injector(css, "orca-plugin-defaults", "beforeend");
128}
static std::string document_start_injector(const std::string &markup, const char *dom_id, const char *position, const std::string &prelude={}, const std::string &on_inject={})
Definition WebViewHostDialog.cpp:130

References document_start_injector().

Referenced by Slic3r::GUI::WebPanel::WebPanel(), and Slic3r::GUI::WebDialog::add_user_scripts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ em_unit()

int Slic3r::GUI::DPIAware< wxDialog >::em_unit ( ) const
inlineinherited
203{ return m_em_unit; }
Definition GUI_Utils.hpp:107

Referenced by Slic3r::GUI::AuxiliaryDialog::AuxiliaryDialog(), Slic3r::GUI::CopyrightsDialog::CopyrightsDialog(), Slic3r::GUI::DesignTextDialog::DesignTextDialog(), Slic3r::GUI::EditGCodeDialog::EditGCodeDialog(), Slic3r::GUI::FileArchiveDialog::FileArchiveDialog(), Slic3r::GUI::MsgNoUpdates::MsgNoUpdates(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::OAuthDialog::OAuthDialog(), Slic3r::GUI::ParamsDialog::ParamsDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::SettingsDialog::SettingsDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), anonymous_namespace{3DPrinterOS.cpp}::UploadOptionsDialog::UploadOptionsDialog(), Slic3r::GUI::PublishSettingsDialog::add_row_ui(), Slic3r::GUI::DiffPresetDialog::complete_dialog_creation(), Slic3r::GUI::DiffPresetDialog::create_edit_sizer(), Slic3r::GUI::DiffPresetDialog::create_presets_sizer(), Slic3r::GUI::DiffPresetDialog::create_tree(), Slic3r::GUI::ElegooPrintHostSendDialog::init(), Slic3r::GUI::FlashforgePrintHostSendDialog::init(), Slic3r::GUI::PrintHostSendDialog::init(), Slic3r::GUI::AboutDialog::on_dpi_changed(), Slic3r::GUI::AuxiliaryDialog::on_dpi_changed(), Slic3r::GUI::BedShapeDialog::on_dpi_changed(), Slic3r::GUI::ConfigWizard::on_dpi_changed(), Slic3r::GUI::CopyrightsDialog::on_dpi_changed(), Slic3r::GUI::DiffPresetDialog::on_dpi_changed(), Slic3r::GUI::EditGCodeDialog::on_dpi_changed(), Slic3r::GUI::FileArchiveDialog::on_dpi_changed(), Slic3r::GUI::OAuthDialog::on_dpi_changed(), Slic3r::GUI::ObjectTableDialog::on_dpi_changed(), Slic3r::GUI::ParamsDialog::on_dpi_changed(), Slic3r::GUI::PhysicalPrinterDialog::on_dpi_changed(), Slic3r::GUI::PrintHostQueueDialog::on_dpi_changed(), Slic3r::GUI::PurgeModeDialog::on_dpi_changed(), Slic3r::GUI::SavePresetDialog::on_dpi_changed(), Slic3r::GUI::SendSystemInfoDialog::on_dpi_changed(), Slic3r::GUI::SettingsDialog::on_dpi_changed(), and Slic3r::GUI::UnsavedChangesDialog::on_dpi_changed().

Here is the caller graph for this function:

◆ enable_force_rescale()

void Slic3r::GUI::DPIAware< wxDialog >::enable_force_rescale ( )
inlineinherited
206{ m_force_rescale = true; }

◆ EndModal()

void Slic3r::GUI::DPIDialog::EndModal ( int retCode)
inlineoverrideinherited
306 {
307 if (!dialogStack.empty() && dialogStack.front() != this) {
308 // This is a bug in wxWidgets
309 // when the dialog is not top modal dialog, EndModal() just hide dialog without quit
310 // the modal event loop. And the modal event loop blocks us from bottom widgets.
311 // Solution: let user click it manually or close outside. FIXME
312 BOOST_LOG_TRIVIAL(warning) << "DPIAware::EndModal Error: dialogStack is not empty, but top dialog is not this one. retCode=" << retCode;
313 return;
314 }
315
316 return wxDialog::EndModal(retCode);
317 }
std::deque< wxDialog * > dialogStack
Definition GUI_Utils.cpp:549

References Slic3r::GUI::dialogStack.

Referenced by Slic3r::GUI::CloneDialog::CloneDialog(), Slic3r::GUI::ConfigWizard::ConfigWizard(), Slic3r::GUI::CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(), Slic3r::GUI::DeleteConfirmDialog::DeleteConfirmDialog(), Slic3r::GUI::DesignVariableDialog::DesignVariableDialog(), Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::FlashforgeSlotDialog(), Slic3r::GUI::GuideFrame::GuideFrame(), Slic3r::GUI::InputIpAddressDialog::InputIpAddressDialog(), Slic3r::GUI::ManualNozzleCountDialog::ManualNozzleCountDialog(), Slic3r::GUI::MsgUpdateConfig::MsgUpdateConfig(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::MultiChoiceDialog::MultiChoiceDialog(), Slic3r::GUI::NetworkErrorDialog::NetworkErrorDialog(), Slic3r::GUI::NetworkPluginRestartDialog::NetworkPluginRestartDialog(), Slic3r::GUI::PartSkipConfirmDialog::PartSkipConfirmDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::PlateNameEditDialog::PlateNameEditDialog(), Slic3r::GUI::PlateSettingsDialog::PlateSettingsDialog(), Slic3r::GUI::PublishSettingsDialog::PublishSettingsDialog(), Slic3r::GUI::SelectMachineDialog::SelectMachineDialog(), Slic3r::GUI::SendFailedConfirm::SendFailedConfirm(), Slic3r::GUI::SendSystemInfoDialog::SendSystemInfoDialog(), Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), Slic3r::GUI::SingleChoiceDialog::SingleChoiceDialog(), StepMeshDialog::StepMeshDialog(), Slic3r::GUI::SyncAmsInfoDialog::SyncAmsInfoDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), Slic3r::GUI::UpdatePluginDialog::UpdatePluginDialog(), Slic3r::GUI::UpdateVersionDialog::UpdateVersionDialog(), Slic3r::GUI::wgtDeviceNozzleRackUpgradeDlg::wgtDeviceNozzleRackUpgradeDlg(), Slic3r::GUI::SavePresetDialog::accept(), Slic3r::GUI::MsgDialog::add_button(), Slic3r::GUI::TipsDialog::add_button(), Slic3r::GUI::FilamentPickerDialog::BindEvents(), Slic3r::GUI::PluginPickerDialog::build_capability_ui(), Slic3r::GUI::BedShapeDialog::build_dialog(), Slic3r::GUI::PluginPickerDialog::build_ui(), Slic3r::GUI::UnsavedChangesDialog::close(), Slic3r::GUI::FileArchiveDialog::create_btn_sizer(), Slic3r::GUI::ColorDecomposeDialog::create_button_panel(), Slic3r::GUI::MixedFilamentDialog::create_button_panel(), Slic3r::GUI::CreateFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::CreatePresetForPrinterDialog::create_dialog_buttons(), Slic3r::GUI::EditFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::create_dialog_buttons(), Slic3r::GUI::PreferencesDialog::create_item_language_combobox(), Slic3r::GUI::PreferencesDialog::create_item_region_combobox(), Slic3r::GUI::PreferencesDialog::create_items(), Slic3r::GUI::CreatePrinterPresetDialog::create_page1_dialog_buttons(), Slic3r::GUI::CreatePrinterPresetDialog::create_page2_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::data_init(), Slic3r::GUI::WebDialog::destroy_silently(), Slic3r::GUI::EditFilamentPresetDialog::edit_preset(), Slic3r::GUI::ConnectPrinterDialog::end_modal(), Slic3r::GUI::PrintHostSendDialog::EndModal(), Slic3r::GUI::ColorPickerDialog::finish(), Slic3r::GUI::WebDialog::finish(), Slic3r::GUI::Newer3mfVersionDialog::get_btn_sizer(), Slic3r::GUI::ScoreDialog::get_button_sizer(), Slic3r::GUI::WebViewHostDialog::handle_common_script_command(), Slic3r::GUI::ExportPresetBundleDialog::InitExportData(), Slic3r::GUI::SelectMachineDialog::navigate_to_timelapse_page(), Slic3r::GUI::BindMachineDialog::on_bind_success(), Slic3r::GUI::ConnectPrinterDialog::on_button_confirm(), Slic3r::GUI::RecenterDialog::on_button_confirm(), Slic3r::GUI::BindMachineDialog::on_cancel(), Slic3r::GUI::EditCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::InputIpAddressDialog::on_cancel(), Slic3r::GUI::NewCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::OAuthDialog::on_cancel(), Slic3r::GUI::PingCodeBindDialog::on_cancel(), Slic3r::GUI::SelectMachineDialog::on_cancel(), Slic3r::GUI::SendToPrinterDialog::on_cancel(), Slic3r::GUI::SyncAmsInfoDialog::on_cancel(), Slic3r::GUI::UnBindMachineDialog::on_cancel(), Slic3r::GUI::WebDialog::on_close_window(), Slic3r::GUI::NetworkPluginDownloadDialog::on_dont_ask(), Slic3r::GUI::NetworkPluginDownloadDialog::on_download(), Slic3r::GUI::EditDevNameDialog::on_edit_name(), Slic3r::GUI::ConfirmBeforeSendDialog::on_hide(), Slic3r::GUI::PrivacyUpdateDialog::on_hide(), Slic3r::GUI::ShortcutCaptureDialog::on_key(), Slic3r::GUI::TextureImportDialog::on_ok_clicked(), Slic3r::GUI::FileArchiveDialog::on_open_button(), Slic3r::GUI::NetworkPluginDownloadDialog::on_remind_later(), Slic3r::GUI::ProjectDropDialog::on_select_cancel(), Slic3r::GUI::SavePresetDialog::on_select_cancel(), Slic3r::GUI::ProjectDropDialog::on_select_ok(), Slic3r::GUI::SendMultiMachinePage::on_send(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip(), Slic3r::GUI::TextureImportDialog::on_skip_clicked(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip_version(), Slic3r::GUI::Cornering_Test_Dlg::on_start(), Slic3r::GUI::FlowRateCalibrationDialog::on_start(), Slic3r::GUI::Input_Shaping_Damp_Test_Dlg::on_start(), Slic3r::GUI::Input_Shaping_Freq_Test_Dlg::on_start(), Slic3r::GUI::MaxVolumetricSpeed_Test_Dlg::on_start(), Slic3r::GUI::PA_Calibration_Dlg::on_start(), Slic3r::GUI::Retraction_Test_Dlg::on_start(), Slic3r::GUI::Temp_Calibration_Dlg::on_start(), Slic3r::GUI::VFA_Test_Dlg::on_start(), Slic3r::GUI::CalibrationDialog::on_start_calibration(), Slic3r::GUI::UnBindMachineDialog::on_unbind_printer(), Slic3r::GUI::PartSkipDialog::OnApplyDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::OnCancel(), Slic3r::GUI::AboutDialog::onCloseDialog(), Slic3r::GUI::CopyrightsDialog::onCloseDialog(), Slic3r::GUI::MultiNozzleSyncDialog::OnRackStatusReadingFinished(), Slic3r::GUI::GuideFrame::OnScriptMessage(), Slic3r::GUI::InputIpAddressDialog::OnTimer(), Slic3r::GUI::KBShortcutsDialog::open_mouse_preferences(), Slic3r::GUI::TroubleshootDialog::PackAll(), Slic3r::GUI::TroubleshootDialog::RebuildSystemProfiles(), Slic3r::GUI::SpeedDialWebDialog::run_action(), Slic3r::GUI::OAuthDialog::Show(), Slic3r::GUI::MultiNozzleSyncDialog::UpdateButton(), and Slic3r::GUI::CreatePrinterPresetDialog::validate_input_valid().

◆ force_rescale()

bool Slic3r::GUI::DPIAware< wxDialog >::force_rescale ( ) const
inlineinherited
201{ return m_force_rescale; }

◆ handle_common_script_command()

bool Slic3r::GUI::WebViewHostDialog::handle_common_script_command ( const nlohmann::json & payload,
int close_return_code = wxID_CANCEL )
protectedinherited
251{
252 const std::string command = payload.value("command", "");
253 if (command == "close_page") {
254 if (IsModal())
255 EndModal(close_return_code);
256 else
257 Close();
258 return true;
259 }
260
261 return false;
262}
void EndModal(int retCode) override
Definition GUI_Utils.hpp:305

References Slic3r::GUI::DPIDialog::EndModal().

Referenced by Slic3r::GUI::ExportPresetBundleDialog::on_script_message(), Slic3r::GUI::PluginsConfigDialog::on_script_message(), Slic3r::GUI::PluginsDialog::on_script_message(), Slic3r::GUI::PresetBundleDialog::on_script_message(), Slic3r::GUI::SpeedDialWebDialog::on_script_message(), Slic3r::GUI::TerminalDialog::on_script_message(), and Slic3r::GUI::WebDialog::on_script_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_new_scale_factor()

bool Slic3r::GUI::DPIAware< wxDialog >::is_new_scale_factor ( ) const
inlineprivateinherited
262{ return fabs(m_scale_factor - m_prev_scale_factor) > 0.001; }

◆ ListBundles()

void Slic3r::GUI::PresetBundleDialog::ListBundles ( )
331{
332 json res;
333 res["command"] = "list_bundles";
334 res["sequence_id"] = "2000";
335 res["data"] = json::array();
336
337 const auto& all_bundles = bundle_copy;
338
339 auto strip_prefix = [](const std::vector<std::string>& names) {
340 json arr = json::array();
341 for (const auto& name : names)
342 arr.push_back(boost::filesystem::path(name).filename().string());
343 return arr;
344 };
345
346 for (const auto& bundle : all_bundles) {
347 const auto& metadata = bundle.second;
348 json temp;
349 temp["id"] = metadata.id;
350 temp["name"] = metadata.name;
351 temp["type"] = metadata.bundle_type == Subscribed ? "Subscribed" : metadata.bundle_type == Local ? "Local" : "Default";
352 temp["author"] = metadata.author;
353 temp["version"] = metadata.version;
354 temp["description"] = metadata.description;
355 temp["path"] = metadata.path;
356
357 temp["printers"] = strip_prefix(metadata.printer_presets);
358 temp["filaments"] = strip_prefix(metadata.filament_presets);
359 temp["processes"] = strip_prefix(metadata.print_presets);
360
361 temp["update_available"] = metadata.update_available;
362 temp["unauthorized"] = metadata.unauthorized;
363 res["auto_update_enabled"] = app_config->get_bool("preset_bundle_auto_update");
364
365 res["data"].push_back(std::move(temp));
366 }
367
368 call_web_handler(res);
369}
void call_web_handler(const nlohmann::json &payload, const wxString &handler=wxT("HandleStudio"))
Definition WebViewHostDialog.cpp:242
nlohmann::json json
Definition AssembleList.cpp:42
@ Local
Definition PresetBundle.hpp:113

References app_config, bundle_copy, Slic3r::GUI::WebViewHostDialog::call_web_handler(), Slic3r::Local, and Slic3r::Subscribed.

Referenced by on_script_message(), and StartDialogWorker().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_url()

void Slic3r::GUI::WebViewHostDialog::load_url ( const wxString & url)
inherited
225{
226 if (!m_browser)
227 return;
228
229 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << " enter, url=" << into_u8(url);
231 m_browser->SetFocus();
232}
static void LoadUrl(wxWebView *webView, wxString const &url)
Definition WebView.cpp:480
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
void trace(unsigned int level, const char *message)
Definition utils.cpp:247

References Slic3r::GUI::into_u8(), WebView::LoadUrl(), m_browser, and Slic3r::trace().

Referenced by create_webview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ localized_strings()

nlohmann::json Slic3r::GUI::PresetBundleDialog::localized_strings ( ) const
overridevirtual

Reimplemented from Slic3r::GUI::WebViewHostDialog.

212{
213 return {
214 {"refresh", _u8L("Refresh")},
215 {"name", _u8L("Name")},
216 {"type", _u8L("Type")},
217 {"version", _u8L("Version")},
218 {"update", _u8L("Update")},
219 {"export_presets", _u8L("Export Presets")},
220 {"close", _u8L("Close")},
221 {"open_folder", _u8L("Show in folder")},
222 {"delete_bundle", _u8L("Delete bundle")},
223 {"unsubscribe_bundle", _u8L("Unsubscribe bundle")},
224 {"update_available", _u8L("Update available")},
225 {"unauthorized_bundle", _u8L("Unauthorized bundle")},
226 {"open_in_browser", _u8L("Open this bundle in your browser")},
227 {"type_subscribed", _u8L("Subscribed")},
228 {"type_local", _u8L("Local")},
229 {"type_default", _u8L("Default")},
230 {"printer", _u8L("Printer")},
231 {"filament", _u8L("Filament")},
232 {"process", _u8L("Process")},
233 };
234}
#define _u8L(s)
Definition I18N.hpp:11

References _u8L.

◆ localized_strings_script()

std::string Slic3r::GUI::WebViewHostDialog::localized_strings_script ( const nlohmann::json & strings)
staticinherited
157{
158 return "window.ORCA_UI_STRINGS = " + strings.dump(-1, ' ', false, nlohmann::json::error_handler_t::ignore) + ";";
159}

Referenced by Slic3r::GUI::GuideFrame::GuideFrame(), WipingDialog::WipingDialog(), Slic3r::GUI::add_page_strings(), Slic3r::GUI::ProjectPanel::create_browser(), Slic3r::GUI::WebViewPanel::create_browser(), and register_theme_user_scripts().

Here is the caller graph for this function:

◆ normal_font()

◆ on_dpi_changed()

void Slic3r::GUI::WebViewHostDialog::on_dpi_changed ( const wxRect & suggested_rect)
overrideprotectedvirtualinherited

Implements Slic3r::GUI::DPIAware< wxDialog >.

265{
266 Refresh();
267}

◆ on_script_message()

void Slic3r::GUI::PresetBundleDialog::on_script_message ( const nlohmann::json & payload)
overridevirtual

Implements Slic3r::GUI::WebViewHostDialog.

292{
294 return;
295
296 const std::string strCmd = j.value("command", "");
297 if (strCmd == "request_bundles") {
298 ListBundles();
299 } else if (strCmd == "refresh_bundles") {
300 m_check_update_pending.store(true, std::memory_order_relaxed);
301 } else if (strCmd == "update_bundle") {
302 std::string id = j.value("bundle_id", "");
303 auto* evt = new wxCommandEvent(EVT_UPDATE_PRESET_BUNDLE);
304 evt->SetString(wxString::FromUTF8(id));
305 wxQueueEvent(&wxGetApp(), evt);
306 } else if (strCmd == "set_auto_update") {
307 bool enabled = j.value("enabled", false);
308 app_config->set_bool("preset_bundle_auto_update", enabled ? true : false);
309 app_config->save();
310 } else if (strCmd == "export_page") {
311 wxGetApp().CallAfter([this]() {
312 ExportPresetBundleDialog dlg(this);
313 dlg.ShowModal();
314 });
315 } else if (strCmd == "top_row_menu_action") {
316 const std::string action = j.value("action", "");
317 const std::string id = j.value("bundle_id", "");
318 if (action == "open_folder")
319 OpenFolder(id);
320 else if (action == "delete_bundle")
321 DeleteBundle(id);
322 else if (action == "unsubscribe_bundle")
324 } else if (strCmd == "open_bundle_on_cloud") {
325 OpenBundleOnCloud(j.value("bundle_id", ""));
326 }
327}
void OpenFolder(const std::string &id)
Definition PresetBundleDialog.cpp:371
void DeleteBundle(const std::string &id)
Definition PresetBundleDialog.cpp:390
void UnsubscribeBundle(const std::string &id)
Definition PresetBundleDialog.cpp:408
std::atomic< bool > m_check_update_pending
Definition PresetBundleDialog.hpp:94
void OpenBundleOnCloud(const std::string &id)
Definition PresetBundleDialog.cpp:426
void ListBundles()
Definition PresetBundleDialog.cpp:330
bool handle_common_script_command(const nlohmann::json &payload, int close_return_code=wxID_CANCEL)
Definition WebViewHostDialog.cpp:250

References app_config, DeleteBundle(), Slic3r::GUI::WebViewHostDialog::handle_common_script_command(), ListBundles(), m_check_update_pending, OpenBundleOnCloud(), OpenFolder(), Slic3r::GUI::DPIAware< P >::ShowModal(), and UnsubscribeBundle().

Here is the call graph for this function:

◆ on_script_message_event()

void Slic3r::GUI::WebViewHostDialog::on_script_message_event ( wxWebViewEvent & event)
privateinherited
275{
276 const wxString payload = event.GetString();
277
278 try {
279 on_script_message(nlohmann::json::parse(payload.utf8_string()));
280 } catch (const std::exception& e) {
282 }
283}
virtual void on_script_message_parse_error(const wxString &payload, const std::exception &error)
Definition WebViewHostDialog.cpp:269
virtual void on_script_message(const nlohmann::json &payload)=0

References on_script_message(), and on_script_message_parse_error().

Referenced by create_webview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_script_message_parse_error()

void Slic3r::GUI::WebViewHostDialog::on_script_message_parse_error ( const wxString & payload,
const std::exception & error )
protectedvirtualinherited
270{
271 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << "; payload=" << into_u8(payload) << "; error=" << error.what();
272}

References Slic3r::GUI::into_u8(), and Slic3r::trace().

Referenced by on_script_message_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_sys_color_changed()

◆ on_webview_recreated()

void Slic3r::GUI::WebViewHostDialog::on_webview_recreated ( wxCommandEvent & event)
privateinherited
311{
312 // Handled: do NOT Skip(), so WebView::RecreateAll skips the redundant reload.
314}
void apply_theme_live()
Definition WebViewHostDialog.cpp:299

References apply_theme_live().

Referenced by create_webview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnBundleUpdate()

void Slic3r::GUI::PresetBundleDialog::OnBundleUpdate ( wxCommandEvent & evt)
192{
193 // const std::string bundle_id = evt.GetString().ToStdString();
194 m_update_bundles.store(true);
195}
std::atomic< bool > m_update_bundles
Definition PresetBundleDialog.hpp:95

References m_update_bundles.

Referenced by PresetBundleDialog().

Here is the caller graph for this function:

◆ OnFSWatch()

void Slic3r::GUI::PresetBundleDialog::OnFSWatch ( wxFileSystemWatcherEvent & e)
protected
72{
73 GUI::wxGetApp().preset_bundle->load_presets(*app_config, ForwardCompatibilitySubstitutionRule::EnableSilentDisableSystem);
74 wxGetApp().mainframe->update_side_preset_ui();
75
76 // ListBundles();
77 m_update_bundles.store(true);
78 e.Skip();
79}
@ EnableSilentDisableSystem
Definition Config.hpp:251

References app_config, Slic3r::EnableSilentDisableSystem, and m_update_bundles.

Referenced by PresetBundleDialog().

Here is the caller graph for this function:

◆ OnPresetBundlePage()

void Slic3r::GUI::PresetBundleDialog::OnPresetBundlePage ( )

◆ OpenBundleOnCloud()

void Slic3r::GUI::PresetBundleDialog::OpenBundleOnCloud ( const std::string & id)
427{
428 if (id.empty())
429 return;
430
431 if (!wxGetApp().getAgent())
432 return;
433
434 auto orca_agent = std::dynamic_pointer_cast<OrcaCloudServiceAgent>(wxGetApp().getAgent()->get_cloud_agent());
435 if (!orca_agent)
436 return;
437
438 wxLaunchDefaultBrowser(wxString::FromUTF8(orca_agent->get_bundle_url(id)));
439}

References Slic3r::empty().

Referenced by on_script_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OpenFolder()

void Slic3r::GUI::PresetBundleDialog::OpenFolder ( const std::string & id)
372{
373 wxGetApp().preset_bundle->bundles.ReadLock();
374 wxString target = _L(wxGetApp().preset_bundle->bundles.m_bundles.find(id)->second.path);
375 wxGetApp().preset_bundle->bundles.ReadUnlock();
376 wxFileName fn(target);
377 if (fn.FileExists())
378 target = fn.GetPath();
379
380 if (target.empty() || !wxFileName::DirExists(target)) {
381 wxMessageBox(_L("Bundle folder does not exist."), _L("Open Folder"), wxOK | wxICON_WARNING, this);
382 return;
383 }
384
385 if (!wxLaunchDefaultApplication(target)) {
386 wxMessageBox(_L("Failed to open folder."), _L("Open Folder"), wxOK | wxICON_ERROR, this);
387 }
388}

References _L.

Referenced by on_script_message().

Here is the caller graph for this function:

◆ prev_scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::prev_scale_factor ( ) const
inlineinherited
196{ return m_prev_scale_factor; }

◆ recreate_GUI()

bool Slic3r::GUI::PresetBundleDialog::recreate_GUI ( ) const
inline
54{ return m_recreate_GUI; }
bool m_recreate_GUI
Definition PresetBundleDialog.hpp:87

References m_recreate_GUI.

◆ RefreshBundleMap()

void Slic3r::GUI::PresetBundleDialog::RefreshBundleMap ( )
198{
199 wxGetApp().preset_bundle->bundles.ReadLock();
200 bundle_copy = wxGetApp().preset_bundle->bundles.m_bundles;
201 wxGetApp().preset_bundle->bundles.ReadUnlock();
202}

References bundle_copy.

Referenced by PresetBundleDialog(), and StartDialogWorker().

Here is the caller graph for this function:

◆ register_theme_user_scripts()

void Slic3r::GUI::WebViewHostDialog::register_theme_user_scripts ( )
protectedinherited
286{
287 if (!m_browser)
288 return;
289 // Added once, at creation. Deliberately no RemoveAllUserScripts() here: the "wx"
290 // script message handler is registered separately (AddScriptMessageHandler), but on
291 // some backends RemoveAllUserScripts() drops it too, which would break
292 // window.wx.postMessage / HandleStudio. Live re-theme goes through apply_theme_live().
293 m_browser->AddUserScript(wxString::FromUTF8(theme_user_script()));
294 if (const nlohmann::json strings = localized_strings(); !strings.is_null())
295 m_browser->AddUserScript(wxString::FromUTF8(localized_strings_script(strings)));
297}
static std::string theme_user_script()
Definition WebViewHostDialog.cpp:93
static std::string localized_strings_script(const nlohmann::json &strings)
Definition WebViewHostDialog.cpp:156
virtual void add_user_scripts()
Definition WebViewHostDialog.hpp:95
virtual nlohmann::json localized_strings() const
Definition WebViewHostDialog.hpp:99

References add_user_scripts(), localized_strings(), localized_strings_script(), m_browser, and theme_user_script().

Referenced by create_webview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rescale()

void Slic3r::GUI::DPIAware< wxDialog >::rescale ( const wxRect & suggested_rect)
inlineprivateinherited
265 {
266 this->Freeze();
267
268 m_force_rescale = false;
269
270 // set normal application font as a current window font
271 m_normal_font = this->GetFont();
272
274
275 // rescale missed controls sizes and images
277
278 this->Layout();
279 this->Thaw();
280
281 // reset previous scale factor from current scale factor value
283 }
virtual void on_dpi_changed(const wxRect &suggested_rect)=0
void update_em_unit()
Definition GUI_Utils.hpp:249

◆ run_script()

bool Slic3r::GUI::WebViewHostDialog::run_script ( const wxString & script)
inherited
235{
236 if (!m_browser)
237 return false;
238
239 return WebView::RunScript(m_browser, script);
240}
static bool RunScript(wxWebView *webView, wxString const &msg)
Definition WebView.cpp:491

References m_browser, and WebView::RunScript().

Referenced by apply_theme_live(), call_web_handler(), Slic3r::GUI::ColorPickerDialog::focus_webview(), Slic3r::GUI::ColorPickerDialog::handle_web_command(), and Slic3r::GUI::ColorPickerDialog::send_initial_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::scale_factor ( ) const
inlineinherited
195{ return m_scale_factor; }

◆ seq_top_layer_only_changed()

bool Slic3r::GUI::PresetBundleDialog::seq_top_layer_only_changed ( ) const
inline
bool m_seq_top_layer_only_changed
Definition PresetBundleDialog.hpp:86

References m_seq_top_layer_only_changed.

◆ set_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::set_em_unit ( int v)
inlineinherited
200{ m_em_unit = v; }

◆ set_prev_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_prev_scale_factor ( float v)
inlineinherited

◆ set_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_scale_factor ( float v)
inlineinherited
198{ m_scale_factor = v; }

◆ ShowModal()

◆ StartDialogWorker()

void Slic3r::GUI::PresetBundleDialog::StartDialogWorker ( )
82{
84 return;
85 }
86
87 m_dialog_worker_token = std::make_shared<int>(0);
88
89 m_dialog_worker_thread = Slic3r::create_thread([this, token = std::weak_ptr<int>(m_dialog_worker_token)] {
90 while (!token.expired()) {
91 // after comparing version with the cloud, if there is an update, we will update the rows to reflect
92
93 if (m_check_update_pending.exchange(false, std::memory_order_relaxed)) {
94 if (CheckUpdateCloud()) {
96 }
97 }
98 if (m_update_bundles.exchange(false, std::memory_order_relaxed)) {
100 ListBundles();
101 }
102
103 boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
104 }
105 });
106}
std::shared_ptr< int > m_dialog_worker_token
Definition PresetBundleDialog.hpp:93
bool CheckUpdateCloud()
Definition PresetBundleDialog.cpp:126
boost::thread m_dialog_worker_thread
Definition PresetBundleDialog.hpp:92
boost::thread create_thread(boost::thread::attributes &attrs, Fn &&fn)
Definition Thread.hpp:48

References CheckUpdateCloud(), Slic3r::create_thread(), ListBundles(), m_check_update_pending, m_dialog_worker_thread, m_dialog_worker_token, m_update_bundles, and RefreshBundleMap().

Referenced by PresetBundleDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StopDialogWorker()

void Slic3r::GUI::PresetBundleDialog::StopDialogWorker ( )
179{
181 return;
182 }
183
184 m_dialog_worker_token.reset();
185
186 if (m_dialog_worker_thread.joinable()) {
188 }
189}

References m_dialog_worker_thread, and m_dialog_worker_token.

Referenced by ~PresetBundleDialog().

Here is the caller graph for this function:

◆ theme_apply_script()

std::string Slic3r::GUI::WebViewHostDialog::theme_apply_script ( )
staticinherited
88{ return host_theme_apply_js(); }

Referenced by Slic3r::GUI::WebPanel::apply_theme().

Here is the caller graph for this function:

◆ theme_user_script()

std::string Slic3r::GUI::WebViewHostDialog::theme_user_script ( )
staticinherited
94{
95 const std::string style = "<style id=\"orca-host-theme-vars\">" + host_theme_vars_css() + "</style>";
97 style, "orca-host-theme-vars", "afterbegin",
98 "window.__orcaHostThemed=true;var theme=\"" + host_theme_name() + "\";",
99 "if(document.documentElement)document.documentElement.setAttribute('data-orca-theme',theme);");
100}
std::string host_theme_vars_css()
Definition WebViewHostDialog.cpp:40
std::string host_theme_name()
Definition WebViewHostDialog.cpp:35

References document_start_injector(), and style.

Referenced by Slic3r::GUI::WebPanel::WebPanel(), and register_theme_user_scripts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnsubscribeBundle()

void Slic3r::GUI::PresetBundleDialog::UnsubscribeBundle ( const std::string & id)
409{
410 if (id.empty())
411 return;
412
413 const int rc = wxMessageBox(_L("Unsubscribe bundle?"), _L("UnsubscribeBundle"), wxYES_NO | wxNO_DEFAULT | wxICON_WARNING, this);
414
415 if (rc != wxYES)
416 return;
417
418 if (!UnsubscribeBundleById(id)) {
419 wxMessageBox(_L("Failed to unsubscribe bundle."), _L("Unsubscribe Bundle"), wxOK | wxICON_ERROR, this);
420 return;
421 }
422
423 wxGetApp().mainframe->update_side_preset_ui();
424}
bool UnsubscribeBundleById(const std::string &id)
Definition PresetBundleDialog.cpp:289

References _L, Slic3r::empty(), and UnsubscribeBundleById().

Referenced by on_script_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnsubscribeBundleById()

bool Slic3r::GUI::PresetBundleDialog::UnsubscribeBundleById ( const std::string & id)
289{ return wxGetApp().unsubscribe_bundle(id); }

Referenced by UnsubscribeBundle().

Here is the caller graph for this function:

◆ update_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::update_em_unit ( )
inlineprivateinherited
250 {
251 // Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3).
252 // So, calculate the m_em_unit value from the font size, as before
253#if !defined(__WXGTK__)
255#else
256 // initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
257 m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
258#endif // __WXGTK__
259 }

Member Data Documentation

◆ app_config

Slic3r::AppConfig* Slic3r::GUI::PresetBundleDialog::app_config
private

◆ bundle_copy

std::unordered_map<std::string, BundleMetadata> Slic3r::GUI::PresetBundleDialog::bundle_copy
protected

◆ m_browser

wxWebView* Slic3r::GUI::WebViewHostDialog::m_browser {nullptr}
privateinherited

◆ m_can_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_can_rescale
privateinherited
235{ true };

◆ m_check_update_pending

std::atomic<bool> Slic3r::GUI::PresetBundleDialog::m_check_update_pending {false}
protected
94{false};

Referenced by on_script_message(), and StartDialogWorker().

◆ m_dialog_worker_thread

boost::thread Slic3r::GUI::PresetBundleDialog::m_dialog_worker_thread
protected

◆ m_dialog_worker_token

std::shared_ptr<int> Slic3r::GUI::PresetBundleDialog::m_dialog_worker_token
protected

◆ m_em_unit

int Slic3r::GUI::DPIAware< wxDialog >::m_em_unit
privateinherited

◆ m_force_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_force_rescale
privateinherited
236{ false };

◆ m_new_font_point_size

int Slic3r::GUI::DPIAware< wxDialog >::m_new_font_point_size
privateinherited

◆ m_normal_font

wxFont Slic3r::GUI::DPIAware< wxDialog >::m_normal_font
privateinherited

◆ m_prev_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_prev_scale_factor
privateinherited

◆ m_recreate_GUI

bool Slic3r::GUI::PresetBundleDialog::m_recreate_GUI {false}
protected
87{false};

Referenced by recreate_GUI().

◆ m_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_scale_factor
privateinherited

◆ m_seq_top_layer_only_changed

bool Slic3r::GUI::PresetBundleDialog::m_seq_top_layer_only_changed {false}
protected
86{false};

Referenced by seq_top_layer_only_changed().

◆ m_update_bundles

std::atomic<bool> Slic3r::GUI::PresetBundleDialog::m_update_bundles {false}
protected
95{false};

Referenced by OnBundleUpdate(), OnFSWatch(), and StartDialogWorker().

◆ m_watcher

wxFileSystemWatcher* Slic3r::GUI::PresetBundleDialog::m_watcher = nullptr
protected

The documentation for this class was generated from the following files: