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) {
int totalw = 0;
int totalh = 0;
+ int diff = 0;
for (int i = 0; i < m_cols; i++) {
- if (i % 2)
- totalw += m_maxw[i] + m_pxw;
- else
- totalw += m_maxw[i];
+ totalw += m_maxw[i] + m_pxw;
}
- totalh = grid->rowCount() * 20;
+ totalh = grid->rowCount() * m_maxh;
if (totalw > size[0])
size[0] = totalw;
+ else {
+ diff = size[0] - totalw;
+ grid->setHorizontalSpacing(diff/5);
+ }
if (totalh > size[1])
size[1] = totalh;
- setMinimumSize(size[0] + 50, size[1] + 150);
+ setMinimumSize(size[0], size[1]);
grid = new QGridLayout(w);
finishGrid(grid, ctrl_class);
void ApplicationWindow::fixWidth(QGridLayout *grid)
{
- double m_pxw = 25.0;
- grid->setContentsMargins(15, 5, 15, 5);
- grid->setColumnStretch(1, 1);
+ grid->setContentsMargins(m_vMargin, m_hMargin, m_vMargin, m_hMargin);
+ grid->setColumnStretch(3, 1);
QList<QWidget *> list = grid->parentWidget()->parentWidget()->findChildren<QWidget *>();
QList<QWidget *>::iterator it;
m_row(0),
m_col(0),
m_cols(n),
+ m_minWidth(175),
+ m_pxw(25.0),
+ m_vMargin(10),
+ m_hMargin(20),
+ m_maxh(0),
m_isRadio(false),
m_isSDR(false),
m_isVbi(false),
{
m_device.append(device);
setSizeConstraint(QLayout::SetMinimumSize);
- m_minWidth = 175;
for (int i = 0; i < n; i++) {
m_maxw[i] = 0;
}
void GeneralTab::fixWidth()
{
- m_pxw = 25.0;
- setContentsMargins(20, 10, 20, 10);
- setColumnStretch(1, 1);
+ setContentsMargins(m_hMargin, m_vMargin, m_hMargin, m_vMargin);
+ setColumnStretch(3, 1);
QList<QWidget *> list = parentWidget()->findChildren<QWidget *>();
QList<QWidget *>::iterator it;
// fix width of subgrids
QList<QGridLayout *>::iterator i;
for (i = m_grids.begin(); i != m_grids.end(); ++i) {
- (*i)->setColumnStretch(1, 1);
+ (*i)->setColumnStretch(3, 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]) {
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) {
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];
+ total += m_maxw[i] + m_pxw;
}
return total;
}
int GeneralTab::getHeight()
{
- return m_row * 20;
+ return m_row * m_maxh;
}
bool GeneralTab::isSlicedVbi() const
if (m_tuner.signal && m_tuner.afc)
chans += m_tuner.afc < 0 ? " too low" : " too high";
chans += ")";
+
m_subchannels->setText(chans);
+ fixWidth();
}
void GeneralTab::stereoModeChanged()
m_freqChannel->setEnabled(enableFreq);
if (m_detectSubchans) {
m_detectSubchans->setEnabled(enableFreq);
- if (!enableFreq)
+ if (!enableFreq) {
m_subchannels->setText("");
+ fixWidth();
+ }
else
detectSubchansClicked();
}
int m_row;
int m_col;
int m_cols;
- int m_minWidth;
- double m_pxw;
+ const int m_minWidth;
+ const double m_pxw;
+ const int m_vMargin;
+ const int m_hMargin;
int m_increment;
int m_maxw[4];
+ int m_maxh;
bool m_isRadio;
bool m_isSDR;
bool m_isVbi;
ApplicationWindow::ApplicationWindow() :
m_capture(NULL),
+ m_pxw(25),
+ m_minWidth(175),
+ m_vMargin(15),
+ m_hMargin(5),
+ m_maxh(0),
m_genTab(NULL),
m_sigMapper(NULL)
{
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");
int size[2];
size[0] = m_genTab->getWidth();
size[1] = m_genTab->getHeight();
- setMinimumSize(size[0] + 50, size[1] + 150); // +margins, menus
+ setMinimumSize(size[0], size[1]);
#ifdef HAVE_ALSA
if (m_genTab->hasAlsaAudio()) {
void startAudio();
void stopAudio();
- int m_maxw[4];
struct buffer *m_buffers;
struct v4l2_format m_capSrcFormat;
struct v4l2_format m_capDestFormat;
void updateFreqChannel();
bool showFrames();
- double m_pxw;
- double m_minWidth;
+ const double m_pxw;
+ const int m_minWidth;
+ const int m_vMargin;
+ const int m_hMargin;
+ int m_maxw[4];
+ int m_maxh;
int m_increment;
GeneralTab *m_genTab;
VbiTab *m_vbiTab;