fix z-board memo size/other validations
This commit is contained in:
@@ -18,7 +18,7 @@ int main(int argc, char *argv[])
|
|||||||
qApp->setFont(QFont("Ubuntu", 11, QFont::Normal, false));
|
qApp->setFont(QFont("Ubuntu", 11, QFont::Normal, false));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::srand(std::time(nullptr));
|
std::srand(static_cast<unsigned int>(std::time(nullptr)));
|
||||||
Settings::init();
|
Settings::init();
|
||||||
|
|
||||||
QCoreApplication::setOrganizationName("zec-qt-wallet-org");
|
QCoreApplication::setOrganizationName("zec-qt-wallet-org");
|
||||||
|
|||||||
@@ -445,6 +445,9 @@ void MainWindow::postToZBoard() {
|
|||||||
Ui_zboard zb;
|
Ui_zboard zb;
|
||||||
zb.setupUi(&d);
|
zb.setupUi(&d);
|
||||||
|
|
||||||
|
if (rpc->getConnection() == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
// Fill the from field with sapling addresses.
|
// Fill the from field with sapling addresses.
|
||||||
for (auto i = rpc->getAllBalances()->keyBegin(); i != rpc->getAllBalances()->keyEnd(); i++) {
|
for (auto i = rpc->getAllBalances()->keyBegin(); i != rpc->getAllBalances()->keyEnd(); i++) {
|
||||||
if (Settings::getInstance()->isSaplingAddress(*i) && rpc->getAllBalances()->value(*i) > 0) {
|
if (Settings::getInstance()->isSaplingAddress(*i) && rpc->getAllBalances()->value(*i) > 0) {
|
||||||
@@ -460,10 +463,20 @@ void MainWindow::postToZBoard() {
|
|||||||
zb.testnetWarning->setText("");
|
zb.testnetWarning->setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRegExpValidator v(QRegExp("^[a-zA-Z0-9_]{3,20}$"), zb.postAs);
|
||||||
|
zb.postAs->setValidator(&v);
|
||||||
|
|
||||||
zb.feeAmount->setText(Settings::getInstance()->getZECUSDDisplayFormat(Utils::getZboardAmount() + Utils::getMinerFee()));
|
zb.feeAmount->setText(Settings::getInstance()->getZECUSDDisplayFormat(Utils::getZboardAmount() + Utils::getMinerFee()));
|
||||||
|
|
||||||
QObject::connect(zb.memoTxt, &QPlainTextEdit::textChanged, [=] () {
|
auto fnBuildNameMemo = [=]() -> QString {
|
||||||
QString txt = zb.memoTxt->toPlainText();
|
auto memo = zb.memoTxt->toPlainText().trimmed();
|
||||||
|
if (!zb.postAs->text().trimmed().isEmpty())
|
||||||
|
memo = zb.postAs->text().trimmed() + ":: " + memo;
|
||||||
|
return memo;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto fnUpdateMemoSize = [=]() {
|
||||||
|
QString txt = fnBuildNameMemo();
|
||||||
zb.memoSize->setText(QString::number(txt.toUtf8().size()) + "/512");
|
zb.memoSize->setText(QString::number(txt.toUtf8().size()) + "/512");
|
||||||
|
|
||||||
if (txt.toUtf8().size() <= 512) {
|
if (txt.toUtf8().size() <= 512) {
|
||||||
@@ -472,12 +485,15 @@ void MainWindow::postToZBoard() {
|
|||||||
zb.memoSize->setStyleSheet("");
|
zb.memoSize->setStyleSheet("");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Overweight
|
// Overweight
|
||||||
zb.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
zb.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
zb.memoSize->setStyleSheet("color: red;");
|
zb.memoSize->setStyleSheet("color: red;");
|
||||||
}
|
}
|
||||||
|
};
|
||||||
});
|
|
||||||
|
// Memo text changed
|
||||||
|
QObject::connect(zb.memoTxt, &QPlainTextEdit::textChanged, fnUpdateMemoSize);
|
||||||
|
QObject::connect(zb.postAs, &QLineEdit::textChanged, fnUpdateMemoSize);
|
||||||
|
|
||||||
zb.memoTxt->setFocus();
|
zb.memoTxt->setFocus();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user