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