Commit c85f3a55 authored by Ghislain Mary's avatar Ghislain Mary Committed by Kevin Funk
Browse files

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.

TODO: Apply to kate/part/snippets as well

BUG: 274299
REVIEW: 103904
parent 0aaac7dc
......@@ -25,6 +25,7 @@
#include <KTextEditor/View>
#include <KToolInvocation>
#include <KMessageBox>
#include <KMessageWidget>
#include "snippetstore.h"
#include "snippet.h"
......@@ -145,9 +146,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 cannot 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