Subversion Repositories Scribus

Rev

Rev 7857 | 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
*/
6438 subik 7
 
1809 subik 8
#include "cwdialog.h"
9
#include "cwdialog.moc"
10
 
11
#include <qvariant.h>
12
#include <qcombobox.h>
13
#include <qheader.h>
14
#include <qlistview.h>
4311 subik 15
#include <qlistbox.h>
1809 subik 16
#include <qlayout.h>
17
#include <qtooltip.h>
18
#include <qwhatsthis.h>
19
#include <qpushbutton.h>
20
#include <qspinbox.h>
21
#include <qpainter.h>
3331 subik 22
#include <qmenubar.h>
3709 subik 23
#include <qgroupbox.h>
24
#include <qslider.h>
6438 subik 25
#include <qtabwidget.h>
7116 subik 26
#include <qtable.h>
1809 subik 27
 
2856 cbradney 28
#include "prefsmanager.h"
3331 subik 29
#include "commonstrings.h"
30
#include "cmykfw.h"
2856 cbradney 31
#include "prefsfile.h"
32
#include "mpalette.h"
3107 subik 33
#include "colorblind.h"
6125 cbradney 34
#include "colorutil.h"
7747 jghali 35
#include "colorlistbox.h"
7478 jghali 36
#include "sccolorengine.h"
1809 subik 37
 
6438 subik 38
CWDialog::CWDialog(QWidget* parent, ScribusDoc* doc, const char* name, bool modal, WFlags fl)
39
        : CWDialogBase (parent, name, modal, fl),
40
          m_Doc(doc)
3331 subik 41
{
7895 jghali 42
        int h, s, v;
43
        ScColor color;
44
        QString colorName;
6438 subik 45
        connectSlots(false);
1809 subik 46
        // setup combobox
47
        typeCombo->insertItem(colorWheel->getTypeDescription(colorWheel->Monochromatic), colorWheel->Monochromatic);
48
        typeCombo->insertItem(colorWheel->getTypeDescription(colorWheel->Analogous), colorWheel->Analogous);
49
        typeCombo->insertItem(colorWheel->getTypeDescription(colorWheel->Complementary), colorWheel->Complementary);
50
        typeCombo->insertItem(colorWheel->getTypeDescription(colorWheel->Split), colorWheel->Split);
51
        typeCombo->insertItem(colorWheel->getTypeDescription(colorWheel->Triadic), colorWheel->Triadic);
52
        typeCombo->insertItem(colorWheel->getTypeDescription(colorWheel->Tetradic), colorWheel->Tetradic);
2911 subik 53
        // defects
7167 cbradney 54
        defectCombo->insertItem(CommonStrings::trVisionNormal);
55
        defectCombo->insertItem(CommonStrings::trVisionProtanopia);
56
        defectCombo->insertItem(CommonStrings::trVisionDeuteranopia);
57
        defectCombo->insertItem(CommonStrings::trVisionTritanopia);
58
        defectCombo->insertItem(CommonStrings::trVisionFullColorBlind);
7895 jghali 59
        // document colors
60
        documentColorList->updateBox(m_Doc->PageColors, ColorListBox::fancyPixmap);
1809 subik 61
        // preferences
2856 cbradney 62
        prefs = PrefsManager::instance()->prefsFile->getPluginContext("colorwheel");
1809 subik 63
        typeCombo->setCurrentItem(prefs->getInt("cw_type", 0));
64
        angleSpin->setValue(prefs->getInt("cw_angle", 15));
7478 jghali 65
        colorWheel->currentDoc = m_Doc;
1809 subik 66
        colorWheel->angle = angleSpin->value();
3331 subik 67
        colorWheel->baseAngle = prefs->getInt("cw_baseangle", 0);
6438 subik 68
        colorspaceTab->setCurrentPage(prefs->getInt("cw_space", 0));
7895 jghali 69
        color.setNamedColor(prefs->get("cw_color", "#00000000"));
70
        // Handle color previously selected in the document tab
71
        if (colorspaceTab->currentPage() == tabDocument)
72
        {
73
                colorName = prefs->get("cw_colorname", "");
74
                if (!colorName.isEmpty() && m_Doc->PageColors.contains(colorName))
75
                        color = m_Doc->PageColors[colorName];
76
                else
77
                        color.setColorRGB(0, 0, 0); //Trigger use of defaults
78
        }
79
        // Handle achromatic colors
80
        QColor rgb = ScColorEngine::getRGBColor(color, m_Doc);
81
        rgb.getHsv(&h, &s, &v);
82
        if (h == -1)
83
        {   // Reset to defaults
84
                colorWheel->baseAngle = 0;
85
                colorWheel->currentColorSpace = colorModelCMYK;
86
                colorWheel->actualColor = colorWheel->colorByAngle(0);
87
                colorspaceTab->setCurrentPage(0);
88
        }
89
        else if (colorspaceTab->currentPage() == tabDocument)
90
        {
91
                colorWheel->actualColor = color;
92
                documentColorList->setCurrentItem(documentColorList->findItem(colorName));
93
        }
94
        else
95
                colorWheel->actualColor = color;
96
 
6438 subik 97
        resize(QSize(prefs->getInt("cw_width", 640),
98
                   prefs->getInt("cw_height", 480)).expandedTo(minimumSizeHint()));
99
        previewLabel->resize(prefs->getInt("cw_samplex", 300), prefs->getInt("cw_sampley", 100));
7895 jghali 100
 
6438 subik 101
        // setup
102
        colorspaceTab_currentChanged(colorspaceTab->currentPage());
7116 subik 103
        currentColorTable->horizontalHeader()->hide();
104
        currentColorTable->setTopMargin(0);
105
        currentColorTable->setNumCols(5);
1809 subik 106
 
6438 subik 107
        // signals and slots that cannot be in ui file
108
        connect(colorWheel, SIGNAL(clicked(int, const QPoint&)),
109
                        this, SLOT(colorWheel_clicked(int, const QPoint&)));
110
        connect(documentColorList, SIGNAL(currentChanged(QListBoxItem *)),
111
                        this, SLOT(documentColorList_currentChanged(QListBoxItem *)));
7116 subik 112
        connect(colorList, SIGNAL(currentChanged(QListBoxItem *)),
113
                        this, SLOT(colorList_currentChanged(QListBoxItem *)));
6438 subik 114
        connectSlots(true);
1809 subik 115
}
116
 
