Rev 215 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | paul | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'Color.ui' |
||
3 | ** |
||
4 | ** Created: Mon Apr 23 19:09:31 2001 |
||
5 | ** by: The User Interface Compiler (uic) |
||
6 | ** |
||
7 | ** WARNING! All changes made in this file will be lost! |
||
8 | ****************************************************************************/ |
||
9 | #include "colorm.h" |
||
10 | #include "colorm.moc" |
||
11 | #include <qvariant.h> |
||
12 | #include <qtooltip.h> |
||
13 | #include <qpixmap.h> |
||
151 | Franz | 14 | #include <cstdlib> |
3 | paul | 15 | #include <qcolordialog.h> |
16 | #include "customfdialog.h" |
||
17 | #include "dcolor.h" |
||
18 | #include "scribusXml.h" |
||
19 | #include "cmykfw.h" |
||
151 | Franz | 20 | #include "query.h" |
188 | Franz | 21 | #include "scribus.h" |
128 | Franz | 22 | |
23 | #if (_MSC_VER >= 1200) |
||
24 | #include "win-config.h" |
||
25 | #else |
||
26 | #include "config.h" |
||
27 | #endif |
||
28 | |||
3 | paul | 29 | extern QPixmap loadIcon(QString nam); |
188 | Franz | 30 | extern ScribusApp* ScApp; |
3 | paul | 31 | |
151 | Franz | 32 | Farbmanager::Farbmanager( QWidget* parent, CListe doco, bool HDoc, QString DcolSet, QStringList Cust ) |
3 | paul | 33 | : QDialog( parent, "dd", true, 0 ) |
34 | { |
||
161 | Franz | 35 | setName( "Farbmanager" ); |
188 | Franz | 36 | DontChange.clear(); |
161 | Franz | 37 | DontChange += "White"; |
38 | DontChange += "Black"; |
||
39 | DontChange += "Cyan"; |
||
40 | DontChange += "Magenta"; |
||
41 | DontChange += "Yellow"; |
||
42 | HaveDoc = HDoc; |
||
43 | CColSet = Cust; |
||
188 | Franz | 44 | setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, |
45 | sizePolicy().hasHeightForWidth() ) ); |
||
46 | setSizeGripEnabled(true); |
||
47 | setCaption( tr( "Colors" ) ); |
||
48 | setIcon(loadIcon("AppIcon.png")); |
||
49 | Layout2 = new QVBoxLayout( this ); |
||
50 | Layout2->setSpacing( 6 ); |
||
51 | Layout2->setMargin( 11 ); |
||
151 | Franz | 52 | |
188 | Franz | 53 | layout5 = new QHBoxLayout( 0, 0, 6, "layout5"); |
54 | ListBox1 = new QListBox( this, "ListBox1" ); |
||
55 | ListBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, |
||
56 | ListBox1->sizePolicy().hasHeightForWidth() ) ); |
||
57 | ListBox1->setMinimumSize( QSize( 164, 228 ) ); |
||
58 | ListBox1->setColumnMode( QListBox::FixedNumber ); |
||
59 | layout5->addWidget( ListBox1 ); |
||
151 | Franz | 60 | |
161 | Franz | 61 | ColorsGroup = new QGroupBox( this, "ColorsGroup" ); |
62 | ColorsGroup->setTitle( tr( "Colors" ) ); |
||
63 | ColorsGroup->setColumnLayout(0, Qt::Vertical ); |
||
64 | ColorsGroup->layout()->setSpacing( 6 ); |
||
65 | ColorsGroup->layout()->setMargin( 11 ); |
||
66 | Layout1 = new QVBoxLayout( ColorsGroup->layout() ); |
||
67 | Layout1->setAlignment( Qt::AlignTop ); |
||
68 | LoadF = new QPushButton( ColorsGroup, "LoadF" ); |
||
188 | Franz | 69 | LoadF->setText( tr( "Append" ) ); |
70 | Layout1->addWidget( LoadF ); |
||
71 | NewF = new QPushButton( ColorsGroup, "NewF" ); |
||
72 | NewF->setText( tr( "New" ) ); |
||
73 | Layout1->addWidget( NewF ); |
||
74 | EditF = new QPushButton( ColorsGroup, "EditF" ); |
||
75 | EditF->setEnabled( false ); |
||
76 | EditF->setText( tr( "Edit" ) ); |
||
77 | EditF->setDefault( true ); |
||
78 | Layout1->addWidget( EditF ); |
||
79 | DupF = new QPushButton( ColorsGroup, "DupF" ); |
||
80 | DupF->setEnabled( false ); |
||
81 | DupF->setText( tr( "Duplicate" ) ); |
||
82 | Layout1->addWidget( DupF ); |
||
83 | DelF = new QPushButton( ColorsGroup, "DelF" ); |
||
84 | DelF->setEnabled( false ); |
||
85 | DelF->setText( tr( "Delete" ) ); |
||
86 | Layout1->addWidget( DelF ); |
||
87 | layout5->addWidget( ColorsGroup ); |
||
88 | Layout2->addLayout( layout5 ); |
||
151 | Franz | 89 | |
188 | Franz | 90 | layout4 = new QHBoxLayout( 0, 0, 6, "layout4"); |
151 | Franz | 91 | |
188 | Franz | 92 | layout3 = new QVBoxLayout( 0, 0, 6, "layout3"); |
93 | SaveF = new QPushButton( this, "SaveF" ); |
||
94 | SaveF->setText( tr( "Save" ) ); |
||
95 | layout3->addWidget( SaveF ); |
||
96 | CancF = new QPushButton( this, "CancF" ); |
||
97 | CancF->setText( tr( "Cancel" ) ); |
||
98 | CancF->setDefault( true ); |
||
99 | layout3->addWidget( CancF ); |
||
100 | layout4->addLayout( layout3 ); |
||
161 | Franz | 101 | if (HaveDoc) |
102 | { |
||
188 | Franz | 103 | layout7 = new QVBoxLayout( 0, 0, 6, "layout3"); |
104 | DelU = new QPushButton( this, "DelU" ); |
||
105 | DelU->setText( tr( "Remove Unused" ) ); |
||
106 | layout7->addWidget( DelU ); |
||
107 | QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
||
108 | layout7->addItem( spacer ); |
||
109 | layout4->addLayout( layout7 ); |
||
161 | Franz | 110 | } |
111 | else |
||
112 | { |
||
113 | ColsSetGroup = new QGroupBox( this, "ColsSetGroup" ); |
||
114 | ColsSetGroup->setTitle( tr( "Color Sets" ) ); |
||
115 | ColsSetGroup->setColumnLayout(0, Qt::Vertical ); |
||
116 | ColsSetGroup->layout()->setSpacing( 6 ); |
||
117 | ColsSetGroup->layout()->setMargin( 11 ); |
||
118 | ColsSetGroupLayout = new QVBoxLayout( ColsSetGroup->layout() ); |
||
119 | ColsSetGroupLayout->setAlignment( Qt::AlignTop ); |
||
120 | textLabel1 = new QLabel( ColsSetGroup, "textLabel1" ); |
||
121 | textLabel1->setText( tr( "Current Color Set:" ) ); |
||
122 | ColsSetGroupLayout->addWidget( textLabel1 ); |
||
123 | CSets = new QPopupMenu(); |
||
124 | CSets->insertItem("Scribus Small"); |
||
125 | CSets->insertItem("X11 RGB-Set"); |
||
187 | Franz | 126 | CSets->insertItem("X11 Grey-Set"); |
127 | CSets->insertItem("Gnome-Set"); |
||
215 | Franz | 128 | CSets->insertItem("SVG-Set"); |
161 | Franz | 129 | if (Cust.count() != 0) |
130 | { |
||
131 | for (uint m = 0; m < Cust.count(); ++m) |
||
132 | CSets->insertItem(Cust[m]); |
||
133 | } |
||
134 | LoadColSet = new QToolButton( ColsSetGroup, "LoadColSet" ); |
||
135 | LoadColSet->setPopup(CSets); |
||
136 | LoadColSet->setPopupDelay(0); |
||
137 | LoadColSet->setText(DcolSet); |
||
138 | ColsSetGroupLayout->addWidget( LoadColSet ); |
||
139 | SaveColSet = new QPushButton( ColsSetGroup, "SaveColSet" ); |
||
140 | SaveColSet->setText( tr( "Save Color Set" ) ); |
||
141 | ColsSetGroupLayout->addWidget( SaveColSet ); |
||
142 | layout4->addWidget( ColsSetGroup ); |
||
143 | } |
||
144 | Layout2->addLayout( layout4 ); |
||
3 | paul | 145 | Ersatzliste.clear(); |
188 | Franz | 146 | EditColors = doco; |
147 | updateCList(); |
||
148 | // signals and slots connections |
||
161 | Franz | 149 | if (!HaveDoc) |
150 | { |
||
151 | connect(CSets, SIGNAL(activated(int)), this, SLOT(loadDefaults(int))); |
||
188 | Franz | 152 | connect(SaveColSet, SIGNAL( clicked() ), this, SLOT( saveDefaults() ) ); |
224 | Franz | 153 | QToolTip::add( LoadColSet, tr( "Choose a color set to load" ) ); |
154 | QToolTip::add( SaveColSet, tr( "Save the current color set" ) ); |
||
161 | Franz | 155 | } |
188 | Franz | 156 | else |
224 | Franz | 157 | { |
188 | Franz | 158 | connect(DelU, SIGNAL( clicked() ), this, SLOT( delUnused() ) ); |
224 | Franz | 159 | QToolTip::add( DelU, tr( "Remove unused colors from current document" ) ); |
160 | } |
||
161 | QToolTip::add( LoadF, tr( "Append colors to the current set from an existing document" ) ); |
||
162 | QToolTip::add( NewF, tr( "Create a new color within the current set" ) ); |
||
163 | QToolTip::add( EditF, tr( "Edit the currently selected color" ) ); |
||
164 | QToolTip::add( DupF, tr( "Make a copy of the currently selected color" ) ); |
||
165 | QToolTip::add( DelF, tr( "Delete the currently selected color" ) ); |
||
166 | QToolTip::add( SaveF, tr( "Make the current colorset the default color set" ) ); |
||
188 | Franz | 167 | connect( SaveF, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
168 | connect( CancF, SIGNAL( clicked() ), this, SLOT( reject() ) ); |
||
169 | connect( NewF, SIGNAL( clicked() ), this, SLOT( neueFarbe() ) ); |
||
170 | connect( EditF, SIGNAL( clicked() ), this, SLOT( editFarbe() ) ); |
||
171 | connect( DupF, SIGNAL( clicked() ), this, SLOT( duplFarbe() ) ); |
||
172 | connect( DelF, SIGNAL( clicked() ), this, SLOT( delFarbe() ) ); |
||
173 | connect( LoadF, SIGNAL( clicked() ), this, SLOT( loadFarben() ) ); |
||
174 | connect( ListBox1, SIGNAL( highlighted(QListBoxItem*) ), this, SLOT( selFarbe(QListBoxItem*) ) ); |
||
3 | paul | 175 | } |
176 | |||
151 | Franz | 177 | void Farbmanager::saveDefaults() |
147 | Franz | 178 | { |
161 | Franz | 179 | QString Cpfad = QString(getenv("HOME"))+"/.scribus/"; |
151 | Franz | 180 | QString Name = LoadColSet->text(); |
174 | Franz | 181 | Query* dia = new Query(this, "Name", 1, 0, tr("Name:"), tr("Choose a Name")); |
187 | Franz | 182 | if ((Name == "Scribus Small") || (Name == "X11 RGB-Set") |
215 | Franz | 183 | || (Name == "X11 Grey-Set") || (Name == "Gnome-Set") || (Name == "SVG-Set")) |
151 | Franz | 184 | dia->Answer->setText(""); |
185 | else |
||
186 | dia->Answer->setText(Name); |
||
187 | if (dia->exec()) |
||
161 | Franz | 188 | { |
189 | QString Fname = Cpfad+dia->Answer->text(); |
||
151 | Franz | 190 | LoadColSet->setText(dia->Answer->text()); |
191 | QFile fx(Fname); |
||
192 | if (fx.open(IO_WriteOnly)) |
||
161 | Franz | 193 | { |
151 | Franz | 194 | QTextStream tsx(&fx); |
195 | QString tmp; |
||
196 | CListe::Iterator itc; |
||
197 | int cp, mp, yp, kp; |
||
198 | for (itc = EditColors.begin(); itc != EditColors.end(); ++itc) |
||
161 | Franz | 199 | { |
151 | Franz | 200 | EditColors[itc.key()].getCMYK(&cp, &mp, &yp, &kp); |
201 | tsx << tmp.setNum(cp) << "\t" ; |
||
202 | tsx << tmp.setNum(mp) << "\t" ; |
||
203 | tsx << tmp.setNum(yp) << "\t" ; |
||
204 | tsx << tmp.setNum(kp) << "\t" ; |
||
205 | tsx << itc.key() << "\n" ; |
||
161 | Franz | 206 | } |
151 | Franz | 207 | fx.close(); |
208 | if (dia->Answer->text() != Name) |
||
161 | Franz | 209 | { |
151 | Franz | 210 | CColSet.append(dia->Answer->text()); |
211 | CSets->insertItem(dia->Answer->text()); |
||
212 | } |
||
213 | } |
||
161 | Franz | 214 | } |
151 | Franz | 215 | delete dia; |
216 | } |
||
217 | |||
218 | void Farbmanager::loadDefaults(int id) |
||
219 | { |
||
220 | int c = CSets->indexOf(id); |
||
221 | LoadColSet->setText(CSets->text(id)); |
||
161 | Franz | 222 | EditColors.clear(); |
223 | QString Cpfad = QString(getenv("HOME"))+"/.scribus/"+CSets->text(id); |
||
224 | QString pfadC = PREL; |
||
225 | QString pfadC2 = pfadC + "/lib/scribus/rgbscribus.txt"; |
||
151 | Franz | 226 | switch (c) |
161 | Franz | 227 | { |
151 | Franz | 228 | case 0: |
190 | Franz | 229 | LoadColSet->setText("Scribus Small"); |
151 | Franz | 230 | EditColors.insert("White", CMYKColor(0, 0, 0, 0)); |
161 | Franz | 231 | EditColors.insert("Black", CMYKColor(0, 0, 0, 255)); |
151 | Franz | 232 | EditColors.insert("Blue", CMYKColor(255, 255, 0, 0)); |
233 | EditColors.insert("Cyan", CMYKColor(255, 0, 0, 0)); |
||
234 | EditColors.insert("Green", CMYKColor(255, 0, 255, 0)); |
||
235 | EditColors.insert("Red", CMYKColor(0, 255, 255, 0)); |
||
236 | EditColors.insert("Yellow", CMYKColor(0, 0, 255, 0)); |
||
237 | EditColors.insert("Magenta", CMYKColor(0, 255, 0, 0)); |
||
238 | break; |
||
239 | case 1: |
||
187 | Franz | 240 | pfadC2 = pfadC + "/lib/scribus/rgbscribus.txt"; |
151 | Franz | 241 | break; |
187 | Franz | 242 | case 2: |
243 | pfadC2 = pfadC + "/lib/scribus/rgbscribusgreys.txt"; |
||
244 | break; |
||
245 | case 3: |
||
246 | pfadC2 = pfadC + "/lib/scribus/rgbscribusgnome.txt"; |
||
247 | break; |
||
215 | Franz | 248 | case 4: |
249 | pfadC2 = pfadC + "/lib/scribus/rgbsvg.txt"; |
||
250 | break; |
||
151 | Franz | 251 | default: |
187 | Franz | 252 | pfadC2 = Cpfad; |
151 | Franz | 253 | break; |
187 | Franz | 254 | } |
190 | Franz | 255 | if (c != 0) |
187 | Franz | 256 | { |
190 | Franz | 257 | QFile fiC(pfadC2); |
258 | if (fiC.open(IO_ReadOnly)) |
||
187 | Franz | 259 | { |
190 | Franz | 260 | QString ColorEn, Cname; |
261 | int Rval, Gval, Bval; |
||
262 | QTextStream tsC(&fiC); |
||
187 | Franz | 263 | ColorEn = tsC.readLine(); |
190 | Franz | 264 | while (!tsC.atEnd()) |
265 | { |
||
266 | ColorEn = tsC.readLine(); |
||
267 | QTextStream CoE(&ColorEn, IO_ReadOnly); |
||
268 | CoE >> Rval; |
||
269 | CoE >> Gval; |
||
270 | CoE >> Bval; |
||
271 | CoE >> Cname; |
||
272 | CMYKColor tmp; |
||
273 | tmp.setColorRGB(Rval, Gval, Bval); |
||
274 | EditColors.insert(Cname, tmp); |
||
275 | } |
||
276 | fiC.close(); |
||
277 | DontChange.clear(); |
||
187 | Franz | 278 | } |
190 | Franz | 279 | else |
280 | { |
||
281 | LoadColSet->setText("Scribus Small"); |
||
282 | EditColors.insert("White", CMYKColor(0, 0, 0, 0)); |
||
283 | EditColors.insert("Black", CMYKColor(0, 0, 0, 255)); |
||
284 | EditColors.insert("Blue", CMYKColor(255, 255, 0, 0)); |
||
285 | EditColors.insert("Cyan", CMYKColor(255, 0, 0, 0)); |
||
286 | EditColors.insert("Green", CMYKColor(255, 0, 255, 0)); |
||
287 | EditColors.insert("Red", CMYKColor(0, 255, 255, 0)); |
||
288 | EditColors.insert("Yellow", CMYKColor(0, 0, 255, 0)); |
||
289 | EditColors.insert("Magenta", CMYKColor(0, 255, 0, 0)); |
||
290 | } |
||
161 | Franz | 291 | } |
147 | Franz | 292 | updateCList(); |
293 | } |
||
294 | |||
3 | paul | 295 | void Farbmanager::loadFarben() |
296 | { |
||
297 | QString fileName; |
||
298 | #ifdef HAVE_LIBZ |
||
112 | Franz | 299 | CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)")); |
3 | paul | 300 | #else |
61 | paul | 301 | CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)")); |
3 | paul | 302 | #endif |
303 | if (dia.exec() == QDialog::Accepted) |
||
304 | fileName = dia.selectedFile(); |
||
305 | else |
||
306 | return; |
||
161 | Franz | 307 | if (!fileName.isEmpty()) |
3 | paul | 308 | { |
161 | Franz | 309 | ScriXmlDoc *ss = new ScriXmlDoc(); |
310 | if (ss->ReadColors(fileName)) |
||
3 | paul | 311 | { |
161 | Franz | 312 | CListe LColors = ss->Farben; |
3 | paul | 313 | CListe::Iterator it; |
314 | for (it = LColors.begin(); it != LColors.end(); ++it) |
||
161 | Franz | 315 | { |
3 | paul | 316 | if (!EditColors.contains(it.key())) |
161 | Franz | 317 | EditColors.insert(it.key(), it.data()); |
318 | } |
||
3 | paul | 319 | updateCList(); |
320 | } |
||
118 | Franz | 321 | delete ss; |
3 | paul | 322 | } |
323 | } |
||
324 | |||
325 | void Farbmanager::delFarbe() |
||
326 | { |
||
327 | if (DontChange.contains(sFarbe)) |
||
328 | return; |
||
147 | Franz | 329 | DelColor *dia = new DelColor(this, EditColors, sFarbe, HaveDoc); |
3 | paul | 330 | if (dia->exec()) |
161 | Franz | 331 | { |
188 | Franz | 332 | Ersatzliste.insert(sFarbe, dia->EFarbe); |
333 | EditColors.remove(sFarbe); |
||
334 | updateCList(); |
||
335 | } |
||
3 | paul | 336 | delete dia; |
337 | } |
||
338 | |||
188 | Franz | 339 | void Farbmanager::delUnused() |
340 | { |
||
341 | PageItem* ite; |
||
342 | bool found; |
||
343 | UsedC.clear(); |
||
344 | CListe::Iterator it; |
||
345 | for (it = EditColors.begin(); it != EditColors.end(); ++it) |
||
346 | { |
||
347 | found = false; |
||
348 | if (DontChange.contains(it.key())) |
||
349 | { |
||
350 | UsedC.insert(it.key(), it.data()); |
||
351 | continue; |
||
352 | } |
||
224 | Franz | 353 | if ((it.key() == ScApp->doc->Dbrush) || (it.key() == ScApp->doc->Dpen) || |
354 | (it.key() == ScApp->doc->DbrushPict) |
||
190 | Franz | 355 | || (it.key() == ScApp->doc->DpenLine) || (it.key() == ScApp->doc->DpenText)) |
356 | { |
||
357 | UsedC.insert(it.key(), it.data()); |
||
358 | continue; |
||
359 | } |
||
188 | Franz | 360 | for (uint b = 0; b < ScApp->view->MasterPages.count(); ++b) |
361 | { |
||
362 | for (uint c = 0; c < ScApp->view->MasterPages.at(b)->Items.count(); ++c) |
||
363 | { |
||
364 | ite = ScApp->view->MasterPages.at(b)->Items.at(c); |
||
365 | if ((ite->PType == 4) || (ite->PType == 8)) |
||
366 | { |
||
367 | for (uint d=0; d<ite->Ptext.count(); ++d) |
||
368 | { |
||
369 | if (it.key() == ite->Ptext.at(d)->ccolor) |
||
370 | found = true; |
||
371 | if (it.key() == ite->Ptext.at(d)->cstroke) |
||
372 | found = true; |
||
373 | if (found) |
||
374 | break; |
||
375 | } |
||
376 | } |
||
224 | Franz | 377 | /* PFJ - 29.02.04 - merged if's to one line */ |
378 | if ((it.key() == ite->Pcolor) || (it.key() == ite->Pcolor2) || |
||
379 | (it.key() == ite->GrColor) || (it.key() == ite->GrColor2)) |
||
188 | Franz | 380 | found = true; |
381 | if (found) |
||
382 | break; |
||
383 | } |
||
384 | if (found) |
||
385 | break; |
||
386 | } |
||
387 | if (found) |
||
388 | { |
||
389 | UsedC.insert(it.key(), it.data()); |
||
390 | continue; |
||
391 | } |
||
392 | for (uint b = 0; b < ScApp->view->DocPages.count(); ++b) |
||
393 | { |
||
394 | for (uint c = 0; c < ScApp->view->DocPages.at(b)->Items.count(); ++c) |
||
395 | { |
||
396 | ite = ScApp->view->DocPages.at(b)->Items.at(c); |
||
397 | if ((ite->PType == 4) || (ite->PType == 8)) |
||
398 | { |
||
399 | for (uint d=0; d<ite->Ptext.count(); ++d) |
||
400 | { |
||
224 | Franz | 401 | /* PFJ - 29.02.04 - Merged if's */ |
402 | if ((it.key() == ite->Ptext.at(d)->ccolor) || |
||
403 | (it.key() == ite->Ptext.at(d)->cstroke)) |
||
188 | Franz | 404 | found = true; |
405 | if (found) |
||
406 | break; |
||
407 | } |
||
408 | } |
||
224 | Franz | 409 | /* PFJ - 29.02.04 - Merged if's */ |
410 | if ((it.key() == ite->Pcolor) || (it.key() == ite->Pcolor2) || |
||
411 | (it.key() == ite->GrColor) || (it.key() == ite->GrColor2)) |
||
188 | Franz | 412 | found = true; |
413 | if (found) |
||
414 | break; |
||
415 | } |
||
416 | if (found) |
||
417 | break; |
||
418 | } |
||
224 | Franz | 419 | /* PFJ - 29.02.04 - Merged if's */ |
420 | if ((it.key() == ScApp->doc->CurrTextFill) || |
||
421 | (it.key() == ScApp->doc->CurrTextStroke)) |
||
188 | Franz | 422 | found = true; |
423 | if (found) |
||
424 | { |
||
425 | UsedC.insert(it.key(), it.data()); |
||
426 | continue; |
||
427 | } |
||
428 | } |
||
429 | EditColors = UsedC; |
||
190 | Franz | 430 | if (EditColors.count() == 0) |
224 | Franz | 431 | { |
190 | Franz | 432 | EditColors.insert("White", CMYKColor(0, 0, 0, 0)); |
433 | EditColors.insert("Black", CMYKColor(0, 0, 0, 255)); |
||
224 | Franz | 434 | } |
188 | Franz | 435 | updateCList(); |
436 | } |
||
437 | |||
3 | paul | 438 | void Farbmanager::duplFarbe() |
439 | { |
||
440 | QString nam; |
||
174 | Franz | 441 | Query *dia = new Query(this, "tt", 1, 0, tr("New Color:"), tr("New Color")); |
115 | Franz | 442 | dia->Answer->setText( tr("Copy of %1").arg(sFarbe)); |
3 | paul | 443 | if (dia->exec()) |
161 | Franz | 444 | { |
3 | paul | 445 | nam = dia->Answer->text(); |
446 | while (EditColors.contains(nam)) |
||
161 | Franz | 447 | { |
3 | paul | 448 | if (!dia->exec()) |
161 | Franz | 449 | { |
3 | paul | 450 | delete dia; |
451 | return; |
||
161 | Franz | 452 | } |
3 | paul | 453 | nam = dia->Answer->text(); |
161 | Franz | 454 | } |
3 | paul | 455 | EditColors.insert(nam, EditColors[sFarbe]); |
161 | Franz | 456 | updateCList(); |
457 | } |
||
3 | paul | 458 | delete dia; |
459 | } |
||
460 | |||
461 | void Farbmanager::neueFarbe() |
||
462 | { |
||
463 | QString nam; |
||
174 | Franz | 464 | Query *dia = new Query(this, "tt", 1, 0, tr("New Color:"), tr("New Color")); |
3 | paul | 465 | dia->Answer->setText(sFarbe); |
466 | if (dia->exec()) |
||
161 | Franz | 467 | { |
3 | paul | 468 | nam = dia->Answer->text(); |
469 | while (EditColors.contains(nam) || (nam == "None")) |
||
161 | Franz | 470 | { |
471 | if (!dia->exec()) |
||
3 | paul | 472 | { |
473 | delete dia; |
||
474 | return; |
||
161 | Franz | 475 | } |
3 | paul | 476 | nam = dia->Answer->text(); |
161 | Franz | 477 | } |
478 | CMYKColor tmpFarbe = CMYKColor(0, 0, 0, 0); |
||
479 | CMYKChoose* dia2 = new CMYKChoose(this, tmpFarbe, nam); |
||
480 | if (!dia2->exec()) |
||
481 | { |
||
3 | paul | 482 | delete dia; |
483 | delete dia2; |
||
484 | return; |
||
161 | Franz | 485 | } |
486 | tmpFarbe = dia2->Farbe; |
||
487 | delete dia2; |
||
3 | paul | 488 | EditColors.insert(nam, tmpFarbe); |
161 | Franz | 489 | updateCList(); |
490 | } |
||
3 | paul | 491 | delete dia; |
492 | } |
||
493 | |||
494 | void Farbmanager::editFarbe() |
||
495 | { |
||
496 | if (DontChange.contains(sFarbe)) |
||
497 | return; |
||
498 | CMYKColor tmpFarbe = CMYKColor(); |
||
499 | CMYKChoose* dia = new CMYKChoose(this, EditColors[sFarbe], sFarbe); |
||
500 | if (!dia->exec()) |
||
161 | Franz | 501 | { |
502 | delete dia; |
||
503 | return; |
||
3 | paul | 504 | } |
505 | tmpFarbe = dia->Farbe; |
||
506 | delete dia; |
||
507 | EditColors[sFarbe] = tmpFarbe; |
||
148 | Franz | 508 | Ersatzliste.insert(sFarbe, sFarbe); |
3 | paul | 509 | updateCList(); |
510 | } |
||
511 | |||
512 | void Farbmanager::selFarbe(QListBoxItem *c) |
||
513 | { |
||
514 | sFarbe = c->text(); |
||
515 | EditF->setEnabled(true); |
||
516 | DupF->setEnabled(true); |
||
161 | Franz | 517 | DelF->setEnabled(EditColors.count() == 1 ? false : true); |
3 | paul | 518 | if (DontChange.contains(sFarbe)) |
161 | Franz | 519 | { |
520 | EditF->setEnabled(false); |
||
521 | DelF->setEnabled(false); |
||
522 | } |
||
3 | paul | 523 | } |
524 | |||
525 | void Farbmanager::updateCList() |
||
526 | { |
||
527 | ListBox1->clear(); |
||
528 | CListe::Iterator it; |
||
529 | QPixmap pm = QPixmap(30, 15); |
||
530 | for (it = EditColors.begin(); it != EditColors.end(); ++it) |
||
161 | Franz | 531 | { |
3 | paul | 532 | pm.fill(EditColors[it.key()].getRGBColor()); |
533 | ListBox1->insertItem(pm, it.key()); |
||
161 | Franz | 534 | } |
80 | Franz | 535 | DelF->setEnabled(EditColors.count() == 1 ? false : true); |
3 | paul | 536 | if (ListBox1->currentItem() == -1) |
537 | { |
||
161 | Franz | 538 | DupF->setEnabled(false); |
539 | EditF->setEnabled(false); |
||
540 | DelF->setEnabled(false); |
||
3 | paul | 541 | } |
542 | ListBox1->setSelected(ListBox1->currentItem(), false); |
||
543 | } |
||
544 |