Commit 15420d6c authored by Kevin Funk's avatar Kevin Funk
Browse files

Explanation on failed snippet validation

Forward port of: https://git.reviewboard.kde.org/r/103904.

CCBUG: 274299
REVIEW: 110481
parent bd3ea32c
......@@ -37,6 +37,7 @@
#include <KTextEditor/View>
#include <KToolInvocation>
#include <KMessageBox>
#include <KMessageWidget>
#include "snippetstore.h"
#include "snippet.h"
......@@ -157,9 +158,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