Rev 1633 | Rev 1735 | 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> |
||
17 | extern QPixmap loadIcon(QString nam); |
||
18 | extern QPointArray FlattenPath(FPointArray ina, QValueList<uint> &Segs); |
||
19 | |||
20 | ExtImageProps::ExtImageProps( QWidget* parent, ImageInfoRecord *info, PageItem *item, ScribusView *view ) : QDialog( parent, "ExtImageProps", true, 0 ) |
||
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")); |
||
43 | blendModes.insert("smud", tr("Exlusion")); |
||
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 ); |
||
1646 | fschmid | 72 | blendMode = new QComboBox( true, tab, "blendMode" ); |
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; |
139 | QValueList<PSDLayer>::iterator it2; |
||
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); |
||
145 | cp->setChecked(!((*it2).flags & 2)); |
||
146 | FlagsSicht.append(cp); |
||
147 | // connect(cp2, SIGNAL(clicked()), this, SLOT(visibleLayer())); |
||
1646 | fschmid | 148 | connect(cp, SIGNAL(clicked()), this, SLOT(changedLayer())); |
1633 | fschmid | 149 | layerTable->setCellWidget(info->layerInfo.count()-counter-1, 0, cp); |
150 | QPixmap pm; |
||
151 | pm.convertFromImage((*it2).thumb); |
||
152 | layerTable->setPixmap(info->layerInfo.count()-counter-1, 1, pm); |
||
153 | layerTable->setText(info->layerInfo.count()-counter-1, 2, (*it2).layerName); |
||
154 | Header->setLabel(info->layerInfo.count()-counter-1, tmp.setNum(counter+1)); |
||
155 | layerTable->setRowHeight(info->layerInfo.count()-counter-1, 40); |
||
156 | counter++; |
||
157 | } |
||
158 | } |
||
159 | else |
||
160 | { |
||
1646 | fschmid | 161 | opacitySpinBox->setValue(100); |
162 | opacitySpinBox->setEnabled(false); |
||
163 | blendMode->setCurrentText( tr("Normal")); |
||
164 | blendMode->setEnabled(false); |
||
1633 | fschmid | 165 | layerTable->setNumRows(1); |
166 | QPixmap pm; |
||
167 | QImage imt; |
||
168 | double sx = item->pixm.width() / 40.0; |
||
169 | double sy = item->pixm.height() / 40.0; |
||
170 | imt = sy < sx ? item->pixm.smoothScale(qRound(item->pixm.width() / sx), qRound(item->pixm.height() / sx)) : |
||
171 | item->pixm.smoothScale(qRound(item->pixm.width() / sy), qRound(item->pixm.height() / sy)); |
||
172 | pm.convertFromImage(imt); |
||
173 | layerTable->setPixmap(0, 1, pm); |
||
174 | layerTable->setText(0, 2, tr("Background")); |
||
175 | QCheckBox *cp = new QCheckBox(this, ""); |
||
176 | cp->setChecked(true); |
||
177 | cp->setEnabled(false); |
||
178 | layerTable->setCellWidget(0, 0, cp); |
||
179 | layerTable->setRowHeight(0, 40); |
||
180 | FlagsSicht.append(cp); |
||
181 | } |
||
182 | tabLayout->addWidget( layerTable ); |
||
1646 | fschmid | 183 | blendMode->setCurrentItem(0); |
1633 | fschmid | 184 | propsTab->insertTab( tab, tr( "Layers" ) ); |
185 | |||
186 | tab_2 = new QWidget( propsTab, "tab_2" ); |
||
187 | tabLayout_2 = new QVBoxLayout( tab_2, 10, 5, "tabLayout_2"); |
||
188 | pathList = new QListBox( tab_2, "pathList" ); |
||
189 | pathList->clear(); |
||
190 | QMap<QString, FPointArray>::Iterator it; |
||
191 | QPixmap dummy(16,16); |
||
192 | dummy.fill(white); |
||
193 | if (info->PDSpathData.count() != 0) |
||
194 | { |
||
195 | for (it = info->PDSpathData.begin(); it != info->PDSpathData.end(); ++it) |
||
196 | { |
||
197 | if (it.key() == info->clipPath) |
||
198 | pathList->insertItem(loadIcon("ok.png"), it.key()); |
||
199 | else |
||
200 | pathList->insertItem(dummy, it.key()); |
||
201 | } |
||
202 | } |
||
203 | tabLayout_2->addWidget( pathList ); |
||
204 | propsTab->insertTab( tab_2, tr( "Paths" ) ); |
||
205 | ExtImagePropsLayout->addWidget( propsTab ); |
||
206 | resize(330, 320); |
||
207 | clearWState( WState_Polished ); |
||
1646 | fschmid | 208 | connect(pathList, SIGNAL( highlighted(QListBoxItem*) ), this, SLOT( selPath(QListBoxItem*) ) ); |
209 | connect(layerTable, SIGNAL(currentChanged(int, int)), this, SLOT(selLayer(int))); |
||
210 | connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changedLayer())); |
||
211 | connect(blendMode, SIGNAL(highlighted(int)), this, SLOT(changedLayer())); |
||
1633 | fschmid | 212 | } |
213 | |||
1646 | fschmid | 214 | void ExtImageProps::changedLayer() |
215 | { |
||
216 | struct LoadRequest loadingInfo; |
||
217 | currentItem->imgInfo.isRequest = true; |
||
218 | currentItem->imgInfo.RequestProps.clear(); |
||
219 | for (uint r = 0; r < layerTable->numRows(); ++r) |
||
220 | { |
||
221 | if (currentLayer == layerTable->numRows() - r - 1) |
||
222 | { |
||
223 | loadingInfo.blend = blendModesRev[blendMode->currentText()]; |
||
224 | loadingInfo.opacity = qRound(opacitySpinBox->value() / 100.0 * 255); |
||
225 | } |
||
226 | else |
||
227 | { |
||
228 | loadingInfo.blend = currentItem->imgInfo.layerInfo[layerTable->numRows() - r - 1].blend; |
||
229 | loadingInfo.opacity = currentItem->imgInfo.layerInfo[layerTable->numRows() - r - 1].opacity; |
||
230 | } |
||
231 | loadingInfo.visible = FlagsSicht.at(layerTable->numRows() - r - 1)->isChecked(); |
||
232 | currentItem->imgInfo.RequestProps.insert(layerTable->numRows() - r - 1, loadingInfo); |
||
233 | } |
||
234 | viewWidget->LoadPict(currentItem->Pfile, currentItem->ItemNr, true); |
||
235 | viewWidget->updateContents(); |
||
236 | } |
||
237 | |||
238 | void ExtImageProps::selLayer(int layer) |
||
239 | { |
||
240 | if ((currentItem->imgInfo.isRequest) && (currentItem->imgInfo.RequestProps.contains(layerTable->numRows() - layer - 1))) |
||
241 | { |
||
242 | opacitySpinBox->setValue(qRound(currentItem->imgInfo.RequestProps[layerTable->numRows() - layer - 1].opacity / 255.0 * 100)); |
||
243 | blendMode->setCurrentText(blendModes[currentItem->imgInfo.RequestProps[layerTable->numRows() - layer - 1].blend]); |
||
244 | } |
||
245 | else |
||
246 | { |
||
247 | opacitySpinBox->setValue(qRound(currentItem->imgInfo.layerInfo[layerTable->numRows() - layer - 1].opacity / 255.0 * 100)); |
||
248 | blendMode->setCurrentText(blendModes[currentItem->imgInfo.layerInfo[layerTable->numRows() - layer - 1].blend]); |
||
249 | } |
||
250 | opacitySpinBox->setEnabled(true); |
||
251 | blendMode->setEnabled(true); |
||
252 | currentLayer = layerTable->numRows() - layer - 1; |
||
253 | } |
||
254 | |||
1633 | fschmid | 255 | void ExtImageProps::selPath(QListBoxItem *c) |
256 | { |
||
257 | currentItem->PoLine = currentItem->imgInfo.PDSpathData[c->text()].copy(); |
||
258 | currentItem->imgInfo.usedPath = c->text(); |
||
259 | QWMatrix cl; |
||
260 | cl.scale(72.0 / currentItem->dpiX, 72.0 / currentItem->dpiY); |
||
261 | currentItem->PoLine.map(cl); |
||
262 | currentItem->FrameType = 3; |
||
263 | currentItem->Clip = FlattenPath(currentItem->PoLine, currentItem->Segments); |
||
264 | currentItem->ClipEdited = true; |
||
265 | double lx = currentItem->Xpos; |
||
266 | double ly = currentItem->Ypos; |
||
267 | currentItem->LocalX = 0; |
||
268 | currentItem->LocalY = 0; |
||
269 | viewWidget->AdjustItemSize(currentItem); |
||
270 | viewWidget->MoveItem(lx- currentItem->Xpos, ly - currentItem->Ypos, currentItem, false); |
||
271 | viewWidget->setRedrawBounding(currentItem); |
||
272 | } |
||
273 |