1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : scripting settings for camera interface.
9
* Copyright (C) 2012 by Petri Damstén <damu@iki.fi>
11
* This program is free software; you can redistribute it
12
* and/or modify it under the terms of the GNU General
13
* Public License as published by the Free Software Foundation;
14
* either version 2, or (at your option)
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* ============================================================ */
24
#include "scriptingsettings.moc"
28
#include <QVBoxLayout>
30
#include <QToolButton>
36
#include <kurlrequester.h>
42
#include "tooltipdialog.h"
47
class ScriptingSettings::Private
55
tooltipToggleButton(0)
60
KUrlRequester* script;
61
TooltipDialog* tooltipDialog;
62
QToolButton* tooltipToggleButton;
65
ScriptingSettings::ScriptingSettings(QWidget* const parent)
66
: QWidget(parent), d(new Private)
68
d->tooltipDialog = new TooltipDialog(this);
69
d->tooltipDialog->setTooltip(i18n("<p>These expressions may be used to customize the command line:</p>"
70
"<p><b>%file</b>: full path of the imported file</p>"
71
"<p><b>%filename</b>: file name of the imported file</p>"
72
"<p><b>%path</b>: path of the imported file</p>"
73
"<p><b>%orgfilename</b>: original file name</p>"
74
"<p><b>%orgpath</b>: original path</p>"
75
"<p>If there are no expressions full path is added to the command.<p>"
77
d->tooltipDialog->resize(650, 530);
79
QVBoxLayout* vlay = new QVBoxLayout(this);
80
d->scriptLabel = new QLabel(i18n("Execute script for image:"), this);
81
KHBox* hbox = new KHBox(this);
82
d->script = new KUrlRequester(hbox);
83
KFile::Modes mode = KFile::File | KFile::ExistingOnly | KFile::LocalOnly;
84
d->script->setMode(mode);
85
d->script->setClickMessage(i18n("No script selected"));
86
d->tooltipToggleButton = new QToolButton(hbox);
87
d->tooltipToggleButton->setIcon(SmallIcon("dialog-information"));
88
d->tooltipToggleButton->setToolTip(i18n("Show a list of all available options"));
90
vlay->addWidget(d->scriptLabel);
91
vlay->addWidget(hbox);
93
vlay->setMargin(KDialog::spacingHint());
94
vlay->setSpacing(KDialog::spacingHint());
96
setWhatsThis(i18n("Set here the script that is executed for every imported image."));
98
// ---------------------------------------------------------------------------------------
100
connect(d->tooltipToggleButton, SIGNAL(clicked(bool)),
101
this, SLOT(slotToolTipButtonToggled(bool)));
104
ScriptingSettings::~ScriptingSettings()
109
void ScriptingSettings::readSettings(KConfigGroup& group)
111
d->script->setText(group.readEntry("Script", QString()));
114
void ScriptingSettings::saveSettings(KConfigGroup& group)
116
group.writeEntry("Script", d->script->text());
119
void ScriptingSettings::settings(DownloadSettings* const settings) const
121
settings->script = d->script->text();
124
void ScriptingSettings::slotToolTipButtonToggled(bool /*checked*/)
126
if (!d->tooltipDialog->isVisible())
128
d->tooltipDialog->show();
131
d->tooltipDialog->raise();
134
} // namespace Digikam