Skip to content

Commit

Permalink
Use utf8 aware string conversion for wxLaunchDefaultBrowser() (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
Exzap committed Sep 5, 2022
1 parent 0030fa4 commit e5d7d5d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/gui/ChecksumTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "gui/helpers/wxCustomEvents.h"
#include "util/helpers/helpers.h"
#include "gui/helpers/wxHelpers.h"
#include "gui/wxHelper.h"
#include "Cafe/Filesystem/WUD/wud.h"

#include <zip.h>
Expand Down Expand Up @@ -518,7 +519,7 @@ void ChecksumTool::VerifyJsonEntry(const rapidjson::Document& doc)
file.flush();
file.close();

wxLaunchDefaultBrowser(fmt::format("file:{}", path));
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", path)));
}
else
wxMessageBox(_("Can't open file to write!"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,7 @@ class CemuAboutDialog : public wxDialog
"/*****************************************************************************/\r\n"
);
delete fs;
wxLaunchDefaultBrowser(fmt::format("file:{}", _utf8Wrapper(tempPath)));
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _utf8Wrapper(tempPath))));
});
lineSizer->Add(noticeLink, 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
Expand Down
3 changes: 2 additions & 1 deletion src/gui/TitleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Cafe/TitleList/GameInfo.h"
#include "util/helpers/helpers.h"
#include "gui/helpers/wxHelpers.h"
#include "gui/wxHelper.h"
#include "gui/components/wxTitleManagerList.h"
#include "gui/components/wxDownloadManagerList.h"
#include "gui/GameUpdateWindow.h"
Expand Down Expand Up @@ -479,7 +480,7 @@ void TitleManager::OnSaveOpenDirectory(wxCommandEvent& event)
if (!fs::exists(target) || !fs::is_directory(target))
return;

wxLaunchDefaultBrowser(fmt::format("file:{}", _utf8Wrapper(target)));
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _utf8Wrapper(target))));
}

void TitleManager::OnSaveDelete(wxCommandEvent& event)
Expand Down
10 changes: 5 additions & 5 deletions src/gui/components/wxGameList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ void wxGameList::OnContextMenuSelected(wxCommandEvent& event)
{
fs::path path(gameInfo.GetBase().GetPath());
_stripPathFilename(path);
wxLaunchDefaultBrowser(fmt::format("file:{}", _utf8Wrapper(path)));
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _utf8Wrapper(path))));
break;
}
case kWikiPage:
Expand All @@ -577,28 +577,28 @@ void wxGameList::OnContextMenuSelected(wxCommandEvent& event)
wxASSERT(!tokens.empty());
const std::string company_code = gameInfo.GetBase().GetMetaInfo()->GetCompanyCode();
wxASSERT(company_code.size() >= 2);
wxLaunchDefaultBrowser(fmt::format("https://wiki.cemu.info/wiki/{}{}", *tokens.rbegin(), company_code.substr(company_code.size() - 2).c_str()));
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("https://wiki.cemu.info/wiki/{}{}", *tokens.rbegin(), company_code.substr(company_code.size() - 2).c_str())));
}
break;
}

case kContextMenuSaveFolder:
{
wxLaunchDefaultBrowser(fmt::format("file:{}", _utf8Wrapper(gameInfo.GetSaveFolder())));
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _utf8Wrapper(gameInfo.GetSaveFolder()))));
break;
}
case kContextMenuUpdateFolder:
{
fs::path path(gameInfo.GetUpdate().GetPath());
_stripPathFilename(path);
wxLaunchDefaultBrowser(fmt::format("file:{}", _utf8Wrapper(path)));
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _utf8Wrapper(path))));
break;
}
case kContextMenuDLCFolder:
{
fs::path path(gameInfo.GetAOC().front().GetPath());
_stripPathFilename(path);
wxLaunchDefaultBrowser(fmt::format("file:{}", _utf8Wrapper(path)));
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _utf8Wrapper(path))));
break;
}
case kContextMenuEditGraphicPacks:
Expand Down
2 changes: 1 addition & 1 deletion src/gui/components/wxTitleManagerList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ void wxTitleManagerList::OnContextMenuSelected(wxCommandEvent& event)
case kContextMenuOpenDirectory:
{
const auto path = fs::is_directory(entry->path) ? entry->path : entry->path.parent_path();
wxLaunchDefaultBrowser(fmt::format("file:{}", _utf8Wrapper(path)));
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _utf8Wrapper(path))));
}
break;
case kContextMenuDelete:
Expand Down

0 comments on commit e5d7d5d

Please sign in to comment.