/*****************************************************************************
 *
 *  mainwidget.cpp -- Container for player and encoder controls.
 *
 *  Copyright (C) 2010 Starbuck <starbuck@labdv.com>
 *  All rights reserved.
 *
 *  This file is part of the Gui4 module of the DVDx 4 application.
 *
 *  GNU Lesser General Public License Usage
 *  This file may be used under the terms of the GNU Lesser General
 *  Public License version 2.1 as published by the Free Software
 *  Foundation and appearing in the file LICENSE.LGPL included in the
 *  packaging of this file.  Please review the following information to
 *  ensure the GNU Lesser General Public License version 2.1 requirements
 *  will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 *
 *  GNU General Public License Usage
 *  Alternatively, this file may be used under the terms of the GNU
 *  General Public License version 3.0 as published by the Free Software
 *  Foundation and appearing in the file LICENSE.GPL included in the
 *  packaging of this file.  Please review the following information to
 *  ensure the GNU General Public License version 3.0 requirements will be
 *  met: http://www.gnu.org/copyleft/gpl.html.
 *
 *****************************************************************************/

#include "mainwidget.h"
#include <QGroupBox>
#include <QVBoxLayout>

MainWidget::MainWidget(PlayerWidget *player, EncoderWidget *encoder)
	:QWidget(0)
{
	verticalLayout = new QVBoxLayout;
	verticalLayout->setContentsMargins(0,0,0,0);

#ifdef Q_OS_MAC
	setSizePolicy( QSizePolicy::Expanding , QSizePolicy::Maximum );
#else
	setSizePolicy( QSizePolicy::Maximum , QSizePolicy::Maximum );
#endif

	player->setSizePolicy( QSizePolicy::Expanding , QSizePolicy::Expanding );
	encoder->setSizePolicy( QSizePolicy::Expanding , QSizePolicy::Expanding );

	this->encoder = encoder;
	this->player = player;

	verticalLayout->addWidget(this->player);
	verticalLayout->addWidget(this->encoder);

	setLayout(verticalLayout);
}

void MainWidget::setEncoder(EncoderWidget *encoder)
{
	verticalLayout->removeWidget(this->encoder);

	this->encoder = encoder;
	verticalLayout->addWidget(this->encoder);
}

void MainWidget::setPlayer(PlayerWidget *player)
{
	verticalLayout->removeWidget(this->player);

	this->player = player;
	verticalLayout->addWidget(this->player);
}

void MainWidget::adjustGuiSize()
{
	adjustSize();

	emit guiSizeAdjustRequest();
}
