VideoPage.cpp 5.13 KB
Newer Older
1 2 3
/*****************************************************************************
 * VideoPage.cpp: Wizard page for configuring video settings
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * Authors: Ludovic Fauvet <etix@l0cal.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.
 *****************************************************************************/

#include "VideoPage.h"
#include "SettingsManager.h"

26
VideoPage::VideoPage( QWidget* parent ) :
27 28 29 30 31 32 33 34 35 36 37 38 39
    QWizardPage( parent )
{
    ui.setupUi( this );

    setTitle( tr( "New project wizard" ) );
    setSubTitle( tr( "Configure Video settings" ) );

    setFinalPage( true );

    connect( ui.comboBoxVideoPresets, SIGNAL( currentIndexChanged(int) ),
             this, SLOT( updateVideoPresets() ) );
    connect( ui.comboBoxAudioPresets, SIGNAL( currentIndexChanged(int) ),
             this, SLOT( updateAudioPresets() ) );
40
    registerField( "fps", ui.doubleSpinBoxVideoFPS, "value", SIGNAL( valueChanged( double ) ) );
41 42 43 44
    registerField( "width", ui.spinBoxVideoWidth );
    registerField( "height", ui.spinBoxVideoHeight );
    registerField( "samplerate", ui.comboBoxAudioSamplerate );
    registerField( "channels", ui.spinBoxAudioChannels );
45 46
}

47 48
void
VideoPage::changeEvent( QEvent* e )
49 50 51 52 53 54 55 56 57 58 59 60
{
    QWizardPage::changeEvent( e );
    switch ( e->type() )
    {
    case QEvent::LanguageChange:
        ui.retranslateUi( this );
        break;
    default:
        break;
    }
}

61 62
int
VideoPage::nextId() const
63 64 65 66
{
    return -1;
}

67 68
void
VideoPage::initializePage()
69
{
70 71 72 73
    int     projectFps = 30;
    int     projectHeight = 300;
    int     projectWidth = 480;
    int     sampleRate = 44000;
74 75

    ui.comboBoxVideoPresets->setCurrentIndex( 0 );
76
    ui.comboBoxAudioPresets->setCurrentIndex( 1 );
77 78 79 80 81 82 83 84 85 86
    ui.spinBoxVideoWidth->setValue( projectWidth );
    ui.spinBoxVideoHeight->setValue( projectHeight );
    ui.doubleSpinBoxVideoFPS->setValue( projectFps );

    switch ( sampleRate )
    {
    case 48000:
        ui.comboBoxAudioSamplerate->setCurrentIndex( HZ_48000 );
        break;
    case 22000:
87
        ui.comboBoxAudioSamplerate->setCurrentIndex( HZ_22050 );
88 89
        break;
    case 11000:
90
        ui.comboBoxAudioSamplerate->setCurrentIndex( HZ_11025 );
91 92 93
        break;
    case 44000:
    default:
94
        ui.comboBoxAudioSamplerate->setCurrentIndex( HZ_44100 );
95 96 97 98
        break;
    }
}

99 100
bool
VideoPage::validatePage()
101 102 103 104
{
    return true;
}

105 106
void
VideoPage::cleanupPage()
107 108 109
{
}

110 111
void
VideoPage::setVideoFormEnabled( bool enabled )
112 113 114 115 116
{
    ui.spinBoxVideoWidth->setEnabled( enabled );
    ui.spinBoxVideoHeight->setEnabled( enabled );
}

117 118
void
VideoPage::setAudioFormEnabled( bool enabled )
119 120 121 122 123
{
    ui.spinBoxAudioChannels->setEnabled( enabled );
    ui.comboBoxAudioSamplerate->setEnabled( enabled );
}

124 125
void
VideoPage::updateVideoPresets()
126 127 128 129 130 131 132 133 134 135 136
{
    if ( ui.comboBoxVideoPresets->currentIndex() == 0 )
        setVideoFormEnabled( true );
    else
        setVideoFormEnabled( false );

    switch ( ui.comboBoxVideoPresets->currentIndex() )
    {
    case PRESET_VideoCustom: break;
    case PRESET_480i:
        setVideoResolution( 720, 480 );
137
        setVideoFPS( 30.0 );
138 139 140
        break;
    case PRESET_576i:
        setVideoResolution( 720, 576 );
141
        setVideoFPS( 25.0 );
142 143 144
        break;
    case PRESET_480p:
        setVideoResolution( 720, 480 );
145
        setVideoFPS( 29.97 );
146 147 148
        break;
    case PRESET_576p:
        setVideoResolution( 720, 576 );
149
        setVideoFPS( 29.97 );
150 151 152
        break;
    case PRESET_720p:
        setVideoResolution( 1280, 720 );
153
        setVideoFPS( 29.97 );
154 155 156
        break;
    case PRESET_1080i:
        setVideoResolution( 1920, 1080 );
157
        setVideoFPS( 30.0 );
158 159 160
        break;
    case PRESET_1080p:
        setVideoResolution( 1920, 1080 );
161
        setVideoFPS( 29.97 );
162 163 164 165
        break;
    }
}

166 167
void
VideoPage::updateAudioPresets()
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
{
    if ( ui.comboBoxAudioPresets->currentIndex() == 0 )
        setAudioFormEnabled( true );
    else
        setAudioFormEnabled( false );

    switch ( ui.comboBoxAudioPresets->currentIndex() )
    {
    case PRESET_AudioCustom: break;
    case PRESET_STEREO:
        ui.spinBoxAudioChannels->setValue( 2 );
        break;
    case PRESET_MONO:
        ui.spinBoxAudioChannels->setValue( 1 );
        break;
    }
}

186 187
void
VideoPage::setVideoResolution( int width, int height )
188 189 190 191
{
    ui.spinBoxVideoWidth->setValue( width );
    ui.spinBoxVideoHeight->setValue( height );
}
192 193 194 195 196 197

void
VideoPage::setVideoFPS( double fps )
{
    ui.doubleSpinBoxVideoFPS->setValue( fps );
}