GeneralSettingsWidget::GeneralSettingsWidget( QWidget* parent )
    :SettingsWidget( parent ),
      ui( new Ui::GeneralSettingsWidget )
{
    ui->setupUi( this );

    populateLanguages();
    connect( ui->languages, SIGNAL( currentIndexChanged( int ) ), SLOT( onSettingsChanged() ) );

    ui->notifications->setChecked( unicorn::Settings().value( SETTING_NOTIFICATIONS, ui->notifications->isChecked() ).toBool() );
    ui->lastRadio->setChecked( unicorn::Settings().value( SETTING_LAST_RADIO, ui->lastRadio->isChecked() ).toBool() );
    ui->sendCrashReports->setChecked( unicorn::Settings().value( SETTING_SEND_CRASH_REPORTS, ui->sendCrashReports->isChecked() ).toBool() );

    connect( ui->notifications, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->lastRadio, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->sendCrashReports, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );

#ifdef Q_OS_MAC
    ui->showAs->hide();

    ui->showWhere->addItem( tr("Menu bar and dock icons") );
    ui->showWhere->addItem( tr("Only dock icon (hide menu bar icon)") );
    ui->showWhere->addItem( tr("Only menu bar icon (hide dock icon)") );

    int showWhereIndex = unicorn::Settings().value( SETTING_SHOW_WHERE, -1 ).toInt();

    if ( showWhereIndex == -1 )
    {
        bool showAs = unicorn::Settings().value( SETTING_SHOW_AS, true ).toBool();
        ui->showWhere->setCurrentIndex( showAs ? 0 : 1 );
        unicorn::Settings().setValue( SETTING_SHOW_WHERE, ui->showWhere->currentIndex() );
    }
    else
        ui->showWhere->setCurrentIndex( showWhereIndex );

    connect( ui->showWhere, SIGNAL(currentIndexChanged(int)), SLOT(onSettingsChanged()) );

#else
    ui->showWhere->hide();

    ui->showAs->setChecked( unicorn::Settings().value( SETTING_SHOW_AS, ui->showAs->isChecked() ).toBool() );
    connect( ui->showAs, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
//FIXME: hideDock doesnt exist?!
//     ui->hideDock->hide();
#endif

#ifndef Q_WS_X11
    ui->launch->setChecked( unicorn::AppSettings( APP_LAUNCH ).value( SETTING_LAUNCH_ITUNES, ui->launch->isChecked() ).toBool() );
    ui->updates->setChecked( unicorn::Settings().value( SETTING_CHECK_UPDATES, ui->updates->isChecked() ).toBool() );
    connect( ui->launch, SIGNAL(stateChanged(int) ), SLOT( onSettingsChanged() ) );
    connect( ui->updates, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
#else
    ui->launch->hide();
    ui->updates->hide();
#endif
}
GeneralSettingsWidget::GeneralSettingsWidget( QWidget* parent )
    :SettingsWidget( parent ),
      ui( new Ui::GeneralSettingsWidget )
{
    ui->setupUi( this );

    populateLanguages();

    ui->notifications->setChecked( unicorn::Settings().notifications() );
    ui->sendCrashReports->setChecked( unicorn::Settings().sendCrashReports() );
    ui->beta->setChecked( unicorn::Settings().betaUpdates() );

#if !defined( Q_OS_WIN ) && !defined( Q_OS_MAC )
    ui->beta->hide(); // only have a beta update setting in mac and windows
#endif

#ifdef Q_OS_MAC
    ui->mediaKeys->setChecked( unicorn::Settings().value( "mediaKeys", true ).toBool() );

    ui->showAs->setChecked( unicorn::Settings().showAS() );
    ui->showDock->setChecked( unicorn::Settings().showDock() );

#else
    ui->showDock->hide();
    ui->mediaKeys->hide();

    ui->showAs->setChecked( unicorn::Settings().showAS() );
#endif

#ifndef Q_WS_X11
    ui->launch->setChecked( unicorn::OldeAppSettings().launchWithMediaPlayers() );
    ui->updates->setChecked( unicorn::Settings().checkForUpdates() );
#else
    ui->launch->hide();
    ui->updates->hide();
#endif

    connect( ui->languages, SIGNAL( currentIndexChanged( int ) ), SLOT( onSettingsChanged() ) );
    connect( ui->notifications, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->sendCrashReports, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->beta, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->showAs, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->showDock, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->mediaKeys, SIGNAL(stateChanged(int)), SLOT(onSettingsChanged()) );    connect( ui->launch, SIGNAL(stateChanged(int) ), SLOT( onSettingsChanged() ) );
    connect( ui->updates, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
}
GeneralSettingsWidget::GeneralSettingsWidget( QWidget* parent )
    :SettingsWidget( parent ),
      ui( new Ui::GeneralSettingsWidget )
{
    ui->setupUi( this );

    populateLanguages();

    connect( ui->languages, SIGNAL( currentIndexChanged( int ) ), SLOT( onSettingsChanged() ) );

    connect( ui->showAs, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->launch, SIGNAL(stateChanged(int) ), SLOT( onSettingsChanged() ) );
    connect( ui->notifications, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->lastRadio, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->sendCrashReports, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );
    connect( ui->updates, SIGNAL(stateChanged(int)), SLOT( onSettingsChanged() ) );

    ui->showAs->setChecked( unicorn::Settings().value( SETTING_SHOW_AS, ui->showAs->isChecked() ).toBool() );
    ui->launch->setChecked( unicorn::Settings().value( SETTING_LAUNCH_ITUNES, ui->launch->isChecked() ).toBool() );
    ui->notifications->setChecked( unicorn::Settings().value( SETTING_NOTIFICATIONS, ui->notifications->isChecked() ).toBool() );
    ui->lastRadio->setChecked( unicorn::Settings().value( SETTING_LAST_RADIO, ui->lastRadio->isChecked() ).toBool() );
    ui->sendCrashReports->setChecked( unicorn::Settings().value( SETTING_SEND_CRASH_REPORTS, ui->sendCrashReports->isChecked() ).toBool() );
    ui->updates->setChecked( unicorn::Settings().value( SETTING_CHECK_UPDATES, ui->updates->isChecked() ).toBool() );
}