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