aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/applets/software_keyboard.h
blob: 8d95ca511f75130b2fcdd099f6c4746594521949 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2018 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <QDialog>
#include <QValidator>
#include "common/assert.h"
#include "core/frontend/applets/software_keyboard.h"

class GMainWindow;
class QDialogButtonBox;
class QLabel;
class QLineEdit;
class QVBoxLayout;
class QtSoftwareKeyboard;

class QtSoftwareKeyboardValidator final : public QValidator {
public:
    explicit QtSoftwareKeyboardValidator(Core::Frontend::SoftwareKeyboardParameters parameters);
    State validate(QString& input, int& pos) const override;

private:
    Core::Frontend::SoftwareKeyboardParameters parameters;
};

class QtSoftwareKeyboardDialog final : public QDialog {
    Q_OBJECT

public:
    QtSoftwareKeyboardDialog(QWidget* parent,
                             Core::Frontend::SoftwareKeyboardParameters parameters);
    ~QtSoftwareKeyboardDialog() override;

    void Submit();
    void Reject();

    std::u16string GetText() const;
    bool GetStatus() const;

private:
    bool ok = false;
    std::u16string text;

    QDialogButtonBox* buttons;
    QLabel* header_label;
    QLabel* sub_label;
    QLabel* guide_label;
    QLineEdit* line_edit;
    QVBoxLayout* layout;

    Core::Frontend::SoftwareKeyboardParameters parameters;
};

class QtSoftwareKeyboard final : public QObject, public Core::Frontend::SoftwareKeyboardApplet {
public:
    explicit QtSoftwareKeyboard(GMainWindow& parent);
    ~QtSoftwareKeyboard() override;

    std::optional<std::u16string> GetText(
        Core::Frontend::SoftwareKeyboardParameters parameters) const override;
    void SendTextCheckDialog(std::u16string error_message) const override;

private:
    GMainWindow& main_window;
};