Replaced all occurrences of boost::nowide::narrow for wxStrings with into_u8

This commit is contained in:
tamasmeszaros 2023-12-18 14:33:11 +01:00
parent bffa3f8578
commit 8d6497297a
22 changed files with 51 additions and 52 deletions

View File

@ -1426,7 +1426,7 @@ Worker::Worker(wxWindow* parent)
wxGetApp().SetWindowVariantForButton(button_path);
this->Add(button_path, 0, wxEXPAND | wxTOP | wxLEFT, 5);
button_path->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) {
boost::filesystem::path chosen_dest(boost::nowide::narrow(m_input_path->GetValue()));
boost::filesystem::path chosen_dest(into_u8(m_input_path->GetValue()));
wxDirDialog dialog(m_parent, _L("Choose folder") + ":", chosen_dest.string() );
if (dialog.ShowModal() == wxID_OK)

View File

@ -308,7 +308,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%/icons/PrusaSlicer.png",resources_dir());
@ -364,7 +364,7 @@ void DesktopIntegrationDialog::perform_desktop_integration()
// 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/PrusaSlicer%2%.desktop", target_dir_desktop, version_suffix);
@ -582,7 +582,7 @@ void DesktopIntegrationDialog::perform_downloader_desktop_integration()
// 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/PrusaSlicerURLProtocol%2%.desktop", target_dir_desktop, version_suffix);

View File

@ -169,7 +169,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;
@ -181,7 +181,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)

View File

@ -227,7 +227,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());

View File

@ -473,10 +473,10 @@ bool create_process(const boost::filesystem::path& path, const std::wstring& cmd
return true;
}
else
error_msg = "CreateProcessW failed to create process " + boost::nowide::narrow(path.wstring());
error_msg = "CreateProcessW failed to create process " + into_u8(path.wstring());
}
else
error_msg = "Executable doesn't exists. Path: " + boost::nowide::narrow(path.wstring());
error_msg = "Executable doesn't exists. Path: " + into_u8(path.wstring());
return false;
}
#endif //_WIN32

View File

@ -638,7 +638,7 @@ static void register_win32_device_notification_event()
// if (lpdbi->dbcc_classguid == GUID_DEVINTERFACE_VOLUME) {
// printf("DBT_DEVICEARRIVAL %d - Media has arrived: %ws\n", msg_count, lpdbi->dbcc_name);
if (lpdbi->dbcc_classguid == GUID_DEVINTERFACE_HID)
plater->GetEventHandler()->AddPendingEvent(HIDDeviceAttachedEvent(EVT_HID_DEVICE_ATTACHED, boost::nowide::narrow(lpdbi->dbcc_name)));
plater->GetEventHandler()->AddPendingEvent(HIDDeviceAttachedEvent(EVT_HID_DEVICE_ATTACHED, into_u8(lpdbi->dbcc_name)));
}
break;
case DBT_DEVICEREMOVECOMPLETE:
@ -649,7 +649,7 @@ static void register_win32_device_notification_event()
// if (lpdbi->dbcc_classguid == GUID_DEVINTERFACE_VOLUME)
// printf("DBT_DEVICEARRIVAL %d - Media was removed: %ws\n", msg_count, lpdbi->dbcc_name);
if (lpdbi->dbcc_classguid == GUID_DEVINTERFACE_HID)
plater->GetEventHandler()->AddPendingEvent(HIDDeviceDetachedEvent(EVT_HID_DEVICE_DETACHED, boost::nowide::narrow(lpdbi->dbcc_name)));
plater->GetEventHandler()->AddPendingEvent(HIDDeviceDetachedEvent(EVT_HID_DEVICE_DETACHED, into_u8(lpdbi->dbcc_name)));
}
break;
default:
@ -712,7 +712,7 @@ static void register_win32_device_notification_event()
copy_data_structure = (COPYDATASTRUCT*)lParam;
if (copy_data_structure->dwData == 1) {
LPCWSTR arguments = (LPCWSTR)copy_data_structure->lpData;
Slic3r::GUI::wxGetApp().other_instance_message_handler()->handle_message(boost::nowide::narrow(arguments));
Slic3r::GUI::wxGetApp().other_instance_message_handler()->handle_message(into_u8(arguments));
}
return true;
});
@ -1115,9 +1115,9 @@ void GUI_App::jump_to_option(size_t selected)
{
const Search::Option& opt = m_searcher.get_option(selected);
if (opt.type == Preset::TYPE_PREFERENCES)
open_preferences(opt.opt_key(), boost::nowide::narrow(opt.group));
open_preferences(opt.opt_key(), into_u8(opt.group));
else
get_tab(opt.type)->activate_option(opt.opt_key(), boost::nowide::narrow(opt.category));
get_tab(opt.type)->activate_option(opt.opt_key(), into_u8(opt.category));
}
void GUI_App::jump_to_option(const std::string& composite_key)
@ -1134,7 +1134,7 @@ void GUI_App::jump_to_option(const std::string& composite_key)
// so resort searcher before get an option
m_searcher.sort_options_by_key();
const Search::Option& opt = m_searcher.get_option(opt_key, tab->type());
tab->activate_option(opt_key, boost::nowide::narrow(opt.category));
tab->activate_option(opt_key, into_u8(opt.category));
// Revert sort of searcher back
m_searcher.sort_options_by_label();
@ -3052,7 +3052,7 @@ void GUI_App::MacOpenURL(const wxString& url)
BOOST_LOG_TRIVIAL(error) << "Recieved command to open URL, but it is not allowed in app configuration. URL: " << url;
return;
}
start_download(boost::nowide::narrow(url));
start_download(into_u8(url));
}
#endif /* __APPLE */

