void MadeupWindow::selectColor(const td::QVector4<float> &initial_color, std::function<void(const QColor &)> onSelect) { QColorDialog *picker = new QColorDialog(toQColor(initial_color), this); picker->setOption(QColorDialog::ShowAlphaChannel); picker->setOption(QColorDialog::NoButtons); connect(picker, &QColorDialog::currentColorChanged, onSelect); picker->setAttribute(Qt::WA_DeleteOnClose); picker->show(); }
void AdvancedSettings::onSelectorClicked() { int emitter = getEmitter (QObject::sender()); /* Configure the color dialog */ QString color; QColorDialog dialog; dialog.setCurrentColor (getColor (emitter)); dialog.setOption (QColorDialog::DontUseNativeDialog); /* Get new color */ if (dialog.exec() == QColorDialog::Accepted) color = QVariant (dialog.currentColor()).toString(); /* User clicked the 'Cancel' button in the color dialog */ else return; /* Update the line edit that matches the button that called this function */ switch (emitter) { case Base: ui.BaseEdit->setText (color); break; case Highlight: ui.HighlightEdit->setText (color); break; case Background: ui.BackgroundEdit->setText (color); break; case Foreground: ui.ForegroundEdit->setText (color); break; } }
void cubeConfiguration::on_btMonoChromeColor_clicked() { QColorDialog *colorDialog = new QColorDialog(m_cube->getdefaultColor(), this); colorDialog->setOption ( QColorDialog::ShowAlphaChannel); connect(colorDialog, SIGNAL(currentColorChanged(QColor)), m_cube, SLOT(setMonoChromeColor(QColor))); colorDialog->show(); }
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; } }
void ColorsIcon::pickColor(QPalette::ColorRole role) { // TODO: QColorDialog is bugged. Corrupts alpha when no adjustment occurs. QColorDialog dlg; dlg.setOption(QColorDialog::DontUseNativeDialog); dlg.setOption(QColorDialog::ShowAlphaChannel); dlg.setCurrentColor(role == QPalette::Foreground ? mPen : mBrush); dlg.setWindowTitle(role == QPalette::Foreground ? tr("Select pen color") : tr("Select brush color")); // Execute dialog if(dlg.exec() == QDialog::Accepted) { // Emit color change emit colorPicked(role, dlg.currentColor()); } }