diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index ee9870e3..13ef543e 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -3246,6 +3246,16 @@ void Player::actFlowT() actIncPT(-1, 1); } +void AnnotationDialog::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Return && event->modifiers() & Qt::ControlModifier) { + event->accept(); + accept(); + return; + } + QInputDialog::keyPressEvent(event); +} + void Player::actSetAnnotation() { QString oldAnnotation; @@ -3257,15 +3267,18 @@ void Player::actSetAnnotation() } } - bool ok; dialogSemaphore = true; - QString annotation = QInputDialog::getMultiLineText(game, tr("Set annotation"), - tr("Please enter the new annotation:"), oldAnnotation, &ok) - .left(MAX_NAME_LENGTH); + AnnotationDialog *dialog = new AnnotationDialog(game); + dialog->setOptions(QInputDialog::UsePlainTextEditForTextInput); + dialog->setWindowTitle(tr("Set annotation")); + dialog->setLabelText(tr("Please enter the new annotation:")); + dialog->setTextValue(oldAnnotation); + bool ok = dialog->exec(); dialogSemaphore = false; if (clearCardsToDelete() || !ok) { return; } + QString annotation = dialog->textValue().left(MAX_NAME_LENGTH); QList commandList; for (const auto &item : sel) { diff --git a/cockatrice/src/player.h b/cockatrice/src/player.h index f19c6306..646644a1 100644 --- a/cockatrice/src/player.h +++ b/cockatrice/src/player.h @@ -477,4 +477,15 @@ public: void setLastToken(CardInfoPtr cardInfo); }; +class AnnotationDialog : public QInputDialog +{ + Q_OBJECT + void keyPressEvent(QKeyEvent *e) override; + +public: + AnnotationDialog(QWidget *parent) : QInputDialog(parent) + { + } +}; + #endif