2018-11-09 20:13:15 -05:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
2018-11-11 16:39:25 -05:00
|
|
|
|
2018-11-09 20:13:15 -05:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QValidator>
|
|
|
|
#include "common/assert.h"
|
|
|
|
#include "core/frontend/applets/software_keyboard.h"
|
|
|
|
|
2018-11-11 16:39:25 -05:00
|
|
|
class GMainWindow;
|
2018-11-09 20:13:15 -05:00
|
|
|
class QDialogButtonBox;
|
|
|
|
class QLabel;
|
|
|
|
class QLineEdit;
|
|
|
|
class QVBoxLayout;
|
|
|
|
class QtSoftwareKeyboard;
|
|
|
|
|
|
|
|
class QtSoftwareKeyboardValidator final : public QValidator {
|
|
|
|
public:
|
2018-11-11 16:39:25 -05:00
|
|
|
explicit QtSoftwareKeyboardValidator(Core::Frontend::SoftwareKeyboardParameters parameters);
|
|
|
|
State validate(QString& input, int& pos) const override;
|
2018-11-09 20:13:15 -05:00
|
|
|
|
|
|
|
private:
|
2018-11-11 16:39:25 -05:00
|
|
|
Core::Frontend::SoftwareKeyboardParameters parameters;
|
2018-11-09 20:13:15 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class QtSoftwareKeyboardDialog final : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
QtSoftwareKeyboardDialog(QWidget* parent,
|
2018-11-11 16:39:25 -05:00
|
|
|
Core::Frontend::SoftwareKeyboardParameters parameters);
|
|
|
|
~QtSoftwareKeyboardDialog() override;
|
|
|
|
|
2018-11-20 11:36:47 -05:00
|
|
|
void accept() override;
|
|
|
|
void reject() override;
|
2018-11-09 20:13:15 -05:00
|
|
|
|
2018-11-11 20:16:38 -05:00
|
|
|
std::u16string GetText() const;
|
|
|
|
bool GetStatus() const;
|
2018-11-11 16:39:25 -05:00
|
|
|
|
2018-11-09 20:13:15 -05:00
|
|
|
private:
|
|
|
|
bool ok = false;
|
|
|
|
std::u16string text;
|
|
|
|
|
|
|
|
QDialogButtonBox* buttons;
|
|
|
|
QLabel* header_label;
|
|
|
|
QLabel* sub_label;
|
|
|
|
QLabel* guide_label;
|
2018-11-17 14:44:16 -05:00
|
|
|
QLabel* length_label;
|
2018-11-09 20:13:15 -05:00
|
|
|
QLineEdit* line_edit;
|
|
|
|
QVBoxLayout* layout;
|
|
|
|
|
2018-11-11 16:39:25 -05:00
|
|
|
Core::Frontend::SoftwareKeyboardParameters parameters;
|
2018-11-09 20:13:15 -05:00
|
|
|
};
|
|
|
|
|
2018-11-11 16:39:25 -05:00
|
|
|
class QtSoftwareKeyboard final : public QObject, public Core::Frontend::SoftwareKeyboardApplet {
|
2018-11-12 11:08:09 -05:00
|
|
|
Q_OBJECT
|
|
|
|
|
2018-11-09 20:13:15 -05:00
|
|
|
public:
|
2018-11-11 16:39:25 -05:00
|
|
|
explicit QtSoftwareKeyboard(GMainWindow& parent);
|
|
|
|
~QtSoftwareKeyboard() override;
|
2018-11-09 20:13:15 -05:00
|
|
|
|
2018-11-12 11:08:09 -05:00
|
|
|
void RequestText(std::function<void(std::optional<std::u16string>)> out,
|
|
|
|
Core::Frontend::SoftwareKeyboardParameters parameters) const override;
|
2018-11-17 12:18:03 -05:00
|
|
|
void SendTextCheckDialog(std::u16string error_message,
|
|
|
|
std::function<void()> finished_check) const override;
|
2018-11-09 20:13:15 -05:00
|
|
|
|
2018-11-12 11:08:09 -05:00
|
|
|
signals:
|
|
|
|
void MainWindowGetText(Core::Frontend::SoftwareKeyboardParameters parameters) const;
|
|
|
|
void MainWindowTextCheckDialog(std::u16string error_message) const;
|
|
|
|
|
2018-11-20 11:29:19 -05:00
|
|
|
private:
|
2018-11-12 11:08:09 -05:00
|
|
|
void MainWindowFinishedText(std::optional<std::u16string> text);
|
2018-11-17 12:18:03 -05:00
|
|
|
void MainWindowFinishedCheckDialog();
|
2018-11-12 11:08:09 -05:00
|
|
|
|
|
|
|
mutable std::function<void(std::optional<std::u16string>)> text_output;
|
2018-11-17 12:18:03 -05:00
|
|
|
mutable std::function<void()> finished_check;
|
2018-11-09 20:13:15 -05:00
|
|
|
};
|