VLMCPreferences.cpp 3.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*****************************************************************************
 * VLMCPreferences.cpp: VLMC preferences class
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * 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 "QDebug"

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

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
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 );
}
51

52
void    VLMCPreferences::load()
53
{
54
    SettingsManager* settMan = SettingsManager::getInstance();
55
    const QString& part = m_defaults ? "default" : m_settName;
56

57 58 59 60
    QString     outputFPS = settMan->getValue( part, "VLMCOutPutFPS" )->get().toString();
    QString     tracksNb = settMan->getValue( part, "VLMCTracksNb" )->get().toString();
    bool        autoSave = settMan->getValue( part, "AutomaticBackup" )->get().toBool();
    QString     autoSaveInterval = settMan->getValue( part, "AutomaticBackupInterval" )->get().toString();
61 62 63

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

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

    settMan->setValue( m_settName, "VLMCOutPutFPS", outputFPS );
    settMan->setValue( m_settName, "VLMCTracksNb", tracksNb );
79 80
    settMan->setValue( m_settName, "AutomaticBackup", autoSave );
    settMan->setValue( m_settName, "AutomaticBackupInterval", autoSaveInterval );
81
}