From: Hans Verkuil Date: Tue, 8 Jul 2014 21:34:13 +0000 (+0200) Subject: Revert "qv4l2: alignment and size mods" X-Git-Tag: v4l-utils-1.3.90~149 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0da875368f31b350d3731e1cabb0a08b0e223cd;p=platform%2Fupstream%2Fv4l-utils.git Revert "qv4l2: alignment and size mods" This reverts commit 59fae23b008f4f12a655f35cecdb1248412524a7. --- diff --git a/utils/qv4l2/ctrl-tab.cpp b/utils/qv4l2/ctrl-tab.cpp index f177b21..c8aff55 100644 --- a/utils/qv4l2/ctrl-tab.cpp +++ b/utils/qv4l2/ctrl-tab.cpp @@ -34,7 +34,6 @@ #include #include -#include #include #include #include @@ -59,10 +58,6 @@ static bool is_valid_type(__u32 type) void ApplicationWindow::addWidget(QGridLayout *grid, QWidget *w, Qt::Alignment align) { - if (m_col % 2) - w->setMinimumWidth(m_minWidth); - if (w->sizeHint().width() > m_maxw[m_col]) - m_maxw[m_col] = w->sizeHint().width(); grid->addWidget(w, m_row, m_col, align | Qt::AlignVCenter); m_col++; if (m_col == m_cols) { @@ -71,7 +66,7 @@ void ApplicationWindow::addWidget(QGridLayout *grid, QWidget *w, Qt::Alignment a } } -void ApplicationWindow::addTabs(int size[]) +void ApplicationWindow::addTabs() { v4l2_queryctrl qctrl; unsigned ctrl_class; @@ -135,9 +130,6 @@ void ApplicationWindow::addTabs(int size[]) id = ctrl_class | 1; m_col = m_row = 0; m_cols = 4; - for (int j = 0; j < m_cols; j++) { - m_maxw[j] = 0; - } const v4l2_queryctrl &qctrl = m_ctrlMap[id]; QWidget *t = new QWidget(m_tabs); @@ -147,6 +139,7 @@ void ApplicationWindow::addTabs(int size[]) vbox->addWidget(w); QGridLayout *grid = new QGridLayout(w); + grid->setSpacing(3); m_tabs->addTab(t, (char *)qctrl.name); for (i = 0; i < iter->second.size(); i++) { @@ -160,52 +153,11 @@ void ApplicationWindow::addTabs(int size[]) grid->setRowStretch(grid->rowCount() - 1, 1); w = new QWidget(t); vbox->addWidget(w); - fixWidth(grid); - - int totalw = 0; - int totalh = 0; - for (int i = 0; i < m_cols; i++) { - if (i % 2) - totalw += (m_maxw[i]+m_pxw); - else - totalw += (m_maxw[i]); - } - totalh = grid->rowCount()*20; - if (totalw > size[0]) - size[0] = totalw; - if (totalh > size[1]) - size[1] = totalh; - setMinimumSize(size[0]+50, size[1]+150); - grid = new QGridLayout(w); finishGrid(grid, ctrl_class); } } -void ApplicationWindow::fixWidth(QGridLayout *grid) -{ - double m_pxw = 25.0; - grid->setContentsMargins(25,20,25,20); - grid->setColumnStretch(1,1); - QList list = grid->parentWidget()->parentWidget()->findChildren(); - QList::iterator it; - - for (it = list.begin(); it != list.end(); ++it) { - if (((*it)->sizeHint().width()) > m_minWidth) { - m_increment = (int) ceil(((*it)->sizeHint().width() - m_minWidth)/m_pxw); - (*it)->setMinimumWidth(m_minWidth+(m_increment*m_pxw)); // for stepsize expantion of widgets - } - } - - for (int j = 0; j < m_cols; j++) - { - if (j % 2) // only add possible expansion for odd columns - grid->setColumnMinimumWidth(j, m_maxw[j]+m_pxw); - else - grid->setColumnMinimumWidth(j, m_maxw[j]); - } -} - void ApplicationWindow::finishGrid(QGridLayout *grid, unsigned ctrl_class) { QWidget *w = grid->parentWidget(); @@ -216,9 +168,6 @@ void ApplicationWindow::finishGrid(QGridLayout *grid, unsigned ctrl_class) grid->addWidget(frame, 0, 0, 1, m_cols); m_col = 0; m_row = grid->rowCount(); - - QWidget *m_w = new QWidget(); - QHBoxLayout *m_boxLayoutBottom = new QHBoxLayout(m_w); QCheckBox *cbox = new QCheckBox("Update on change", w); m_widgetMap[ctrl_class | CTRL_UPDATE_ON_CHANGE] = cbox; @@ -230,24 +179,23 @@ void ApplicationWindow::finishGrid(QGridLayout *grid, unsigned ctrl_class) QPushButton *defBut = new QPushButton("Set Defaults", w); m_widgetMap[ctrl_class | CTRL_DEFAULTS] = defBut; - m_boxLayoutBottom->addWidget(defBut); + addWidget(grid, defBut); connect(defBut, SIGNAL(clicked()), m_sigMapper, SLOT(map())); m_sigMapper->setMapping(defBut, ctrl_class | CTRL_DEFAULTS); QPushButton *refreshBut = new QPushButton("Refresh", w); m_widgetMap[ctrl_class | CTRL_REFRESH] = refreshBut; - m_boxLayoutBottom->addWidget(refreshBut); + addWidget(grid, refreshBut); connect(refreshBut, SIGNAL(clicked()), m_sigMapper, SLOT(map())); m_sigMapper->setMapping(refreshBut, ctrl_class | CTRL_REFRESH); QPushButton *button = new QPushButton("Update", w); m_widgetMap[ctrl_class | CTRL_UPDATE] = button; - m_boxLayoutBottom->addWidget(button); + addWidget(grid, button); connect(button, SIGNAL(clicked()), m_sigMapper, SLOT(map())); m_sigMapper->setMapping(button, ctrl_class | CTRL_UPDATE); connect(cbox, SIGNAL(toggled(bool)), button, SLOT(setDisabled(bool))); - - grid->addWidget(m_w, m_row, 3, Qt::AlignRight); + cbox->setChecked(true); refresh(ctrl_class); @@ -267,7 +215,7 @@ void ApplicationWindow::addCtrl(QGridLayout *grid, const v4l2_queryctrl &qctrl) QHBoxLayout *m_boxLayout = new QHBoxLayout(wContainer); m_boxLayout->setMargin(0); unsigned dif; - + switch (qctrl.type) { case V4L2_CTRL_TYPE_INTEGER: addLabel(grid, name); diff --git a/utils/qv4l2/general-tab.cpp b/utils/qv4l2/general-tab.cpp index b9159c4..9760bac 100644 --- a/utils/qv4l2/general-tab.cpp +++ b/utils/qv4l2/general-tab.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -102,24 +101,20 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) m_device.append(device); setSpacing(3); setSizeConstraint(QLayout::SetMinimumSize); - m_minWidth = 175; - for (int i = 0; i < n; i++) { - m_maxw[i] = 0; - } if (querycap(m_querycap)) { addLabel("Device:"); - addLabel(device + (useWrapper() ? " (wrapped)" : "")); + addLabel(device + (useWrapper() ? " (wrapped)" : ""), Qt::AlignLeft); addLabel("Driver:"); - addLabel((char *)m_querycap.driver); + addLabel((char *)m_querycap.driver, Qt::AlignLeft); addLabel("Card:"); - addLabel((char *)m_querycap.card); + addLabel((char *)m_querycap.card, Qt::AlignLeft); addLabel("Bus:"); - addLabel((char *)m_querycap.bus_info); + addLabel((char *)m_querycap.bus_info, Qt::AlignLeft); } g_tuner(m_tuner); @@ -187,19 +182,18 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) QWidget *wStd = new QWidget(); QGridLayout *m_stdRow = new QGridLayout(wStd); - m_grids.append(m_stdRow); if (needsStd) { v4l2_std_id tmp; m_tvStandard = new QComboBox(parent); - m_stdRow->addWidget(new QLabel("TV Standard", parentWidget()), 0, 0, Qt::AlignLeft); + m_stdRow->addWidget(new QLabel("TV Standard", parentWidget()), 0, 0, Qt::AlignRight); m_stdRow->addWidget(m_tvStandard, 0, 1, Qt::AlignLeft); connect(m_tvStandard, SIGNAL(activated(int)), SLOT(standardChanged(int))); refreshStandards(); if (ioctl_exists(VIDIOC_QUERYSTD, &tmp)) { m_qryStandard = new QPushButton("Query Standard", parent); - m_stdRow->addWidget(new QLabel("", parentWidget()), 0, 2, Qt::AlignLeft); + m_stdRow->addWidget(new QLabel("", parentWidget()), 0, 2, Qt::AlignRight); m_stdRow->addWidget(m_qryStandard, 0, 3, Qt::AlignLeft); connect(m_qryStandard, SIGNAL(clicked()), SLOT(qryStdClicked())); } @@ -207,16 +201,15 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) QWidget *wTim = new QWidget(); QGridLayout *m_timRow = new QGridLayout(wTim); - m_grids.append(m_timRow); if (needsTimings) { m_videoTimings = new QComboBox(parent); - m_timRow->addWidget(new QLabel("Video Timings", parentWidget()), 0, 0, Qt::AlignLeft); + m_timRow->addWidget(new QLabel("Video Timings", parentWidget()), 0, 0, Qt::AlignRight); 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", parent); - m_timRow->addWidget(new QLabel("", parentWidget()), 0, 2, Qt::AlignLeft); + m_timRow->addWidget(new QLabel("", parentWidget()), 0, 2, Qt::AlignRight); m_timRow->addWidget(m_qryTimings, 0, 3, Qt::AlignLeft); connect(m_qryTimings, SIGNAL(clicked()), SLOT(qryTimingsClicked())); } @@ -230,26 +223,24 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) QWidget *wFrameSR = new QWidget(); QGridLayout *m_wh = new QGridLayout(wFrameWH); QGridLayout *m_sr = new QGridLayout(wFrameSR); - m_grids.append(m_wh); - m_grids.append(m_sr); - m_wh->addWidget(new QLabel("Frame Width", parentWidget()), 0, 0, Qt::AlignLeft); + m_wh->addWidget(new QLabel("Frame Width", parentWidget()), 0, 0, Qt::AlignRight); m_frameWidth = new QSpinBox(parent); m_wh->addWidget(m_frameWidth, 0, 1, Qt::AlignLeft); connect(m_frameWidth, SIGNAL(editingFinished()), SLOT(frameWidthChanged())); - m_wh->addWidget(new QLabel("Frame Height", parentWidget()), 0, 2, Qt::AlignLeft); + m_wh->addWidget(new QLabel("Frame Height", parentWidget()), 0, 2, Qt::AlignRight); m_frameHeight = new QSpinBox(parent); m_wh->addWidget(m_frameHeight, 0, 3, Qt::AlignLeft); connect(m_frameHeight, SIGNAL(editingFinished()), SLOT(frameHeightChanged())); - m_sr->addWidget(new QLabel("Frame Size", parentWidget()), 0, 0, Qt::AlignLeft); + m_sr->addWidget(new QLabel("Frame Size", parentWidget()), 0, 0, Qt::AlignRight); m_frameSize = new QComboBox(parent); m_frameSize->setSizeAdjustPolicy(QComboBox::AdjustToContents); m_sr->addWidget(m_frameSize, 0, 1, Qt::AlignLeft); connect(m_frameSize, SIGNAL(activated(int)), SLOT(frameSizeChanged(int))); - m_sr->addWidget(new QLabel("Frame Rate", parentWidget()), 0, 2, Qt::AlignLeft); + m_sr->addWidget(new QLabel("Frame Rate", parentWidget()), 0, 2, Qt::AlignRight); m_frameInterval = new QComboBox(parent); m_frameInterval->setSizeAdjustPolicy(QComboBox::AdjustToContents); m_sr->addWidget(m_frameInterval, 0, 3, Qt::AlignLeft); @@ -263,7 +254,6 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) QWidget *wFreq = new QWidget(); QGridLayout *m_freqRows = new QGridLayout(wFreq); - m_grids.append(m_freqRows); if (m_tuner.capability) { const char *unit = (m_tuner.capability & V4L2_TUNER_CAP_LOW) ? " kHz" : @@ -283,14 +273,14 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) m_freq->setStatusTip(m_freq->whatsThis()); connect(m_freq, SIGNAL(valueChanged(double)), SLOT(freqChanged(double))); updateFreq(); - m_freqRows->addWidget(new QLabel("Frequency", parentWidget()), 0, 0, Qt::AlignLeft); + m_freqRows->addWidget(new QLabel("Frequency", parentWidget()), 0, 0, Qt::AlignRight); m_freqRows->addWidget(m_freq, 0, 1, Qt::AlignLeft); } if (m_tuner.capability && !isSDR()) { m_subchannels = new QLabel("", parent); m_detectSubchans = new QPushButton("Refresh Tuner Status", parent); - m_freqRows->addWidget(m_subchannels, 0, 2, Qt::AlignLeft); + m_freqRows->addWidget(m_subchannels, 0, 2, Qt::AlignRight); m_freqRows->addWidget(m_detectSubchans, 0, 3, Qt::AlignLeft); connect(m_detectSubchans, SIGNAL(clicked()), SLOT(detectSubchansClicked())); detectSubchansClicked(); @@ -301,13 +291,13 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) for (int i = 0; v4l2_channel_lists[i].name; i++) { m_freqTable->addItem(v4l2_channel_lists[i].name); } - m_freqRows->addWidget(new QLabel("Frequency Table", parentWidget()), 1, 0, Qt::AlignLeft); + m_freqRows->addWidget(new QLabel("Frequency Table", parentWidget()), 1, 0, Qt::AlignRight); m_freqRows->addWidget(m_freqTable, 1, 1, Qt::AlignLeft); connect(m_freqTable, SIGNAL(activated(int)), SLOT(freqTableChanged(int))); m_freqChannel = new QComboBox(parent); m_freqChannel->setSizeAdjustPolicy(QComboBox::AdjustToContents); - m_freqRows->addWidget(new QLabel("Channels", parentWidget()), 1, 2, Qt::AlignLeft); + m_freqRows->addWidget(new QLabel("Channels", parentWidget()), 1, 2, Qt::AlignRight); m_freqRows->addWidget(m_freqChannel, 1, 3, Qt::AlignLeft); connect(m_freqChannel, SIGNAL(activated(int)), SLOT(freqChannelChanged(int))); updateFreqChannel(); @@ -701,52 +691,6 @@ done: updateGUI(m_videoInput->currentIndex()); else updateGUI(0); - fixWidth(); -} - -void GeneralTab::fixWidth() -{ - m_pxw = 25.0; - setContentsMargins(25,20,25,20); - setColumnStretch(1,1); - - QList list = parentWidget()->findChildren(); - QList::iterator it; - for (it = list.begin(); it != list.end(); ++it) { - if (((*it)->sizeHint().width()) > m_minWidth) { - m_increment = (int) ceil(((*it)->sizeHint().width() - m_minWidth)/m_pxw); - (*it)->setMinimumWidth(m_minWidth+(m_increment*m_pxw)); // for stepsize expansion of widgets - } - } - - //fix width of subgrids - QList::iterator i; - for (i = m_grids.begin(); i != m_grids.end(); ++i) { - (*i)->setColumnStretch(1,1); - (*i)->setContentsMargins(0,0,0,0); - for (int n = 0; n < (*i)->count(); n++) { - 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 - (*i)->itemAt(n)->widget()->setMinimumWidth(m_maxw[n % 4]); - } - for (int j = 0; j < m_cols; j++) { - if (j % 2) - (*i)->setColumnMinimumWidth(j,m_maxw[j]+m_pxw); - else - (*i)->setColumnMinimumWidth(j,m_maxw[j]); - } - } - - for (int j = 0; j < m_cols; j++) { - if (j % 2) - setColumnMinimumWidth(j, m_maxw[j]+m_pxw); - else - setColumnMinimumWidth(j, m_maxw[j]); - } } unsigned GeneralTab::getColorspace() const @@ -995,11 +939,6 @@ void GeneralTab::changeAudioDevice() void GeneralTab::addWidget(QWidget *w, Qt::Alignment align) { - if (m_col % 2) - w->setMinimumWidth(m_minWidth); - if (w->sizeHint().width() > m_maxw[m_col]) { - m_maxw[m_col] = w->sizeHint().width(); - } QGridLayout::addWidget(w, m_row, m_col, align | Qt::AlignVCenter); m_col++; if (m_col == m_cols) { @@ -1008,24 +947,6 @@ void GeneralTab::addWidget(QWidget *w, Qt::Alignment align) } } -int GeneralTab::getWidth() -{ - int total = 0; - for (int i = 0; i < m_cols; i++) { - if (i % 2) - total += (m_maxw[i]+m_pxw); - else - total += (m_maxw[i]); - } - return total; -} - -int GeneralTab::getHeight() -{ - int total = m_row*20; - return total; -} - bool GeneralTab::isSlicedVbi() const { return m_vbiMethods && m_vbiMethods->currentText() == "Sliced"; diff --git a/utils/qv4l2/general-tab.h b/utils/qv4l2/general-tab.h index bc09f2d..20b336f 100644 --- a/utils/qv4l2/general-tab.h +++ b/utils/qv4l2/general-tab.h @@ -85,8 +85,6 @@ public: void sourceChange(const v4l2_event &ev); unsigned getDisplayColorspace() const; unsigned getColorspace() const; - int getWidth(); - int getHeight(); public slots: void showAllAudioDevices(bool use); @@ -130,7 +128,6 @@ private slots: void composeChanged(); private: - void fixWidth(); void updateGUI(int); void updateVideoInput(); void updateVideoOutput(); @@ -167,7 +164,7 @@ private: #endif void addWidget(QWidget *w, Qt::Alignment align = Qt::AlignLeft); - void addLabel(const QString &text, Qt::Alignment align = Qt::AlignLeft) + void addLabel(const QString &text, Qt::Alignment align = Qt::AlignRight) { addWidget(new QLabel(text, parentWidget()), align); } @@ -183,10 +180,6 @@ private: int m_row; int m_col; int m_cols; - int m_minWidth; - double m_pxw; - int m_increment; - int m_maxw[4]; bool m_isRadio; bool m_isSDR; bool m_isVbi; @@ -213,7 +206,6 @@ private: std::map m_audioOutDeviceMap; // General tab - QList m_grids; QStackedWidget *m_stackedStandards; QStackedWidget *m_stackedFrameSettings; QStackedWidget *m_stackedFrequency; diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp index b885f3b..f51b4e2 100644 --- a/utils/qv4l2/qv4l2.cpp +++ b/utils/qv4l2/qv4l2.cpp @@ -74,7 +74,6 @@ ApplicationWindow::ApplicationWindow() : m_nbuffers = 0; m_buffers = NULL; m_makeSnapshot = false; - m_minWidth = 175; QAction *openAct = new QAction(QIcon(":/fileopen.png"), "&Open Device", this); openAct->setStatusTip("Open a v4l device, use libv4l2 wrapper if possible"); @@ -195,6 +194,7 @@ ApplicationWindow::ApplicationWindow() : statusBar()->showMessage("Ready", 2000); m_tabs = new QTabWidget; + m_tabs->setMinimumSize(300, 200); setCentralWidget(m_tabs); } @@ -223,10 +223,6 @@ 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]+50, size[1]+150);//+margins, menus #ifdef HAVE_ALSA if (m_genTab->hasAlsaAudio()) { @@ -245,7 +241,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(); if (caps() & (V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE)) { w = new QWidget(m_tabs); m_vbiTab = new VbiTab(w); diff --git a/utils/qv4l2/qv4l2.h b/utils/qv4l2/qv4l2.h index 2f21ddc..72e0095 100644 --- a/utils/qv4l2/qv4l2.h +++ b/utils/qv4l2/qv4l2.h @@ -105,7 +105,6 @@ private: void startAudio(); void stopAudio(); - int m_maxw[4]; struct buffer *m_buffers; struct v4l2_format m_capSrcFormat; struct v4l2_format m_capDestFormat; @@ -156,12 +155,11 @@ public: private: void addWidget(QGridLayout *grid, QWidget *w, Qt::Alignment align = Qt::AlignLeft); - void addLabel(QGridLayout *grid, const QString &text, Qt::Alignment align = Qt::AlignLeft) + void addLabel(QGridLayout *grid, const QString &text, Qt::Alignment align = Qt::AlignRight) { addWidget(grid, new QLabel(text, parentWidget()), align); } - void fixWidth(QGridLayout *grid); - void addTabs(int size[]); + void addTabs(); void finishGrid(QGridLayout *grid, unsigned ctrl_class); void addCtrl(QGridLayout *grid, const struct v4l2_queryctrl &qctrl); void updateCtrl(unsigned id); @@ -188,9 +186,6 @@ private: void updateFreqChannel(); bool showFrames(); - double m_pxw; - double m_minWidth; - int m_increment; GeneralTab *m_genTab; VbiTab *m_vbiTab; QAction *m_capStartAct;