/*****************************************************************************
 *
 *  confaudmp3mencoderdialog.h -- Input the MP3 audio codec parameters.
 *
 *  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.
 *
 *****************************************************************************/

#ifndef CONFAUDMP3MENCODERDIALOG_H
#define CONFAUDMP3MENCODERDIALOG_H

#include "../video/video_struct.h"

#include <QtCore/QLocale>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QCheckBox>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QGroupBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QRadioButton>
#include <QtGui/QSlider>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>


class ConfAudMp3MEncoderDialog : public QDialog
{
	Q_OBJECT

public:
	ConfAudMp3MEncoderDialog(encoder_audio_settings_t *settings, 
		audio_t *track,
		QWidget *parent = 0);

private slots:
	void accept();
	void bitrateSliderChanged(const int);
	void bitrateLineEditChanged(const QString &);
	void vbr_qSliderChanged(const int);
	void vbr_aqSliderChanged(const int);
	void toggleFast();
	void toggleForce_Cbr();
	void toggleHighPass();
	void highpassSliderChanged(const int);
	void highpassLineEditChanged(const QString &);
	void toggleLowPass();
	void lowpassSliderChanged(const int);
	void lowpassLineEditChanged(const QString &);
	void toggleRatio();
	void ratioSliderChanged(const int);
	void selectSampling(const int);
	void selectMethod(const int);
	void selectPadding(const int);
	void selectStereo(const int);
	void selectPreset();
	void defaultPushButtonClicked();

private:
	void setToolTip();
	QString labelToolTip( const QString &defaults, const QString &details );
	QString editToolTip( const QString &name, const QString &range = tr("") );
	QString boxToolTip( const QString &name, const QString &defaults, const QString &range, const QString &details );

	void populateSampling();
	void populateMethod();
	void populateStereo();
	void populatePadding();

	void updateControls();

	// Tabs
	QTabWidget *tabWidget;
	QDialogButtonBox *buttonBox;
	QVBoxLayout *verticalLayout;
	QWidget *mainTab;
	QWidget *advancedTab;

	// Main tab
	QVBoxLayout *mainTabVLayout;

	QGroupBox *presetGroupBox;
	QVBoxLayout *presetVLayout;
	QRadioButton *presetNoneRadioButton;
	QRadioButton *presetMediumRadioButton;
	QRadioButton *presetStandardRadioButton;
	QRadioButton *presetExtremeRadioButton;
	QRadioButton *presetInsaneRadioButton;
	QRadioButton *presetAbrRadioButton;
	QSlider *presetAbrSlider;			

	QHBoxLayout *methodHLayout;
	QLabel *methodLabel;
	QComboBox *methodComboBox;

	QGroupBox *bitrateGroupBox;
	QVBoxLayout *bitrateVLayout;
	QHBoxLayout *bitrateHLayout;
	QSlider *bitrateSlider;			
	QLineEdit *bitrateLineEdit;

	QGroupBox *vbr_optionsGroupBox;
	QVBoxLayout *vbr_optionsVLayout;
	QGridLayout *vbr_qualityGLayout;
	QLabel *vbr_qLowLabel;
	QLabel *vbr_qHighLabel;
	QSlider *vbr_qSlider;			
	QLabel *vbr_aqLowLabel;
	QLabel *vbr_aqHighLabel;
	QSlider *vbr_aqSlider;			

	QGroupBox *preset_optsGroupBox;
	QVBoxLayout *preset_optsVLayout;
	QCheckBox *fastCheckBox;
	QCheckBox *force_cbrCheckBox;

	QHBoxLayout *defaultHLayout;
	QPushButton *defaultPushButton;
	QSpacerItem *defaultHSpacer;

	QSpacerItem *mainTabVSpacer;

	// Advanced tab
	QVBoxLayout *advancedTabVLayout;

	QGroupBox *srateGroupBox;
	QHBoxLayout *srateHLayout;
	QComboBox *srateComboBox;
	QSpacerItem *srateHSpacer;

	QGroupBox *filterGroupBox;
	QGridLayout *filterGLayout;
	QCheckBox *highpassCheckBox;
	QSlider *highpassSlider;
	QLineEdit *highpassLineEdit;
	QCheckBox *lowpassCheckBox;
	QSlider *lowpassSlider;
	QLineEdit *lowpassLineEdit;

	QGroupBox *extraGroupBox;
	QGridLayout *extraGLayout;
	QLabel *stereoLabel;
	QComboBox *stereoComboBox;
	QLabel *paddingLabel;
	QComboBox *paddingComboBox;
	QCheckBox *ratioCheckBox;
	QSlider *ratioSlider;		

	QSpacerItem *advancedTabVSpacer;

	encoder_audio_settings_t *callerSettings;  // settings to modify
	encoder_audio_settings_t *encSettings;  // local copy
	audio_t *audioSource;  // for recommended stuff (rez, fps)

	QIntValidator *bitrateValidator;
	QIntValidator *highpassValidator;
	QIntValidator *lowpassValidator;

	int bitrateMin, bitrateMax;
	int frequenceMin,  frequenceMax;
};

#endif
