add ctrl enter as shortcut for ok when setting annotation (#4929)

This commit is contained in:
ebbit1q 2023-12-15 19:55:11 +01:00 committed by GitHub
parent 4acc8bfe80
commit 28f80e18a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 4 deletions

View file

@ -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<const ::google::protobuf::Message *> commandList;
for (const auto &item : sel) {

View file

@ -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