yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

applet: Add operation completed callback

This commit is contained in:
Zach Hilman 2018-11-17 12:18:03 -05:00
parent 6209fe0c27
commit 19b2571aec
8 changed files with 34 additions and 9 deletions

View File

@ -18,10 +18,12 @@ void DefaultSoftwareKeyboardApplet::RequestText(
out(parameters.initial_text);
}
void DefaultSoftwareKeyboardApplet::SendTextCheckDialog(std::u16string error_message) const {
void DefaultSoftwareKeyboardApplet::SendTextCheckDialog(
std::u16string error_message, std::function<void()> finished_check) const {
LOG_WARNING(Service_AM,
"(STUBBED) called - Default fallback software keyboard does not support text "
"check! (error_message={})",
Common::UTF16ToUTF8(error_message));
finished_check();
}
} // namespace Core::Frontend

View File

@ -39,14 +39,16 @@ public:
virtual void RequestText(std::function<void(std::optional<std::u16string>)> out,
SoftwareKeyboardParameters parameters) const = 0;
virtual void SendTextCheckDialog(std::u16string error_message) const = 0;
virtual void SendTextCheckDialog(std::u16string error_message,
std::function<void()> finished_check) const = 0;
};
class DefaultSoftwareKeyboardApplet final : public SoftwareKeyboardApplet {
public:
void RequestText(std::function<void(std::optional<std::u16string>)> out,
SoftwareKeyboardParameters parameters) const override;
void SendTextCheckDialog(std::u16string error_message) const override;
void SendTextCheckDialog(std::u16string error_message,
std::function<void()> finished_check) const override;
};
} // namespace Core::Frontend

View File

@ -605,8 +605,10 @@ private:
ASSERT(applet != nullptr);
applet->Initialize(storage_stack);
storage_stack.clear();
interactive_storage_stack.clear();
while (!storage_stack.empty())
storage_stack.pop();
while (!interactive_storage_stack.empty())
interactive_storage_stack.pop();
applet->Execute([this](IStorage storage) { AppletStorageProxyOutData(storage); },
[this](IStorage storage) { AppletStorageProxyOutInteractiveData(storage); },
[this] { state_changed_event->Signal(); });

View File

@ -87,7 +87,7 @@ void SoftwareKeyboard::ReceiveInteractiveData(std::shared_ptr<IStorage> storage)
std::array<char16_t, SWKBD_OUTPUT_INTERACTIVE_BUFFER_SIZE / 2 - 2> string;
std::memcpy(string.data(), data.data() + 4, string.size() * 2);
frontend.SendTextCheckDialog(
Common::UTF16StringFromFixedZeroTerminatedBuffer(string.data(), string.size()));
Common::UTF16StringFromFixedZeroTerminatedBuffer(string.data(), string.size()), state);
}
}

View File

@ -3,11 +3,13 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <mutex>
#include <QDialogButtonBox>
#include <QFont>
#include <QLabel>
#include <QLineEdit>
#include <QVBoxLayout>
#include "core/hle/lock.h"
#include "yuzu/applets/software_keyboard.h"
#include "yuzu/main.h"
@ -122,10 +124,20 @@ void QtSoftwareKeyboard::RequestText(std::function<void(std::optional<std::u16st
emit MainWindowGetText(parameters);
}
void QtSoftwareKeyboard::SendTextCheckDialog(std::u16string error_message) const {
void QtSoftwareKeyboard::SendTextCheckDialog(std::u16string error_message,
std::function<void()> finished_check) const {
this->finished_check = finished_check;
emit MainWindowTextCheckDialog(error_message);
}
void QtSoftwareKeyboard::MainWindowFinishedText(std::optional<std::u16string> text) {
// Acquire the HLE mutex
std::lock_guard<std::recursive_mutex> lock(HLE::g_hle_lock);
text_output(text);
}
void QtSoftwareKeyboard::MainWindowFinishedCheckDialog() {
// Acquire the HLE mutex
std::lock_guard<std::recursive_mutex> lock(HLE::g_hle_lock);
finished_check();
}

View File

@ -62,7 +62,8 @@ public:
void RequestText(std::function<void(std::optional<std::u16string>)> out,
Core::Frontend::SoftwareKeyboardParameters parameters) const override;
void SendTextCheckDialog(std::u16string error_message) const override;
void SendTextCheckDialog(std::u16string error_message,
std::function<void()> finished_check) const override;
signals:
void MainWindowGetText(Core::Frontend::SoftwareKeyboardParameters parameters) const;
@ -70,7 +71,9 @@ signals:
public slots:
void MainWindowFinishedText(std::optional<std::u16string> text);
void MainWindowFinishedCheckDialog();
private:
mutable std::function<void(std::optional<std::u16string>)> text_output;
mutable std::function<void()> finished_check;
};

View File

@ -215,14 +215,17 @@ void GMainWindow::SoftwareKeyboardGetText(
dialog.setWindowModality(Qt::WindowModal);
dialog.exec();
if (!dialog.GetStatus())
if (!dialog.GetStatus()) {
emit SoftwareKeyboardFinishedText(std::nullopt);
return;
}
emit SoftwareKeyboardFinishedText(dialog.GetText());
}
void GMainWindow::SoftwareKeyboardInvokeCheckDialog(std::u16string error_message) {
QMessageBox::warning(this, tr("Text Check Failed"), QString::fromStdU16String(error_message));
emit SoftwareKeyboardFinishedCheckDialog();
}
void GMainWindow::InitializeWidgets() {

View File

@ -100,6 +100,7 @@ signals:
void UpdateThemedIcons();
void SoftwareKeyboardFinishedText(std::optional<std::u16string> text);
void SoftwareKeyboardFinishedCheckDialog();
public slots:
void SoftwareKeyboardGetText(const Core::Frontend::SoftwareKeyboardParameters& parameters);