qv4l2: better handling of string controls with a step > 1
authorHans Verkuil <hans.verkuil@cisco.com>
Sat, 12 Jul 2014 00:28:56 +0000 (02:28 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Sat, 12 Jul 2014 00:28:56 +0000 (02:28 +0200)
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 <hans.verkuil@cisco.com>
utils/qv4l2/ctrl-tab.cpp

index 6156d99..a036c7d 100644 (file)
@@ -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<QLineEdit *>(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)