aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/extcap_argument.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/qt/extcap_argument.cpp b/ui/qt/extcap_argument.cpp
index e7e5f4a736..ed7884eb25 100644
--- a/ui/qt/extcap_argument.cpp
+++ b/ui/qt/extcap_argument.cpp
@@ -451,6 +451,34 @@ bool ExtArgText::isValid()
if (isRequired() && value().length() == 0)
valid = false;
+ /* Does the validator, if any, consider the value valid?
+ *
+ * If it considers it an "intermediate" value, rather than an "invalid"
+ * value, the user will be able to transfer the input focus to another
+ * widget, and, as long as all widgets have values for which isValid()
+ * is true, they wil be able to click the "Start" button.
+ *
+ * For QIntValidator(), used for integral fields with minimum and
+ * maximum values, a value that's larger than the maximum but has
+ * the same number of digits as the maximum is "intermediate" rather
+ * than "invalid", so the user will be able to cause that value to
+ * be passed to the extcap module; see bug 16510.
+ *
+ * So we explicitly call the hasAcceptableInput() method on the
+ * text box; that returns false if the value is not "valid", and
+ * that includes "intermediate" values.
+ *
+ * This way, 1) non-colorblind users are informed that the value
+ * is invalid by the text box background being red (perhaps the
+ * user isn't fully colorblind, or perhaps the background is a
+ * noticeably different grayscale), and 2) the user won't be able
+ * to start the capture until they fix the problem.
+ *
+ * XXX - it might be nice to have some way of indicating to the
+ * user what the problem is with the value - alert box? Tooltip? */
+ if (!textBox->hasAcceptableInput())
+ valid = false;
+
/* validation should only be checked if there is a value. if the argument
* must be present (isRequired) the check above will handle that */
if (valid && _argument->regexp != NULL && value().length() > 0)