1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2005-07-23
* Description : simple plugins dialog without threadable
* filter interface. The dialog layout is
* designed to accept custom widgets in
* preview and settings area.
*
* Copyright (C) 2005-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 <tqgroupbox.h>
#include <tqlabel.h>
#include <tqwhatsthis.h>
#include <tqpushbutton.h>
#include <tqtimer.h>
#include <tqlayout.h>
#include <tqframe.h>
#include <tqtimer.h>
#include <tqsplitter.h>
#include <tqhbox.h>
// KDE includes.
#include <kcursor.h>
#include <tdelocale.h>
#include <tdeglobalsettings.h>
#include <tdeaboutdata.h>
#include <khelpmenu.h>
#include <kiconloader.h>
#include <tdeapplication.h>
#include <tdepopupmenu.h>
#include <kstandarddirs.h>
#include <tdeconfig.h>
// Local includes.
#include "ddebug.h"
#include "sidebar.h"
#include "dimginterface.h"
#include "imagedlgbase.h"
#include "imagedlgbase.moc"
namespace Digikam
{
class ImageDlgBasePriv
{
public:
ImageDlgBasePriv()
{
aboutData = 0;
timer = 0;
parent = 0;
mainLayout = 0;
hbox = 0;
settingsSideBar = 0;
splitter = 0;
}
bool tryAction;
TQGridLayout *mainLayout;
TQWidget *parent;
TQString name;
TQTimer *timer;
TQHBox *hbox;
TQSplitter *splitter;
TDEAboutData *aboutData;
Sidebar *settingsSideBar;
};
ImageDlgBase::ImageDlgBase(TQWidget* parent, TQString title, TQString name,
bool loadFileSettings, bool tryAction, TQFrame* bannerFrame)
: KDialogBase(Plain, 0, Help|Default|User1|User2|User3|Try|Ok|Cancel, Ok,
parent, 0, true, true,
TQString(),
i18n("&Save As..."),
i18n("&Load..."))
{
kapp->setOverrideCursor( KCursor::waitCursor() );
setCaption(DImgInterface::defaultInterface()->getImageFileName() + TQString(" - ") + title);
showButton(User1, false);
d = new ImageDlgBasePriv;
d->parent = parent;
d->name = name;
d->tryAction = tryAction;
setButtonWhatsThis ( Default, i18n("<p>Reset all filter parameters to their default values.") );
setButtonWhatsThis ( User3, i18n("<p>Load all filter parameters from settings text file.") );
setButtonWhatsThis ( User2, i18n("<p>Save all filter parameters to settings text file.") );
showButton(User2, loadFileSettings);
showButton(User3, loadFileSettings);
showButton(Try, tryAction);
resize(configDialogSize(name + TQString(" Tool Dialog")));
// -------------------------------------------------------------
d->mainLayout = new TQGridLayout( plainPage(), 2, 1);
if (bannerFrame)
{
bannerFrame->reparent( plainPage(), TQPoint(0, 0) );
d->mainLayout->addMultiCellWidget(bannerFrame, 0, 0, 0, 1);
}
// -------------------------------------------------------------
d->hbox = new TQHBox(plainPage());
d->splitter = new TQSplitter(d->hbox);
d->splitter->setFrameStyle( TQFrame::NoFrame );
d->splitter->setFrameShadow( TQFrame::Plain );
d->splitter->setFrameShape( TQFrame::NoFrame );
d->splitter->setOpaqueResize(false);
d->mainLayout->addMultiCellWidget(d->hbox, 1, 2, 0, 1);
d->mainLayout->setColStretch(0, 10);
d->mainLayout->setRowStretch(2, 10);
kapp->restoreOverrideCursor();
}
ImageDlgBase::~ImageDlgBase()
{
if (d->timer)
delete d->timer;
if (d->aboutData)
delete d->aboutData;
delete d->settingsSideBar;
delete d;
}
void ImageDlgBase::readSettings(void)
{
TDEConfig *config = kapp->config();
config->setGroup(d->name + TQString(" Tool Dialog"));
if(config->hasKey("SplitterSizes"))
d->splitter->setSizes(config->readIntListEntry("SplitterSizes"));
readUserSettings();
}
void ImageDlgBase::writeSettings()
{
TDEConfig *config = kapp->config();
config->setGroup(d->name + TQString(" Tool Dialog"));
config->writeEntry("SplitterSizes", d->splitter->sizes());
config->sync();
saveDialogSize(d->name + TQString(" Tool Dialog"));
}
void ImageDlgBase::closeEvent(TQCloseEvent *e)
{
writeSettings();
e->accept();
}
void ImageDlgBase::slotCancel()
{
writeSettings();
done(Cancel);
}
void ImageDlgBase::slotOk()
{
writeSettings();
writeUserSettings();
finalRendering();
}
void ImageDlgBase::slotDefault()
{
resetValues();
slotEffect();
}
void ImageDlgBase::slotHelp()
{
// If setAboutData() is called by plugin, well DigikamImagePlugins help is launched,
// else digiKam help. In this case, setHelp() method must be used to set anchor and handbook name.
if (d->aboutData)
TDEApplication::kApplication()->invokeHelp(d->name, "digikam");
else
KDialogBase::slotHelp();
}
void ImageDlgBase::setAboutData(TDEAboutData *about)
{
d->aboutData = about;
TQPushButton *helpButton = actionButton( Help );
KHelpMenu* helpMenu = new KHelpMenu(this, d->aboutData, false);
helpMenu->menu()->removeItemAt(0);
helpMenu->menu()->insertItem(i18n("digiKam Handbook"), this, TQ_SLOT(slotHelp()), 0, -1, 0);
helpButton->setPopup( helpMenu->menu() );
}
void ImageDlgBase::setPreviewAreaWidget(TQWidget *w)
{
w->reparent( d->splitter, TQPoint(0, 0) );
TQSizePolicy rightSzPolicy(TQSizePolicy::Preferred,
TQSizePolicy::Expanding,
2, 1);
w->setSizePolicy(rightSzPolicy);
}
void ImageDlgBase::setUserAreaWidget(TQWidget *w)
{
TQString sbName(d->name + TQString(" Image Plugin Sidebar"));
d->settingsSideBar = new Sidebar(d->hbox, sbName.ascii(), Sidebar::Right);
d->settingsSideBar->setSplitter(d->splitter);
d->settingsSideBar->appendTab(w, SmallIcon("configure"), i18n("Settings"));
d->settingsSideBar->loadViewState();
readSettings();
}
void ImageDlgBase::slotTimer()
{
if (d->timer)
{
d->timer->stop();
delete d->timer;
}
d->timer = new TQTimer( this );
connect( d->timer, TQ_SIGNAL(timeout()),
this, TQ_SLOT(slotEffect()) );
d->timer->start(500, true);
}
} // NameSpace Digikam
|