~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to core/utilities/cameragui/widgets/scriptingsettings.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2012-08-13 18:23:16 UTC
  • mfrom: (1.2.41)
  • Revision ID: package-import@ubuntu.com-20120813182316-mket5nnbld3zjaii
Tags: 4:2.8.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2012-07-20
 
7
 * Description : scripting settings for camera interface.
 
8
 *
 
9
 * Copyright (C) 2012 by Petri Damstén <damu@iki.fi>
 
10
 *
 
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)
 
15
 * any later version.
 
16
 *
 
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.
 
21
 *
 
22
 * ============================================================ */
 
23
 
 
24
#include "scriptingsettings.moc"
 
25
 
 
26
// Qt includes
 
27
 
 
28
#include <QVBoxLayout>
 
29
#include <QLabel>
 
30
#include <QToolButton>
 
31
 
 
32
// KDE includes
 
33
 
 
34
#include <kdialog.h>
 
35
#include <klocale.h>
 
36
#include <kurlrequester.h>
 
37
#include <khbox.h>
 
38
#include <kdebug.h>
 
39
 
 
40
// Local includes
 
41
 
 
42
#include "tooltipdialog.h"
 
43
 
 
44
namespace Digikam
 
45
{
 
46
 
 
47
class ScriptingSettings::Private
 
48
{
 
49
public:
 
50
 
 
51
    Private()
 
52
        : scriptLabel(0),
 
53
          script(0),
 
54
          tooltipDialog(0),
 
55
          tooltipToggleButton(0)
 
56
    {
 
57
    }
 
58
 
 
59
    QLabel*        scriptLabel;
 
60
    KUrlRequester* script;
 
61
    TooltipDialog* tooltipDialog;
 
62
    QToolButton*   tooltipToggleButton;
 
63
};
 
64
 
 
65
ScriptingSettings::ScriptingSettings(QWidget* const parent)
 
66
    : QWidget(parent), d(new Private)
 
67
{
 
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>"
 
76
                                     ));
 
77
    d->tooltipDialog->resize(650, 530);
 
78
 
 
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"));
 
89
 
 
90
    vlay->addWidget(d->scriptLabel);
 
91
    vlay->addWidget(hbox);
 
92
    vlay->addStretch();
 
93
    vlay->setMargin(KDialog::spacingHint());
 
94
    vlay->setSpacing(KDialog::spacingHint());
 
95
 
 
96
    setWhatsThis(i18n("Set here the script that is executed for every imported image."));
 
97
 
 
98
    // ---------------------------------------------------------------------------------------
 
99
 
 
100
    connect(d->tooltipToggleButton, SIGNAL(clicked(bool)),
 
101
            this, SLOT(slotToolTipButtonToggled(bool)));
 
102
}
 
103
 
 
104
ScriptingSettings::~ScriptingSettings()
 
105
{
 
106
    delete d;
 
107
}
 
108
 
 
109
void ScriptingSettings::readSettings(KConfigGroup& group)
 
110
{
 
111
    d->script->setText(group.readEntry("Script", QString()));
 
112
}
 
113
 
 
114
void ScriptingSettings::saveSettings(KConfigGroup& group)
 
115
{
 
116
    group.writeEntry("Script", d->script->text());
 
117
}
 
118
 
 
119
void ScriptingSettings::settings(DownloadSettings* const settings) const
 
120
{
 
121
    settings->script = d->script->text();
 
122
}
 
123
 
 
124
void ScriptingSettings::slotToolTipButtonToggled(bool /*checked*/)
 
125
{
 
126
    if (!d->tooltipDialog->isVisible())
 
127
    {
 
128
        d->tooltipDialog->show();
 
129
    }
 
130
 
 
131
    d->tooltipDialog->raise();
 
132
}
 
133
 
 
134
}  // namespace Digikam