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
|
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** TQt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void SQ_ImageConvert::init()
{
tableLib->header()->hide();
createExtension();
initLibs();
pushWriteOptions->setPixmap(TQPixmap(locate("data", "images/imageedit/resize_toolbutton2.png")));
pushOptions->setPixmap(SQ_IconLoader::instance()->loadIcon("configure", TDEIcon::Desktop, TDEIcon::SizeSmall));
SQ_Config::instance()->setGroup("Image edit options");
imageopt.putto = SQ_Config::instance()->readEntry("convert_putto", TQString());
imageopt.where_to_put = SQ_Config::instance()->readNumEntry("convert_where_to_put", 0);
imageopt.close = SQ_Config::instance()->readBoolEntry("convert_close", true);
done = true;
}
void SQ_ImageConvert::initLibs()
{
TQListViewItem *first;
TQValueVector<SQ_LIBRARY>::iterator itEnd = SQ_LibraryHandler::instance()->end();
for(TQValueVector<SQ_LIBRARY>::iterator it = SQ_LibraryHandler::instance()->begin();
it != itEnd;++it)
{
if((*it).writestatic)
{
TQFileInfo libfileinfo((*it).libpath);
TQListViewItem *item = new TQListViewItem(tableLib, TQString(), TQString((*it).quickinfo));
item->setPixmap(0, (*it).mime);
tableLib->insertItem(item);
}
}
first = tableLib->firstChild();
if(first)
{
tableLib->setSelected(first, true);
slotCurrentLibraryChanged(first);
}
}
void SQ_ImageConvert::slotShowExtWrapper(bool show)
{
showExtension(show);
}
void SQ_ImageConvert::createExtension()
{
SQ_WriteOption *c = new SQ_WriteOption(this);
c->slider->setRange(0, 255, 1, true);
setExtension(c);
setOrientation(TQt::Horizontal);
}
void SQ_ImageConvert::slotDebugText(const TQString &text, bool bold)
{
textResult->setBold(bold);
textResult->insertAt(text, paragraph, textResult->paragraphLength(paragraph));
textResult->setBold(false);
}
void SQ_ImageConvert::slotStartConvert()
{
pushConvert->setDefault(false);
pushConvert->setDisabled(true);
pushCancel->setDefault(true);
pushCancel->setFocus();
widgetStack->raiseWidget(1);
showExtension(false);
tqApp->processEvents();
TQListViewItem *i = tableLib->selectedItem();
if(!i)
return;
SQ_ImageConvertOptions copt;
copt.libname = i->text(1);
emit convert(&imageopt, &copt);
}
void SQ_ImageConvert::startConvertion(int count)
{
done = false;
paragraph = 0;
progress->setProgress(0);
progress->setTotalSteps(count);
}
void SQ_ImageConvert::slotOneProcessed()
{
progress->advance(1);
paragraph++;
}
void SQ_ImageConvert::slotCurrentLibraryChanged( TQListViewItem * i)
{
if(!i)
return;
TQString name = i->text(1);
SQ_LIBRARY *l = SQ_LibraryHandler::instance()->libraryByName(name);
if(!l)
return;
SQ_WriteOption *e = (SQ_WriteOption*)extension();
if(!e)
return;
e->widgetStack->raiseWidget(0);
bool bslider = (l->opt.compression_scheme == CompressionInternal && (l->opt.compression_min || l->opt.compression_max));
e->slider->setShown(bslider);
e->checkRLE->setShown(!bslider);
if(bslider)
{
e->slider->setRange(l->opt.compression_min, l->opt.compression_max, 1, true);
e->slider->setValue(l->opt.compression_def);
}
bool rle = true;
if(!(l->opt.compression_scheme & CompressionRLE))
{
e->checkRLE->hide();
rle = false;
}
bool binter = l->opt.interlaced;
e->checkInterlaced->setShown(binter);
if(!binter && !rle && !bslider)
e->widgetStack->raiseWidget(1);
}
void SQ_ImageConvert::fillWriteOptions(fmt_writeoptions *opt, const fmt_writeoptionsabs &opt2)
{
SQ_WriteOption *e = (SQ_WriteOption*)extension();
if(!e)
return;
opt->interlaced = (opt2.interlaced) ? e->checkInterlaced->isChecked() : false;
if(opt2.compression_scheme == CompressionInternal)
opt->compression_scheme = CompressionInternal;
else if(opt2.compression_scheme == CompressionRLE)
opt->compression_scheme = (e->checkRLE->isChecked()) ? CompressionRLE : CompressionNo;
else
opt->compression_scheme = CompressionNo;
opt->compression_level = (opt->compression_scheme != CompressionNo) ? e->slider->value() : 0;
}
void SQ_ImageConvert::slotOptions()
{
SQ_ImageEditOptions o(this);
// SQ_ImageEditOptions will write needed TDEConfig entries, if
// exec() will return TQDialog::Accepted
o.setConfigPrefix("convert");
o.exec(&imageopt);
}
void SQ_ImageConvert::slotDone(bool close)
{
done = true;
if(close)
reject();
}
void SQ_ImageConvert::slotReject()
{
if(done)
reject();
}
void SQ_ImageConvert::closeEvent(TQCloseEvent *e)
{
if(done)
e->accept();
else
{
e->ignore();
TQWhatsThis::display(SQ_ErrorString::instance()->string(SQE_NOTFINISHED));
}
}
|