qv4l2: use the new toolbutton for three buttons in the general tab
authorHans Verkuil <hans.verkuil@cisco.com>
Thu, 17 Jul 2014 10:52:20 +0000 (12:52 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Thu, 17 Jul 2014 10:52:20 +0000 (12:52 +0200)
Replace the old pushbutton for Refresh Tuner Status and Query Standard
and Timings with the new, much better looking tool button.

This allows us to put the label on the left and the tuner status on
the right of the tool button, which looks much better.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/qv4l2/general-tab.cpp
utils/qv4l2/general-tab.h

index 716bd7a..c5e732b 100644 (file)
@@ -26,6 +26,7 @@
 #include <QComboBox>
 #include <QCheckBox>
 #include <QPushButton>
+#include <QToolButton>
 #include <QLineEdit>
 #include <QDoubleValidator>
 
@@ -306,8 +307,9 @@ void GeneralTab::inputSection(bool needsStd, bool needsTimings, v4l2_input vin)
                connect(m_tvStandard, SIGNAL(activated(int)), SLOT(standardChanged(int)));
                refreshStandards();
                if (ioctl_exists(VIDIOC_QUERYSTD, &tmp)) {
-                       m_qryStandard = new QPushButton("Query Standard", parentWidget());
-                       m_stdRow->addWidget(new QLabel("", parentWidget()), 0, 2, Qt::AlignLeft);
+                       m_qryStandard = new QToolButton(parentWidget());
+                       m_qryStandard->setIcon(QIcon(":/enterbutt.png"));
+                       m_stdRow->addWidget(new QLabel("Query Standard", parentWidget()), 0, 2, Qt::AlignLeft);
                        m_stdRow->addWidget(m_qryStandard, 0, 3, Qt::AlignLeft);
                        connect(m_qryStandard, SIGNAL(clicked()), SLOT(qryStdClicked()));
                }
@@ -323,8 +325,9 @@ void GeneralTab::inputSection(bool needsStd, bool needsTimings, v4l2_input vin)
                m_timRow->addWidget(m_videoTimings, 0, 1, Qt::AlignLeft);
                connect(m_videoTimings, SIGNAL(activated(int)), SLOT(timingsChanged(int)));
                refreshTimings();
-               m_qryTimings = new QPushButton("Query Timings", parentWidget());
-               m_timRow->addWidget(new QLabel("", parentWidget()), 0, 2, Qt::AlignLeft);
+               m_qryTimings = new QToolButton(parentWidget());
+               m_qryTimings->setIcon(QIcon(":/enterbutt.png"));
+               m_timRow->addWidget(new QLabel("Query Timings", parentWidget()), 0, 2, Qt::AlignLeft);
                m_timRow->addWidget(m_qryTimings, 0, 3, Qt::AlignLeft);
                connect(m_qryTimings, SIGNAL(clicked()), SLOT(qryTimingsClicked()));
        }
@@ -361,10 +364,22 @@ void GeneralTab::inputSection(bool needsStd, bool needsTimings, v4l2_input vin)
        }
 
        if (m_tuner.capability && !isSDR()) {
-               m_subchannels = new QLabel("", parentWidget());
-               m_detectSubchans = new QPushButton("Refresh Tuner Status", parentWidget());
-               m_freqRows->addWidget(m_subchannels, 0, 2, Qt::AlignLeft);
-               m_freqRows->addWidget(m_detectSubchans, 0, 3, Qt::AlignLeft);
+               QLabel *l = new QLabel("Refresh Tuner Status", parentWidget());
+               QWidget *w = new QWidget(parentWidget());
+               QHBoxLayout *box = new QHBoxLayout(w);
+
+               box->setMargin(0);
+               m_detectSubchans = new QToolButton(w);
+               m_detectSubchans->setIcon(QIcon(":/enterbutt.png"));
+               m_subchannels = new QLabel("", w);
+               //m_detectSubchans->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
+               //m_subchannels->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
+               box->addWidget(m_detectSubchans, 0, Qt::AlignLeft);
+               box->addWidget(m_subchannels, 0, Qt::AlignLeft);
+               //box->addStretch(1000);
+               //w->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+               m_freqRows->addWidget(l, 0, 2, Qt::AlignLeft);
+               m_freqRows->addWidget(w, 0, 3, Qt::AlignLeft);
                connect(m_detectSubchans, SIGNAL(clicked()), SLOT(detectSubchansClicked()));
                detectSubchansClicked();
        }
@@ -779,10 +794,12 @@ void GeneralTab::fixWidth()
                        if ((*i)->itemAt(n)->widget()->sizeHint().width() > m_maxw[n % 4]) {
                                m_maxw[n % 4] = (*i)->itemAt(n)->widget()->sizeHint().width();
                        }
-                       if (n % 2)
-                               (*i)->itemAt(n)->widget()->setMinimumWidth(m_minWidth);
-                       else
+                       if (n % 2) {
+                               if (!qobject_cast<QToolButton*>((*i)->itemAt(n)->widget()))
+                                       (*i)->itemAt(n)->widget()->setMinimumWidth(m_minWidth);
+                       } else {
                                (*i)->itemAt(n)->widget()->setMinimumWidth(m_maxw[n % 4]);
+                       }
                }
                for (int j = 0; j < m_cols; j++) {
                        if (j % 2)
@@ -1046,7 +1063,7 @@ void GeneralTab::changeAudioDevice()
 
 void GeneralTab::addWidget(QWidget *w, Qt::Alignment align)
 {
-       if (m_col % 2)
+       if (m_col % 2 && !qobject_cast<QToolButton*>(w))
                w->setMinimumWidth(m_minWidth);
        if (w->sizeHint().width() > m_maxw[m_col])
                m_maxw[m_col] = w->sizeHint().width();
index 4ee0395..79865da 100644 (file)
@@ -45,7 +45,7 @@ extern "C" {
 class QComboBox;
 class QCheckBox;
 class QSpinBox;
-class QPushButton;
+class QToolButton;
 class QSlider;
 
 class GeneralTab: public QGridLayout, public v4l2
@@ -231,13 +231,13 @@ private:
        QComboBox *m_audioInput;
        QComboBox *m_audioOutput;
        QComboBox *m_tvStandard;
-       QPushButton *m_qryStandard;
+       QToolButton *m_qryStandard;
        QComboBox *m_videoTimings;
        QComboBox *m_pixelAspectRatio;
        QComboBox *m_colorspace;
        QComboBox *m_displayColorspace;
        QComboBox *m_cropping;
-       QPushButton *m_qryTimings;
+       QToolButton *m_qryTimings;
        QDoubleSpinBox *m_freq;
        QComboBox *m_freqTable;
        QComboBox *m_freqChannel;
@@ -246,7 +246,7 @@ private:
        QDoubleSpinBox *m_freqRf;
        QCheckBox *m_stereoMode;
        QCheckBox *m_rdsMode;
-       QPushButton *m_detectSubchans;
+       QToolButton *m_detectSubchans;
        QComboBox *m_vidCapFormats;
        QComboBox *m_vidFields;
        QComboBox *m_frameSize;