6438 subik 117
CWDialog::~CWDialog()
1809 subik 118
{
119
        // preferences
7895 jghali 120
        QString colorName = (colorspaceTab->currentPage() == tabDocument) ? documentColorList->currentText() : "";
1809 subik 121
        prefs->set("cw_type", typeCombo->currentItem());
122
        prefs->set("cw_angle", angleSpin->value());
3331 subik 123
        prefs->set("cw_baseangle", colorWheel->baseAngle);
7895 jghali 124
        prefs->set("cw_color", colorWheel->actualColor.name());
125
        prefs->set("cw_colorname", colorName);
6438 subik 126
        prefs->set("cw_space", colorspaceTab->currentPageIndex());
127
        // GUI settings
128
        prefs->set("cw_width", width());
129
        prefs->set("cw_height", height());
130
        prefs->set("cw_samplex", previewLabel->width());
131
        prefs->set("cw_sampley", previewLabel->height());
1809 subik 132
}
133
 
6438 subik 134
void CWDialog::connectSlots(bool conn)
1809 subik 135
{
6438 subik 136
        if (conn)
137
        {
138
                connect( cSpin, SIGNAL( valueChanged(int) ), this, SLOT( cSpin_valueChanged(int) ) );
139
                connect( mSpin, SIGNAL( valueChanged(int) ), this, SLOT( mSpin_valueChanged(int) ) );
140
                connect( ySpin, SIGNAL( valueChanged(int) ), this, SLOT( ySpin_valueChanged(int) ) );
141
                connect( kSpin, SIGNAL( valueChanged(int) ), this, SLOT( kSpin_valueChanged(int) ) );
142
                connect( rSpin, SIGNAL( valueChanged(int) ), this, SLOT( rSpin_valueChanged(int) ) );
143
                connect( gSpin, SIGNAL( valueChanged(int) ), this, SLOT( gSpin_valueChanged(int) ) );
144
                connect( bSpin, SIGNAL( valueChanged(int) ), this, SLOT( bSpin_valueChanged(int) ) );
7159 subik 145
                connect( hSpin, SIGNAL( valueChanged(int) ), this, SLOT( hSpin_valueChanged(int) ) );
146
                connect( sSpin, SIGNAL( valueChanged(int) ), this, SLOT( sSpin_valueChanged(int) ) );
147
                connect( vSpin, SIGNAL( valueChanged(int) ), this, SLOT( vSpin_valueChanged(int) ) );
6438 subik 148
        }
149
        else
150
        {
151
                disconnect( cSpin, SIGNAL( valueChanged(int) ), this, SLOT( cSpin_valueChanged(int) ) );
152
                disconnect( mSpin, SIGNAL( valueChanged(int) ), this, SLOT( mSpin_valueChanged(int) ) );
153
                disconnect( ySpin, SIGNAL( valueChanged(int) ), this, SLOT( ySpin_valueChanged(int) ) );
154
                disconnect( kSpin, SIGNAL( valueChanged(int) ), this, SLOT( kSpin_valueChanged(int) ) );
155
                disconnect( rSpin, SIGNAL( valueChanged(int) ), this, SLOT( rSpin_valueChanged(int) ) );
156
                disconnect( gSpin, SIGNAL( valueChanged(int) ), this, SLOT( gSpin_valueChanged(int) ) );
157
                disconnect( bSpin, SIGNAL( valueChanged(int) ), this, SLOT( bSpin_valueChanged(int) ) );
7159 subik 158
                disconnect( hSpin, SIGNAL( valueChanged(int) ), this, SLOT( hSpin_valueChanged(int) ) );
159
                disconnect( sSpin, SIGNAL( valueChanged(int) ), this, SLOT( sSpin_valueChanged(int) ) );
160
                disconnect( vSpin, SIGNAL( valueChanged(int) ), this, SLOT( vSpin_valueChanged(int) ) );
6438 subik 161
        }
1809 subik 162
}
163
 
