Host: Add ReportStatusMessage()

This commit is contained in:
Stenzek
2026-01-12 17:33:44 +10:00
parent 8f94a56ab2
commit 82ab3e84a5
4 changed files with 21 additions and 0 deletions

View File

@@ -37,6 +37,9 @@ std::optional<std::time_t> GetResourceFileTimestamp(std::string_view filename, b
/// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller.
void ReportErrorAsync(std::string_view title, std::string_view message);
/// Displays a message in either the on-screen display or status bar, depending on host capabilities.
void ReportStatusMessage(std::string_view message);
/// Displays an asynchronous confirmation on the UI thread, but does not block the caller.
/// The callback may be executed on a different thread. Use RunOnCoreThread() in the callback to ensure safety.
using ConfirmMessageAsyncCallback = std::function<void(bool)>;

View File

@@ -1329,6 +1329,11 @@ void Host::ReportErrorAsync(std::string_view title, std::string_view message)
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, TinyString(title).c_str(), SmallString(message).c_str(), nullptr);
}
void Host::ReportStatusMessage(std::string_view message)
{
Host::AddOSDMessage(OSDMessageType::Info, std::string(message));
}
void Host::RequestResizeHostDisplay(s32 width, s32 height)
{
using namespace MiniHost;

View File

@@ -2081,6 +2081,14 @@ void Host::ReportErrorAsync(std::string_view title, std::string_view message)
message.empty() ? QString() : QString::fromUtf8(message.data(), message.size()));
}
void Host::ReportStatusMessage(std::string_view message)
{
if (message.empty())
return;
emit g_core_thread->statusMessage(QtUtils::StringViewToQString(message));
}
void Host::ConfirmMessageAsync(std::string_view title, std::string_view message, ConfirmMessageAsyncCallback callback,
std::string_view yes_text, std::string_view no_text)
{

View File

@@ -166,6 +166,11 @@ void Host::ReportErrorAsync(std::string_view title, std::string_view message)
ERROR_LOG("ReportErrorAsync: {}", message);
}
void Host::ReportStatusMessage(std::string_view message)
{
INFO_LOG("ReportStatusMessage: {}", message);
}
void Host::ConfirmMessageAsync(std::string_view title, std::string_view message, ConfirmMessageAsyncCallback callback,
std::string_view yes_text, std::string_view no_text)
{