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
|
/* ============================================================
*
* This file is a part of kipi-plugins project
* http://www.kipi-plugins.org
*
* Date : 2004-10-01
* Description : a kipi plugin to batch process images
*
* Copyright (C) 2004-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.
*
* ============================================================ */
// Include files for TQt
#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqcombobox.h>
#include <tqwhatsthis.h>
#include <tqcheckbox.h>
#include <tqpushbutton.h>
// Include files for KDE
#include <klocale.h>
#include <kconfig.h>
#include <kmessagebox.h>
#include <knuminput.h>
#include <kprocess.h>
#include <kcolorbutton.h>
#include <kapplication.h>
#include <khelpmenu.h>
#include <kiconloader.h>
#include <kpopupmenu.h>
// Local includes
#include "pluginsversion.h"
#include "kpaboutdata.h"
#include "outputdialog.h"
#include "imagepreview.h"
#include "borderoptionsdialog.h"
#include "borderimagesdialog.h"
#include "borderimagesdialog.moc"
namespace KIPIBatchProcessImagesPlugin
{
BorderImagesDialog::BorderImagesDialog( KURL::List urlList, KIPI::Interface* interface, TQWidget *tqparent )
: BatchProcessImagesDialog( urlList, interface, i18n("Batch-Bordering Images"), tqparent )
{
// About data and help button.
m_about = new KIPIPlugins::KPAboutData(I18N_NOOP("Batch Image-bordering"),
0,
KAboutData::License_GPL,
I18N_NOOP("A Kipi plugin for batch bordering images\n"
"This plugin use the \"convert\" program from \"ImageMagick\" package."),
"(c) 2003-2008, Gilles Caulier");
m_about->addAuthor("Gilles Caulier", I18N_NOOP("Author and maintainer"),
"caulier dot gilles at gmail dot com");
m_helpButton = actionButton( Help );
KHelpMenu* helpMenu = new KHelpMenu(this, m_about, false);
helpMenu->menu()->removeItemAt(0);
helpMenu->menu()->insertItem(i18n("Plugin Handbook"), this, TQT_SLOT(slotHelp()), 0, -1, 0);
m_helpButton->setPopup( helpMenu->menu() );
//---------------------------------------------
m_nbItem = m_selectedImageFiles.count();
//---------------------------------------------
groupBox1->setTitle( i18n("Images Bordering Options") );
m_labelType->setText( i18n("Border:") );
m_Type->insertItem(i18n("Solid"));
// Niepce is Real name. This is the first guy in the world to have build a camera.
m_Type->insertItem("Niepce");
m_Type->insertItem(i18n("Raise"));
m_Type->insertItem(i18n("Frame"));
m_Type->setCurrentText(i18n("Niepce"));
whatsThis = i18n("<p>Select here the border type for your images:<p>"
"<b>Solid</b>: just surround the images with a line.<p>"
"<b>Niepce</b>: surround the images with a fine line and a large border "
"(ideal for black and white pictures).<p>"
"<b>Raise</b>: creating a 3D effect around the images.<p>"
"<b>Frame</b>: surround the images with an ornamental border.<p>");
TQWhatsThis::add( m_Type, whatsThis );
//---------------------------------------------
readSettings();
listImageFiles();
}
BorderImagesDialog::~BorderImagesDialog()
{
delete m_about;
}
void BorderImagesDialog::slotHelp( void )
{
KApplication::kApplication()->invokeHelp("borderimages", "kipi-plugins");
}
void BorderImagesDialog::slotOptionsClicked(void)
{
int Type = m_Type->currentItem();
BorderOptionsDialog *optionsDialog = new BorderOptionsDialog(this, Type);
if ( Type == 0 ) // Solid
{
optionsDialog->m_solidBorderWidth->setValue(m_solidWidth);
optionsDialog->m_button_solidBorderColor->setColor(m_solidColor);
}
if ( Type == 1 ) // Niepce
{
optionsDialog->m_lineNiepceBorderWidth->setValue(m_lineNiepceWidth);
optionsDialog->m_button_lineNiepceBorderColor->setColor(m_lineNiepceColor);
optionsDialog->m_NiepceBorderWidth->setValue(m_NiepceWidth);
optionsDialog->m_button_NiepceBorderColor->setColor(m_NiepceColor);
}
if ( Type == 2 ) // Raise
{
optionsDialog->m_raiseBorderWidth->setValue(m_raiseWidth);
}
if ( Type == 3 ) // Frame
{
optionsDialog->m_frameBorderWidth->setValue(m_frameWidth);
optionsDialog->m_frameBevelBorderWidth->setValue(m_bevelWidth);
optionsDialog->m_button_frameBorderColor->setColor(m_frameColor);
}
if ( optionsDialog->exec() == KMessageBox::Ok )
{
if ( Type == 0 ) // Solid
{
m_solidWidth = optionsDialog->m_solidBorderWidth->value();
m_solidColor = optionsDialog->m_button_solidBorderColor->color();
}
if ( Type == 1 ) // Niepce
{
m_lineNiepceWidth = optionsDialog->m_lineNiepceBorderWidth->value();
m_lineNiepceColor = optionsDialog->m_button_lineNiepceBorderColor->color();
m_NiepceWidth = optionsDialog->m_NiepceBorderWidth->value();
m_NiepceColor = optionsDialog->m_button_NiepceBorderColor->color();
}
if ( Type == 2 ) // Raise
{
m_raiseWidth = optionsDialog->m_raiseBorderWidth->value();
}
if ( Type == 3 ) // Frame
{
m_frameWidth = optionsDialog->m_frameBorderWidth->value();
m_bevelWidth = optionsDialog->m_frameBevelBorderWidth->value();
m_frameColor = optionsDialog->m_button_frameBorderColor->color();
}
}
delete optionsDialog;
}
void BorderImagesDialog::readSettings(void)
{
// Read all settings from configuration file.
m_config = new KConfig("kipirc");
m_config->setGroup("BorderImages Settings");
m_Type->setCurrentItem(m_config->readNumEntry("BorderType", 1)); // Niepce per default.
TQColor *ColorBlack = new TQColor( 0, 0, 0 );
TQColor *ColorWhite = new TQColor( 255, 255, 255 );
m_solidWidth = m_config->readNumEntry("SolidWidth", 25);
m_solidColor = m_config->readColorEntry("SolidColor", ColorBlack);
m_lineNiepceWidth = m_config->readNumEntry("LineNiepceWidth", 10);
m_lineNiepceColor = m_config->readColorEntry("LineNiepceColor", ColorBlack);
m_NiepceWidth = m_config->readNumEntry("NiepceWidth", 100);
m_NiepceColor = m_config->readColorEntry("NiepceColor", ColorWhite);
m_raiseWidth = m_config->readNumEntry("RaiseWidth", 50);
m_frameWidth = m_config->readNumEntry("FrameWidth", 25);
m_bevelWidth = m_config->readNumEntry("BevelWidth", 10);
m_frameColor = m_config->readColorEntry("FrameColor", ColorBlack);
if (m_config->readEntry("SmallPreview", "true") == "true")
m_smallPreview->setChecked( true );
else
m_smallPreview->setChecked( false );
m_overWriteMode->setCurrentItem(m_config->readNumEntry("OverWriteMode", 2)); // 'Rename' per default...
if (m_config->readEntry("RemoveOriginal", "false") == "true")
m_removeOriginal->setChecked( true );
else
m_removeOriginal->setChecked( false );
delete ColorWhite;
delete ColorBlack;
delete m_config;
}
void BorderImagesDialog::saveSettings(void)
{
// Write all settings in configuration file.
m_config = new KConfig("kipirc");
m_config->setGroup("BorderImages Settings");
m_config->writeEntry("BorderType", m_Type->currentItem());
m_config->writeEntry("SolidWidth", m_solidWidth);
m_config->writeEntry("SolidColor", m_solidColor);
m_config->writeEntry("LineNiepceWidth", m_lineNiepceWidth);
m_config->writeEntry("LineNiepceColor", m_lineNiepceColor);
m_config->writeEntry("NiepceWidth", m_NiepceWidth);
m_config->writeEntry("NiepceColor", m_NiepceColor);
m_config->writeEntry("RaiseWidth", m_raiseWidth);
m_config->writeEntry("FrameWidth", m_frameWidth);
m_config->writeEntry("BevelWidth", m_bevelWidth);
m_config->writeEntry("FrameColor", m_frameColor);
m_config->writeEntry("SmallPreview", m_smallPreview->isChecked());
m_config->writeEntry("OverWriteMode", m_overWriteMode->currentItem());
m_config->writeEntry("RemoveOriginal", m_removeOriginal->isChecked());
m_config->sync();
delete m_config;
}
TQString BorderImagesDialog::makeProcess(KProcess* proc, BatchProcessImagesItem *item,
const TQString& albumDest, bool previewMode)
{
*proc << "convert";
if ( previewMode && m_smallPreview->isChecked() ) // Preview mode and small preview enabled !
{
*m_PreviewProc << "-crop" << "300x300+0+0";
m_previewOutput.append( " -crop 300x300+0+0 ");
}
if (m_Type->currentItem() == 0) // Solid
{
*proc << "-border";
TQString Temp, Temp2;
Temp2 = Temp.setNum( m_solidWidth ) + "x";
Temp2.append(Temp.setNum( m_solidWidth ));
*proc << Temp2;
*proc << "-bordercolor";
Temp2 = "rgb(" + Temp.setNum(m_solidColor.red()) + ",";
Temp2.append(Temp.setNum(m_solidColor.green()) + ",");
Temp2.append(Temp.setNum(m_solidColor.blue()) + ")");
*proc << Temp2;
}
if (m_Type->currentItem() == 1) // Niepce
{
TQString Temp, Temp2;
*proc << "-border";
Temp2 = Temp.setNum( m_lineNiepceWidth ) + "x";
Temp2.append(Temp.setNum( m_lineNiepceWidth ));
*proc << Temp2;
*proc << "-bordercolor";
Temp2 = "rgb(" + Temp.setNum(m_NiepceColor.red()) + ",";
Temp2.append(Temp.setNum(m_NiepceColor.green()) + ",");
Temp2.append(Temp.setNum(m_NiepceColor.blue()) + ")");
*proc << Temp2;
*proc << "-border";
Temp2 = Temp.setNum( m_NiepceWidth ) + "x";
Temp2.append(Temp.setNum( m_NiepceWidth ));
*proc << Temp2;
*proc << "-bordercolor";
Temp2 = "rgb(" + Temp.setNum(m_lineNiepceColor.red()) + ",";
Temp2.append(Temp.setNum(m_lineNiepceColor.green()) + ",");
Temp2.append(Temp.setNum(m_lineNiepceColor.blue()) + ")");
*proc << Temp2;
}
if (m_Type->currentItem() == 2) // Raise
{
*proc << "-raise";
TQString Temp, Temp2;
Temp2 = Temp.setNum( m_raiseWidth ) + "x";
Temp2.append(Temp.setNum( m_raiseWidth ));
*proc << Temp2;
}
if (m_Type->currentItem() == 3) // Frame
{
*proc << "-frame";
TQString Temp, Temp2;
Temp2 = Temp.setNum( m_frameWidth ) + "x";
Temp2.append(Temp.setNum( m_frameWidth ) + "+");
Temp2.append(Temp.setNum( m_bevelWidth ) + "+");
Temp2.append(Temp.setNum( m_bevelWidth ) );
*proc << Temp2;
*proc << "-mattecolor";
Temp2 = "rgb(" + Temp.setNum(m_frameColor.red()) + ",";
Temp2.append(Temp.setNum(m_frameColor.green()) + ",");
Temp2.append(Temp.setNum(m_frameColor.blue()) + ")");
*proc << Temp2;
}
*proc << "-verbose";
*proc << item->pathSrc();
if ( !previewMode ) // No preview mode !
*proc << albumDest + "/" + item->nameDest();
return(extractArguments(proc));
}
} // NameSpace KIPIBatchProcessImagesPlugin
|