void NodeConfigurationDialog::setNodeLabelColor(void) { if (!graph) return; if (!graph->numValidNodes) { QMessageBox::information(this, tr("A Serious Lack of Nodes"), tr("No nodes to configure yet, sorry.")); return; } QColor clr( graph->nodes[0].labelColor.r, graph->nodes[0].labelColor.g, graph->nodes[0].labelColor.b, graph->nodes[0].labelColor.a); QColorDialog *d = new QColorDialog(clr, this); d->setOption(QColorDialog::ShowAlphaChannel, true); d->exec(); if (QDialog::Accepted==d->result()) { clr=d->currentColor(); watcher::Color c(clr.red(), clr.green(), clr.blue(), clr.alpha()); QString ss; ss.sprintf("background-color: #%02x%02x%02x; color: #%02x%02x%02x", clr.red(), clr.green(), clr.blue(), (~clr.red())&0xFF, (~clr.green())&0xFF, (~clr.blue())&0xFF); labelColorButton->setStyleSheet(ss); if (useNodeId) graph->nodes[curNodeId].labelColor=c; else for (size_t n=0; n<graph->numValidNodes; n++) graph->nodes[n].labelColor=c; } }
/** Handler for changing the foreground colour of an integrated peak. */ void PeaksWorkspaceWidget::onForegroundColourClicked() { QColorDialog colourDlg; colourDlg.result(); QColor selectedColour = colourDlg.getColor(); if (selectedColour.isValid()) { ui.btnPeakColor->setBackgroundColor(selectedColour); emit peakColourChanged(this->m_ws, selectedColour); } }
//-------------------------------------------------------------------------------------- void RMapObjectTableViewDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { switch (index.data(Qt::UserRole).toInt()) { case RMapObjectModel::ET_COLOR_SELECTOR: { QColorDialog *colorbox = static_cast<QColorDialog *>(editor); if (colorbox->result() == QDialog::Accepted) { QColor color = colorbox->currentColor(); model->setData(index, color, Qt::EditRole); } break; } case RMapObjectModel::ET_FONT_SELECTOR: { RFontSelectorDialog *fontSelector = static_cast<RFontSelectorDialog *>(editor); if (fontSelector->result() == QDialog::Accepted) { const RFontDescriptor *fd = fontSelector->currentFontDescriptor(); model->setData(index, qVariantFromValue(fd), Qt::EditRole); } break; } case RMapObjectModel::ET_PICTURE_SELECTOR: { RPictureSelectorDialog *pictureSelector = static_cast<RPictureSelectorDialog *>(editor); if (pictureSelector->result() == QDialog::Accepted) { const RImageDescriptor *id = pictureSelector->currentImageDescriptor(); model->setData(index, qVariantFromValue(id), Qt::EditRole); } break; } case RMapObjectModel::ET_REFS_SELECTOR: { QComboBox *refsSelector = static_cast<QComboBox *>(editor); int row = refsSelector->currentIndex(); int data = refsSelector->itemData(row).toInt(); const RRefsDescriptor *rd = &RMapRegistry::instance().getRefsDescriptorById(data); model->setData(index, qVariantFromValue(rd), Qt::EditRole); break; } default: QItemDelegate::setModelData(editor, model, index); break; } }