From 5241a897f4098274e52b9cf420eddb7ee1a6fe4a Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 12 Jul 2014 02:28:56 +0200 Subject: [PATCH] qv4l2: better handling of string controls with a step > 1 The strings will be filled-out to the end of the step size. That way the user doesn't have to count spaces just to make sure the right string length is returned. Signed-off-by: Hans Verkuil --- utils/qv4l2/ctrl-tab.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/qv4l2/ctrl-tab.cpp b/utils/qv4l2/ctrl-tab.cpp index 6156d99..a036c7d 100644 --- a/utils/qv4l2/ctrl-tab.cpp +++ b/utils/qv4l2/ctrl-tab.cpp @@ -494,15 +494,19 @@ QString ApplicationWindow::getString(unsigned id) const v4l2_queryctrl &qctrl = m_ctrlMap[id]; QWidget *w = m_widgetMap[qctrl.id]; QString v; + int mod; switch (qctrl.type) { case V4L2_CTRL_TYPE_STRING: v = static_cast(w)->text(); + mod = v.length() % qctrl.step; + if (mod) + v += QString(qctrl.step - mod, ' '); break; default: break; } - setWhat(w, id, v); + setWhat(w, id, QString("'") + v + "'"); return v; } @@ -904,7 +908,7 @@ void ApplicationWindow::setString(unsigned id, const QString &v) default: break; } - setWhat(w, id, v); + setWhat(w, id, QString("'") + v + "'"); } void ApplicationWindow::setDefaults(unsigned ctrl_class) -- 2.7.4