6438 subik 164
void CWDialog::documentColorList_currentChanged(QListBoxItem *item)
1809 subik 165
{
6438 subik 166
        if (!item)
167
                return;
7116 subik 168
        ScColor c(m_Doc->PageColors[documentColorList->currentText()]);
6438 subik 169
        colorWheel->currentColorSpace = c.getColorModel();
170
        setupColorComponents();
171
}
172
 
173
void CWDialog::colorspaceTab_currentChanged( QWidget * tab)
174
{
175
        if (tab == tabCMYK)
176
                colorWheel->currentColorSpace = colorModelCMYK;
177
        if (tab == tabRGB)
178
                colorWheel->currentColorSpace = colorModelRGB;
179
        if (tab == tabDocument)
1809 subik 180
        {
6438 subik 181
                if (documentColorList->currentItem() == -1)
182
                        documentColorList->setSelected(0, true);
183
                documentColorList_currentChanged(documentColorList->item(documentColorList->currentItem()));
1809 subik 184
        }
6438 subik 185
        processColors(typeCombo->currentItem(), true);
1809 subik 186
}
187
 
6438 subik 188
void CWDialog::typeCombo_activated(int index)
1809 subik 189
{
6438 subik 190
        processColors(index, false);
191
}
192
 
193
void CWDialog::processColors(int index, bool updateSpins)
194
{
195
        bool angEnable = false;
7180 subik 196
        //colorList->clear();
1809 subik 197
        if (index == colorWheel->Monochromatic)
6438 subik 198
                colorWheel->currentType = colorWheel->Monochromatic;
1809 subik 199
        if (index == colorWheel->Analogous)
200
        {
6438 subik 201
                angEnable = true;
202
                colorWheel->currentType = colorWheel->Analogous;
1809 subik 203
        }
204
        if (index == colorWheel->Complementary)
6438 subik 205
                colorWheel->currentType = colorWheel->Complementary;
1809 subik 206
        if (index == colorWheel->Split)
207
        {
6438 subik 208
                angEnable = true;
209
                colorWheel->currentType = colorWheel->Split;
1809 subik 210
        }
211
        if (index == colorWheel->Triadic)
6438 subik 212
                colorWheel->currentType = colorWheel->Triadic;
1809 subik 213
        if (index == colorWheel->Tetradic)
214
        {
6438 subik 215
                angEnable = true;
216
                colorWheel->currentType = colorWheel->Tetradic;
1809 subik 217
        }
6438 subik 218
        angleSpin->setEnabled(angEnable);
219
        angleLabel->setEnabled(angEnable);
220
        colorWheel->makeColors();
1809 subik 221
        fillColorList();
222
        setPreview();
6438 subik 223
        if (updateSpins)
7159 subik 224
        {
225
//              setupFromColor(colorWheel->actualColor);
226
                setupRGBComponent(colorWheel->actualColor);
227
                setupCMYKComponent(colorWheel->actualColor);
228
                setupHSVComponent(colorWheel->actualColor);
229
        }
230
        updateNamedLabels();
1809 subik 231
}
232
 
