mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-03 10:17:58 -05:00
* Percent-Encode Local File URLs for Embedded Web Pages The Home tab, setup wizard, Project tab and other embedded pages were loaded from file:// URLs built by pasting the resources path into a string. A '#', '%' or '?' in the install path was then read as a URL fragment, escape or query, so the pages failed to load, for example a portable install under D:\#OneDrive showed a directory listing instead of the setup wizard. Add file_url_from_path(), built on wxFileSystem::FileNameToURL, and use it wherever a local page or image URL is built from a path. Queries such as ?lang= are appended after the path is encoded. The wizard's printer cover images are passed to the page as file URLs too. * Encode the Login Error Page URL and Cover More Windows Path Forms The login dialog's error page was still loaded from a raw resources path; it now uses file_url_from_path like the other local pages. The Windows file URL tests now also cover a resources path joined with a forward-slash relative path, as the callers build them, and a UNC path. * Build the Flush Dialog Page URLs with the Shared Helper WipingDialog and NozzleListTable still called wxFileSystem::FileNameToURL directly. They now go through file_url_from_path like every other local page, so the URLs are built in one place. Adds a test for a resources directory with a '#' in its name, which the plugin page check did not recognise before.
93 lines
4.0 KiB
C++
93 lines
4.0 KiB
C++
#ifndef slic3r_GUI_hpp_
|
|
#define slic3r_GUI_hpp_
|
|
|
|
namespace boost { class any; }
|
|
namespace boost::filesystem { class path; }
|
|
|
|
#include <wx/string.h>
|
|
|
|
#include "libslic3r/Config.hpp"
|
|
#include "libslic3r/Preset.hpp"
|
|
|
|
class wxWindow;
|
|
class wxMenuBar;
|
|
class wxComboCtrl;
|
|
class wxFileDialog;
|
|
class wxTopLevelWindow;
|
|
|
|
namespace Slic3r {
|
|
|
|
class AppConfig;
|
|
class DynamicPrintConfig;
|
|
class Print;
|
|
|
|
namespace GUI {
|
|
|
|
void disable_screensaver();
|
|
void enable_screensaver();
|
|
bool debugged();
|
|
void break_to_debugger();
|
|
|
|
// Platform specific Ctrl+/Alt+ (Windows, Linux) vs. ⌘/⌥ (OSX) prefixes
|
|
extern const std::string& shortkey_ctrl_prefix();
|
|
extern const std::string& shortkey_alt_prefix();
|
|
extern const std::string& shortkey_shift_prefix(); // Shift is the same on all platforms, but we provide a function for consistency with Ctrl/Alt prefixes
|
|
|
|
extern AppConfig* get_app_config();
|
|
|
|
extern void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_language_change);
|
|
|
|
// Change option value in config
|
|
void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index = 0);
|
|
|
|
// If has_code_excerpts is true, code excerpts (a source line and the caret line below it) render
|
|
// monospaced so the caret aligns. Used for placeholder-parser errors.
|
|
void show_error(wxWindow* parent, const wxString& message, bool has_code_excerpts = false);
|
|
void show_error(wxWindow* parent, const char* message, bool has_code_excerpts = false);
|
|
inline void show_error(wxWindow* parent, const std::string& message, bool has_code_excerpts = false) { show_error(parent, message.c_str(), has_code_excerpts); }
|
|
void show_error_id(int id, const std::string& message); // For Perl
|
|
void show_info(wxWindow* parent, const wxString& message, const wxString& title = wxString());
|
|
void show_info(wxWindow* parent, const char* message, const char* title = nullptr);
|
|
inline void show_info(wxWindow* parent, const std::string& message,const std::string& title = std::string()) { show_info(parent, message.c_str(), title.c_str()); }
|
|
void warning_catcher(wxWindow* parent, const wxString& message);
|
|
void show_substitutions_info(const PresetsConfigSubstitutions& presets_config_substitutions);
|
|
void show_substitutions_info(const ConfigSubstitutions& config_substitutions, const std::string& filename);
|
|
|
|
// Creates a wxCheckListBoxComboPopup inside the given wxComboCtrl, filled with the given text and items.
|
|
// Items data must be separated by '|', and contain the item name to be shown followed by its initial value (0 for false, 1 for true).
|
|
// For example "Item1|0|Item2|1|Item3|0", and so on.
|
|
void create_combochecklist(wxComboCtrl* comboCtrl, const std::string& text, const std::string& items);
|
|
|
|
// Returns the current state of the items listed in the wxCheckListBoxComboPopup contained in the given wxComboCtrl,
|
|
// encoded inside an unsigned int.
|
|
unsigned int combochecklist_get_flags(wxComboCtrl* comboCtrl);
|
|
|
|
// Sets the current state of the items listed in the wxCheckListBoxComboPopup contained in the given wxComboCtrl,
|
|
// with the flags encoded in the given unsigned int.
|
|
void combochecklist_set_flags(wxComboCtrl* comboCtrl, unsigned int flags);
|
|
|
|
// wxString conversions:
|
|
|
|
// wxString from std::string in UTF8
|
|
wxString from_u8(const std::string &str);
|
|
// std::string in UTF8 from wxString
|
|
std::string into_u8(const wxString &str);
|
|
// wxString from boost path
|
|
wxString from_path(const boost::filesystem::path &path);
|
|
// boost path from wxString
|
|
boost::filesystem::path into_path(const wxString &str);
|
|
// file:// URL of a local path, percent-encoded so characters such as '#', '%' and '?' stay part of the path.
|
|
// Append any query or fragment to the result.
|
|
wxString file_url_from_path(const boost::filesystem::path &path);
|
|
|
|
// Display an About dialog
|
|
extern void about();
|
|
// Ask the destop to open the datadir using the default file explorer.
|
|
extern void desktop_open_datadir_folder();
|
|
// Ask the destop to open one folder
|
|
extern void desktop_open_any_folder(const std::string& path);
|
|
} // namespace GUI
|
|
} // namespace Slic3r
|
|
|
|
#endif
|