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,50 +56,43 @@ 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"> <widget class="QLabel" name="label_7">
<property name="spacing"> <property name="sizePolicy">
<number>14</number> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<item> <property name="text">
<widget class="QLabel" name="label_7"> <string>Computer &amp;name</string>
<property name="sizePolicy"> </property>
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <property name="buddy">
<horstretch>0</horstretch> <cstring>m_pLineEditName</cstring>
<verstretch>0</verstretch> </property>
</sizepolicy> </widget>
</property>
<property name="text">
<string>Computer &amp;name</string>
</property>
<property name="buddy">
<cstring>m_pLineEditName</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_pLineEditName">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxLength">
<number>255</number>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item row="0" column="1">
<widget class="QLineEdit" name="m_pLineEditName">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxLength">
<number>255</number>
</property>
</widget>
</item>
<item row="1" column="1">
<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));