6438 subik 233
void CWDialog::colorWheel_clicked(int, const QPoint&)
1809 subik 234
{
6438 subik 235
        processColors(typeCombo->currentItem(), true);
1809 subik 236
}
237
 
6438 subik 238
void CWDialog::angleSpin_valueChanged(int value)
1809 subik 239
{
240
        colorWheel->angle = value;
6438 subik 241
        processColors(typeCombo->currentItem(), false);
1809 subik 242
}
243
 
6438 subik 244
void CWDialog::setPreview()
1809 subik 245
{
6438 subik 246
        int x = previewLabel->width();
247
        int y = previewLabel->height();
248
        QValueList<ScColor> cols = colorWheel->colorList.values();
249
        int xstep = x / cols.count();
250
        QPixmap pm = QPixmap(x, y);
251
        QPainter *p = new QPainter(&pm);
252
        QFontMetrics fm = p->fontMetrics();
253
 
254
        pm.fill(Qt::white);
255
        p->setPen(Qt::white);
256
        p->drawRect(0, 0, x, y);
7185 subik 257
        QColor c;
6438 subik 258
        for (uint i = 0; i < cols.count(); ++i)
259
        {
7185 subik 260
                //c = computeDefect(cols[i].getRGBColor());
7478 jghali 261
                c = computeDefect( ScColorEngine::getDisplayColor(cols[i], m_Doc) );
6438 subik 262
                p->setPen(c);
263
                p->setBrush(c);
264
                p->drawRect(i * xstep, 0, xstep, y);
265
        }
266
        p->setPen(Qt::black);
267
        p->setBrush(Qt::black);
268
        p->drawText(15, 5 + fm.height(), "Lorem ipsum dolor sit amet");
269
        p->setPen(Qt::white);
270
        p->setBrush(Qt::white);
7185 subik 271
        p->drawText(90, y - 5 - fm.height(), "Lorem ipsum dolor sit amet");
6438 subik 272
        p->end();
273
        delete(p);
274
        previewLabel->clear();
275
        previewLabel->setPixmap(pm);
276
}
277
 
278
QColor CWDialog::computeDefect(QColor c)
279
{
280
        if (defectCombo->currentItem() == VisionDefectColor::normalVision)
281
                return c;
282
        VisionDefectColor *defect = new VisionDefectColor(c);
283
        defect->deficiency = defectCombo->currentItem();
284
        defect->convertDefect();
285
        QColor nc = defect->getColor();
286
        delete defect;
287
        return nc;
288
}
289
 
290
void CWDialog::fillColorList()
291
{
7185 subik 292
        uint ix = colorList->currentItem();
6438 subik 293
        colorList->updateBox(colorWheel->colorList, ColorListBox::fancyPixmap);
7180 subik 294
        QListBoxItem *item = colorList->findItem(colorWheel->trBaseColor);
295
        if (item->prev())
296
        {
297
                colorList->takeItem(item);
298
                colorList->insertItem(item, 0);
299
        }
300
        colorList->setCurrentItem(ix > colorList->count() ? 0 : ix);
6438 subik 301
}
302
 
