diff --git a/scribus/plugins/colorwheel/cwdialog.cpp b/scribus/plugins/colorwheel/cwdialog.cpp index 73b2bbc3c..3bb080148 100644 --- a/scribus/plugins/colorwheel/cwdialog.cpp +++ b/scribus/plugins/colorwheel/cwdialog.cpp @@ -93,6 +93,18 @@ CWDialog::CWDialog(QWidget* parent, ScribusDoc* doc, const char* name, bool moda resize(QSize(prefs->getInt("cw_width", 640), prefs->getInt("cw_height", 480)).expandedTo(minimumSizeHint())); previewLabel->resize(prefs->getInt("cw_samplex", 300), prefs->getInt("cw_sampley", 100)); + + for (int i = 0; i < currentColorTable->rowCount(); i++) + { + for (int j = 0; j < currentColorTable->columnCount(); j++) + { + auto item = new QTableWidgetItem(); + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + currentColorTable->setItem(i, j, item); + + } + + } // setup colorspaceTab_currentChanged(colorspaceTab->currentIndex()); @@ -510,49 +522,46 @@ void CWDialog::colorList_currentChanged(const QString& itemText) // if it's base color we do not need to recompute it again if (itemText == colorWheel->trBaseColor) { - currentColorTable->setItem(0, 4, new QTableWidgetItem(cmykLabel->text())); - currentColorTable->setItem(1, 4, new QTableWidgetItem(rgbLabel->text())); - currentColorTable->setItem(2, 4, new QTableWidgetItem(hsvLabel->text())); - currentColorTable->setItem(0, 0, new QTableWidgetItem(cSpin->text())); - currentColorTable->setItem(0, 1, new QTableWidgetItem(mSpin->text())); - currentColorTable->setItem(0, 2, new QTableWidgetItem(ySpin->text())); - currentColorTable->setItem(0, 3, new QTableWidgetItem(kSpin->text())); - currentColorTable->setItem(1, 0, new QTableWidgetItem(rSpin->text())); - currentColorTable->setItem(1, 1, new QTableWidgetItem(gSpin->text())); - currentColorTable->setItem(1, 2, new QTableWidgetItem(bSpin->text())); - currentColorTable->setItem(2, 0, new QTableWidgetItem(hSpin->text())); - currentColorTable->setItem(2, 1, new QTableWidgetItem(sSpin->text())); - currentColorTable->setItem(2, 2, new QTableWidgetItem(vSpin->text())); + currentColorTable->item(0, 4)->setText(cmykLabel->text()); + currentColorTable->item(1, 4)->setText(rgbLabel->text()); + currentColorTable->item(2, 4)->setText(hsvLabel->text()); + currentColorTable->item(0, 0)->setText(cSpin->text()); + currentColorTable->item(0, 1)->setText(mSpin->text()); + currentColorTable->item(0, 2)->setText(ySpin->text()); + currentColorTable->item(0, 3)->setText(kSpin->text()); + currentColorTable->item(1, 0)->setText(rSpin->text()); + currentColorTable->item(1, 1)->setText(gSpin->text()); + currentColorTable->item(1, 2)->setText(bSpin->text()); + currentColorTable->item(2, 0)->setText(hSpin->text()); + currentColorTable->item(2, 1)->setText(sSpin->text()); + currentColorTable->item(2, 2)->setText(vSpin->text()); } else { ScColor col(colorWheel->colorList[itemText]); - currentColorTable->setItem(0, 4, new QTableWidgetItem(col.nameCMYK(m_Doc))); - currentColorTable->setItem(1, 4, new QTableWidgetItem(col.nameRGB(m_Doc))); - currentColorTable->setItem(2, 4, new QTableWidgetItem(getHexHsv(col))); + currentColorTable->item(0, 4)->setText(col.nameCMYK(m_Doc)); + currentColorTable->item(1, 4)->setText(col.nameRGB(m_Doc)); + currentColorTable->item(2, 4)->setText(getHexHsv(col)); // components QString num; CMYKColor cmyk; ScColorEngine::getCMYKValues(col, m_Doc, cmyk); - currentColorTable->setItem(0, 0, new QTableWidgetItem(num.setNum(cmyk.c))); - currentColorTable->setItem(0, 1, new QTableWidgetItem(num.setNum(cmyk.m))); - currentColorTable->setItem(0, 2, new QTableWidgetItem(num.setNum(cmyk.y))); - currentColorTable->setItem(0, 3, new QTableWidgetItem(num.setNum(cmyk.k))); + currentColorTable->item(0, 0)->setText(num.setNum(cmyk.c)); + currentColorTable->item(0, 1)->setText(num.setNum(cmyk.m)); + currentColorTable->item(0, 2)->setText(num.setNum(cmyk.y)); + currentColorTable->item(0, 3)->setText(num.setNum(cmyk.k)); RGBColor rgb; ScColorEngine::getRGBValues(col, m_Doc, rgb); - currentColorTable->setItem(1, 0, new QTableWidgetItem(num.setNum(rgb.r))); - currentColorTable->setItem(1, 1, new QTableWidgetItem(num.setNum(rgb.g))); - currentColorTable->setItem(1, 2, new QTableWidgetItem(num.setNum(rgb.b))); + currentColorTable->item(1, 0)->setText(num.setNum(rgb.r)); + currentColorTable->item(1, 1)->setText(num.setNum(rgb.g)); + currentColorTable->item(1, 2)->setText(num.setNum(rgb.b)); int h, s, v; QColor hsvCol(ScColorEngine::getRGBColor(col, m_Doc)); hsvCol.getHsv(&h, &s, &v); - currentColorTable->setItem(2, 0, new QTableWidgetItem(num.setNum(h))); - currentColorTable->setItem(2, 1, new QTableWidgetItem(num.setNum(s))); - currentColorTable->setItem(2, 2, new QTableWidgetItem(num.setNum(v))); + currentColorTable->item(2, 0)->setText(num.setNum(h)); + currentColorTable->item(2, 1)->setText(num.setNum(s)); + currentColorTable->item(2, 2)->setText(num.setNum(v)); } - int columnWidth = currentColorTable->fontMetrics().maxWidth() * 4; - for (int i = 0; i < 4 ; ++i) - currentColorTable->setColumnWidth(i, columnWidth); } QString CWDialog::getHexHsv(const ScColor& c)