Rev 2040 | Rev 2529 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1633 | fschmid | 1 | #include "extimageprops.h" |
2 | #include "extimageprops.moc" |
||
3 | #include <qvariant.h> |
||
4 | #include <qpushbutton.h> |
||
5 | #include <qtabwidget.h> |
||
6 | #include <qwidget.h> |
||
7 | #include <qlabel.h> |
||
8 | #include <qcombobox.h> |
||
9 | #include <qcheckbox.h> |
||
10 | #include <qspinbox.h> |
||
11 | #include <qtable.h> |
||
12 | #include <qlistbox.h> |
||
13 | #include <qlayout.h> |
||
14 | #include <qtooltip.h> |
||
15 | #include <qwhatsthis.h> |
||
16 | #include <qheader.h> |
||
1735 | fschmid | 17 | #include "scpainter.h" |
1633 | fschmid | 18 | extern QPixmap loadIcon(QString nam); |
19 | extern QPointArray FlattenPath(FPointArray ina, QValueList<uint> &Segs); |
||
1735 | fschmid | 20 | extern FPoint getMinClipF(FPointArray* Clip); |
1633 | fschmid | 21 | |
2004 | fschmid | 22 | ExtImageProps::ExtImageProps( QWidget* parent, ScImage::ImageInfoRecord *info, PageItem *item, ScribusView *view ) : QDialog( parent, "ExtImageProps", true, 0 ) |
1633 | fschmid | 23 | { |
24 | setIcon(loadIcon("AppIcon.png")); |
||
25 | setCaption( tr( "Extended Image Properties" ) ); |
||
26 | ExtImagePropsLayout = new QVBoxLayout( this, 10, 5, "ExtImagePropsLayout"); |
||
27 | viewWidget = view; |
||
28 | currentItem = item; |
||
1646 | fschmid | 29 | currentLayer = 0; |
30 | blendModes.clear(); |
||
31 | blendModes.insert("norm", tr("Normal")); |
||
32 | blendModes.insert("dark", tr("Darken")); |
||
33 | blendModes.insert("lite", tr("Lighten")); |
||
34 | blendModes.insert("hue ", tr("Hue")); |
||
35 | blendModes.insert("sat ", tr("Saturation")); |
||
36 | blendModes.insert("colr", tr("Color")); |
||
37 | blendModes.insert("lum ", tr("Luminosity")); |
||
38 | blendModes.insert("mul ", tr("Multiply")); |
||
39 | blendModes.insert("scrn", tr("Screen")); |
||
40 | blendModes.insert("diss", tr("Dissolve")); |
||
41 | blendModes.insert("over", tr("Overlay")); |
||
42 | blendModes.insert("hLit", tr("Hard Light")); |
||
43 | blendModes.insert("sLit", tr("Soft Light")); |
||
44 | blendModes.insert("diff", tr("Difference")); |
||
2217 | cbradney | 45 | blendModes.insert("smud", tr("Exclusion")); |
1646 | fschmid | 46 | blendModes.insert("div ", tr("Color Dodge")); |
47 | blendModes.insert("idiv", tr("Color Burn")); |
||
48 | blendModesRev.clear(); |
||
49 | blendModesRev.insert( tr("Normal"), "norm"); |
||
50 | blendModesRev.insert( tr("Darken"), "dark"); |
||
51 | blendModesRev.insert( tr("Lighten"), "lite"); |
||
52 | blendModesRev.insert( tr("Hue"), "hue "); |
||
53 | blendModesRev.insert( tr("Saturation"), "sat "); |
||
54 | blendModesRev.insert( tr("Color"), "colr"); |
||
55 | blendModesRev.insert( tr("Luminosity"), "lum "); |
||
56 | blendModesRev.insert( tr("Multiply"), "mul "); |
||
57 | blendModesRev.insert( tr("Screen"), "scrn"); |
||
58 | blendModesRev.insert( tr("Dissolve"), "diss"); |
||
59 | blendModesRev.insert( tr("Overlay"), "over"); |
||
60 | blendModesRev.insert( tr("Hard Light"), "hLit"); |
||
61 | blendModesRev.insert( tr("Soft Light"), "sLit"); |
||
62 | blendModesRev.insert( tr("Difference"), "diff"); |
||
63 | blendModesRev.insert( tr("Exlusion"), "smud"); |
||
64 | blendModesRev.insert( tr("Color Dodge"), "div "); |
||
65 | blendModesRev.insert( tr("Color Burn"), "idiv"); |
||
1633 | fschmid | 66 | propsTab = new QTabWidget( this, "propsTab" ); |
67 | |||
68 | tab = new QWidget( propsTab, "tab" ); |
||
69 | tabLayout = new QVBoxLayout( tab, 10, 5, "tabLayout"); |
||
70 | layout1 = new QHBoxLayout( 0, 0, 5, "layout1"); |
||
71 | textLabel1 = new QLabel( tab, "textLabel1" ); |
||
72 | textLabel1->setText( tr( "Blend Mode:" ) ); |
||
73 | layout1->addWidget( textLabel1 ); |
||
1646 | fschmid | 74 | blendMode = new QComboBox( true, tab, "blendMode" ); |
75 | blendMode->setEditable(false); |
||
76 | blendMode->clear(); |
||
77 | blendMode->insertItem( tr("Normal")); |
||
78 | blendMode->insertItem( tr("Darken")); |
||
79 | blendMode->insertItem( tr("Lighten")); |
||
80 | blendMode->insertItem( tr("Hue")); |
||
81 | blendMode->insertItem( tr("Saturation")); |
||
82 | blendMode->insertItem( tr("Color")); |
||
83 | blendMode->insertItem( tr("Luminosity")); |
||
84 | blendMode->insertItem( tr("Multiply")); |
||
85 | blendMode->insertItem( tr("Screen")); |
||
86 | blendMode->insertItem( tr("Dissolve")); |
||
87 | blendMode->insertItem( tr("Overlay")); |
||
88 | blendMode->insertItem( tr("Hard Light")); |
||
89 | blendMode->insertItem( tr("Soft Light")); |
||
90 | blendMode->insertItem( tr("Difference")); |
||
91 | blendMode->insertItem( tr("Exlusion")); |
||
92 | blendMode->insertItem( tr("Color Dodge")); |
||
93 | blendMode->insertItem( tr("Color Burn")); |
||
1633 | fschmid | 94 | layout1->addWidget( blendMode ); |
95 | textLabel2 = new QLabel( tab, "textLabel2" ); |
||
96 | textLabel2->setText( tr( "Opacity:" ) ); |
||
97 | layout1->addWidget( textLabel2 ); |
||
98 | opacitySpinBox = new QSpinBox( tab, "opacitySpinBox" ); |
||
1646 | fschmid | 99 | opacitySpinBox->setMinValue(0); |
100 | opacitySpinBox->setMaxValue(100); |
||
101 | opacitySpinBox->setLineStep(10); |
||
102 | opacitySpinBox->setSuffix( tr(" %")); |
||
1633 | fschmid | 103 | layout1->addWidget( opacitySpinBox ); |
104 | tabLayout->addLayout( layout1 ); |
||
105 | layerTable = new QTable( tab, "layerTable" ); |
||
106 | layerTable->setNumRows( 0 ); |
||
107 | layerTable->setNumCols( 3 ); |
||
108 | QHeader *header = layerTable->horizontalHeader(); |
||
109 | header->setLabel(0, loadIcon("Layervisible.xpm"), ""); |
||
110 | header->setLabel(1, ""); |
||
111 | header->setLabel(2, tr("Name")); |
||
112 | layerTable->setColumnReadOnly(0, true); |
||
113 | layerTable->setColumnReadOnly(1, true); |
||
114 | layerTable->setColumnReadOnly(2, true); |
||
115 | layerTable->setColumnWidth(0, 24); |
||
116 | layerTable->setColumnWidth(1, 40); |
||
117 | layerTable->setColumnStretchable(2, true); |
||
118 | layerTable->setRowMovingEnabled(false); |
||
119 | layerTable->setSorting(false); |
||
120 | layerTable->setSelectionMode( QTable::SingleRow ); |
||
121 | layerTable->setFocusStyle( QTable::FollowStyle ); |
||
122 | QHeader *Header = layerTable->verticalHeader(); |
||
123 | Header->setMovingEnabled(false); |
||
1646 | fschmid | 124 | Header->setResizeEnabled(false); |
1633 | fschmid | 125 | FlagsSicht.clear(); |
126 | if (info->layerInfo.count() != 0) |
||
127 | { |
||
1646 | fschmid | 128 | if ((info->isRequest) && (info->RequestProps.contains(0))) |
129 | { |
||
130 | opacitySpinBox->setValue(qRound(info->RequestProps[0].opacity / 255.0 * 100)); |
||
131 | blendMode->setCurrentText(blendModes[info->RequestProps[0].blend]); |
||
132 | } |
||
133 | else |
||
134 | { |
||
135 | opacitySpinBox->setValue(qRound(info->layerInfo[0].opacity / 255.0 * 100)); |
||
136 | blendMode->setCurrentText(blendModes[info->layerInfo[0].blend]); |
||
137 | } |
||
138 | opacitySpinBox->setEnabled(true); |
||
139 | blendMode->setEnabled(true); |
||
1633 | fschmid | 140 | QString tmp; |
2004 | fschmid | 141 | QValueList<ScImage::PSDLayer>::iterator it2; |
1633 | fschmid | 142 | layerTable->setNumRows(info->layerInfo.count()); |
143 | uint counter = 0; |
||
144 | for (it2 = info->layerInfo.begin(); it2 != info->layerInfo.end(); ++it2) |
||
145 | { |
||
146 | QCheckBox *cp = new QCheckBox(this, (*it2).layerName); |
||
1735 | fschmid | 147 | if ((info->isRequest) && (info->RequestProps.contains(counter))) |
148 | cp->setChecked(info->RequestProps[counter].visible); |
||
149 | else |
||
150 | cp->setChecked(!((*it2).flags & 2)); |
||
1633 | fschmid | 151 | FlagsSicht.append(cp); |
1646 | fschmid | 152 | connect(cp, SIGNAL(clicked()), this, SLOT(changedLayer())); |
1633 | fschmid | 153 | layerTable->setCellWidget(info->layerInfo.count()-counter-1, 0, cp); |
154 | QPixmap pm; |
||
155 | pm.convertFromImage((*it2).thumb); |
||
156 | layerTable->setPixmap(info->layerInfo.count()-counter-1, 1, pm); |
||
157 | layerTable->setText(info->layerInfo.count()-counter-1, 2, (*it2).layerName); |
||
158 | Header->setLabel(info->layerInfo.count()-counter-1, tmp.setNum(counter+1)); |
||
159 | layerTable->setRowHeight(info->layerInfo.count()-counter-1, 40); |
||
160 | counter++; |
||
161 | } |
||
162 | } |
||
163 | else |
||
164 | { |
||
1646 | fschmid | 165 | opacitySpinBox->setValue(100); |
166 | opacitySpinBox->setEnabled(false); |
||
167 | blendMode->setCurrentText( tr("Normal")); |
||
168 | blendMode->setEnabled(false); |
||
1633 | fschmid | 169 | layerTable->setNumRows(1); |
170 | QPixmap pm; |
||
171 | QImage imt; |
||
172 | double sx = item->pixm.width() / 40.0; |
||
173 | double sy = item->pixm.height() / 40.0; |
||
174 | imt = sy < sx ? item->pixm.smoothScale(qRound(item->pixm.width() / sx), qRound(item->pixm.height() / sx)) : |
||
175 | item->pixm.smoothScale(qRound(item->pixm.width() / sy), qRound(item->pixm.height() / sy)); |
||
176 | pm.convertFromImage(imt); |
||
177 | layerTable->setPixmap(0, 1, pm); |
||
178 | layerTable->setText(0, 2, tr("Background")); |
||
179 | QCheckBox *cp = new QCheckBox(this, ""); |
||
180 | cp->setChecked(true); |
||
181 | cp->setEnabled(false); |
||
182 | layerTable->setCellWidget(0, 0, cp); |
||
183 | layerTable->setRowHeight(0, 40); |
||
184 | FlagsSicht.append(cp); |
||
185 | } |
||
186 | tabLayout->addWidget( layerTable ); |
||
1646 | fschmid | 187 | blendMode->setCurrentItem(0); |
1633 | fschmid | 188 | propsTab->insertTab( tab, tr( "Layers" ) ); |
189 | |||
190 | tab_2 = new QWidget( propsTab, "tab_2" ); |
||
191 | tabLayout_2 = new QVBoxLayout( tab_2, 10, 5, "tabLayout_2"); |
||
192 | pathList = new QListBox( tab_2, "pathList" ); |
||
193 | pathList->clear(); |
||
194 | QMap<QString, FPointArray>::Iterator it; |
||
195 | if (info->PDSpathData.count() != 0) |
||
196 | { |
||
197 | for (it = info->PDSpathData.begin(); it != info->PDSpathData.end(); ++it) |
||
198 | { |
||
1735 | fschmid | 199 | QPixmap pixm(40, 40); |
200 | ScPainter *p = new ScPainter(&pixm, 40, 40); |
||
201 | p->clear(); |
||
202 | p->translate(3.0, 3.0); |
||
1633 | fschmid | 203 | if (it.key() == info->clipPath) |
1735 | fschmid | 204 | { |
205 | pixm.fill(green); |
||
206 | p->clear(green); |
||
207 | } |
||
1633 | fschmid | 208 | else |
1735 | fschmid | 209 | pixm.fill(white); |
210 | FPointArray Path; |
||
211 | Path.resize(0); |
||
2040 | fschmid | 212 | Path = info->PDSpathData[it.key()].copy(); |
1735 | fschmid | 213 | FPoint min = getMinClipF(&Path); |
214 | Path.translate(-min.x(), -min.y()); |
||
215 | FPoint max = Path.WidthHeight(); |
||
216 | QWMatrix mm; |
||
217 | mm.scale(34.0 / QMAX(max.x(), max.y()), 34.0 / QMAX(max.x(), max.y())); |
||
218 | Path.map(mm); |
||
219 | p->setupPolygon(&Path); |
||
220 | p->setPen(black); |
||
221 | p->setBrush(white); |
||
222 | p->setFillMode(0); |
||
223 | p->setLineWidth(1.0); |
||
224 | p->strokePath(); |
||
225 | p->end(); |
||
226 | delete p; |
||
227 | pathList->insertItem(pixm, it.key()); |
||
2040 | fschmid | 228 | if (it.key() == info->usedPath) |
229 | pathList->setSelected(pathList->count()-1, true); |
||
1633 | fschmid | 230 | } |
231 | } |
||
232 | tabLayout_2->addWidget( pathList ); |
||
2040 | fschmid | 233 | resetPath = new QPushButton( tr("Don't use any Path"), tab_2, "reset"); |
234 | tabLayout_2->addWidget( resetPath ); |
||
1633 | fschmid | 235 | propsTab->insertTab( tab_2, tr( "Paths" ) ); |
236 | ExtImagePropsLayout->addWidget( propsTab ); |
||
237 | resize(330, 320); |
||
238 | clearWState( WState_Polished ); |
||
1646 | fschmid | 239 | connect(pathList, SIGNAL( highlighted(QListBoxItem*) ), this, SLOT( selPath(QListBoxItem*) ) ); |
240 | connect(layerTable, SIGNAL(currentChanged(int, int)), this, SLOT(selLayer(int))); |
||
241 | connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changedLayer())); |
||
1735 | fschmid | 242 | connect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer())); |
2040 | fschmid | 243 | connect(resetPath, SIGNAL(clicked()), this, SLOT(noPath())); |
244 | |||
1633 | fschmid | 245 | } |
246 | |||
1646 | fschmid | 247 | void ExtImageProps::changedLayer() |
248 | { |
||
2004 | fschmid | 249 | struct ScImage::LoadRequest loadingInfo; |
250 | currentItem->pixm.imgInfo.isRequest = true; |
||
1735 | fschmid | 251 | for (int r = 0; r < layerTable->numRows(); ++r) |
1646 | fschmid | 252 | { |
253 | if (currentLayer == layerTable->numRows() - r - 1) |
||
254 | { |
||
255 | loadingInfo.blend = blendModesRev[blendMode->currentText()]; |
||
256 | loadingInfo.opacity = qRound(opacitySpinBox->value() / 100.0 * 255); |
||
257 | } |
||
2004 | fschmid | 258 | else if (currentItem->pixm.imgInfo.RequestProps.contains(layerTable->numRows() - r - 1)) |
1735 | fschmid | 259 | { |
2004 | fschmid | 260 | loadingInfo.blend = currentItem->pixm.imgInfo.RequestProps[layerTable->numRows() - r - 1].blend; |
261 | loadingInfo.opacity = currentItem->pixm.imgInfo.RequestProps[layerTable->numRows() - r - 1].opacity; |
||
1735 | fschmid | 262 | } |
1646 | fschmid | 263 | else |
264 | { |
||
2004 | fschmid | 265 | loadingInfo.blend = currentItem->pixm.imgInfo.layerInfo[layerTable->numRows() - r - 1].blend; |
266 | loadingInfo.opacity = currentItem->pixm.imgInfo.layerInfo[layerTable->numRows() - r - 1].opacity; |
||
1646 | fschmid | 267 | } |
268 | loadingInfo.visible = FlagsSicht.at(layerTable->numRows() - r - 1)->isChecked(); |
||
2004 | fschmid | 269 | currentItem->pixm.imgInfo.RequestProps.insert(layerTable->numRows() - r - 1, loadingInfo); |
1646 | fschmid | 270 | } |
271 | viewWidget->LoadPict(currentItem->Pfile, currentItem->ItemNr, true); |
||
272 | viewWidget->updateContents(); |
||
273 | } |
||
274 | |||
275 | void ExtImageProps::selLayer(int layer) |
||
276 | { |
||
1735 | fschmid | 277 | disconnect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changedLayer())); |
278 | disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer())); |
||
2004 | fschmid | 279 | if ((currentItem->pixm.imgInfo.isRequest) && (currentItem->pixm.imgInfo.RequestProps.contains(layerTable->numRows() - layer - 1))) |
1646 | fschmid | 280 | { |
2004 | fschmid | 281 | opacitySpinBox->setValue(qRound(currentItem->pixm.imgInfo.RequestProps[layerTable->numRows() - layer - 1].opacity / 255.0 * 100)); |
282 | blendMode->setCurrentText(blendModes[currentItem->pixm.imgInfo.RequestProps[layerTable->numRows() - layer - 1].blend]); |
||
1646 | fschmid | 283 | } |
284 | else |
||
285 | { |
||
2004 | fschmid | 286 | opacitySpinBox->setValue(qRound(currentItem->pixm.imgInfo.layerInfo[layerTable->numRows() - layer - 1].opacity / 255.0 * 100)); |
287 | blendMode->setCurrentText(blendModes[currentItem->pixm.imgInfo.layerInfo[layerTable->numRows() - layer - 1].blend]); |
||
1646 | fschmid | 288 | } |
289 | opacitySpinBox->setEnabled(true); |
||
290 | blendMode->setEnabled(true); |
||
291 | currentLayer = layerTable->numRows() - layer - 1; |
||
1735 | fschmid | 292 | connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changedLayer())); |
293 | connect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer())); |
||
1646 | fschmid | 294 | } |
295 | |||
2040 | fschmid | 296 | void ExtImageProps::noPath() |
297 | { |
||
298 | disconnect(pathList, SIGNAL( highlighted(QListBoxItem*) ), this, SLOT( selPath(QListBoxItem*) ) ); |
||
299 | currentItem->imageClip.resize(0); |
||
300 | currentItem->pixm.imgInfo.usedPath = ""; |
||
301 | pathList->clearSelection(); |
||
302 | viewWidget->updateContents(); |
||
303 | connect(pathList, SIGNAL( highlighted(QListBoxItem*) ), this, SLOT( selPath(QListBoxItem*) ) ); |
||
304 | } |
||
305 | |||
1633 | fschmid | 306 | void ExtImageProps::selPath(QListBoxItem *c) |
307 | { |
||
2040 | fschmid | 308 | currentItem->imageClip = currentItem->pixm.imgInfo.PDSpathData[c->text()].copy(); |
2004 | fschmid | 309 | currentItem->pixm.imgInfo.usedPath = c->text(); |
1633 | fschmid | 310 | QWMatrix cl; |
2040 | fschmid | 311 | cl.translate(currentItem->LocalX*currentItem->LocalScX, currentItem->LocalY*currentItem->LocalScY); |
312 | cl.scale(currentItem->LocalScX, currentItem->LocalScY); |
||
313 | currentItem->imageClip.map(cl); |
||
2012 | fschmid | 314 | viewWidget->updateContents(); |
1633 | fschmid | 315 | } |
316 |