applets/swkbd: Add callback support

This commit is contained in:
zhupengfei 2019-03-17 09:35:20 +08:00
parent 2ff7ed4200
commit 8078256a88
6 changed files with 154 additions and 64 deletions

View file

@ -109,14 +109,20 @@ void QtKeyboardDialog::HandleValidationError(Frontend::ValidationError error) {
QtKeyboard::QtKeyboard(QWidget& parent_) : parent(parent_) {}
void QtKeyboard::Setup(const Frontend::KeyboardConfig& config) {
SoftwareKeyboard::Setup(config);
void QtKeyboard::Execute(const Frontend::KeyboardConfig& config) {
SoftwareKeyboard::Execute(config);
if (this->config.button_config != Frontend::ButtonConfig::None) {
ok_id = static_cast<u8>(this->config.button_config);
}
QMetaObject::invokeMethod(this, "OpenInputDialog", Qt::BlockingQueuedConnection);
}
void QtKeyboard::ShowError(const std::string& error) {
QString message = QString::fromStdString(error);
QMetaObject::invokeMethod(this, "ShowErrorDialog", Qt::BlockingQueuedConnection,
Q_ARG(QString, message));
}
void QtKeyboard::OpenInputDialog() {
QtKeyboardDialog dialog(&parent, this);
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
@ -127,3 +133,7 @@ void QtKeyboard::OpenInputDialog() {
dialog.button);
Finalize(dialog.text.toStdString(), dialog.button);
}
void QtKeyboard::ShowErrorDialog(QString message) {
QMessageBox::critical(&parent, tr("Software Keyboard"), message);
}