/*****************************************************************************
 *
 *  mediainfodatadialog.cpp -- Show MediaInfo data.
 *
 *  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 "mediainfodatadialog.h"
#include <QLayout>
#include <QTextEdit>
#include <QGroupBox>

MediaInfoDataDialog::MediaInfoDataDialog(interfacemediainfo_data_t *data, QWidget *parent)
	: QDialog(parent)
{
	setWindowTitle( tr("Media informations") );

	QTextEdit *dataTextEdit = new QTextEdit;
	dataTextEdit->setReadOnly(true);
	dataTextEdit->setHtml( data->text.prepend("<pre>").append("</pre>") );

	buttonBox = new QDialogButtonBox(this);
	buttonBox->setFocusPolicy(Qt::StrongFocus);
	buttonBox->setOrientation(Qt::Horizontal);
	buttonBox->setStandardButtons(QDialogButtonBox::Ok);
	buttonBox->setCenterButtons(true);

	QVBoxLayout *mainLayout = new QVBoxLayout;
	mainLayout->addWidget(dataTextEdit);
	mainLayout->addWidget(buttonBox);

	int charWidth = dataTextEdit->fontMetrics().averageCharWidth();

#ifdef WIN32
	setMinimumWidth( charWidth * 95 );
#else
	setMinimumWidth( charWidth * 65 );
#endif

	setAttribute(Qt::WA_AlwaysShowToolTips);
	
	setLayout(mainLayout);

	connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
	connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

	buttonBox->setFocus();  // remove RadioBox focus on Linux
}
