You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kipi-plugins/kipi-plugins/metadataedit/commentremovedialog.cpp

220 lines
6.7 KiB

/* ============================================================
*
* This file is a part of kipi-plugins project
* http://www.kipi-plugins.org
*
* Date : 2006-11-20
* Description : a dialog to batch remove comments
*
* 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 <tqlabel.h>
#include <tqframe.h>
#include <tqlayout.h>
#include <tqpushbutton.h>
#include <tqcheckbox.h>
#include <tqwhatsthis.h>
// KDE includes.
#include <klocale.h>
#include <tdeconfig.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <kapplication.h>
#include <khelpmenu.h>
#include <kpopupmenu.h>
// Local includes.
#include "pluginsversion.h"
#include "kpaboutdata.h"
#include "commentremovedialog.h"
#include "commentremovedialog.moc"
namespace KIPIMetadataEditPlugin
{
class CommentRemoveDialogDialogPrivate
{
public:
CommentRemoveDialogDialogPrivate()
{
about = 0;
removeHOSTCommentCheck = 0;
removeJFIFCommentCheck = 0;
removeEXIFCommentCheck = 0;
removeIPTCCaptionCheck = 0;
}
TQCheckBox *removeHOSTCommentCheck;
TQCheckBox *removeJFIFCommentCheck;
TQCheckBox *removeEXIFCommentCheck;
TQCheckBox *removeIPTCCaptionCheck;
KIPIPlugins::KPAboutData *about;
};
CommentRemoveDialog::CommentRemoveDialog(TQWidget* parent)
: KDialogBase(Plain, i18n("Remove Image Captions"),
Help|Ok|Cancel, Ok,
parent, 0, true, true)
{
d = new CommentRemoveDialogDialogPrivate;
// ---------------------------------------------------------------
// About data and help button.
d->about = new KIPIPlugins::KPAboutData(I18N_NOOP("Edit Metadata"),
0,
TDEAboutData::License_GPL,
I18N_NOOP("A Plugin to edit pictures metadata"),
"(c) 2006-2008, Gilles Caulier");
d->about->addAuthor("Gilles Caulier", I18N_NOOP("Author and Maintainer"),
"caulier dot gilles at gmail dot com");
KHelpMenu* helpMenu = new KHelpMenu(this, d->about, false);
helpMenu->menu()->removeItemAt(0);
helpMenu->menu()->insertItem(i18n("Plugin Handbook"),
this, TQT_SLOT(slotHelp()), 0, -1, 0);
actionButton(Help)->setPopup( helpMenu->menu() );
// ------------------------------------------------------------
TQVBoxLayout *vlay = new TQVBoxLayout(plainPage(), 0, KDialog::spacingHint());
d->removeHOSTCommentCheck = new TQCheckBox(i18n("Remove caption created by %1")
.arg(TDEApplication::kApplication()->aboutData()->appName()),
plainPage());
d->removeJFIFCommentCheck = new TQCheckBox(i18n("Remove JFIF Comment section"), plainPage());
d->removeEXIFCommentCheck = new TQCheckBox(i18n("Remove EXIF Comment"), plainPage());
d->removeIPTCCaptionCheck = new TQCheckBox(i18n("Remove IPTC caption"), plainPage());
TQLabel *note = new TQLabel(i18n("<b>Note: Captions from currently selected images "
"will be permanently removed.</b>"), plainPage());
// ------------------------------------------------------------
vlay->addWidget(d->removeHOSTCommentCheck);
vlay->addWidget(d->removeJFIFCommentCheck);
vlay->addWidget(d->removeEXIFCommentCheck);
vlay->addWidget(d->removeIPTCCaptionCheck);
vlay->addWidget(note);
// ------------------------------------------------------------
readSettings();
}
CommentRemoveDialog::~CommentRemoveDialog()
{
delete d->about;
delete d;
}
void CommentRemoveDialog::slotHelp()
{
TDEApplication::kApplication()->invokeHelp("metadataedit", "kipi-plugins");
}
void CommentRemoveDialog::closeEvent(TQCloseEvent *e)
{
if (!e) return;
saveSettings();
e->accept();
}
void CommentRemoveDialog::slotCancel()
{
saveSettings();
KDialogBase::slotCancel();
}
void CommentRemoveDialog::readSettings()
{
TDEConfig config("kipirc");
config.setGroup("Comments Remove Settings");
setCheckedRemoveHOSTComment(config.readBoolEntry("Remove HOST Comment", true));
setCheckedRemoveJFIFComment(config.readBoolEntry("Remove JFIF Comment", true));
setCheckedRemoveEXIFComment(config.readBoolEntry("Remove EXIF Comment", true));
setCheckedRemoveIPTCCaption(config.readBoolEntry("Remove IPTC Caption", true));
resize(configDialogSize(config, TQString("Comments Remove Dialog")));
}
void CommentRemoveDialog::saveSettings()
{
TDEConfig config("kipirc");
config.setGroup("Comments Remove Settings");
config.writeEntry("Remove HOST Comment", removeHOSTCommentIsChecked());
config.writeEntry("Remove JFIF Comment", removeJFIFCommentIsChecked());
config.writeEntry("Remove EXIF Comment", removeEXIFCommentIsChecked());
config.writeEntry("Remove IPTC Caption", removeIPTCCaptionIsChecked());
saveDialogSize(config, TQString("Comments Remove Dialog"));
config.sync();
}
void CommentRemoveDialog::slotOk()
{
saveSettings();
accept();
}
bool CommentRemoveDialog::removeHOSTCommentIsChecked()
{
return d->removeHOSTCommentCheck->isChecked();
}
bool CommentRemoveDialog::removeJFIFCommentIsChecked()
{
return d->removeJFIFCommentCheck->isChecked();
}
bool CommentRemoveDialog::removeEXIFCommentIsChecked()
{
return d->removeEXIFCommentCheck->isChecked();
}
bool CommentRemoveDialog::removeIPTCCaptionIsChecked()
{
return d->removeIPTCCaptionCheck->isChecked();
}
void CommentRemoveDialog::setCheckedRemoveHOSTComment(bool c)
{
d->removeHOSTCommentCheck->setChecked(c);
}
void CommentRemoveDialog::setCheckedRemoveJFIFComment(bool c)
{
d->removeJFIFCommentCheck->setChecked(c);
}
void CommentRemoveDialog::setCheckedRemoveEXIFComment(bool c)
{
d->removeEXIFCommentCheck->setChecked(c);
}
void CommentRemoveDialog::setCheckedRemoveIPTCCaption(bool c)
{
d->removeIPTCCaptionCheck->setChecked(c);
}
} // namespace KIPIMetadataEditPlugin