software_keyboard.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2018 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <QDialog>
  6. #include <QValidator>
  7. #include "core/frontend/applets/software_keyboard.h"
  8. class GMainWindow;
  9. class QDialogButtonBox;
  10. class QLabel;
  11. class QLineEdit;
  12. class QVBoxLayout;
  13. class QtSoftwareKeyboard;
  14. class QtSoftwareKeyboardValidator final : public QValidator {
  15. public:
  16. explicit QtSoftwareKeyboardValidator(Core::Frontend::SoftwareKeyboardParameters parameters);
  17. State validate(QString& input, int& pos) const override;
  18. private:
  19. Core::Frontend::SoftwareKeyboardParameters parameters;
  20. };
  21. class QtSoftwareKeyboardDialog final : public QDialog {
  22. Q_OBJECT
  23. public:
  24. QtSoftwareKeyboardDialog(QWidget* parent,
  25. Core::Frontend::SoftwareKeyboardParameters parameters);
  26. ~QtSoftwareKeyboardDialog() override;
  27. void accept() override;
  28. void reject() override;
  29. std::u16string GetText() const;
  30. private:
  31. std::u16string text;
  32. QDialogButtonBox* buttons;
  33. QLabel* header_label;
  34. QLabel* sub_label;
  35. QLabel* guide_label;
  36. QLabel* length_label;
  37. QLineEdit* line_edit;
  38. QVBoxLayout* layout;
  39. Core::Frontend::SoftwareKeyboardParameters parameters;
  40. };
  41. class QtSoftwareKeyboard final : public QObject, public Core::Frontend::SoftwareKeyboardApplet {
  42. Q_OBJECT
  43. public:
  44. explicit QtSoftwareKeyboard(GMainWindow& parent);
  45. ~QtSoftwareKeyboard() override;
  46. void RequestText(std::function<void(std::optional<std::u16string>)> out,
  47. Core::Frontend::SoftwareKeyboardParameters parameters) const override;
  48. void SendTextCheckDialog(std::u16string error_message,
  49. std::function<void()> finished_check) const override;
  50. signals:
  51. void MainWindowGetText(Core::Frontend::SoftwareKeyboardParameters parameters) const;
  52. void MainWindowTextCheckDialog(std::u16string error_message) const;
  53. private:
  54. void MainWindowFinishedText(std::optional<std::u16string> text);
  55. void MainWindowFinishedCheckDialog();
  56. mutable std::function<void(std::optional<std::u16string>)> text_output;
  57. mutable std::function<void()> finished_check;
  58. };