software_keyboard.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 "common/assert.h"
  8. #include "core/frontend/applets/software_keyboard.h"
  9. class GMainWindow;
  10. class QDialogButtonBox;
  11. class QLabel;
  12. class QLineEdit;
  13. class QVBoxLayout;
  14. class QtSoftwareKeyboard;
  15. class QtSoftwareKeyboardValidator final : public QValidator {
  16. public:
  17. explicit QtSoftwareKeyboardValidator(Core::Frontend::SoftwareKeyboardParameters parameters);
  18. State validate(QString& input, int& pos) const override;
  19. private:
  20. Core::Frontend::SoftwareKeyboardParameters parameters;
  21. };
  22. class QtSoftwareKeyboardDialog final : public QDialog {
  23. Q_OBJECT
  24. public:
  25. QtSoftwareKeyboardDialog(QWidget* parent,
  26. Core::Frontend::SoftwareKeyboardParameters parameters);
  27. ~QtSoftwareKeyboardDialog() override;
  28. void Submit();
  29. void Reject();
  30. std::u16string GetText() const;
  31. bool GetStatus() const;
  32. private:
  33. bool ok = false;
  34. std::u16string text;
  35. QDialogButtonBox* buttons;
  36. QLabel* header_label;
  37. QLabel* sub_label;
  38. QLabel* guide_label;
  39. QLabel* length_label;
  40. QLineEdit* line_edit;
  41. QVBoxLayout* layout;
  42. Core::Frontend::SoftwareKeyboardParameters parameters;
  43. };
  44. class QtSoftwareKeyboard final : public QObject, public Core::Frontend::SoftwareKeyboardApplet {
  45. Q_OBJECT
  46. public:
  47. explicit QtSoftwareKeyboard(GMainWindow& parent);
  48. ~QtSoftwareKeyboard() override;
  49. void RequestText(std::function<void(std::optional<std::u16string>)> out,
  50. Core::Frontend::SoftwareKeyboardParameters parameters) const override;
  51. void SendTextCheckDialog(std::u16string error_message,
  52. std::function<void()> finished_check) const override;
  53. signals:
  54. void MainWindowGetText(Core::Frontend::SoftwareKeyboardParameters parameters) const;
  55. void MainWindowTextCheckDialog(std::u16string error_message) const;
  56. public slots:
  57. void MainWindowFinishedText(std::optional<std::u16string> text);
  58. void MainWindowFinishedCheckDialog();
  59. private:
  60. mutable std::function<void(std::optional<std::u16string>)> text_output;
  61. mutable std::function<void()> finished_check;
  62. };