/* ============================================================
 *
 * This file is a part of digiKam project
 * http://www.digikam.org
 *
 * Date        : 2006-07-09
 * Description : tool tip contents configuration setup tab
 *
 * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot 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, 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.
 *
 * ============================================================ */

// TQt includes.

#include <tqlayout.h>
#include <tqvgroupbox.h>
#include <tqcheckbox.h>
#include <tqwhatsthis.h>

// KDE includes.

#include <tdelocale.h>
#include <kdialogbase.h>
#include <tdeapplication.h>
#include <tdeconfig.h>

// Local includes.

#include "setuptooltip.h"
#include "setuptooltip.moc"

namespace ShowFoto
{

class SetupToolTipPriv
{
public:

    SetupToolTipPriv()
    {
        showToolTipsBox   = 0;

        showFileNameBox   = 0;
        showFileDateBox   = 0;
        showFileSizeBox   = 0;
        showImageTypeBox  = 0;
        showImageDimBox   = 0;

        showPhotoMakeBox  = 0;
        showPhotoDateBox  = 0;
        showPhotoFocalBox = 0;
        showPhotoExpoBox  = 0;
        showPhotoModeBox  = 0;
        showPhotoFlashBox = 0;
        showPhotoWbBox    = 0;

        fileSettingBox    = 0;
        photoSettingBox   = 0;
    }

    TQCheckBox  *showToolTipsBox;

    TQCheckBox  *showFileNameBox;
    TQCheckBox  *showFileDateBox;
    TQCheckBox  *showFileSizeBox;
    TQCheckBox  *showImageTypeBox;
    TQCheckBox  *showImageDimBox;

    TQCheckBox  *showPhotoMakeBox;
    TQCheckBox  *showPhotoDateBox;
    TQCheckBox  *showPhotoFocalBox;
    TQCheckBox  *showPhotoExpoBox;
    TQCheckBox  *showPhotoModeBox;
    TQCheckBox  *showPhotoFlashBox;
    TQCheckBox  *showPhotoWbBox;