View File

@ -4671,7 +4671,7 @@ void ObjectList::fix_through_winsdk()
// Show info notification
wxString msg = MenuFactory::get_repaire_result_message(succes_models, failed_models);
plater->get_notification_manager()->push_notification(NotificationType::RepairFinished, NotificationManager::NotificationLevel::PrintInfoShortNotificationLevel, boost::nowide::narrow(msg));
plater->get_notification_manager()->push_notification(NotificationType::RepairFinished, NotificationManager::NotificationLevel::PrintInfoShortNotificationLevel, into_u8(msg));
}
void ObjectList::simplify()

View File

@ -976,12 +976,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);

View File

@ -1143,7 +1143,7 @@ void NotificationManager::URLDownloadNotification::render_pause_button_inner(ImG
button_text = (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);
@ -1182,7 +1182,7 @@ void NotificationManager::URLDownloadNotification::render_open_button_inner(ImGu
button_text = 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);

View File

@ -4324,7 +4324,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);

View File

@ -203,7 +203,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)
@ -469,7 +469,7 @@ void PrintHostQueueDialog::on_progress(Event &evt)
job_list->GetValue(hst, evt.job_id, COL_HOST);
const wchar_t * nm_str = nm.GetString();
const wchar_t * hst_str = hst.GetString();
wxGetApp().notification_manager()->set_upload_job_notification_percentage(evt.job_id + 1, boost::nowide::narrow(nm_str), boost::nowide::narrow(hst_str), evt.progress / 100.f);
wxGetApp().notification_manager()->set_upload_job_notification_percentage(evt.job_id + 1, into_u8(nm_str), into_u8(hst_str), evt.progress / 100.f);
}
}
@ -515,17 +515,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);
}

View File

@ -57,7 +57,7 @@ static char marker_by_type(Preset::Type type, PrinterTechnology pt)
std::string Option::opt_key() const
{
return boost::nowide::narrow(key).substr(2);
return into_u8(key).substr(2);
}
void FoundOption::get_marked_label_and_tooltip(const char** label_, const char** tooltip_) const

View File

@ -493,7 +493,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);

View File

@ -920,7 +920,7 @@ void Sidebar::update_sliced_info_sizer()
wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : from_u8(short_time_ui(get_time_dhms(float(ps.estimated_print_time))));
m_sliced_info->SetTextAndShow(siEstimatedTime, t_est, _L("Estimated printing time") + ":");
m_plater->get_notification_manager()->set_slicing_complete_print_time(_u8L("Estimated printing time") + ": " + boost::nowide::narrow(t_est), m_plater->is_sidebar_collapsed());
m_plater->get_notification_manager()->set_slicing_complete_print_time(_u8L("Estimated printing time") + ": " + into_u8(t_est), m_plater->is_sidebar_collapsed());
// Hide non-SLA sliced info parameters
m_sliced_info->SetTextAndShow(siFilament_m, "N/A");

View File

@ -149,7 +149,7 @@ void WifiConfigDialog::on_retrieve_password(wxCommandEvent& e)
return;
}
std::string psk = m_wifi_scanner->get_psk(boost::nowide::narrow(m_ssid_combo->GetValue()));
std::string psk = m_wifi_scanner->get_psk(into_u8(m_ssid_combo->GetValue()));
if (psk.empty()) {
// TRN Alert message when retrieving password for wifi from keychain. Probably will display only on Apple so keychain is MacOS term.
wxString msg = _L("No password in the keychain for given SSID.");
@ -214,7 +214,7 @@ void WifiConfigDialog::on_ok(wxCommandEvent& e)
return;
}
std::string selected_path = boost::nowide::narrow(m_drive_combo->GetValue());
std::string selected_path = into_u8(m_drive_combo->GetValue());
if (selected_path.empty()) {
// TRN Alert message when writing WiFi configuration file to usb drive.

View File

@ -101,7 +101,7 @@ bool Duet::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn e
if (dsf) {
http.set_put_body(upload_data.source_path);
if (connect_msg.empty())
http.header("X-Session-Key", boost::nowide::narrow(connect_msg));
http.header("X-Session-Key", GUI::into_u8(connect_msg));
} else {
http.set_post_body(upload_data.source_path);
}

View File

@ -1,8 +1,7 @@
#include "WifiScanner.hpp"
#include "slic3r/GUI/GUI.hpp"
#include <boost/log/trivial.hpp>
#include <boost/nowide/system.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/filesystem.hpp>
@ -143,7 +142,7 @@ void fill_wifi_map(Slic3r::WifiSsidPskMap& wifi_map, std::string& connected_ssid
{
wxString xml(xmlstr);
boost::property_tree::ptree pt;
std::stringstream ss(boost::nowide::narrow(xml));
std::stringstream ss(Slic3r::GUI::into_u8(xml));
boost::property_tree::read_xml(ss, pt);
std::string password;
std::string psk_protected;