303
void CWDialog::defectCombo_activated(int)
304
{
305
        setPreview();
306
}
307
 
308
void CWDialog::addButton_clicked()
309
{
1809 subik 310
        QString status("<qt><h2>" + tr("Merging colors") + "</h2><p>");
1811 subik 311
        bool err = false;
1809 subik 312
        for (ColorList::iterator it = colorWheel->colorList.begin(); it != colorWheel->colorList.end(); ++it)
313
        {
5781 cbradney 314
                if (m_Doc->PageColors.contains(it.key()))
1811 subik 315
                {
3372 cbradney 316
                        status += "<b>" + tr("Error: ") + "</b>" + tr("Color %1 exists already!").arg(it.key()) + "<br/>";
1811 subik 317
                        err = true;
318
                }
1809 subik 319
                else
320
                {
3372 cbradney 321
                        status += tr("Color %1 appended.").arg(it.key()) + "<br/>";
5781 cbradney 322
                        m_Doc->PageColors[it.key()] = it.data();
1809 subik 323
                }
324
        }
1811 subik 325
        status += "<p>" + tr("Now opening the color manager.") + "</p></qt>";
326
        if (err)
327
        {
328
                QMessageBox::information(this, tr("Color Merging"), status);
5781 cbradney 329
                m_Doc->scMW()->slotEditColors();
1811 subik 330
                return;
331
        }
5781 cbradney 332
        m_Doc->scMW()->propertiesPalette->updateColorList();
1809 subik 333
        accept();
334
}
335
 
6438 subik 336
void CWDialog::replaceButton_clicked()
1811 subik 337
{
338
        for (ColorList::iterator it = colorWheel->colorList.begin(); it != colorWheel->colorList.end(); ++it)
339
        {
5781 cbradney 340
                m_Doc->PageColors[it.key()] = it.data();
1811 subik 341
        }
5781 cbradney 342
        m_Doc->scMW()->propertiesPalette->updateColorList();
1811 subik 343
        accept();
344
}
1809 subik 345
 
6438 subik 346
void CWDialog::cancelButton_clicked()
1809 subik 347
{
348
        reject();
349
}
350
 
6438 subik 351
void CWDialog::cSpin_valueChanged( int )
2911 subik 352
{
6438 subik 353
        setupColorComponents();
2911 subik 354
}
355
 
6438 subik 356
void CWDialog::mSpin_valueChanged( int )
1809 subik 357
{
6438 subik 358
        setupColorComponents();
359
}
1809 subik 360
 
6438 subik 361
void CWDialog::ySpin_valueChanged( int )
362
{
363
        setupColorComponents();
1809 subik 364
}
2911 subik 365
 
6438 subik 366
void CWDialog::kSpin_valueChanged( int )
2911 subik 367
{
6438 subik 368
        setupColorComponents();
2911 subik 369
}
370
 
6438 subik 371
void CWDialog::rSpin_valueChanged( int )
3331 subik 372
{
6438 subik 373
        setupColorComponents();
374
}
3710 subik 375
 
6438 subik 376
void CWDialog::gSpin_valueChanged( int )
377
{
378
        setupColorComponents();
3331 subik 379
}
380
 
6438 subik 381
void CWDialog::bSpin_valueChanged( int )
3709 subik 382
{
6438 subik 383
        setupColorComponents();
3709 subik 384
}
385
 
7159 subik 386
void CWDialog::hSpin_valueChanged( int )
3331 subik 387
{
7159 subik 388
        setupColorComponents();
389
}
390
 
391
void CWDialog::sSpin_valueChanged( int )
392
{
393
        setupColorComponents();
394
}
395
 
396
void CWDialog::vSpin_valueChanged( int )
397
{
398
        setupColorComponents();
399
}
400
 
