qv4l2: removed redundant set size
authorAnton Arbring <aarbring@cisco.com>
Tue, 22 Jul 2014 08:25:42 +0000 (10:25 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Tue, 22 Jul 2014 09:08:59 +0000 (11:08 +0200)
The widgets individual minimum sizes are enough
and the height calculation causes problems on
high dpi screens.

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

index 5ff3acc..2277607 100644 (file)
@@ -64,8 +64,6 @@ void ApplicationWindow::addWidget(QGridLayout *grid, QWidget *w, Qt::Alignment a
                w->setMinimumWidth(m_minWidth);
        if (w->sizeHint().width() > m_maxw[m_col])
                m_maxw[m_col] = w->sizeHint().width();
-       if (w->sizeHint().height() > m_maxh)
-               m_maxh = w->sizeHint().height();
        grid->addWidget(w, m_row, m_col, align | Qt::AlignVCenter);
        m_col++;
        if (m_col == m_cols) {
@@ -74,7 +72,7 @@ void ApplicationWindow::addWidget(QGridLayout *grid, QWidget *w, Qt::Alignment a
        }
 }
 
-void ApplicationWindow::addTabs(int size[])
+void ApplicationWindow::addTabs(int m_winWidth)
 {
        v4l2_query_ext_ctrl qec = { 0 };
        unsigned ctrl_class;
@@ -160,22 +158,16 @@ void ApplicationWindow::addTabs(int size[])
                fixWidth(grid);
 
                int totalw = 0;
-               int totalh = 0;
                int diff = 0;
                for (int i = 0; i < m_cols; i++) {
                        totalw += m_maxw[i] + m_pxw;
                }
-               totalh = grid->rowCount() * m_maxh;
-               if (totalw > size[0])
-                       size[0] = totalw;
+               if (totalw > m_winWidth)
+                       m_winWidth = totalw;
                else {
-                 diff = size[0] - totalw;
+                 diff = m_winWidth - totalw;
                  grid->setHorizontalSpacing(diff/5);
                }
-               if (totalh > size[1])
-                       size[1] = totalh;
-               setMinimumSize(size[0], size[1]);
-
                grid = new QGridLayout(w);
                finishGrid(grid, ctrl_class);
        }
index 76de783..f4ff8f5 100644 (file)
@@ -64,7 +64,6 @@ GeneralTab::GeneralTab(const QString &device, cv4l_fd *fd, int n, QWidget *paren
        m_pxw(25.0),
        m_vMargin(10),
        m_hMargin(20),
-       m_maxh(0),
        m_isRadio(false),
        m_isSDR(false),
        m_isVbi(false),
@@ -1077,8 +1076,6 @@ void GeneralTab::addWidget(QWidget *w, Qt::Alignment align)
                w->setMinimumWidth(m_minWidth);
        if (w->sizeHint().width() > m_maxw[m_col])
                m_maxw[m_col] = w->sizeHint().width();
-       if (w->sizeHint().height() > m_maxh)
-               m_maxh = w->sizeHint().height();
        QGridLayout::addWidget(w, m_row, m_col, align | Qt::AlignVCenter);
        m_col++;
        if (m_col == m_cols) {
@@ -1116,11 +1113,6 @@ int GeneralTab::getWidth()
        return total;
 }
 
-int GeneralTab::getHeight()
-{
-       return rowCount() * m_maxh;
-}
-
 bool GeneralTab::isSlicedVbi() const
 {
        return m_vbiMethods && m_vbiMethods->currentText() == "Sliced";
index 84955f0..afa380f 100644 (file)
@@ -83,7 +83,6 @@ public:
        unsigned getDisplayColorspace() const;
        unsigned getColorspace() const;
        int getWidth();
-       int getHeight();
 
 public slots:
        void showAllAudioDevices(bool use);
index 472f203..dffacc0 100644 (file)
@@ -68,7 +68,6 @@ ApplicationWindow::ApplicationWindow() :
        m_minWidth(175),
        m_vMargin(15),
        m_hMargin(5),
-       m_maxh(0),
        m_genTab(NULL),
        m_sigMapper(NULL)
 {
@@ -246,10 +245,7 @@ void ApplicationWindow::setDevice(const QString &device, bool rawOpen)
 
        QWidget *w = new QWidget(m_tabs);
        m_genTab = new GeneralTab(device, this, 4, w);
-       int size[2];
-       size[0] = m_genTab->getWidth();
-       size[1] = m_genTab->getHeight();
-       setMinimumSize(size[0], size[1]);
+       int m_winWidth = m_genTab->getWidth();
 
 #ifdef HAVE_ALSA
        if (m_genTab->hasAlsaAudio()) {
@@ -268,7 +264,7 @@ void ApplicationWindow::setDevice(const QString &device, bool rawOpen)
        connect(m_genTab, SIGNAL(displayColorspaceChanged()), this, SLOT(updateDisplayColorspace()));
        connect(m_genTab, SIGNAL(clearBuffers()), this, SLOT(clearBuffers()));
        m_tabs->addTab(w, "General Settings");
-       addTabs(size);
+       addTabs(m_winWidth);
        m_vbiTab = NULL;
        if (has_vbi_cap()) {
                w = new QWidget(m_tabs);
index f90c6c9..d8ab231 100644 (file)
@@ -169,7 +169,7 @@ private:
                addWidget(grid, new QLabel(text, parentWidget()), align);
        }
        void fixWidth(QGridLayout *grid);
-       void addTabs(int size[]);
+       void addTabs(int m_winWidth);
        void finishGrid(QGridLayout *grid, unsigned ctrl_class);
        void addCtrl(QGridLayout *grid, const struct v4l2_query_ext_ctrl &qec);
        void updateCtrl(unsigned id);
@@ -204,7 +204,6 @@ private:
        const int m_vMargin;
        const int m_hMargin;
        int m_maxw[4];
-       int m_maxh;
        int m_increment;
        GeneralTab *m_genTab;
        VbiTab *m_vbiTab;