/* Copyright (C) 2003-2010 Jesper K. Pedersen <blackie@kde.org>

   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; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/
#include "PluginsPage.h"
#include <QCheckBox>
#include <QLabel>
#include <QVBoxLayout>
#include <MainWindow/Window.h>
#include <config-kpa-kipi.h>
#ifdef HASKIPI
#  include <libkipi/version.h>
#if KIPI_VERSION >= 0x020000
#  include <libkipi/configwidget.h>
#endif
#  include <libkipi/pluginloader.h>
#endif

Settings::PluginsPage::PluginsPage( QWidget* parent )
    : QWidget(parent)
{
    // TODO: DEPENDENCY: the circular dependency on mainwindow is unfortunate.
    ::MainWindow::Window::theMainWindow()->loadPlugins();
    QVBoxLayout* lay1 = new QVBoxLayout( this );

    QLabel* label = new QLabel( i18n("Choose Plugins to load:"), this );
    lay1->addWidget( label );

    _pluginConfig = KIPI::PluginLoader::instance()->configWidget( this );
    lay1->addWidget( _pluginConfig );

    _delayLoadingPlugins = new QCheckBox( i18n("Delay loading plugins until the plugin menu is opened"), this );
    lay1->addWidget( _delayLoadingPlugins );
}

void Settings::PluginsPage::saveSettings( Settings::SettingsData* opt )
{
    _pluginConfig->apply();
    opt->setDelayLoadingPlugins( _delayLoadingPlugins->isChecked() );
}

void Settings::PluginsPage::loadSettings( Settings::SettingsData* opt )
{
    _delayLoadingPlugins->setChecked( opt->delayLoadingPlugins() );
}
// vi:expandtab:tabstop=4 shiftwidth=4:
