VLMCPreferences.cpp 3.38 KB
Newer Older
1 2 3
/*****************************************************************************
 * VLMCPreferences.cpp: VLMC preferences class
 *****************************************************************************
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
 *
 * Authors: Geoffroy Lacarriere <geoffroylaca@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.
 *****************************************************************************/

#include "VLMCPreferences.h"
24
#include "SettingsManager.h"
25

26 27
#include <QWidget>
#include <QtDebug>
28

29
VLMCPreferences::VLMCPreferences( QWidget *parent )
30
    : PreferenceWidget( parent ),
31
    m_type( SettingsManager::Vlmc )
32 33
{
    m_ui.setupUi(this);
34 35
    setAutomaticSaveLabelVisiblity( m_ui.automaticSave->isChecked() );
    connect( m_ui.automaticSave, SIGNAL( stateChanged(int) ), this, SLOT( setAutomaticSaveLabelVisiblity( int ) ) );
36 37
}

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
VLMCPreferences::~VLMCPreferences()
{
}

void    VLMCPreferences::setAutomaticSaveLabelVisiblity( int visible )
{
    setAutomaticSaveLabelVisiblity( visible != 0 );
}

void    VLMCPreferences::setAutomaticSaveLabelVisiblity( bool visible )
{
    m_ui.automaticSaveInterval->setVisible( visible );
    m_ui.automaticSaveIntervalLabel->setVisible( visible );
    m_ui.minutesLabel->setVisible( visible );
}
53

54
void    VLMCPreferences::load()
55
{
56 57
    SettingsManager* settMan = SettingsManager::getInstance();

58 59 60 61
    QString     outputFPS = VLMC_GET_STRING( "global/VLMCOutputFPS" );
    QString     tracksNb = VLMC_GET_STRING( "global/VLMCTracksNb" );
    bool        autoSave = VLMC_GET_BOOL( "global/AutomaticBackup" );
    QString     autoSaveInterval = VLMC_GET_STRING( "global/AutomaticBackupInterval" );
62 63 64

    m_ui.outputFPS->setText( outputFPS );
    m_ui.tracksNb->setText( tracksNb );
65 66 67
    m_ui.automaticSave->setChecked( autoSave );
    m_ui.automaticSaveInterval->setText( autoSaveInterval );
    setAutomaticSaveLabelVisiblity( autoSave );
68 69
}

70
void    VLMCPreferences::save()
71
{
72 73 74
    SettingsManager* settMan = SettingsManager::getInstance();
    QVariant outputFPS( m_ui.outputFPS->text() );
    QVariant tracksNb( m_ui.tracksNb->text() );
75 76
    QVariant autoSave( m_ui.automaticSave->isChecked() );
    QVariant autoSaveInterval( m_ui.automaticSaveInterval->text() );
77

78 79 80 81
    settMan->setImmediateValue( "global/VLMCOutPutFPS", outputFPS, m_type );
    settMan->setImmediateValue( "global/VLMCTracksNb", tracksNb, m_type );
    settMan->setImmediateValue( "global/AutomaticBackup", autoSave, m_type );
    settMan->setImmediateValue( "global/AutomaticBackupInterval", autoSaveInterval, m_type );
82
}
83 84 85 86 87 88 89 90 91 92 93 94 95

void VLMCPreferences::changeEvent( QEvent *e )
{
    QWidget::changeEvent( e );
    switch ( e->type() )
    {
    case QEvent::LanguageChange:
        m_ui.retranslateUi( this );
        break;
    default:
        break;
    }
}