diff --git a/src/addressbook.cpp b/src/addressbook.cpp index cd9a490..85f9e56 100644 --- a/src/addressbook.cpp +++ b/src/addressbook.cpp @@ -98,6 +98,9 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { ab.setupUi(&d); Settings::saveRestore(&d); + QRegExpValidator v(QRegExp(Settings::labelRegExp), ab.label); + ab.label->setValidator(&v); + AddressBookModel model(ab.addresses); ab.addresses->setModel(&model); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d59634e..7c78be9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1045,6 +1045,10 @@ void MainWindow::setupRecieveTab() { } }); + // Validator for label + QRegExpValidator* v = new QRegExpValidator(QRegExp(Settings::labelRegExp), ui->rcvLabel); + ui->rcvLabel->setValidator(v); + // Select item in address list QObject::connect(ui->listRecieveAddresses, QOverload::of(&QComboBox::currentIndexChanged), [=] (int index) { diff --git a/src/settings.cpp b/src/settings.cpp index fdb464e..86b8f68 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -204,3 +204,4 @@ bool Settings::isValidAddress(QString addr) { ztsexp.exactMatch(addr) || zsexp.exactMatch(addr); } +const QString Settings::labelRegExp("[a-zA-Z0-9\\-_]{0,40}"); diff --git a/src/settings.h b/src/settings.h index fb18779..ee5318b 100644 --- a/src/settings.h +++ b/src/settings.h @@ -73,6 +73,8 @@ public: static bool isValidAddress(QString addr); + static const QString labelRegExp; + static const int updateSpeed = 20 * 1000; // 20 sec static const int quickUpdateSpeed = 5 * 1000; // 5 sec static const int priceRefreshSpeed = 60 * 60 * 1000; // 1 hr