Macro: Fix validation of save dialog

Change-Id: I2a19e2954057b816152d6c5a01648f4b6db0a3ed
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2023-11-13 08:32:30 +01:00
parent b8d568979c
commit f73e7076cb

View File

@@ -35,6 +35,7 @@
#include <QLineEdit> #include <QLineEdit>
#include <QList> #include <QList>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton>
#include <QRegularExpressionValidator> #include <QRegularExpressionValidator>
namespace Macros::Internal { namespace Macros::Internal {
@@ -214,12 +215,17 @@ public:
setWindowTitle(Tr::tr("Save Macro")); setWindowTitle(Tr::tr("Save Macro"));
m_name = new QLineEdit; m_name = new QLineEdit;
m_name->setValidator(new QRegularExpressionValidator(QRegularExpression("\\w*"), this)); m_name->setValidator(new QRegularExpressionValidator(QRegularExpression("\\w+"), this));
m_description = new QLineEdit; m_description = new QLineEdit;
auto buttonBox = new QDialogButtonBox; auto buttonBox = new QDialogButtonBox;
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save); buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save);
auto saveButton = buttonBox->button(QDialogButtonBox::Save);
saveButton->setEnabled(false);
connect(m_name, &QLineEdit::textChanged, [saveButton, this]() {
saveButton->setEnabled(m_name->hasAcceptableInput());
});
using namespace Layouting; using namespace Layouting;