mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 07:34:03 -06:00
Use boost::nowide
directly from boost (#9037)
* Use `boost::nowide` directly from boost Cherry-picked from prusa3d/PrusaSlicer@bffa3f8578 Co-authored-by: tamasmeszaros <meszaros.q@gmail.com> * Replaced all occurrences of boost::nowide::narrow for wxStrings with into_u8 Cherry-picked from prusa3d/PrusaSlicer@8d6497297a Co-authored-by: tamasmeszaros <meszaros.q@gmail.com> * Fix flatpak build
This commit is contained in:
parent
45221a2bea
commit
ed45bf425e
39 changed files with 36 additions and 2506 deletions
|
@ -117,7 +117,7 @@ void resolve_path_from_var(const std::string& var, std::vector<std::string>& pat
|
|||
wxString wxdirs;
|
||||
if (! wxGetEnv(boost::nowide::widen(var), &wxdirs) || wxdirs.empty() )
|
||||
return;
|
||||
std::string dirs = boost::nowide::narrow(wxdirs);
|
||||
std::string dirs = into_u8(wxdirs);
|
||||
for (size_t i = dirs.find(':'); i != std::string::npos; i = dirs.find(':'))
|
||||
{
|
||||
paths.push_back(dirs.substr(0, i));
|
||||
|
@ -302,7 +302,7 @@ void DesktopIntegrationDialog::perform_desktop_integration()
|
|||
// if all failed - try creating default home folder
|
||||
if (i == target_candidates.size() - 1) {
|
||||
// create $HOME/.local/share
|
||||
create_path(boost::nowide::narrow(wxFileName::GetHomeDir()), ".local/share/icons" + icon_theme_dirs);
|
||||
create_path(into_u8(wxFileName::GetHomeDir()), ".local/share/icons" + icon_theme_dirs);
|
||||
// copy icon
|
||||
target_dir_icons = GUI::format("%1%/.local/share",wxFileName::GetHomeDir());
|
||||
std::string icon_path = GUI::format("%1%/images/OrcaSlicer.png",resources_dir());
|
||||
|
@ -354,7 +354,7 @@ void DesktopIntegrationDialog::perform_desktop_integration()
|
|||
// if all failed - try creating default home folder
|
||||
if (i == target_candidates.size() - 1) {
|
||||
// create $HOME/.local/share
|
||||
create_path(boost::nowide::narrow(wxFileName::GetHomeDir()), ".local/share/applications");
|
||||
create_path(into_u8(wxFileName::GetHomeDir()), ".local/share/applications");
|
||||
// create desktop file
|
||||
target_dir_desktop = GUI::format("%1%/.local/share",wxFileName::GetHomeDir());
|
||||
std::string path = GUI::format("%1%/applications/OrcaSlicer%2%.desktop", target_dir_desktop, version_suffix);
|
||||
|
@ -562,7 +562,7 @@ void DesktopIntegrationDialog::perform_downloader_desktop_integration(std::strin
|
|||
// if all failed - try creating default home folder
|
||||
if (!candidate_found) {
|
||||
// create $HOME/.local/share
|
||||
create_path(boost::nowide::narrow(wxFileName::GetHomeDir()), ".local/share/applications");
|
||||
create_path(into_u8(wxFileName::GetHomeDir()), ".local/share/applications");
|
||||
// create desktop file
|
||||
target_dir_desktop = GUI::format("%1%/.local/share", wxFileName::GetHomeDir());
|
||||
std::string path = GUI::format("%1%/applications/OrcaSlicerURLProtocol-%2%%3%.desktop", target_dir_desktop, url_prefix, version_suffix);
|
||||
|
|
|
@ -175,7 +175,7 @@ void Downloader::start_download(const std::string& full_url)
|
|||
void Downloader::on_progress(wxCommandEvent& event)
|
||||
{
|
||||
size_t id = event.GetInt();
|
||||
float percent = (float)std::stoi(boost::nowide::narrow(event.GetString())) / 100.f;
|
||||
float percent = (float)std::stoi(into_u8(event.GetString())) / 100.f;
|
||||
//BOOST_LOG_TRIVIAL(error) << "progress " << id << ": " << percent;
|
||||
NotificationManager* ntf_mngr = wxGetApp().notification_manager();
|
||||
BOOST_LOG_TRIVIAL(trace) << "Download "<< id << ": " << percent;
|
||||
|
@ -187,7 +187,7 @@ void Downloader::on_error(wxCommandEvent& event)
|
|||
set_download_state(event.GetInt(), DownloadState::DownloadError);
|
||||
BOOST_LOG_TRIVIAL(error) << "Download error: " << event.GetString();
|
||||
NotificationManager* ntf_mngr = wxGetApp().notification_manager();
|
||||
ntf_mngr->set_download_URL_error(id, boost::nowide::narrow(event.GetString()));
|
||||
ntf_mngr->set_download_URL_error(id, into_u8(event.GetString()));
|
||||
show_error(nullptr, format_wxstr(L"%1%\n%2%", _L("The download has failed") + ":", event.GetString()));
|
||||
}
|
||||
void Downloader::on_complete(wxCommandEvent& event)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <thread>
|
||||
#include <curl/curl.h>
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
#include <boost/nowide/convert.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
|
|
@ -228,7 +228,7 @@ FileArchiveDialog::FileArchiveDialog(wxWindow* parent_window, mz_zip_archive* ar
|
|||
path = boost::filesystem::path(extra.substr(0, extra_size));
|
||||
} else {
|
||||
wxString wname = boost::nowide::widen(stat.m_filename);
|
||||
std::string name = boost::nowide::narrow(wname);
|
||||
std::string name = into_u8(wname);
|
||||
path = boost::filesystem::path(name);
|
||||
}
|
||||
assert(!path.empty());
|
||||
|
|
|
@ -5923,7 +5923,7 @@ void GUI_App::MacOpenURL(const wxString& url)
|
|||
{
|
||||
if (url.empty())
|
||||
return;
|
||||
start_download(boost::nowide::narrow(url));
|
||||
start_download(into_u8(url));
|
||||
}
|
||||
|
||||
// wxWidgets override to get an event on open files.
|
||||
|
@ -6685,7 +6685,7 @@ void GUI_App::associate_url(std::wstring url_prefix)
|
|||
}
|
||||
key_full = key_string;
|
||||
#elif defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
|
||||
DesktopIntegrationDialog::perform_downloader_desktop_integration(boost::nowide::narrow(url_prefix));
|
||||
DesktopIntegrationDialog::perform_downloader_desktop_integration(into_u8(url_prefix));
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
|
|
|
@ -5418,7 +5418,7 @@ void ObjectList::fix_through_netfabb()
|
|||
}
|
||||
if (msg.IsEmpty())
|
||||
msg = _L("Repairing was canceled");
|
||||
plater->get_notification_manager()->push_notification(NotificationType::NetfabbFinished, NotificationManager::NotificationLevel::PrintInfoShortNotificationLevel, boost::nowide::narrow(msg));
|
||||
plater->get_notification_manager()->push_notification(NotificationType::NetfabbFinished, NotificationManager::NotificationLevel::PrintInfoShortNotificationLevel, into_u8(msg));
|
||||
}
|
||||
|
||||
void ObjectList::simplify()
|
||||
|
|
|
@ -1151,12 +1151,12 @@ bool Mouse3DController::connect_device()
|
|||
if (m_device != nullptr) {
|
||||
wchar_t buffer[1024];
|
||||
hid_get_manufacturer_string(m_device, buffer, 1024);
|
||||
m_device_str = boost::nowide::narrow(buffer);
|
||||
m_device_str = into_u8(buffer);
|
||||
// #3479 seems to show that sometimes an extra whitespace is added, so we remove it
|
||||
boost::algorithm::trim(m_device_str);
|
||||
|
||||
hid_get_product_string(m_device, buffer, 1024);
|
||||
m_device_str += "/" + boost::nowide::narrow(buffer);
|
||||
m_device_str += "/" + into_u8(buffer);
|
||||
// #3479 seems to show that sometimes an extra whitespace is added, so we remove it
|
||||
boost::algorithm::trim(m_device_str);
|
||||
|
||||
|
|
|
@ -1364,7 +1364,7 @@ void NotificationManager::URLDownloadNotification::render_pause_button_inner(ImG
|
|||
button_text = m_is_dark ? (m_download_paused ? ImGui::PlayHoverDarkButton : ImGui::PauseHoverDarkButton) : (m_download_paused ? ImGui::PlayHoverButton : ImGui::PauseHoverButton);
|
||||
}
|
||||
|
||||
ImVec2 button_pic_size = ImGui::CalcTextSize(boost::nowide::narrow(button_text).c_str());
|
||||
ImVec2 button_pic_size = ImGui::CalcTextSize(into_u8(button_text).c_str());
|
||||
ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f);
|
||||
ImGui::SetCursorPosX(win_size.x - m_line_height * 5.0f);
|
||||
ImGui::SetCursorPosY(win_size.y / 2 - button_size.y);
|
||||
|
@ -1405,7 +1405,7 @@ void NotificationManager::URLDownloadNotification::render_open_button_inner(ImGu
|
|||
button_text = m_is_dark ? ImGui::OpenHoverDarkButton : ImGui::OpenHoverButton;
|
||||
}
|
||||
|
||||
ImVec2 button_pic_size = ImGui::CalcTextSize(boost::nowide::narrow(button_text).c_str());
|
||||
ImVec2 button_pic_size = ImGui::CalcTextSize(into_u8(button_text).c_str());
|
||||
ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f);
|
||||
ImGui::SetCursorPosX(win_size.x - m_line_height * 5.0f);
|
||||
ImGui::SetCursorPosY(win_size.y / 2 - button_size.y);
|
||||
|
|
|
@ -10390,7 +10390,7 @@ bool Plater::preview_zip_archive(const boost::filesystem::path& archive_path)
|
|||
if (size != stat.m_uncomp_size) // size must fit
|
||||
continue;
|
||||
wxString wname = boost::nowide::widen(stat.m_filename);
|
||||
std::string name = boost::nowide::narrow(wname);
|
||||
std::string name = into_u8(wname);
|
||||
fs::path archive_path(name);
|
||||
|
||||
std::string extra(1024, 0);
|
||||
|
|
|
@ -227,7 +227,7 @@ std::string PrintHostSendDialog::storage() const
|
|||
return GUI::format("%1%", m_preselected_storage);
|
||||
if (combo_storage->GetSelection() < 0 || combo_storage->GetSelection() >= int(m_paths.size()))
|
||||
return {};
|
||||
return boost::nowide::narrow(m_paths[combo_storage->GetSelection()]);
|
||||
return into_u8(m_paths[combo_storage->GetSelection()]);
|
||||
}
|
||||
|
||||
void PrintHostSendDialog::EndModal(int ret)
|
||||
|
@ -491,7 +491,7 @@ void PrintHostQueueDialog::on_progress(Event &evt)
|
|||
wxVariant nm, hst;
|
||||
job_list->GetValue(nm, evt.job_id, COL_FILENAME);
|
||||
job_list->GetValue(hst, evt.job_id, COL_HOST);
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_percentage(evt.job_id + 1, boost::nowide::narrow(nm.GetString()), boost::nowide::narrow(hst.GetString()), evt.progress / 100.f);
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_percentage(evt.job_id + 1, into_u8(nm.GetString()), into_u8(hst.GetString()), evt.progress / 100.f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -512,7 +512,7 @@ void PrintHostQueueDialog::on_error(Event &evt)
|
|||
wxVariant nm, hst;
|
||||
job_list->GetValue(nm, evt.job_id, COL_FILENAME);
|
||||
job_list->GetValue(hst, evt.job_id, COL_HOST);
|
||||
wxGetApp().notification_manager()->upload_job_notification_show_error(evt.job_id + 1, boost::nowide::narrow(nm.GetString()), boost::nowide::narrow(hst.GetString()));
|
||||
wxGetApp().notification_manager()->upload_job_notification_show_error(evt.job_id + 1, into_u8(nm.GetString()), into_u8(hst.GetString()));
|
||||
}
|
||||
|
||||
void PrintHostQueueDialog::on_cancel(Event &evt)
|
||||
|
@ -527,7 +527,7 @@ void PrintHostQueueDialog::on_cancel(Event &evt)
|
|||
wxVariant nm, hst;
|
||||
job_list->GetValue(nm, evt.job_id, COL_FILENAME);
|
||||
job_list->GetValue(hst, evt.job_id, COL_HOST);
|
||||
wxGetApp().notification_manager()->upload_job_notification_show_canceled(evt.job_id + 1, boost::nowide::narrow(nm.GetString()), boost::nowide::narrow(hst.GetString()));
|
||||
wxGetApp().notification_manager()->upload_job_notification_show_canceled(evt.job_id + 1, into_u8(nm.GetString()), into_u8(hst.GetString()));
|
||||
}
|
||||
|
||||
void PrintHostQueueDialog::on_info(Event& evt)
|
||||
|
@ -538,17 +538,17 @@ void PrintHostQueueDialog::on_info(Event& evt)
|
|||
if (evt.tag == L"resolve") {
|
||||
wxVariant hst(evt.status);
|
||||
job_list->SetValue(hst, evt.job_id, COL_HOST);
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_host(evt.job_id + 1, boost::nowide::narrow(evt.status));
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_host(evt.job_id + 1, into_u8(evt.status));
|
||||
} else if (evt.tag == L"complete") {
|
||||
wxVariant hst(evt.status);
|
||||
job_list->SetValue(hst, evt.job_id, COL_ERRORMSG);
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_completed(evt.job_id + 1);
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_status(evt.job_id + 1, boost::nowide::narrow(evt.status));
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_status(evt.job_id + 1, into_u8(evt.status));
|
||||
} else if(evt.tag == L"complete_with_warning"){
|
||||
wxVariant hst(evt.status);
|
||||
job_list->SetValue(hst, evt.job_id, COL_ERRORMSG);
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_completed_with_warning(evt.job_id + 1);
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_status(evt.job_id + 1, boost::nowide::narrow(evt.status));
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_status(evt.job_id + 1, into_u8(evt.status));
|
||||
} else if (evt.tag == L"set_complete_off") {
|
||||
wxGetApp().notification_manager()->set_upload_job_notification_comp_on_100(evt.job_id + 1, false);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ static char marker_by_type(Preset::Type type, PrinterTechnology pt)
|
|||
}
|
||||
}
|
||||
|
||||
std::string Option::opt_key() const { return boost::nowide::narrow(key).substr(2); }
|
||||
std::string Option::opt_key() const { return into_u8(key).substr(2); }
|
||||
|
||||
void FoundOption::get_marked_label_and_tooltip(const char **label_, const char **tooltip_) const
|
||||
{
|
||||
|
@ -210,9 +210,9 @@ bool OptionsSearcher::search(const std::string &search, bool force /* = false*/,
|
|||
std::string label = into_u8(get_label(opt));
|
||||
//all
|
||||
if (type == Preset::TYPE_INVALID) {
|
||||
found.emplace_back(FoundOption{label, label, boost::nowide::narrow(get_tooltip(opt)), i, 0});
|
||||
found.emplace_back(FoundOption{label, label, into_u8(get_tooltip(opt)), i, 0});
|
||||
} else if (type == opt.type){
|
||||
found.emplace_back(FoundOption{label, label, boost::nowide::narrow(get_tooltip(opt)), i, 0});
|
||||
found.emplace_back(FoundOption{label, label, into_u8(get_tooltip(opt)), i, 0});
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -253,9 +253,9 @@ bool OptionsSearcher::search(const std::string &search, bool force /* = false*/,
|
|||
#endif
|
||||
|
||||
if (type == Preset::TYPE_INVALID) {
|
||||
found.emplace_back(FoundOption{label_plain, label_u8, boost::nowide::narrow(get_tooltip(opt)), i, score});
|
||||
found.emplace_back(FoundOption{label_plain, label_u8, into_u8(get_tooltip(opt)), i, score});
|
||||
} else if (type == opt.type) {
|
||||
found.emplace_back(FoundOption{label_plain, label_u8, boost::nowide::narrow(get_tooltip(opt)), i, score});
|
||||
found.emplace_back(FoundOption{label_plain, label_u8, into_u8(get_tooltip(opt)), i, score});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -498,7 +498,7 @@ static std::string generate_system_info_json()
|
|||
std::vector<std::wstring> blacklisted_libraries;
|
||||
BlacklistedLibraryCheck::get_instance().get_blacklisted(blacklisted_libraries);
|
||||
for (const std::wstring& wstr : blacklisted_libraries) {
|
||||
std::string utf8 = boost::nowide::narrow(wstr);
|
||||
std::string utf8 = into_u8(wstr);
|
||||
if (size_t last_bs_pos = utf8.find_last_of("\\"); last_bs_pos < utf8.size() - 1) {
|
||||
// Remove anything before last backslash so we don't send the path to the DLL.
|
||||
utf8.erase(0, last_bs_pos + 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue