SYNERGY-936 Update computer name validation

This commit is contained in:
Serhii Hadzhilov 2021-05-07 14:29:18 +03:00
parent b82f34eddf
commit 8db102bd6b
2 changed files with 31 additions and 38 deletions

View file

@ -56,19 +56,14 @@ background-color: rgba(192,192,192, 0.1);
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<property name="topMargin"> <property name="topMargin">
<number>15</number> <number>15</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>15</number> <number>15</number>
</property> </property>
<item> <item row="0" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>14</number>
</property>
<item>
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -84,7 +79,7 @@ background-color: rgba(192,192,192, 0.1);
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QLineEdit" name="m_pLineEditName"> <widget class="QLineEdit" name="m_pLineEditName">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -97,9 +92,7 @@ background-color: rgba(192,192,192, 0.1);
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="1" column="1">
</item>
<item>
<widget class="QLabel" name="m_pLabelNameError"> <widget class="QLabel" name="m_pLabelNameError">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -123,7 +116,7 @@ font-weight: bold;</string>
<string/> <string/>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>

View file

@ -29,7 +29,7 @@ namespace validators
ScreenNameValidator::ScreenNameValidator(QLineEdit* parent, QLabel* errors, const ScreenList* pScreens) : ScreenNameValidator::ScreenNameValidator(QLineEdit* parent, QLabel* errors, const ScreenList* pScreens) :
LineEditValidator(parent, errors) LineEditValidator(parent, errors)
{ {
addValidator(std::make_unique<EmptyStringValidator>("Computer name can't be empty")); addValidator(std::make_unique<EmptyStringValidator>("Computer name is required"));
addValidator(std::make_unique<SpacesValidator>("Remove spaces")); addValidator(std::make_unique<SpacesValidator>("Remove spaces"));
addValidator(std::make_unique<RegExpValidator>("Remove unsupported characters", QRegExp("[a-z0-9\\._-]{,255}", Qt::CaseInsensitive))); addValidator(std::make_unique<RegExpValidator>("Remove unsupported characters", QRegExp("[a-z0-9\\._-]{,255}", Qt::CaseInsensitive)));
addValidator(std::make_unique<ScreenDuplicationsValidator>("A computer with this name already exists", parent ? parent->text() : "", pScreens)); addValidator(std::make_unique<ScreenDuplicationsValidator>("A computer with this name already exists", parent ? parent->text() : "", pScreens));