    TQVGroupBox *fileSettingBox;
    TQVGroupBox *photoSettingBox;
};

SetupToolTip::SetupToolTip(TQWidget* parent)
            : TQWidget(parent)
{
    d = new SetupToolTipPriv;
    TQVBoxLayout *layout = new TQVBoxLayout( parent, 0, KDialog::spacingHint() );

    d->showToolTipsBox = new TQCheckBox(i18n("Show Thumbbar items toolti&ps"), parent);
    TQWhatsThis::add( d->showToolTipsBox, i18n("<p>Set this option to display image information when "
                                              "the mouse hovers over a thumbbar item."));

    layout->addWidget(d->showToolTipsBox);

    // --------------------------------------------------------

    d->fileSettingBox = new TQVGroupBox(i18n("File/Image Information"), parent);

    d->showFileNameBox = new TQCheckBox(i18n("Show file name"), d->fileSettingBox);
    TQWhatsThis::add( d->showFileNameBox, i18n("<p>Set this option to display the image file name."));

    d->showFileDateBox = new TQCheckBox(i18n("Show file date"), d->fileSettingBox);
    TQWhatsThis::add( d->showFileDateBox, i18n("<p>Set this option to display the image file date."));

    d->showFileSizeBox = new TQCheckBox(i18n("Show file size"), d->fileSettingBox);
    TQWhatsThis::add( d->showFileSizeBox, i18n("<p>Set this option to display the image file size."));

    d->showImageTypeBox = new TQCheckBox(i18n("Show image type"), d->fileSettingBox);
    TQWhatsThis::add( d->showImageTypeBox, i18n("<p>Set this option to display the image type."));

    d->showImageDimBox = new TQCheckBox(i18n("Show image dimensions"), d->fileSettingBox);
    TQWhatsThis::add( d->showImageDimBox, i18n("<p>Set this option to display the image dimensions in pixels."));

    layout->addWidget(d->fileSettingBox);

    // --------------------------------------------------------

    d->photoSettingBox = new TQVGroupBox(i18n("Photograph Information"), parent);

    d->showPhotoMakeBox = new TQCheckBox(i18n("Show camera make and model"), d->photoSettingBox);
    TQWhatsThis::add( d->showPhotoMakeBox, i18n("<p>Set this option to display the make and model of the "
                                               "camera with which the image has been taken."));

    d->showPhotoDateBox = new TQCheckBox(i18n("Show camera date"), d->photoSettingBox);
    TQWhatsThis::add( d->showPhotoDateBox, i18n("<p>Set this option to display the date when the image was taken."));

    d->showPhotoFocalBox = new TQCheckBox(i18n("Show camera aperture and focal length"), d->photoSettingBox);
    TQWhatsThis::add( d->showPhotoFocalBox, i18n("<p>Set this option to display the camera aperture and focal settings "
                     "used to take the image."));

    d->showPhotoExpoBox = new TQCheckBox(i18n("Show camera exposure and sensitivity"), d->photoSettingBox);
    TQWhatsThis::add( d->showPhotoExpoBox, i18n("<p>Set this option to display the camera exposure and sensitivity "
                     "used to take the image."));

    d->showPhotoModeBox = new TQCheckBox(i18n("Show camera mode and program"), d->photoSettingBox);
    TQWhatsThis::add( d->showPhotoModeBox, i18n("<p>Set this option to display the camera mode and program "
                     "used to take the image."));

    d->showPhotoFlashBox = new TQCheckBox(i18n("Show camera flash settings"), d->photoSettingBox);
    TQWhatsThis::add( d->showPhotoFlashBox, i18n("<p>Set this option to display the camera flash settings "
                     "used to take the image."));

    d->showPhotoWbBox = new TQCheckBox(i18n("Show camera white balance settings"), d->photoSettingBox);
    TQWhatsThis::add( d->showPhotoWbBox, i18n("<p>Set this option to display the camera white balance settings "
                     "used to take the image."));

    layout->addWidget(d->photoSettingBox);
    layout->addStretch();

    // --------------------------------------------------------

    connect(d->showToolTipsBox, TQ_SIGNAL(toggled(bool)),
            d->fileSettingBox, TQ_SLOT(setEnabled(bool)));

    connect(d->showToolTipsBox, TQ_SIGNAL(toggled(bool)),
            d->photoSettingBox, TQ_SLOT(setEnabled(bool)));

    // --------------------------------------------------------

    readSettings();
    adjustSize();
}

SetupToolTip::~SetupToolTip()
{
    delete d;
}

void SetupToolTip::readSettings()
{
    TDEConfig* config = tdeApp->config();
    config->setGroup("ImageViewer Settings");

    d->showToolTipsBox->setChecked(config->readBoolEntry("Show ToolTips", true));

    d->showFileNameBox->setChecked(config->readBoolEntry("ToolTips Show File Name", true));
    d->showFileDateBox->setChecked(config->readBoolEntry("ToolTips Show File Date", false));
    d->showFileSizeBox->setChecked(config->readBoolEntry("ToolTips Show File Size", false));
    d->showImageTypeBox->setChecked(config->readBoolEntry("ToolTips Show Image Type", false));
    d->showImageDimBox->setChecked(config->readBoolEntry("ToolTips Show Image Dim", true));

    d->showPhotoMakeBox->setChecked(config->readBoolEntry("ToolTips Show Photo Make", true));
    d->showPhotoDateBox->setChecked(config->readBoolEntry("ToolTips Show Photo Date", true));
    d->showPhotoFocalBox->setChecked(config->readBoolEntry("ToolTips Show Photo Focal", true));
    d->showPhotoExpoBox->setChecked(config->readBoolEntry("ToolTips Show Photo Expo", true));
    d->showPhotoModeBox->setChecked(config->readBoolEntry("ToolTips Show Photo Mode", true));
    d->showPhotoFlashBox->setChecked(config->readBoolEntry("ToolTips Show Photo Flash", false));
    d->showPhotoWbBox->setChecked(config->readBoolEntry("ToolTips Show Photo WB", false));

    d->fileSettingBox->setEnabled(d->showToolTipsBox->isChecked());
    d->photoSettingBox->setEnabled(d->showToolTipsBox->isChecked());
}

void SetupToolTip::applySettings()
{
    TDEConfig* config = tdeApp->config();
    config->setGroup("ImageViewer Settings");

    config->writeEntry("Show ToolTips", d->showToolTipsBox->isChecked());

    config->writeEntry("ToolTips Show File Name", d->showFileNameBox->isChecked());
    config->writeEntry("ToolTips Show File Date", d->showFileDateBox->isChecked());
    config->writeEntry("ToolTips Show File Size", d->showFileSizeBox->isChecked());
    config->writeEntry("ToolTips Show Image Type", d->showImageTypeBox->isChecked());
    config->writeEntry("ToolTips Show Image Dim", d->showImageDimBox->isChecked());

    config->writeEntry("ToolTips Show Photo Make", d->showPhotoMakeBox->isChecked());
    config->writeEntry("ToolTips Show Photo Date", d->showPhotoDateBox->isChecked());
    config->writeEntry("ToolTips Show Photo Focal", d->showPhotoFocalBox->isChecked());
    config->writeEntry("ToolTips Show Photo Expo", d->showPhotoExpoBox->isChecked());
    config->writeEntry("ToolTips Show Photo Mode", d->showPhotoModeBox->isChecked());
    config->writeEntry("ToolTips Show Photo Flash", d->showPhotoFlashBox->isChecked());
    config->writeEntry("ToolTips Show Photo WB", d->showPhotoWbBox->isChecked());

    config->sync();
}

}  // namespace ShowFoto

