]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
Calc: allow pasting full precision Monero amounts
authortobtoht <thotbot@protonmail.com>
Thu, 21 Oct 2021 19:08:33 +0000 (21:08 +0200)
committertobtoht <thotbot@protonmail.com>
Thu, 21 Oct 2021 19:08:33 +0000 (21:08 +0200)
src/CalcWidget.cpp

index f773716787535ecbd9c54a22f200ba6708728fa6..8bc654df51714ab0fe11cbee99456d69ac425eda 100644 (file)
@@ -23,13 +23,12 @@ CalcWidget::CalcWidget(QWidget *parent)
     ui->imageExchange->setFixedSize(26, 26);
 
     // validator/locale for input
-    QLocale lo(QLocale::C);
-    lo.setNumberOptions(QLocale::RejectGroupSeparator);
-    auto dv = new QDoubleValidator(0.0, 2147483647, 10, this); // [0, 32bit max], 10 decimals of precision
-    dv->setNotation(QDoubleValidator::StandardNotation);
-    dv->setLocale(lo);
-    ui->lineFrom->setValidator(dv);
-    ui->lineTo->setValidator(dv);
+    QString amount_rx = R"(^\d{0,8}[\.]\d{0,12}$)";
+    QRegExp rx;
+    rx.setPattern(amount_rx);
+    QValidator *validator = new QRegExpValidator(rx, this);
+    ui->lineFrom->setValidator(validator);
+    ui->lineTo->setValidator(validator);
 
     connect(&appData()->prices, &Prices::fiatPricesUpdated, this, &CalcWidget::onPricesReceived);
     connect(&appData()->prices, &Prices::cryptoPricesUpdated, this, &CalcWidget::onPricesReceived);