qv4l2: fix input parameters and missing status tips
cover qv4l2: fix input parameters and missing status tips
- Fixes some of the missing status tips in the general tab.
- Fixes the frequency hint, now displaying correct value hints.
- Fixes the program parameters.
PATCH 1/2 qv4l2: fix missing status tips
Signed-off-by Bård Eirik Winther <[email protected]>
--- utils/qv4l2/general-tab.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
utils/qv4l2/general-tab.cpp +9 -2
@@ -236,7 +236,9 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) m_freq = new QLineEdit(parent); m_freq->setValidator(val); m_freq->setWhatsThis(QString("Frequency\nLow: %1\nHigh: %2") - .arg(m_tuner.rangelow / factor).arg(m_tuner.rangehigh / factor)); + .arg(m_tuner.rangelow / factor) + .arg((double)m_tuner.rangehigh / factor, 0, 'f', 2)); + m_freq->setStatusTip(m_freq->whatsThis()); connect(m_freq, SIGNAL(lostFocus()), SLOT(freqChanged())); connect(m_freq, SIGNAL(returnPressed()), SLOT(freqChanged())); updateFreq();
@@ -306,7 +308,9 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) m_freq = new QLineEdit(parent); m_freq->setValidator(val); m_freq->setWhatsThis(QString("Frequency\nLow: %1\nHigh: %2") - .arg(m_modulator.rangelow / factor).arg(m_modulator.rangehigh / factor)); + .arg(m_tuner.rangelow / factor) + .arg((double)m_tuner.rangehigh / factor, 0, 'f', 2)); + m_freq->setStatusTip(m_freq->whatsThis()); connect(m_freq, SIGNAL(lostFocus()), SLOT(freqChanged())); connect(m_freq, SIGNAL(returnPressed()), SLOT(freqChanged())); updateFreq();
@@ -899,6 +903,7 @@ void GeneralTab::updateAudioInput() what += ", has AVL"; if (audio.mode & V4L2_AUDMODE_AVL) what += ", AVL is on"; + m_audioInput->setStatusTip(what); m_audioInput->setWhatsThis(what); }
@@ -951,6 +956,7 @@ void GeneralTab::updateStandard() (double)vs.frameperiod.numerator / vs.frameperiod.denominator, vs.frameperiod.numerator, vs.frameperiod.denominator, vs.framelines); + m_tvStandard->setStatusTip(what); m_tvStandard->setWhatsThis(what); updateVidCapFormat(); }
@@ -1014,6 +1020,7 @@ void GeneralTab::updateTimings() what.sprintf("Video Timings (%u)\n" "Frame %ux%u\n", p.index, p.timings.bt.width, p.timings.bt.height); + m_videoTimings->setStatusTip(what); m_videoTimings->setWhatsThis(what); updateVidCapFormat(); }
Signature · 1 line
1.8.4.rc1
PATCH 2/2 qv4l2: fix input parameters
In reply to Bård Eirik WintherSigned-off-by Bård Eirik Winther <[email protected]>
--- utils/qv4l2/qv4l2.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 96 insertions(+), 16 deletions(-)
utils/qv4l2/qv4l2.cpp +96 -16
@@ -1146,33 +1146,113 @@ void ApplicationWindow::closeEvent(QCloseEvent *event) ApplicationWindow *g_mw; +static void usage() +{ + printf(" Usage:\n" + " qv4l2 [-R] [-h] [-d <dev>] [-r <dev>] [-V <dev>]\n" + "\n -d, --device=<dev> use device <dev> as the video device\n" + " if <dev> is a number, then /dev/video<dev> is used\n" + " -r, --radio-device=<dev> use device <dev> as the radio device\n" + " if <dev> is a number, then /dev/radio<dev> is used\n" + " -V, --vbi-device=<dev> use device <dev> as the vbi device\n" + " if <dev> is a number, then /dev/vbi<dev> is used\n" + " -h, --help display this help message\n" + " -R, --raw open device in raw mode.\n"); +} + +static void usageError(const char *msg) +{ + printf("Missing parameter for %s\n", msg); + usage(); +} + +static QString getDeviceName(QString dev, QString &name) +{ + bool ok; + name.toInt(&ok); + return ok ? QString("%1%2").arg(dev).arg(name) : name; +} + int main(int argc, char **argv) { QApplication a(argc, argv); - QString device = "/dev/video0"; bool raw = false; - bool help = false; - int i; + QString device; + QString video_device; + QString radio_device; + QString vbi_device; a.setWindowIcon(QIcon(":/qv4l2.png")); g_mw = new ApplicationWindow(); g_mw->setWindowTitle("V4L2 Test Bench"); - for (i = 1; i < argc; i++) { - const char *arg = a.argv()[i]; - if (!strcmp(arg, "-r")) + QStringList args = a.arguments(); + for (int i = 1; i < args.size(); i++) { + + if (args[i] == "-d" || args[i] == "--device") { + ++i; + if (i >= args.size()) { + usageError("--device"); + return 0; + } + + video_device = args.at(i); + if (video_device.startsWith("-")) { + usageError("--device"); + return 0; + } + break; + + } else if (args[i] == "-r" || args[i] == "--radio-device") { + ++i; + if (i >= args.size()) { + usageError("--radio-device"); + return 0; + } + + radio_device = args.at(i); + if (radio_device.startsWith("-")) { + usageError("--radio-device"); + return 0; + } + break; + + } else if (args[i] == "-V" || args[i] == "--vbi-device") { + ++i; + if (i >= args.size()) { + usageError("--vbi-device"); + return 0; + } + + vbi_device = args.at(i); + if (vbi_device.startsWith("-")) { + usageError("--vbi-device"); + return 0; + } + break; + + } else if (args[i] == "-h" || args[i] == "--help") { + usage(); + return 0; + + } else if (args[i] == "-R" || args[i] == "--raw") { raw = true; - else if (!strcmp(arg, "-h")) - help = true; - else if (arg[0] != '-') - device = arg; - } - if (help) { - printf("qv4l2 [-r] [-h] [device node]\n\n" - "-h\tthis help message\n" - "-r\topen device node in raw mode\n"); - return 0; + break; + } else { + printf("Unknown argument %s\n", args[i].toAscii().data()); + return 0; + } } + + if (video_device != NULL) + device = getDeviceName("/dev/video", video_device); + else if (radio_device != NULL) + device = getDeviceName("/dev/radio", radio_device); + else if (vbi_device != NULL) + device = getDeviceName("/dev/vbi", vbi_device); + else + device = "/dev/video0"; + g_mw->setDevice(device, raw); g_mw->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
Signature · 1 line
1.8.4.rc1