401
void CWDialog::setupRGBComponent(ScColor col)
402
{
7485 jghali 403
        RGBColor rgb;
404
        ScColorEngine::getRGBValues(col, m_Doc, rgb);
6438 subik 405
        connectSlots(false);
7485 jghali 406
        rSpin->setValue(rgb.r);
407
        gSpin->setValue(rgb.g);
408
        bSpin->setValue(rgb.b);
6438 subik 409
        connectSlots(true);
3331 subik 410
}
3353 subik 411
 
7159 subik 412
void CWDialog::setupCMYKComponent(ScColor col)
3353 subik 413
{
7485 jghali 414
        CMYKColor cmyk;
415
        ScColorEngine::getCMYKValues(col, m_Doc, cmyk);
6438 subik 416
        connectSlots(false);
7493 subik 417
        cSpin->setValue(qRound(cmyk.c / 2.55));
418
        mSpin->setValue(qRound(cmyk.m / 2.55));
419
        ySpin->setValue(qRound(cmyk.y / 2.55));
420
        kSpin->setValue(qRound(cmyk.k / 2.55));
6438 subik 421
        connectSlots(true);
422
}
423
 
7159 subik 424
void CWDialog::setupHSVComponent(ScColor col)
6438 subik 425
{
7159 subik 426
        int h, s, v;
7478 jghali 427
        QColor qc(ScColorEngine::getRGBColor(col, m_Doc));
7159 subik 428
        qc.getHsv(&h, &s, &v);
6438 subik 429
        connectSlots(false);
7159 subik 430
        hSpin->setValue(h);
431
        sSpin->setValue(s);
432
        vSpin->setValue(v);
6438 subik 433
        connectSlots(true);
434
}
435
 
436
void CWDialog::setupColorComponents()
437
{
438
        ScColor c;
439
        if (colorspaceTab->currentPage() == tabCMYK)
7159 subik 440
        {
7493 subik 441
                c = ScColor(qRound(cSpin->value() * 2.55), qRound(mSpin->value() * 2.55),
442
                                        qRound(ySpin->value() * 2.55), qRound(kSpin->value() * 2.55));
7484 jghali 443
                c = ScColorEngine::convertToModel(c, m_Doc, colorModelCMYK);
7159 subik 444
                setupRGBComponent(c);
445
                setupHSVComponent(c);
446
        }
6438 subik 447
        if (colorspaceTab->currentPage() == tabRGB)
7159 subik 448
        {
449
                c = ScColor(rSpin->value(), gSpin->value(), bSpin->value());
7484 jghali 450
                c = ScColorEngine::convertToModel(c, m_Doc, colorModelRGB);
7159 subik 451
                setupCMYKComponent(c);
452
                setupHSVComponent(c);
453
        }
454
        if (colorspaceTab->currentPage() == tabHSV)
455
        {
456
                QColor qc;
457
                qc.setHsv(hSpin->value(), sSpin->value(), vSpin->value());
458
                c.fromQColor(qc);
7484 jghali 459
                c = ScColorEngine::convertToModel(c, m_Doc, colorModelRGB);
7159 subik 460
                setupCMYKComponent(c);
461
                setupRGBComponent(c);
462
        }
6438 subik 463
        if (colorspaceTab->currentPage() == tabDocument)
7159 subik 464
        {
465
                c = m_Doc->PageColors[documentColorList->currentText()];
466
                setupRGBComponent(c);
467
                setupCMYKComponent(c);
468
                setupHSVComponent(c);
469
        }
6438 subik 470
 
3353 subik 471
        if (colorWheel->recomputeColor(c))
6438 subik 472
                processColors(typeCombo->currentItem(), false);
3353 subik 473
        else
6438 subik 474
        {
475
                colorList->clear();
3353 subik 476
                QMessageBox::information(this, caption(),
6438 subik 477
                                                                 "<qt>" + tr("Unable to find the requested color. "
478
                                                                                 "You have probably selected black, gray or white. "
479
                                                                                 "There is no way to process this color.") + "</qt>");
480
        }
7159 subik 481
        updateNamedLabels();
482
}
483
 
