/***************************************************************************
   This file is part of LinTV
   lintvpages.h
   All the code for the various setup pages in LinTV.

   Author: Jesse L. Zamora <xtremek2009@gmail.com>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
 ***************************************************************************/

#ifndef LINTVPAGES_H
#define LINTVPAGES_H

#include <QtGui/QWidget>
#include "ui_snapshot_settings.h"
#include "ui_audio_settings.h"
#include "ui_video_settings.h"

class QListWidget;
class QComboBox;
class QRadioButton;
class QPushButton;

class RecordSettingsPage : public QWidget
{
    Q_OBJECT

public:
    RecordSettingsPage(QWidget *parent);
    
    // I love inline functions...don't you?
    void acceptSettings() { 
        saveSettings(); 
    }

private slots:
    void presetsListWidgetChanged(const QString& );
    void customRadioButtonToggled(bool );

    void videoBitrateChanged(int );
    void peakVideoBitrateChanged(int );
    void resRadioButtonClicked(bool );

    void recordFormatActivated(int );

    void noSoundToggled(bool );
private:
    void loadUi();
    void connectSignalsSlots();
    void loadSettings();
    void saveSettings();

    void checkPresetSettings();

private:
    QWidget *formWidget;

    // All the widgets in the form
    KUrlRequester *recordLocation;

    QListWidget *presetsListWidget;
    QPushButton *savePresetPushButton;

    QSpinBox *bitrateSpinBox;
    QComboBox *frameratesComboBox;

    QRadioButton *largeResRadioButton;
    QRadioButton *mediumResRadioButton;
    QRadioButton *smallResRadioButton;
    QRadioButton *customResRadioButton;
    QSpinBox *widthSpinBox;
    QLabel *xLabel;
    QSpinBox *heightSpinBox;
  
    QComboBox *formatsComboBox;

    QRadioButton *stereoRadioButton;
    QRadioButton *monoRadioButton;
    QRadioButton *noSoundRadioButton;
    
    QRadioButton *mp3RadioButton;
    QRadioButton *mp2RadioButton;
    QRadioButton *ac3RadioButton;

    QComboBox *audioBitrateComboBox;
    QLabel *averageSizeLabel;

    QRadioButton *highRateRadioButton;
    QRadioButton *mediumRateRadioButton;
    QRadioButton *lowRateRadioButton;

    QGroupBox *audioBitrateGroupBox;
    QGroupBox *audioFormatGroupBox;
    QGroupBox *audioRateGroupBox;

    // WinTV specific stuff
    /*QRadioButton *constantBitrateRadioButton;
    QRadioButton *variableBitrateRadioButton;
    QSpinBox *peakBitrateSpinBox;

    QRadioButton *jointStereoRadioButton;
    QRadioButton *dualRadioButton;*/

    bool m_checking;

    QLocale floatLocale;
};

class SnapshotSettingsPage : public QWidget, public Ui::snapshotSettingsPage
{
    Q_OBJECT

public:
    SnapshotSettingsPage(QWidget *parent);
  
    void acceptSettings();

private slots:
    void on_customRadioButton_toggled(bool);

private:
    Ui::snapshotSettingsPage page;
};

class AudioSettingsPage : public QWidget, public Ui::audioSettingsPage
{
    Q_OBJECT
public:
    AudioSettingsPage(QWidget *parent);

    void acceptSettings();

private:
    Ui::audioSettingsPage page;
};

class VideoSettingsPage : public QWidget, public Ui::videoSettingsPage
{
    Q_OBJECT
public:
    VideoSettingsPage(QWidget *parent);

    void acceptSettings();

private slots:
    void on_countryRegionRadioButton_toggled(bool );
    void on_countryRegionListWidget_currentRowChanged(int );

    void on_standardComboBox_currentIndexChanged(const QString & );

    void updateResolutionLabel();
    void resetDefaults();

    void updateResolution();

private:
    void loadSettings();
    void saveSettings();

    void setStandard(QString);

private:
    Ui::videoSettingsPage page;

    int m_width, m_height;

    QString selectedStandard;
};

#endif
