|
|
@ -79,13 +79,13 @@ void KevaAddKeyDialog::cancel() |
|
|
|
void KevaAddKeyDialog::onKeyChanged(const QString& key) |
|
|
|
void KevaAddKeyDialog::onKeyChanged(const QString& key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Calculate current size
|
|
|
|
// Calculate current size
|
|
|
|
int keyTextLength = key.toStdString().size(); |
|
|
|
int keySize = key.toStdString().size(); |
|
|
|
int valueTextLength = ui->valueText->toPlainText().toStdString().size(); |
|
|
|
int valueSize = ui->valueText->toPlainText().toStdString().size(); |
|
|
|
|
|
|
|
|
|
|
|
// Update counter value
|
|
|
|
// Update counter value
|
|
|
|
ui->keyCounter->setText( |
|
|
|
ui->keyCounter->setText( |
|
|
|
QString::number( |
|
|
|
QString::number( |
|
|
|
keyTextLength |
|
|
|
keySize |
|
|
|
) + "/" + QString::number( |
|
|
|
) + "/" + QString::number( |
|
|
|
255 |
|
|
|
255 |
|
|
|
) |
|
|
|
) |
|
|
@ -96,7 +96,7 @@ void KevaAddKeyDialog::onKeyChanged(const QString& key) |
|
|
|
|
|
|
|
|
|
|
|
keyCounterPalette.setColor( |
|
|
|
keyCounterPalette.setColor( |
|
|
|
QPalette::WindowText, |
|
|
|
QPalette::WindowText, |
|
|
|
keyTextLength > 255 ? Qt::red : Qt::darkGreen |
|
|
|
keySize > 255 ? Qt::red : Qt::darkGreen |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
ui->keyCounter->setPalette( |
|
|
|
ui->keyCounter->setPalette( |
|
|
@ -104,8 +104,8 @@ void KevaAddKeyDialog::onKeyChanged(const QString& key) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Update button status
|
|
|
|
// Update button status
|
|
|
|
bool enabled = keyTextLength > 0 && valueTextLength > 0 && |
|
|
|
bool enabled = keySize > 0 && valueSize > 0 && |
|
|
|
keyTextLength <= 255 && valueTextLength < MAX_SCRIPT_ELEMENT_SIZE + 1; |
|
|
|
keySize <= 255 && valueSize < MAX_SCRIPT_ELEMENT_SIZE + 1; |
|
|
|
|
|
|
|
|
|
|
|
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); |
|
|
|
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); |
|
|
|
} |
|
|
|
} |
|
|
@ -113,13 +113,13 @@ void KevaAddKeyDialog::onKeyChanged(const QString& key) |
|
|
|
void KevaAddKeyDialog::onValueChanged() |
|
|
|
void KevaAddKeyDialog::onValueChanged() |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Calculate current size
|
|
|
|
// Calculate current size
|
|
|
|
int keyTextLength = ui->keyText->text().toStdString().size(); |
|
|
|
int keySize = ui->keyText->text().toStdString().size(); |
|
|
|
int valueTextLength = ui->valueText->toPlainText().toStdString().size(); |
|
|
|
int valueSize = ui->valueText->toPlainText().toStdString().size(); |
|
|
|
|
|
|
|
|
|
|
|
// Update counter value
|
|
|
|
// Update counter value
|
|
|
|
ui->valueCounter->setText( |
|
|
|
ui->valueCounter->setText( |
|
|
|
QString::number( |
|
|
|
QString::number( |
|
|
|
valueTextLength |
|
|
|
valueSize |
|
|
|
) + "/" + QString::number( |
|
|
|
) + "/" + QString::number( |
|
|
|
MAX_SCRIPT_ELEMENT_SIZE |
|
|
|
MAX_SCRIPT_ELEMENT_SIZE |
|
|
|
) |
|
|
|
) |
|
|
@ -130,7 +130,7 @@ void KevaAddKeyDialog::onValueChanged() |
|
|
|
|
|
|
|
|
|
|
|
valueCounterPalette.setColor( |
|
|
|
valueCounterPalette.setColor( |
|
|
|
QPalette::WindowText, |
|
|
|
QPalette::WindowText, |
|
|
|
valueTextLength > MAX_SCRIPT_ELEMENT_SIZE ? Qt::red : Qt::darkGreen |
|
|
|
valueSize > MAX_SCRIPT_ELEMENT_SIZE ? Qt::red : Qt::darkGreen |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
ui->valueCounter->setPalette( |
|
|
|
ui->valueCounter->setPalette( |
|
|
@ -138,8 +138,8 @@ void KevaAddKeyDialog::onValueChanged() |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Update button status
|
|
|
|
// Update button status
|
|
|
|
bool enabled = keyTextLength > 0 && valueTextLength > 0 && |
|
|
|
bool enabled = keySize > 0 && valueSize > 0 && |
|
|
|
keyTextLength <= 255 && valueTextLength < MAX_SCRIPT_ELEMENT_SIZE + 1; |
|
|
|
keySize <= 255 && valueSize < MAX_SCRIPT_ELEMENT_SIZE + 1; |
|
|
|
|
|
|
|
|
|
|
|
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); |
|
|
|
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); |
|
|
|
} |
|
|
|
} |
|
|
|