484
void CWDialog::updateNamedLabels()
485
{
7857 jghali 486
        cmykLabel->setText(colorWheel->actualColor.nameCMYK(m_Doc));
487
        cmykLabel2->setText(colorWheel->actualColor.nameCMYK(m_Doc));
488
        rgbLabel->setText(colorWheel->actualColor.nameRGB(m_Doc));
489
        rgbLabel2->setText(colorWheel->actualColor.nameRGB(m_Doc));
7116 subik 490
        hsvLabel->setText(getHexHsv(colorWheel->actualColor));
491
        hsvLabel2->setText(getHexHsv(colorWheel->actualColor));
3353 subik 492
}
7116 subik 493
 
494
void CWDialog::colorList_currentChanged(QListBoxItem * item)
495
{
496
        if (!item)
497
                return;
7185 subik 498
 
499
        // if it's base color we do not need to recompute it again
500
        if (item->text() == colorWheel->trBaseColor)
501
        {
502
                currentColorTable->setText(0, 4, cmykLabel->text());
503
                currentColorTable->setText(1, 4, rgbLabel->text());
504
                currentColorTable->setText(2, 4, hsvLabel->text());
505
                currentColorTable->setText(0, 0, cSpin->text());
506
                currentColorTable->setText(0, 1, mSpin->text());
507
                currentColorTable->setText(0, 2, ySpin->text());
508
                currentColorTable->setText(0, 3, kSpin->text());
509
                currentColorTable->setText(1, 0, rSpin->text());
510
                currentColorTable->setText(1, 1, gSpin->text());
511
                currentColorTable->setText(1, 2, bSpin->text());
512
                currentColorTable->setText(2, 0, hSpin->text());
513
                currentColorTable->setText(2, 1, sSpin->text());
514
                currentColorTable->setText(2, 2, vSpin->text());
515
 
516
        }
517
        else
518
        {
519
                ScColor col(colorWheel->colorList[item->text()]);
7857 jghali 520
                currentColorTable->setText(0, 4, col.nameCMYK(m_Doc));
521
                currentColorTable->setText(1, 4, col.nameRGB(m_Doc));
7185 subik 522
                currentColorTable->setText(2, 4, getHexHsv(col));
523
                // components
524
                QString num;
7485 jghali 525
                CMYKColor cmyk;
526
                ScColorEngine::getCMYKValues(col, m_Doc, cmyk);
527
                currentColorTable->setText(0, 0, num.setNum(cmyk.c));
528
                currentColorTable->setText(0, 1, num.setNum(cmyk.m));
529
                currentColorTable->setText(0, 2, num.setNum(cmyk.y));
530
                currentColorTable->setText(0, 3, num.setNum(cmyk.k));
531
                RGBColor rgb;
532
                ScColorEngine::getRGBValues(col, m_Doc, rgb);
533
                currentColorTable->setText(1, 0, num.setNum(rgb.r));
534
                currentColorTable->setText(1, 1, num.setNum(rgb.g));
535
                currentColorTable->setText(1, 2, num.setNum(rgb.b));
7185 subik 536
                int h, s, v;
7478 jghali 537
                QColor hsvCol(ScColorEngine::getRGBColor(col, m_Doc));
7185 subik 538
                hsvCol.getHsv(&h, &s, &v);
539
                currentColorTable->setText(2, 0, num.setNum(h));
540
                currentColorTable->setText(2, 1, num.setNum(s));
541
                currentColorTable->setText(2, 2, num.setNum(v));
542
        }
7116 subik 543
        currentColorTable->adjustColumn(0);
544
        currentColorTable->adjustColumn(1);
545
        currentColorTable->adjustColumn(2);
546
        currentColorTable->adjustColumn(3);
547
        currentColorTable->adjustColumn(4);
548
}
549
 
550
QString CWDialog::getHexHsv(ScColor c)
551
{
552
        int h, s, v;
7478 jghali 553
        QColor hsvCol(ScColorEngine::getRGBColor(c, m_Doc));
7116 subik 554
        hsvCol.getHsv(&h, &s, &v);
555
        return QString("#%1%2%3").arg(h, 0, 16).arg(s, 0, 16).arg(v, 0, 16);
556
}