Commit a414f42a authored by Ghislain MARY's avatar Ghislain MARY Committed by Milian Wolff
Browse files

show explanation on failed snippet name validation

Show a warning message in a KMessageWidget if a space character is
entered in the snippet name line edit.

BUG: 274299
REVIEW: 103904
parent 351f28b1
......@@ -25,6 +25,7 @@
#include <KTextEditor/View>
#include <KToolInvocation>
#include <KMessageBox>
#include <KMessageWidget>
#include "snippetstore.h"
#include "snippet.h"
......@@ -144,9 +145,15 @@ void EditSnippet::validate()
for ( int i = 0; i < name.length(); ++i ) {
if ( name.at(i).isSpace() ) {
valid = false;
m_ui->messageWidget->setText(i18n("Snippet name must not contain spaces"));
m_ui->messageWidget->animatedShow();
break;
}
}
if (valid) {
// hide message widget if snippet does not include spaces
m_ui->messageWidget->animatedHide();
}
}
button(Ok)->setEnabled(valid);
button(Apply)->setEnabled(valid);
......
......@@ -17,6 +17,19 @@
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="KMessageWidget" name="messageWidget">
<property name="visible">
<bool>false</bool>
</property>
<property name="closeButtonVisible">
<bool>false</bool>
</property>
<property name="messageType">
<enum>KMessageWidget::Warning</enum>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment