Rev 1646 | Go to most recent revision | Details | 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; |
||
27 | propsTab = new QTabWidget( this, "propsTab" ); |
||
28 | |||
29 | tab = new QWidget( propsTab, "tab" ); |
||
30 | tabLayout = new QVBoxLayout( tab, 10, 5, "tabLayout"); |
||
31 | layout1 = new QHBoxLayout( 0, 0, 5, "layout1"); |
||
32 | textLabel1 = new QLabel( tab, "textLabel1" ); |
||
33 | textLabel1->setText( tr( "Blend Mode:" ) ); |
||
34 | layout1->addWidget( textLabel1 ); |
||
35 | blendMode = new QComboBox( false, tab, "blendMode" ); |
||
36 | layout1->addWidget( blendMode ); |
||
37 | textLabel2 = new QLabel( tab, "textLabel2" ); |
||
38 | textLabel2->setText( tr( "Opacity:" ) ); |
||
39 | layout1->addWidget( textLabel2 ); |
||
40 | opacitySpinBox = new QSpinBox( tab, "opacitySpinBox" ); |
||
41 | layout1->addWidget( opacitySpinBox ); |
||
42 | tabLayout->addLayout( layout1 ); |
||
43 | layerTable = new QTable( tab, "layerTable" ); |
||
44 | layerTable->setNumRows( 0 ); |
||
45 | layerTable->setNumCols( 3 ); |
||
46 | QHeader *header = layerTable->horizontalHeader(); |
||
47 | header->setLabel(0, loadIcon("Layervisible.xpm"), ""); |
||
48 | header->setLabel(1, ""); |
||
49 | header->setLabel(2, tr("Name")); |
||
50 | layerTable->setColumnReadOnly(0, true); |
||
51 | layerTable->setColumnReadOnly(1, true); |
||
52 | layerTable->setColumnReadOnly(2, true); |
||
53 | layerTable->setColumnWidth(0, 24); |
||
54 | layerTable->setColumnWidth(1, 40); |
||
55 | layerTable->setColumnStretchable(2, true); |
||
56 | layerTable->setRowMovingEnabled(false); |
||
57 | layerTable->setSorting(false); |
||
58 | layerTable->setSelectionMode( QTable::SingleRow ); |
||
59 | layerTable->setFocusStyle( QTable::FollowStyle ); |
||
60 | QHeader *Header = layerTable->verticalHeader(); |
||
61 | Header->setMovingEnabled(false); |
||
62 | // Header->setResizeEnabled(false); |
||
63 | FlagsSicht.clear(); |
||
64 | if (info->layerInfo.count() != 0) |
||
65 | { |
||
66 | QString tmp; |
||
67 | QValueList<PSDLayer>::iterator it2; |
||
68 | layerTable->setNumRows(info->layerInfo.count()); |
||
69 | uint counter = 0; |
||
70 | for (it2 = info->layerInfo.begin(); it2 != info->layerInfo.end(); ++it2) |
||
71 | { |
||
72 | QCheckBox *cp = new QCheckBox(this, (*it2).layerName); |
||
73 | cp->setChecked(!((*it2).flags & 2)); |
||
74 | FlagsSicht.append(cp); |
||
75 | // connect(cp2, SIGNAL(clicked()), this, SLOT(visibleLayer())); |
||
76 | layerTable->setCellWidget(info->layerInfo.count()-counter-1, 0, cp); |
||
77 | QPixmap pm; |
||
78 | pm.convertFromImage((*it2).thumb); |
||
79 | layerTable->setPixmap(info->layerInfo.count()-counter-1, 1, pm); |
||
80 | layerTable->setText(info->layerInfo.count()-counter-1, 2, (*it2).layerName); |
||
81 | Header->setLabel(info->layerInfo.count()-counter-1, tmp.setNum(counter+1)); |
||
82 | layerTable->setRowHeight(info->layerInfo.count()-counter-1, 40); |
||
83 | counter++; |
||
84 | } |
||
85 | } |
||
86 | else |
||
87 | { |
||
88 | layerTable->setNumRows(1); |
||
89 | QPixmap pm; |
||
90 | QImage imt; |
||
91 | double sx = item->pixm.width() / 40.0; |
||
92 | double sy = item->pixm.height() / 40.0; |
||
93 | imt = sy < sx ? item->pixm.smoothScale(qRound(item->pixm.width() / sx), qRound(item->pixm.height() / sx)) : |
||
94 | item->pixm.smoothScale(qRound(item->pixm.width() / sy), qRound(item->pixm.height() / sy)); |
||
95 | pm.convertFromImage(imt); |
||
96 | layerTable->setPixmap(0, 1, pm); |
||
97 | layerTable->setText(0, 2, tr("Background")); |
||
98 | QCheckBox *cp = new QCheckBox(this, ""); |
||
99 | cp->setChecked(true); |
||
100 | cp->setEnabled(false); |
||
101 | layerTable->setCellWidget(0, 0, cp); |
||
102 | layerTable->setRowHeight(0, 40); |
||
103 | FlagsSicht.append(cp); |
||
104 | } |
||
105 | tabLayout->addWidget( layerTable ); |
||
106 | propsTab->insertTab( tab, tr( "Layers" ) ); |
||
107 | |||
108 | tab_2 = new QWidget( propsTab, "tab_2" ); |
||
109 | tabLayout_2 = new QVBoxLayout( tab_2, 10, 5, "tabLayout_2"); |
||
110 | pathList = new QListBox( tab_2, "pathList" ); |
||
111 | pathList->clear(); |
||
112 | QMap<QString, FPointArray>::Iterator it; |
||
113 | QPixmap dummy(16,16); |
||
114 | dummy.fill(white); |
||
115 | if (info->PDSpathData.count() != 0) |
||
116 | { |
||
117 | for (it = info->PDSpathData.begin(); it != info->PDSpathData.end(); ++it) |
||
118 | { |
||
119 | if (it.key() == info->clipPath) |
||
120 | pathList->insertItem(loadIcon("ok.png"), it.key()); |
||
121 | else |
||
122 | pathList->insertItem(dummy, it.key()); |
||
123 | } |
||
124 | } |
||
125 | tabLayout_2->addWidget( pathList ); |
||
126 | propsTab->insertTab( tab_2, tr( "Paths" ) ); |
||
127 | ExtImagePropsLayout->addWidget( propsTab ); |
||
128 | resize(330, 320); |
||
129 | clearWState( WState_Polished ); |
||
130 | connect( pathList, SIGNAL( highlighted(QListBoxItem*) ), this, SLOT( selPath(QListBoxItem*) ) ); |
||
131 | } |
||
132 | |||
133 | void ExtImageProps::selPath(QListBoxItem *c) |
||
134 | { |
||
135 | currentItem->PoLine = currentItem->imgInfo.PDSpathData[c->text()].copy(); |
||
136 | currentItem->imgInfo.usedPath = c->text(); |
||
137 | QWMatrix cl; |
||
138 | cl.scale(72.0 / currentItem->dpiX, 72.0 / currentItem->dpiY); |
||
139 | currentItem->PoLine.map(cl); |
||
140 | currentItem->FrameType = 3; |
||
141 | currentItem->Clip = FlattenPath(currentItem->PoLine, currentItem->Segments); |
||
142 | currentItem->ClipEdited = true; |
||
143 | double lx = currentItem->Xpos; |
||
144 | double ly = currentItem->Ypos; |
||
145 | currentItem->LocalX = 0; |
||
146 | currentItem->LocalY = 0; |
||
147 | viewWidget->AdjustItemSize(currentItem); |
||
148 | viewWidget->MoveItem(lx- currentItem->Xpos, ly - currentItem->Ypos, currentItem, false); |
||
149 | viewWidget->setRedrawBounding(currentItem); |
||
150 | } |
||
151 |