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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
/* This file is part of the KDE project
Copyright (C) 2001, 2003 Lukas Tinkl <[email protected]>
Andreas Schlapbach <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <tqlabel.h>
#include <tqvbox.h>
#include <tqgroupbox.h>
#include <tqlayout.h>
#include <tqcombobox.h>
#include <tqwhatsthis.h>
#include <tqcheckbox.h>
#include <tqlineedit.h>
#include <tqspinbox.h>
#include <tdelocale.h>
#include <kurl.h>
#include <tdefontdialog.h>
#include <kiconloader.h>
#include <kdebug.h>
#include <klineedit.h>
#include <knuminput.h>
#include <kcolorbutton.h>
#include <kurlrequester.h>
#include <tdeglobalsettings.h>
#include <tdeconfig.h>
#include "imgallerydialog.h"
#include "imgallerydialog.moc"
KIGPDialog::KIGPDialog(TQWidget *parent, const TQString& path, const char *name )
: KDialogBase( IconList, i18n("Configure"), Default|Ok|Cancel,
Ok, parent, name, true, true ),
m_dialogOk( false )
{
m_path = path;
setCaption(i18n("Create Image Gallery"));
setButtonOK( KGuiItem(i18n("Create"),"imagegallery") );
m_config = new TDEConfig("kimgallerypluginrc", false, false);
setupLookPage(path);
setupDirectoryPage(path);
setupThumbnailPage(path);
}
void KIGPDialog::slotDefault()
{
m_title->setText(i18n("Image Gallery for %1").arg(m_path));
m_imagesPerRow->setValue(4);
m_imageName->setChecked(true);
m_imageSize->setChecked(false);
m_imageProperty->setChecked(false);
m_fontName->setCurrentText( TDEGlobalSettings::generalFont().family() );
m_fontSize->setValue(14);
m_foregroundColor->setColor( TQColor( "#d0ffd0") );
m_backgroundColor->setColor( TQColor("#333333") );
m_imageNameReq->setURL(m_path + "images.html");
m_recurseSubDir->setChecked( false );
m_recursionLevel->setEnabled( false );
m_copyOriginalFiles->setChecked( false );
m_useCommentFile->setChecked( false );
m_commentFileReq->setURL(m_path + "comments");
m_commentFileReq->setEnabled( false );
m_imageFormat->setCurrentText( "JPEG");
m_thumbnailSize->setValue(140);
m_colorDepthSet->setChecked(false);
m_colorDepth->setCurrentText("8");
}
void KIGPDialog::setupLookPage(const TQString& path) {
TQFrame *page = addPage( i18n("Look"), i18n("Page Look"),
BarIcon("colorize", TDEIcon::SizeMedium ) );
m_config->setGroup("Look");
TQVBoxLayout *vlay = new TQVBoxLayout( page, 0, spacingHint() );
TQLabel *label;
label = new TQLabel( i18n("&Page title:"), page);
vlay->addWidget(label);
m_title = new TQLineEdit(i18n("Image Gallery for %1").arg(path), page);
vlay->addWidget( m_title );
label->setBuddy(m_title);
m_imagesPerRow = new KIntNumInput(m_config->readNumEntry("ImagesPerRow", 4), page);
m_imagesPerRow->setRange(1, 8, 1, true );
m_imagesPerRow->setLabel( i18n("I&mages per row:") );
vlay->addWidget( m_imagesPerRow );
TQGridLayout *grid = new TQGridLayout( 2, 2 );
vlay->addLayout( grid );
m_imageName = new TQCheckBox( i18n("Show image file &name"), page);
m_imageName->setChecked( m_config->readBoolEntry("ImageName", true) );
grid->addWidget( m_imageName, 0, 0 );
m_imageSize = new TQCheckBox( i18n("Show image file &size"), page);
m_imageSize->setChecked( m_config->readBoolEntry("ImageSize", false) );
grid->addWidget( m_imageSize, 0, 1 );
m_imageProperty = new TQCheckBox( i18n("Show image &dimensions"), page);
m_imageProperty->setChecked( m_config->readBoolEntry("ImageProperty", false) );
grid->addWidget( m_imageProperty, 1, 0 );
TQHBoxLayout *hlay11 = new TQHBoxLayout( );
vlay->addLayout( hlay11 );
m_fontName = new TQComboBox( false,page );
TQStringList standardFonts;
TDEFontChooser::getFontList(standardFonts, 0);
m_fontName->insertStringList( standardFonts );
m_fontName->setCurrentText( m_config->readEntry("FontName", TDEGlobalSettings::generalFont().family() ) );
label = new TQLabel( i18n("Fon&t name:"), page );
label->setBuddy( m_fontName );
hlay11->addWidget( label );
hlay11->addStretch( 1 );
hlay11->addWidget( m_fontName );
TQHBoxLayout *hlay12 = new TQHBoxLayout( );
vlay->addLayout( hlay12 );
m_fontSize = new TQSpinBox( 6, 15, 1, page );
m_fontSize->setValue( m_config->readNumEntry("FontSize", 14) );
label = new TQLabel( i18n("Font si&ze:"), page );
label->setBuddy( m_fontSize );
hlay12->addWidget( label );
hlay12->addStretch( 1 );
hlay12->addWidget( m_fontSize );
TQHBoxLayout *hlay1 = new TQHBoxLayout( spacingHint() );
vlay->addLayout( hlay1 );
m_foregroundColor = new KColorButton(page);
m_foregroundColor->setColor( TQColor( m_config->readEntry("ForegroundColor", "#d0ffd0") ) );
label = new TQLabel( i18n("&Foreground color:"), page);
label->setBuddy( m_foregroundColor );
hlay1->addWidget( label );
hlay1->addStretch( 1 );
hlay1->addWidget(m_foregroundColor);
TQHBoxLayout *hlay2 = new TQHBoxLayout( spacingHint() );
vlay->addLayout( hlay2 );
m_backgroundColor = new KColorButton(page);
m_backgroundColor->setColor( TQColor(m_config->readEntry("BackgroundColor", "#333333") ) );
label = new TQLabel( i18n("&Background color:"), page);
hlay2->addWidget( label );
label->setBuddy( m_backgroundColor );
hlay2->addStretch( 1 );
hlay2->addWidget(m_backgroundColor);
vlay->addStretch(1);
}
void KIGPDialog::setupDirectoryPage(const TQString& path) {
TQFrame *page = addPage( i18n("Folders"), i18n("Folders"),
BarIcon("folder", TDEIcon::SizeMedium ) );
m_config->setGroup("Directory");
TQVBoxLayout *dvlay = new TQVBoxLayout( page, 0, spacingHint() );
TQLabel *label;
label = new TQLabel(i18n("&Save to HTML file:"), page);
dvlay->addWidget( label );
TQString whatsThis;
whatsThis = i18n("<p>The name of the HTML file this gallery will be saved to.");
TQWhatsThis::add( label, whatsThis );
m_imageNameReq = new KURLRequester(path + "images.html", page);
label->setBuddy( m_imageNameReq );
dvlay->addWidget(m_imageNameReq);
connect( m_imageNameReq, TQ_SIGNAL(textChanged(const TQString&)),
this, TQ_SLOT(imageUrlChanged(const TQString&)) );
TQWhatsThis::add( m_imageNameReq, whatsThis );
const bool recurseSubDir = m_config->readBoolEntry("RecurseSubDirectories", false);
m_recurseSubDir = new TQCheckBox(i18n("&Recurse subfolders"), page);
m_recurseSubDir->setChecked( recurseSubDir );
whatsThis = i18n("<p>Whether subfolders should be included for the "
"image gallery creation or not.");
TQWhatsThis::add( m_recurseSubDir, whatsThis );
const int recursionLevel = m_config->readNumEntry("RecursionLevel", 0);
m_recursionLevel = new KIntNumInput( recursionLevel, page );
m_recursionLevel->setRange( 0, 99, 1, true );
m_recursionLevel->setLabel( i18n("Rec&ursion depth:") );
if ( recursionLevel == 0 )
m_recursionLevel->setSpecialValueText( i18n("Endless"));
m_recursionLevel->setEnabled(recurseSubDir);
whatsThis = i18n("<p>You can limit the number of folders the "
"image gallery creator will traverse to by setting an "
"upper bound for the recursion depth.");
TQWhatsThis::add( m_recursionLevel, whatsThis );
connect(m_recurseSubDir, TQ_SIGNAL( toggled(bool) ),
m_recursionLevel, TQ_SLOT( setEnabled(bool) ) );
dvlay->addWidget(m_recurseSubDir);
dvlay->addWidget(m_recursionLevel);
m_copyOriginalFiles = new TQCheckBox(i18n("Copy or&iginal files"), page);
m_copyOriginalFiles->setChecked(m_config->readBoolEntry("CopyOriginalFiles", false) );
dvlay->addWidget(m_copyOriginalFiles);
whatsThis = i18n("<p>This makes a copy of all images and the gallery will refer "
"to these copies instead of the original images.");
TQWhatsThis::add( m_copyOriginalFiles, whatsThis );
const bool useCommentFile = m_config->readBoolEntry("UseCommentFile", false);
m_useCommentFile = new TQCheckBox(i18n("Use &comment file"), page);
m_useCommentFile->setChecked(useCommentFile);
dvlay->addWidget(m_useCommentFile);
whatsThis = i18n("<p>If you enable this option you can specify "
"a comment file which will be used for generating "
"subtitles for the images."
"<p>For details about the file format please see "
"the \"What's This?\" help below.");
TQWhatsThis::add( m_useCommentFile, whatsThis );
label = new TQLabel(i18n("Comments &file:"), page);
label->setEnabled( useCommentFile );
dvlay->addWidget( label );
whatsThis = i18n("<p>You can specify the name of the comment file here. "
"The comment file contains the subtitles for the images. "
"The format of this file is:"
"<p>FILENAME1:"
"<br>Description"
"<br>"
"<br>FILENAME2:"
"<br>Description"
"<br>"
"<br>and so on");
TQWhatsThis::add( label, whatsThis );
m_commentFileReq = new KURLRequester(path + "comments", page);
m_commentFileReq->setEnabled(useCommentFile);
label->setBuddy( m_commentFileReq );
dvlay->addWidget(m_commentFileReq);
TQWhatsThis::add( m_commentFileReq, whatsThis );
connect(m_useCommentFile, TQ_SIGNAL(toggled(bool)),
label, TQ_SLOT(setEnabled(bool)));
connect(m_useCommentFile, TQ_SIGNAL(toggled(bool)),
m_commentFileReq, TQ_SLOT(setEnabled(bool)));
dvlay->addStretch(1);
}
void KIGPDialog::setupThumbnailPage(const TQString& path) {
TQFrame *page = addPage( i18n("Thumbnails"), i18n("Thumbnails"),
BarIcon("thumbnail", TDEIcon::SizeMedium ) );
m_config->setGroup("Thumbnails");
TQLabel *label;
TQVBoxLayout *vlay = new TQVBoxLayout( page, 0, spacingHint() );
TQHBoxLayout *hlay3 = new TQHBoxLayout( spacingHint() );
vlay->addLayout( hlay3 );
m_imageFormat = new TQComboBox(false, page);
m_imageFormat->insertItem("JPEG");
m_imageFormat->insertItem("PNG");
m_imageFormat->setCurrentText( m_config->readEntry("ImageFormat", "JPEG") );
label = new TQLabel( i18n("Image format f&or the thumbnails:"), page);
hlay3->addWidget( label );
label->setBuddy( m_imageFormat );
hlay3->addStretch( 1 );
hlay3->addWidget(m_imageFormat);
m_thumbnailSize = new KIntNumInput(m_config->readNumEntry("ThumbnailSize", 140), page);
m_thumbnailSize->setRange(10, 1000, 1, true );
m_thumbnailSize->setLabel( i18n("Thumbnail size:") );
vlay->addWidget( m_thumbnailSize );
TQGridLayout *grid = new TQGridLayout( 2, 2 );
vlay->addLayout( grid );
TQHBoxLayout *hlay4 = new TQHBoxLayout( spacingHint() );
vlay->addLayout( hlay4 );
const bool colorDepthSet = m_config->readBoolEntry("ColorDepthSet", false);
m_colorDepthSet = new TQCheckBox(i18n("&Set different color depth:"), page);
m_colorDepthSet->setChecked(colorDepthSet);
hlay4->addWidget( m_colorDepthSet );
m_colorDepth = new TQComboBox(false, page);
m_colorDepth->insertItem("1");
m_colorDepth->insertItem("8");
m_colorDepth->insertItem("16");
m_colorDepth->insertItem("32");
m_colorDepth->setCurrentText(m_config->readEntry("ColorDepth", "8"));
m_colorDepth->setEnabled(colorDepthSet);
hlay4->addWidget( m_colorDepth );
connect(m_colorDepthSet, TQ_SIGNAL( toggled(bool) ),
m_colorDepth, TQ_SLOT( setEnabled(bool) ) );
vlay->addStretch(1);
}
void KIGPDialog::writeConfig()
{
m_config->setGroup("Look");
m_config->writeEntry("ImagesPerRow", getImagesPerRow());
m_config->writeEntry("ImageName", printImageName());
m_config->writeEntry("ImageSize", printImageSize());
m_config->writeEntry("ImageProperty", printImageProperty());
m_config->writeEntry("FontName", getFontName());
m_config->writeEntry("FontSize", getFontSize());
m_config->writeEntry("ForegroundColor", TQString(getForegroundColor().name()) );
m_config->writeEntry("BackgroundColor", TQString(getBackgroundColor().name()));
m_config->setGroup("Directory");
m_config->writeEntry("RecurseSubDirectories", recurseSubDirectories());
m_config->writeEntry("RecursionLevel", recursionLevel());
m_config->writeEntry("CopyOriginalFiles", copyOriginalFiles());
m_config->writeEntry("UseCommentFile", useCommentFile());
m_config->setGroup("Thumbnails");
m_config->writeEntry("ThumbnailSize", getThumbnailSize());
m_config->writeEntry("ColorDepth", getColorDepth());
m_config->writeEntry("ColorDepthSet", colorDepthSet());
m_config->writeEntry("ImageFormat", getImageFormat());
m_config->sync();
}
KIGPDialog::~KIGPDialog()
{
}
void KIGPDialog::imageUrlChanged(const TQString &url )
{
enableButtonOK( !url.isEmpty());
}
bool KIGPDialog::printImageName() const
{
return m_imageName->isChecked();
}
bool KIGPDialog::printImageSize() const
{
return m_imageSize->isChecked();
}
bool KIGPDialog::printImageProperty() const
{
return m_imageProperty->isChecked();
}
bool KIGPDialog::recurseSubDirectories() const
{
return m_recurseSubDir->isChecked();
}
int KIGPDialog::recursionLevel() const
{
return m_recursionLevel->value();
}
bool KIGPDialog::copyOriginalFiles() const
{
return m_copyOriginalFiles->isChecked();
}
bool KIGPDialog::useCommentFile() const
{
return m_useCommentFile->isChecked();
}
int KIGPDialog::getImagesPerRow() const
{
return m_imagesPerRow->value();
}
int KIGPDialog::getThumbnailSize() const
{
return m_thumbnailSize->value();
}
int KIGPDialog::getColorDepth() const
{
return m_colorDepth->currentText().toInt();
}
bool KIGPDialog::colorDepthSet() const
{
return m_colorDepthSet->isChecked();
}
const TQString KIGPDialog::getTitle() const
{
return m_title->text();
}
const TQString KIGPDialog::getImageName() const
{
return m_imageNameReq->url();
}
const TQString KIGPDialog::getCommentFile() const
{
return m_commentFileReq->url();
}
const TQString KIGPDialog::getFontName() const
{
return m_fontName->currentText();
}
const TQString KIGPDialog::getFontSize() const
{
return m_fontSize->text();
}
const TQColor KIGPDialog::getBackgroundColor() const
{
return m_backgroundColor->color();
}
const TQColor KIGPDialog::getForegroundColor() const
{
return m_foregroundColor->color();
}
const TQString KIGPDialog::getImageFormat() const
{
return m_imageFormat->currentText();
}
|