Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

cwdialog.cpp

Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 
00008 #include <QHeaderView>
00009 
00010 #include "cmykfw.h"
00011 #include "colorblind.h"
00012 #include "colorlistbox.h"
00013 #include "commonstrings.h"
00014 #include "cwdialog.h"
00015 #include "prefsfile.h"
00016 #include "prefsmanager.h"
00017 #include "propertiespalette.h"
00018 #include "sccolorengine.h"
00019 #include "util_color.h"
00020 
00021 
00022 CWDialog::CWDialog(QWidget* parent, ScribusDoc* doc, const char* name, bool modal, Qt::WFlags fl)
00023     : QDialog (parent, fl),
00024       m_Doc(doc)
00025 {
00026     setupUi(this);
00027     setObjectName(name);
00028     setModal(modal);
00029     int h, s, v;
00030     ScColor color;
00031     QString colorName;
00032     connectSlots(false);
00033     // setup combobox
00034     typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Monochromatic), colorWheel->Monochromatic);
00035     typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Analogous), colorWheel->Analogous);
00036     typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Complementary), colorWheel->Complementary);
00037     typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Split), colorWheel->Split);
00038     typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Triadic), colorWheel->Triadic);
00039     typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Tetradic), colorWheel->Tetradic);
00040     // defects
00041     defectCombo->addItem(CommonStrings::trVisionNormal);
00042     defectCombo->addItem(CommonStrings::trVisionProtanopia);
00043     defectCombo->addItem(CommonStrings::trVisionDeuteranopia);
00044     defectCombo->addItem(CommonStrings::trVisionTritanopia);
00045     defectCombo->addItem(CommonStrings::trVisionFullColorBlind);
00046     // document colors
00047     documentColorList->updateBox(m_Doc->PageColors, ColorListBox::fancyPixmap);
00048     // preferences
00049     prefs = PrefsManager::instance()->prefsFile->getPluginContext("colorwheel");
00050     typeCombo->setCurrentIndex(prefs->getInt("cw_type", 0));
00051     angleSpin->setValue(prefs->getInt("cw_angle", 15));
00052     colorWheel->currentDoc = m_Doc;
00053     colorWheel->angle = angleSpin->value();
00054     colorWheel->baseAngle = prefs->getInt("cw_baseangle", 0);
00055     colorspaceTab->setCurrentIndex(prefs->getInt("cw_space", 0));
00056     color.setNamedColor(prefs->get("cw_color", "#00000000"));
00057     // Handle color previously selected in the document tab
00058     if (colorspaceTab->currentWidget() == tabDocument)
00059     {
00060         colorName = prefs->get("cw_colorname", "");
00061         if (!colorName.isEmpty() && m_Doc->PageColors.contains(colorName))
00062             color = m_Doc->PageColors[colorName];
00063         else
00064             color.setColorRGB(0, 0, 0); //Trigger use of defaults
00065     }
00066     // Handle achromatic colors
00067     QColor rgb = ScColorEngine::getRGBColor(color, m_Doc);
00068     rgb.getHsv(&h, &s, &v);
00069     if (h == -1)
00070     {   // Reset to defaults
00071         colorWheel->baseAngle = 0;
00072         colorWheel->currentColorSpace = colorModelCMYK;
00073         colorWheel->actualColor = colorWheel->colorByAngle(0);
00074         colorspaceTab->setCurrentIndex(0);
00075     }
00076     else if (colorspaceTab->currentWidget() == tabDocument)
00077     {
00078         colorWheel->actualColor = color;
00079         QList<QListWidgetItem*> results = documentColorList->findItems(colorName, Qt::MatchFixedString|Qt::MatchCaseSensitive);
00080         if (results.count() > 0)
00081             documentColorList->setCurrentItem(results[0]);
00082     }
00083     else
00084         colorWheel->actualColor = color;
00085 
00086     resize(QSize(prefs->getInt("cw_width", 640),
00087            prefs->getInt("cw_height", 480)).expandedTo(minimumSizeHint()));
00088     previewLabel->resize(prefs->getInt("cw_samplex", 300), prefs->getInt("cw_sampley", 100));
00089         
00090     // setup
00091     currentColorTable->horizontalHeader()->hide();
00092     colorspaceTab_currentChanged(colorspaceTab->currentIndex());
00093 
00094     // signals and slots that cannot be in ui file
00095     connect(colorWheel, SIGNAL(clicked(int, const QPoint&)),
00096             this, SLOT(colorWheel_clicked(int, const QPoint&)));
00097     connect(documentColorList, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
00098             this, SLOT(documentColorList_currentChanged(QListWidgetItem *)));
00099     connect(colorList, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
00100             this, SLOT(colorList_currentChanged(QListWidgetItem *)));
00101     connect(angleSpin, SIGNAL(valueChanged(int)),
00102             this, SLOT(angleSpin_valueChanged(int)));
00103     connect(colorspaceTab, SIGNAL(currentChanged(int)),
00104             this, SLOT(colorspaceTab_currentChanged(int)));
00105     connect(typeCombo, SIGNAL(activated(int)), this, SLOT(typeCombo_activated(int)));
00106     connect(defectCombo, SIGNAL(activated(int)), this, SLOT(defectCombo_activated(int)));
00107     connect(addButton, SIGNAL(clicked()), this, SLOT(addButton_clicked()));
00108     connect(replaceButton, SIGNAL(clicked()), this, SLOT(replaceButton_clicked()));
00109     connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelButton_clicked()));
00110 
00111     connectSlots(true);
00112 }
00113 
00114 CWDialog::~CWDialog()
00115 {
00116     // preferences
00117     QString colorName = (colorspaceTab->currentWidget() == tabDocument) ? documentColorList->currentColor() : "";
00118     prefs->set("cw_type", typeCombo->currentIndex());
00119     prefs->set("cw_angle", angleSpin->value());
00120     prefs->set("cw_baseangle", colorWheel->baseAngle);
00121     prefs->set("cw_color", colorWheel->actualColor.name());
00122     prefs->set("cw_colorname", colorName);
00123     prefs->set("cw_space", colorspaceTab->currentIndex());
00124     // GUI settings
00125     prefs->set("cw_width", width());
00126     prefs->set("cw_height", height());
00127     prefs->set("cw_samplex", previewLabel->width());
00128     prefs->set("cw_sampley", previewLabel->height());
00129 }
00130 
00131 void CWDialog::connectSlots(bool conn)
00132 {
00133     if (conn)
00134     {
00135         connect( cSpin, SIGNAL( valueChanged(int) ), this, SLOT( cSpin_valueChanged(int) ) );
00136         connect( mSpin, SIGNAL( valueChanged(int) ), this, SLOT( mSpin_valueChanged(int) ) );
00137         connect( ySpin, SIGNAL( valueChanged(int) ), this, SLOT( ySpin_valueChanged(int) ) );
00138         connect( kSpin, SIGNAL( valueChanged(int) ), this, SLOT( kSpin_valueChanged(int) ) );
00139         connect( rSpin, SIGNAL( valueChanged(int) ), this, SLOT( rSpin_valueChanged(int) ) );
00140         connect( gSpin, SIGNAL( valueChanged(int) ), this, SLOT( gSpin_valueChanged(int) ) );
00141         connect( bSpin, SIGNAL( valueChanged(int) ), this, SLOT( bSpin_valueChanged(int) ) );
00142         connect( hSpin, SIGNAL( valueChanged(int) ), this, SLOT( hSpin_valueChanged(int) ) );
00143         connect( sSpin, SIGNAL( valueChanged(int) ), this, SLOT( sSpin_valueChanged(int) ) );
00144         connect( vSpin, SIGNAL( valueChanged(int) ), this, SLOT( vSpin_valueChanged(int) ) );
00145     }
00146     else
00147     {
00148         disconnect( cSpin, SIGNAL( valueChanged(int) ), this, SLOT( cSpin_valueChanged(int) ) );
00149         disconnect( mSpin, SIGNAL( valueChanged(int) ), this, SLOT( mSpin_valueChanged(int) ) );
00150         disconnect( ySpin, SIGNAL( valueChanged(int) ), this, SLOT( ySpin_valueChanged(int) ) );
00151         disconnect( kSpin, SIGNAL( valueChanged(int) ), this, SLOT( kSpin_valueChanged(int) ) );
00152         disconnect( rSpin, SIGNAL( valueChanged(int) ), this, SLOT( rSpin_valueChanged(int) ) );
00153         disconnect( gSpin, SIGNAL( valueChanged(int) ), this, SLOT( gSpin_valueChanged(int) ) );
00154         disconnect( bSpin, SIGNAL( valueChanged(int) ), this, SLOT( bSpin_valueChanged(int) ) );
00155         disconnect( hSpin, SIGNAL( valueChanged(int) ), this, SLOT( hSpin_valueChanged(int) ) );
00156         disconnect( sSpin, SIGNAL( valueChanged(int) ), this, SLOT( sSpin_valueChanged(int) ) );
00157         disconnect( vSpin, SIGNAL( valueChanged(int) ), this, SLOT( vSpin_valueChanged(int) ) );
00158     }
00159 }
00160 
00161 void CWDialog::documentColorList_currentChanged(QListWidgetItem *item)
00162 {
00163     if (!item)
00164         return;
00165     ScColor c(m_Doc->PageColors[documentColorList->currentColor()]);
00166     colorWheel->currentColorSpace = c.getColorModel();
00167     setupColorComponents();
00168 }
00169 
00170 void CWDialog::colorspaceTab_currentChanged(int index)
00171 {
00172     QWidget * tab = colorspaceTab->widget(index);
00173     if (tab == tabCMYK)
00174         colorWheel->currentColorSpace = colorModelCMYK;
00175     if (tab == tabRGB)
00176         colorWheel->currentColorSpace = colorModelRGB;
00177     if (tab == tabDocument)
00178     {
00179         if (!documentColorList->currentItem())
00180         {
00181             documentColorList->setCurrentItem(documentColorList->item(0));
00182             documentColorList->item(0)->setSelected(true);
00183         }
00184         documentColorList_currentChanged(documentColorList->currentItem());
00185     }
00186     processColors(typeCombo->currentIndex(), true);
00187 }
00188 
00189 void CWDialog::typeCombo_activated(int index)
00190 {
00191     processColors(index, false);
00192 }
00193 
00194 void CWDialog::processColors(int index, bool updateSpins)
00195 {
00196     bool angEnable = false;
00197     //colorList->clear();
00198     if (index == colorWheel->Monochromatic)
00199         colorWheel->currentType = colorWheel->Monochromatic;
00200     if (index == colorWheel->Analogous)
00201     {
00202         angEnable = true;
00203         colorWheel->currentType = colorWheel->Analogous;
00204     }
00205     if (index == colorWheel->Complementary)
00206         colorWheel->currentType = colorWheel->Complementary;
00207     if (index == colorWheel->Split)
00208     {
00209         angEnable = true;
00210         colorWheel->currentType = colorWheel->Split;
00211     }
00212     if (index == colorWheel->Triadic)
00213         colorWheel->currentType = colorWheel->Triadic;
00214     if (index == colorWheel->Tetradic)
00215     {
00216         angEnable = true;
00217         colorWheel->currentType = colorWheel->Tetradic;
00218     }
00219     angleSpin->setEnabled(angEnable);
00220     angleLabel->setEnabled(angEnable);
00221     colorWheel->makeColors();
00222     fillColorList();
00223     setPreview();
00224     if (updateSpins)
00225     {
00226 //      setupFromColor(colorWheel->actualColor);
00227         setupRGBComponent(colorWheel->actualColor);
00228         setupCMYKComponent(colorWheel->actualColor);
00229         setupHSVComponent(colorWheel->actualColor);
00230     }
00231     updateNamedLabels();
00232     QList<QListWidgetItem*> results = colorList->findItems(colorWheel->trBaseColor, Qt::MatchFixedString|Qt::MatchCaseSensitive);
00233     if (results.count() > 0)
00234         colorList_currentChanged(results[0]);
00235     colorWheel->update(); // force paint event
00236 }
00237 
00238 void CWDialog::colorWheel_clicked(int, const QPoint&)
00239 {
00240     processColors(typeCombo->currentIndex(), true);
00241 }
00242 
00243 void CWDialog::angleSpin_valueChanged(int value)
00244 {
00245     colorWheel->angle = value;
00246     processColors(typeCombo->currentIndex(), false);
00247 }
00248 
00249 void CWDialog::setPreview()
00250 {
00251     int x = previewLabel->width();
00252     int y = previewLabel->height();
00253     QList<ScColor> cols = colorWheel->colorList.values();
00254     int xstep = x / cols.count();
00255     QPixmap pm = QPixmap(x, y);
00256     QPainter *p = new QPainter(&pm);
00257     QFontMetrics fm = p->fontMetrics();
00258 
00259     pm.fill(Qt::white);
00260     p->setPen(Qt::white);
00261     p->drawRect(0, 0, x, y);
00262     QColor c;
00263     for (int i = 0; i < cols.count(); ++i)
00264     {
00265         //c = computeDefect(cols[i].getRGBColor());
00266         c = computeDefect( ScColorEngine::getDisplayColor(cols[i], m_Doc) );
00267         p->setPen(c);
00268         p->setBrush(c);
00269         p->drawRect(i * xstep, 0, xstep, y);
00270     }
00271     p->setPen(Qt::black);
00272     p->setBrush(Qt::black);
00273     p->drawText(15, 5 + fm.height(), "Lorem ipsum dolor sit amet");
00274     p->setPen(Qt::white);
00275     p->setBrush(Qt::white);
00276     p->drawText(90, y - 5 - fm.height(), "Lorem ipsum dolor sit amet");
00277     p->end();
00278     delete(p);
00279     previewLabel->clear();
00280     previewLabel->setPixmap(pm);
00281 }
00282 
00283 QColor CWDialog::computeDefect(QColor c)
00284 {
00285     if (defectCombo->currentIndex() == VisionDefectColor::normalVision)
00286         return c;
00287     VisionDefectColor defect(c);
00288     defect.deficiency = defectCombo->currentIndex();
00289     defect.convertDefect();
00290     QColor nc = defect.getColor();
00291     return nc;
00292 }
00293 
00294 void CWDialog::fillColorList()
00295 {
00296     int ix = colorList->currentRow();
00297     colorList->updateBox(colorWheel->colorList, ColorListBox::fancyPixmap);
00298     QList<QListWidgetItem*> results = colorList->findItems(colorWheel->trBaseColor, Qt::MatchFixedString|Qt::MatchCaseSensitive);
00299     if (results.count() > 0)
00300     {
00301         QListWidgetItem *item = results[0];
00302         int row = colorList->row(item);
00303         if (row > 0)
00304         {
00305             colorList->takeItem(row);
00306             colorList->insertItem(0, item);
00307         }
00308     }
00309     colorList->setCurrentRow(ix > colorList->count() ? 0 : ix);
00310 }
00311 
00312 void CWDialog::defectCombo_activated(int)
00313 {
00314     setPreview();
00315 }
00316 
00317 void CWDialog::addButton_clicked()
00318 {
00319     QString status("<qt><h2>" + tr("Merging colors") + "</h2><p>");
00320     bool err = false;
00321     for (ColorList::iterator it = colorWheel->colorList.begin(); it != colorWheel->colorList.end(); ++it)
00322     {
00323         if (m_Doc->PageColors.contains(it.key()))
00324         {
00325             status += "<b>" + tr("Error: ") + "</b>" + tr("Color %1 exists already!").arg(it.key()) + "<br/>";
00326             err = true;
00327         }
00328         else
00329         {
00330             status += tr("Color %1 appended.").arg(it.key()) + "<br/>";
00331             m_Doc->PageColors[it.key()] = it.value();
00332         }
00333     }
00334     status += "<p>" + tr("Now opening the color manager.") + "</p></qt>";
00335     if (err)
00336     {
00337         QMessageBox::information(this, tr("Color Merging"), status);
00338         m_Doc->scMW()->slotEditColors();
00339         return;
00340     }
00341     m_Doc->scMW()->propertiesPalette->updateColorList();
00342     accept();
00343 }
00344 
00345 void CWDialog::replaceButton_clicked()
00346 {
00347     for (ColorList::iterator it = colorWheel->colorList.begin(); it != colorWheel->colorList.end(); ++it)
00348     {
00349         m_Doc->PageColors[it.key()] = it.value();
00350     }
00351     m_Doc->scMW()->propertiesPalette->updateColorList();
00352     accept();
00353 }
00354 
00355 void CWDialog::cancelButton_clicked()
00356 {
00357     reject();
00358 }
00359 
00360 void CWDialog::cSpin_valueChanged( int )
00361 {
00362     setupColorComponents();
00363 }
00364 
00365 void CWDialog::mSpin_valueChanged( int )
00366 {
00367     setupColorComponents();
00368 }
00369 
00370 void CWDialog::ySpin_valueChanged( int )
00371 {
00372     setupColorComponents();
00373 }
00374 
00375 void CWDialog::kSpin_valueChanged( int )
00376 {
00377     setupColorComponents();
00378 }
00379 
00380 void CWDialog::rSpin_valueChanged( int )
00381 {
00382     setupColorComponents();
00383 }
00384 
00385 void CWDialog::gSpin_valueChanged( int )
00386 {
00387     setupColorComponents();
00388 }
00389 
00390 void CWDialog::bSpin_valueChanged( int )
00391 {
00392     setupColorComponents();
00393 }
00394 
00395 void CWDialog::hSpin_valueChanged( int )
00396 {
00397     setupColorComponents();
00398 }
00399 
00400 void CWDialog::sSpin_valueChanged( int )
00401 {
00402     setupColorComponents();
00403 }
00404 
00405 void CWDialog::vSpin_valueChanged( int )
00406 {
00407     setupColorComponents();
00408 }
00409 
00410 void CWDialog::setupRGBComponent(ScColor col)
00411 {
00412     RGBColor rgb;
00413     ScColorEngine::getRGBValues(col, m_Doc, rgb);
00414     connectSlots(false);
00415     rSpin->setValue(rgb.r);
00416     gSpin->setValue(rgb.g);
00417     bSpin->setValue(rgb.b);
00418     connectSlots(true);
00419 }
00420 
00421 void CWDialog::setupCMYKComponent(ScColor col)
00422 {
00423     CMYKColor cmyk;
00424     ScColorEngine::getCMYKValues(col, m_Doc, cmyk);
00425     connectSlots(false);
00426     cSpin->setValue(qRound(cmyk.c / 2.55));
00427     mSpin->setValue(qRound(cmyk.m / 2.55));
00428     ySpin->setValue(qRound(cmyk.y / 2.55));
00429     kSpin->setValue(qRound(cmyk.k / 2.55));
00430     connectSlots(true);
00431 }
00432 
00433 void CWDialog::setupHSVComponent(ScColor col)
00434 {
00435     int h, s, v;
00436     QColor qc(ScColorEngine::getRGBColor(col, m_Doc));
00437     qc.getHsv(&h, &s, &v);
00438     connectSlots(false);
00439     hSpin->setValue(h);
00440     sSpin->setValue(s);
00441     vSpin->setValue(v);
00442     connectSlots(true);
00443 }
00444 
00445 void CWDialog::setupColorComponents()
00446 {
00447     ScColor c;
00448     if (colorspaceTab->currentWidget() == tabCMYK)
00449     {
00450         c = ScColor(qRound(cSpin->value() * 2.55), qRound(mSpin->value() * 2.55),
00451                     qRound(ySpin->value() * 2.55), qRound(kSpin->value() * 2.55));
00452         c = ScColorEngine::convertToModel(c, m_Doc, colorModelCMYK);
00453         setupRGBComponent(c);
00454         setupHSVComponent(c);
00455     }
00456     if (colorspaceTab->currentWidget() == tabRGB)
00457     {
00458         c = ScColor(rSpin->value(), gSpin->value(), bSpin->value());
00459         c = ScColorEngine::convertToModel(c, m_Doc, colorModelRGB);
00460         setupCMYKComponent(c);
00461         setupHSVComponent(c);
00462     }
00463     if (colorspaceTab->currentWidget() == tabHSV)
00464     {
00465         QColor qc;
00466         qc.setHsv(hSpin->value(), sSpin->value(), vSpin->value());
00467         c.fromQColor(qc);
00468         c = ScColorEngine::convertToModel(c, m_Doc, colorModelRGB);
00469         setupCMYKComponent(c);
00470         setupRGBComponent(c);
00471     }
00472     if (colorspaceTab->currentWidget() == tabDocument)
00473     {
00474         c = m_Doc->PageColors[documentColorList->currentColor()];
00475         setupRGBComponent(c);
00476         setupCMYKComponent(c);
00477         setupHSVComponent(c);
00478     }
00479 
00480     if (colorWheel->recomputeColor(c))
00481         processColors(typeCombo->currentIndex(), false);
00482     else
00483     {
00484         colorList->clear();
00485         QMessageBox::information(this, windowTitle(),
00486                                  "<qt>" + tr("Unable to find the requested color. "
00487                                          "You have probably selected black, gray or white. "
00488                                          "There is no way to process this color.") + "</qt>");
00489     }
00490     updateNamedLabels();
00491 }
00492 
00493 void CWDialog::updateNamedLabels()
00494 {
00495     cmykLabel->setText(colorWheel->actualColor.nameCMYK(m_Doc));
00496     cmykLabel2->setText(colorWheel->actualColor.nameCMYK(m_Doc));
00497     rgbLabel->setText(colorWheel->actualColor.nameRGB(m_Doc));
00498     rgbLabel2->setText(colorWheel->actualColor.nameRGB(m_Doc));
00499     hsvLabel->setText(getHexHsv(colorWheel->actualColor));
00500     hsvLabel2->setText(getHexHsv(colorWheel->actualColor));
00501 }
00502 
00503 void CWDialog::colorList_currentChanged(QListWidgetItem * item)
00504 {
00505     if (!item)
00506         return;
00507 
00508     // if it's base color we do not need to recompute it again
00509     if (item->text() == colorWheel->trBaseColor)
00510     {
00511         currentColorTable->setItem(0, 4, new QTableWidgetItem(cmykLabel->text()));
00512         currentColorTable->setItem(1, 4, new QTableWidgetItem(rgbLabel->text()));
00513         currentColorTable->setItem(2, 4, new QTableWidgetItem(hsvLabel->text()));
00514         currentColorTable->setItem(0, 0, new QTableWidgetItem(cSpin->text()));
00515         currentColorTable->setItem(0, 1, new QTableWidgetItem(mSpin->text()));
00516         currentColorTable->setItem(0, 2, new QTableWidgetItem(ySpin->text()));
00517         currentColorTable->setItem(0, 3, new QTableWidgetItem(kSpin->text()));
00518         currentColorTable->setItem(1, 0, new QTableWidgetItem(rSpin->text()));
00519         currentColorTable->setItem(1, 1, new QTableWidgetItem(gSpin->text()));
00520         currentColorTable->setItem(1, 2, new QTableWidgetItem(bSpin->text()));
00521         currentColorTable->setItem(2, 0, new QTableWidgetItem(hSpin->text()));
00522         currentColorTable->setItem(2, 1, new QTableWidgetItem(sSpin->text()));
00523         currentColorTable->setItem(2, 2, new QTableWidgetItem(vSpin->text()));
00524     }
00525     else
00526     {
00527         ScColor col(colorWheel->colorList[item->text()]);
00528         currentColorTable->setItem(0, 4, new QTableWidgetItem(col.nameCMYK(m_Doc)));
00529         currentColorTable->setItem(1, 4, new QTableWidgetItem(col.nameRGB(m_Doc)));
00530         currentColorTable->setItem(2, 4, new QTableWidgetItem(getHexHsv(col)));
00531         // components
00532         QString num;
00533         CMYKColor cmyk;
00534         ScColorEngine::getCMYKValues(col, m_Doc, cmyk);
00535         currentColorTable->setItem(0, 0, new QTableWidgetItem(num.setNum(cmyk.c)));
00536         currentColorTable->setItem(0, 1, new QTableWidgetItem(num.setNum(cmyk.m)));
00537         currentColorTable->setItem(0, 2, new QTableWidgetItem(num.setNum(cmyk.y)));
00538         currentColorTable->setItem(0, 3, new QTableWidgetItem(num.setNum(cmyk.k)));
00539         RGBColor rgb;
00540         ScColorEngine::getRGBValues(col, m_Doc, rgb);
00541         currentColorTable->setItem(1, 0, new QTableWidgetItem(num.setNum(rgb.r)));
00542         currentColorTable->setItem(1, 1, new QTableWidgetItem(num.setNum(rgb.g)));
00543         currentColorTable->setItem(1, 2, new QTableWidgetItem(num.setNum(rgb.b)));
00544         int h, s, v;
00545         QColor hsvCol(ScColorEngine::getRGBColor(col, m_Doc));
00546         hsvCol.getHsv(&h, &s, &v);
00547         currentColorTable->setItem(2, 0, new QTableWidgetItem(num.setNum(h)));
00548         currentColorTable->setItem(2, 1, new QTableWidgetItem(num.setNum(s)));
00549         currentColorTable->setItem(2, 2, new QTableWidgetItem(num.setNum(v)));
00550     }
00551     currentColorTable->resizeColumnsToContents();
00552 }
00553 
00554 QString CWDialog::getHexHsv(ScColor c)
00555 {
00556     int h, s, v;
00557     QColor hsvCol(ScColorEngine::getRGBColor(c, m_Doc));
00558     hsvCol.getHsv(&h, &s, &v);
00559     return QString("#%1%2%3").arg(h, 0, 16).arg(s, 0, 16).arg(v, 0, 16);
00560 }
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.