diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-11-12 17:08:09 +0100 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-11-18 16:53:47 +0100 |
commit | 8b433beff34c382e50334bb59c4f71394845558c (patch) | |
tree | f52f432b2ee5f4ef3917c1c0e2fa052930d68f3a /src/yuzu/applets | |
parent | am: Allow applets to push multiple and different channels of data (diff) | |
download | yuzu-8b433beff34c382e50334bb59c4f71394845558c.tar yuzu-8b433beff34c382e50334bb59c4f71394845558c.tar.gz yuzu-8b433beff34c382e50334bb59c4f71394845558c.tar.bz2 yuzu-8b433beff34c382e50334bb59c4f71394845558c.tar.lz yuzu-8b433beff34c382e50334bb59c4f71394845558c.tar.xz yuzu-8b433beff34c382e50334bb59c4f71394845558c.tar.zst yuzu-8b433beff34c382e50334bb59c4f71394845558c.zip |
Diffstat (limited to 'src/yuzu/applets')
-rw-r--r-- | src/yuzu/applets/software_keyboard.cpp | 27 | ||||
-rw-r--r-- | src/yuzu/applets/software_keyboard.h | 15 |
2 files changed, 29 insertions, 13 deletions
diff --git a/src/yuzu/applets/software_keyboard.cpp b/src/yuzu/applets/software_keyboard.cpp index 92992ef87..9fb179f5c 100644 --- a/src/yuzu/applets/software_keyboard.cpp +++ b/src/yuzu/applets/software_keyboard.cpp @@ -105,20 +105,27 @@ bool QtSoftwareKeyboardDialog::GetStatus() const { return ok; } -QtSoftwareKeyboard::QtSoftwareKeyboard(GMainWindow& parent) : main_window(parent) {} +QtSoftwareKeyboard::QtSoftwareKeyboard(GMainWindow& main_window) { + connect(this, &QtSoftwareKeyboard::MainWindowGetText, &main_window, + &GMainWindow::SoftwareKeyboardGetText, Qt::QueuedConnection); + connect(this, &QtSoftwareKeyboard::MainWindowTextCheckDialog, &main_window, + &GMainWindow::SoftwareKeyboardInvokeCheckDialog, Qt::BlockingQueuedConnection); + connect(&main_window, &GMainWindow::SoftwareKeyboardFinishedText, this, + &QtSoftwareKeyboard::MainWindowFinishedText, Qt::QueuedConnection); +} QtSoftwareKeyboard::~QtSoftwareKeyboard() = default; -std::optional<std::u16string> QtSoftwareKeyboard::GetText( - Core::Frontend::SoftwareKeyboardParameters parameters) const { - std::optional<std::u16string> success; - QMetaObject::invokeMethod(&main_window, "SoftwareKeyboardGetText", Qt::BlockingQueuedConnection, - Q_RETURN_ARG(std::optional<std::u16string>, success), - Q_ARG(Core::Frontend::SoftwareKeyboardParameters, parameters)); - return success; +void QtSoftwareKeyboard::RequestText(std::function<void(std::optional<std::u16string>)> out, + Core::Frontend::SoftwareKeyboardParameters parameters) const { + text_output = out; + emit MainWindowGetText(parameters); } void QtSoftwareKeyboard::SendTextCheckDialog(std::u16string error_message) const { - QMetaObject::invokeMethod(&main_window, "SoftwareKeyboardInvokeCheckDialog", - Qt::BlockingQueuedConnection, Q_ARG(std::u16string, error_message)); + emit MainWindowTextCheckDialog(error_message); +} + +void QtSoftwareKeyboard::MainWindowFinishedText(std::optional<std::u16string> text) { + text_output(text); } diff --git a/src/yuzu/applets/software_keyboard.h b/src/yuzu/applets/software_keyboard.h index 8d95ca511..670b05dc9 100644 --- a/src/yuzu/applets/software_keyboard.h +++ b/src/yuzu/applets/software_keyboard.h @@ -54,14 +54,23 @@ private: }; class QtSoftwareKeyboard final : public QObject, public Core::Frontend::SoftwareKeyboardApplet { + Q_OBJECT + public: explicit QtSoftwareKeyboard(GMainWindow& parent); ~QtSoftwareKeyboard() override; - std::optional<std::u16string> GetText( - Core::Frontend::SoftwareKeyboardParameters parameters) const override; + void RequestText(std::function<void(std::optional<std::u16string>)> out, + Core::Frontend::SoftwareKeyboardParameters parameters) const override; void SendTextCheckDialog(std::u16string error_message) const override; +signals: + void MainWindowGetText(Core::Frontend::SoftwareKeyboardParameters parameters) const; + void MainWindowTextCheckDialog(std::u16string error_message) const; + +public slots: + void MainWindowFinishedText(std::optional<std::u16string> text); + private: - GMainWindow& main_window; + mutable std::function<void(std::optional<std::u16string>)> text_output; }; |