From e06a40edcd378030aa700f14874d110c7593efdd Mon Sep 17 00:00:00 2001 From: kvazar Date: Sat, 30 Mar 2024 04:20:21 +0200 Subject: [PATCH] disable save button on key/value length limit reached #7 --- src/qt/kevaaddkeydialog.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qt/kevaaddkeydialog.cpp b/src/qt/kevaaddkeydialog.cpp index 12a71ecbf..3c32d9a56 100644 --- a/src/qt/kevaaddkeydialog.cpp +++ b/src/qt/kevaaddkeydialog.cpp @@ -49,12 +49,16 @@ void KevaAddKeyDialog::cancel() void KevaAddKeyDialog::onKeyChanged(const QString& key) { - bool enabled = key.length() > 0 && ui->valueText->toPlainText().length() > 0; + bool enabled = key.length() > 0 && ui->valueText->toPlainText().length() > 0 && + key.length() <= 255 && ui->valueText->toPlainText().length() < MAX_SCRIPT_ELEMENT_SIZE + 1; + ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); } void KevaAddKeyDialog::onValueChanged() { - bool enabled = ui->valueText->toPlainText().length() > 0 && ui->keyText->text().length() > 0; + bool enabled = ui->keyText->text().length() > 0 && ui->valueText->toPlainText().length() > 0 && + ui->keyText->text().length() <= 255 && ui->valueText->toPlainText().length() < MAX_SCRIPT_ELEMENT_SIZE + 1; + ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); }