void WangColorView::pickColor() { QColorDialog *colorPicker = new QColorDialog(this); colorPicker->setAttribute(Qt::WA_DeleteOnClose); colorPicker->setCurrentColor(mClickedWangColor->color()); connect(colorPicker, &QColorDialog::colorSelected, this, &WangColorView::colorPicked); colorPicker->open(); }
void SettingsDlg::colorDialog( const char * optionName, QString title ) { QColorDialog dlg; dlg.setWindowTitle(title); dlg.setCurrentColor( getColor( optionName, 0x000000 ) ); if ( dlg.exec() == QDialog::Accepted ) { setColor( optionName, dlg.currentColor() ); updateStyleSample(); } }
void ColorEditor::slotClicked() { m_buttonPressed = true; QColorDialog* dialog = new QColorDialog(this); dialog->setCurrentColor(m_color); if (dialog->exec()) m_color=dialog->currentColor(); delete dialog; setFocusToParent(); emit(editingFinished()); }
void CWizPreferenceWindow::on_pushButtonBackgroundColor_clicked() { QColorDialog dlg; dlg.setCurrentColor(m_app.userSettings().editorBackgroundColor()); if (dlg.exec() == QDialog::Accepted) { QString strColor = dlg.currentColor().name(); updateEditorBackgroundColor(strColor); } }
void MainWindow::on_actionSet_background_color_2_triggered() { QColorDialog dialog; dialog.setCurrentColor(mBackgroundColor); int result = dialog.exec(); if (result) { mBackgroundColor = dialog.currentColor(); } }
void ChatBrowser::backGroundChanged() { QColorDialog dialog; dialog.setCurrentColor(m_bgColor); if(dialog.exec()==QDialog::Accepted) { m_bgColor=dialog.currentColor(); setStyleSheet(QString("QTextBrowser { background:%1;}").arg(m_bgColor.name())); } }
void PeopleEditionDialog::on_pbColor_clicked() { QColorDialog dlg; // Setting the selected color to the character's one dlg.setCurrentColor(QColor(_people->color())); // Connecting slot connect(&dlg, SIGNAL(currentColorChanged(QColor)), this, SLOT(OnColorSelected(QColor))); dlg.exec(); }
void QColorPushButton::mousePressEvent(QMouseEvent* pEvent) { QColorDialog ColorDialog; connect(&ColorDialog, SIGNAL(currentColorChanged(const QColor&)), this, SLOT(OnCurrentColorChanged(const QColor&))); ColorDialog.setWindowIcon(GetIcon("color--pencil")); ColorDialog.setCurrentColor(m_Color); ColorDialog.exec(); disconnect(&ColorDialog, SIGNAL(currentColorChanged(const QColor&)), this, SLOT(OnCurrentColorChanged(const QColor&))); }
void SettingsWidget::showColourDialog() { QColorDialog colorDialog; colorDialog.setCurrentColor(settings.tableColour); if (colorDialog.exec() == QDialog::Accepted) { QColor colour = colorDialog.selectedColor(); settings.tableColour = colour.name(); QString colourStyleSheet = "background-color: " + colour.name() + ";"; ui->colourButton->setStyleSheet(colourStyleSheet); applySettings(); } }
void EnvironmentSettingsDialog::on_highlightBarColor_clicked() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, "CSPSoftware", "NESICIDE"); QColorDialog dlg; dlg.setCurrentColor(m_highlightBarColor); if (dlg.exec() == QColorDialog::Accepted) { m_highlightBarColor = dlg.selectedColor(); m_scintilla->setMarkerBackgroundColor(m_highlightBarColor,Marker_Highlight); } }
void PropertiesEditorItem::slotOpenColorEditor() { QColorDialog *dialog = new QColorDialog(parent()); dialog->setCurrentColor(mProperty.read(mObject.data()).value<QColor>()); if (dialog->exec() == QDialog::Accepted) { mProperty.write(mObject.data(), QVariant::fromValue(dialog->currentColor())); QPushButton *button = qobject_cast<QPushButton*>(mWidget.data()); button->setText(dialog->currentColor().name()); } delete dialog; }
void CustomGoalWidgetTest::ColorTest() { QFETCH(QTestEventList, events); QFETCH(QColor, color); QColorDialog * dialog; events.simulate(m_ui->btn_Color); dialog = m_widget->d_ptr->colorDialog; QVERIFY(dialog != NULL); if( dialog == NULL ) return; QVERIFY(QTest::qWaitForWindowActive(dialog)); dialog->setCurrentColor(color); QTest::keyClick(dialog, Qt::Key_Return); // test cancel and button background color QCOMPARE(m_widget->Color(), color); QCOMPARE(GetBackgroundColorName(m_ui->btn_Color), color.name()); events.simulate(m_ui->btn_Color); dialog = m_widget->d_ptr->colorDialog; QVERIFY(dialog != NULL); if( dialog == NULL ) return; QVERIFY(QTest::qWaitForWindowActive(dialog)); dialog->setCurrentColor(QColor(1,1,1)); QTest::keyClick(dialog, Qt::Key_Escape); QCOMPARE(m_widget->Color(), color); QCOMPARE(GetBackgroundColorName(m_ui->btn_Color), color.name()); }
void EnvironmentSettingsDialog::on_styleColor_clicked() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, "CSPSoftware", "NESICIDE"); QColorDialog dlg; int style = ui->styleName->itemData(ui->styleName->currentIndex()).toInt(); dlg.setCurrentColor(m_lexer->color(style)); if (dlg.exec() == QColorDialog::Accepted) { QColor chosenColor = dlg.selectedColor(); m_lexer->setColor(chosenColor,style); } }
void EnvironmentSettingsDialog::on_backgroundColor_clicked() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, "CSPSoftware", "NESICIDE"); QColorDialog dlg; dlg.setCurrentColor(m_lexer->defaultPaper()); if (dlg.exec() == QColorDialog::Accepted) { QColor chosenColor = dlg.selectedColor(); m_lexer->setDefaultPaper(chosenColor); m_lexer->setPaper(chosenColor,-1); } }
void Control3DWidget::onLightColorPicker() { QColorDialog* pDialog = new QColorDialog(this); pDialog->setCurrentColor(m_colCurrentLightColor); //Update all connected View3D's scene colors connect(pDialog, &QColorDialog::currentColorChanged, this, &Control3DWidget::onLightColorChanged); pDialog->exec(); m_colCurrentLightColor = pDialog->currentColor(); //Set color of button new new scene color ui->m_pushButton_lightColorPicker->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(m_colCurrentLightColor.red()).arg(m_colCurrentLightColor.green()).arg(m_colCurrentLightColor.blue())); }
void CDialogIrcSettings::on_toolButtonChangeColorLink_clicked() { QColorDialog* dlgColor = new QColorDialog( this ); dlgColor->setCurrentColor( m_ColorLink ); int result = dlgColor->exec(); if ( result == QDialog::Accepted ) { m_ColorLink = dlgColor->currentColor(); ui->labelColorLink->setStyleSheet( QString( "background-color: %1;" ).arg( m_ColorLink.name() ) ); ui->pushButtonApply->setEnabled( true ); } }
void ColorButton::click() { QColorDialog * dialog = new QColorDialog(this); dialog->setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); QColor savedColor = getColor(); connect(dialog, SIGNAL(currentColorChanged(QColor)), this, SLOT(currentColorChanged(QColor))); dialog->setCurrentColor(getColor()); if (dialog->exec() != QDialog::Accepted) setColor(savedColor); delete dialog; }
void cQSettingsDialog::OnColorClicked( bool iChecked ) /**********************************************************************/ { QPushButton *vSender = (QPushButton*)sender(); Ogre::ColourValue *iColor = (Ogre::ColourValue*)(qvariant_cast<void*>(vSender->property("OgreColor"))); QColorDialog vDialog; vDialog.setCurrentColor( QColor( iColor->r * 255, iColor->g * 255, iColor->b * 255 ) ); if ( !vDialog.exec() ) return; QColor vColor = vDialog.currentColor(); iColor->r = vColor.red() / 255.0f; iColor->g = vColor.green() / 255.0f; iColor->b = vColor.blue() / 255.0f; QPixmap vPixmap( 24, 16 ); vPixmap.fill( vColor ); vSender->setIcon( QIcon( vPixmap ) ); }
void Control3DWidget::onSceneColorPicker() { QColorDialog* pDialog = new QColorDialog(this); pDialog->setCurrentColor(m_colCurrentSceneColor); //Update all connected View3D's scene colors for(int i = 0; i<m_lView3D.size(); i++) { connect(pDialog, &QColorDialog::currentColorChanged, m_lView3D.at(i).data(), &View3D::setSceneColor); } pDialog->exec(); m_colCurrentSceneColor = pDialog->currentColor(); ui->m_pushButton_sceneColorPicker->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(m_colCurrentSceneColor.red()).arg(m_colCurrentSceneColor.green()).arg(m_colCurrentSceneColor.blue())); }
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()); } }
void PreferencesDialog::on_waveView_doubleClicked(const QModelIndex &index) { if (index.column() == 1) { QColorDialog a; if (!(index.flags() & Qt::ItemIsEnabled)) return; quint32 color = index.data(Qt::UserRole).toUInt(); a.setCurrentColor(QColor((QRgb)color)); if (a.exec() == QColorDialog::Accepted) { quint32 cv = a.currentColor().rgba(); waveFilterModel->setData(index, cv, Qt::UserRole); waveFilterModel->setData(index, a.currentColor(), Qt::BackgroundRole); } } }
void PreferencesDialog::on_eventTable_doubleClicked(const QModelIndex &index) { int row=index.row(); int col=index.column(); bool ok; int id=ui->eventTable->item(row,3)->text().toInt(&ok); if (col==1) { QWidget *w=ui->eventTable->cellWidget(row,col); QColorDialog a; QColor color=w->palette().background().color(); a.setCurrentColor(color); if (a.exec()==QColorDialog::Accepted) { QColor c=a.currentColor(); QPalette p(c,c,c,c,c,c,c); w->setPalette(p); m_new_colors[id]=c; //qDebug() << "Color accepted" << col << id; } } }
//-------------------------------------------------------------------------------------- void RMapObjectTableViewDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { switch (index.data(Qt::UserRole).toInt()) { case RMapObjectModel::ET_COLOR_SELECTOR: { QColorDialog *colorbox = static_cast<QColorDialog *>(editor); QColor color = index.model()->data(index, Qt::EditRole).value<QColor>(); colorbox->setCurrentColor(color); break; } case RMapObjectModel::ET_FONT_SELECTOR: { RFontSelectorDialog *fontSelector = static_cast<RFontSelectorDialog *>(editor); const RFontDescriptor *fd = index.model()->data(index, Qt::EditRole).value<const RFontDescriptor *>(); fontSelector->setCurrentFontDescriptor(fd); break; } case RMapObjectModel::ET_PICTURE_SELECTOR: { RPictureSelectorDialog *pictureSelector = static_cast<RPictureSelectorDialog *>(editor); const RImageDescriptor *id = index.model()->data(index, Qt::EditRole).value<const RImageDescriptor *>(); pictureSelector->setCurrentImageDescriptor(id); break; } case RMapObjectModel::ET_REFS_SELECTOR: { QComboBox *refsSelector = static_cast<QComboBox *>(editor); const RRefsDescriptor *rd = index.model()->data(index, Qt::EditRole).value<const RRefsDescriptor *>(); int pos = refsSelector->findData(rd->id()); refsSelector->setCurrentIndex(pos); break; } default: QItemDelegate::setEditorData(editor, index); break; } }
void alertas_ui::on_pushButton_Alert_changeColor_clicked() { if(!ui->tableWidget_AlertList->currentItem()) return; else if(ui->tableWidget_AlertList->currentItem()->text()=="") return; QString ALERTA_CODE; QSqlQuery query; ALERTA_CODE = ui->lineEdit_code->text(); QColor dfault = ui->tableWidget_AlertList->currentItem()->backgroundColor(); QColorDialog *palette = new QColorDialog(); palette->setCurrentColor(dfault); palette->exec(); QColor color(palette->currentColor()); QString COLOR_VALUE = color.name(); int FILA = ui->tableWidget_AlertList->currentItem()->row(); setColorRow(ui->tableWidget_AlertList,FILA,COLOR_VALUE); query.prepare("UPDATE e_alerta SET color=? WHERE alerta_pk="+ALERTA_CODE); query.bindValue(0,COLOR_VALUE); query.exec(); qDebug()<<color.rgb()<<" "<<COLOR_VALUE<<endl; }
virtual void accept() { KColorDialog::accept(); original->setCurrentColor(color()); QMetaObject::invokeMethod(original, "accept"); //workaround protected }
void Data3DTreeDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model()); const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index)); switch(pAbstractItem->type()) { case MetaTreeItemTypes::SurfaceColorGyri: { QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColorGyri).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::SurfaceColorSulci: { QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColorSulci).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::RTDataColormapType: { QString colormap = index.model()->data(index, MetaTreeItemRoles::RTDataColormapType).toString(); QComboBox* pComboBox = static_cast<QComboBox*>(editor); pComboBox->setCurrentText(colormap); break; } case MetaTreeItemTypes::RTDataNormalizationValue: { Spline* pSpline = static_cast<Spline*>(editor); int width = pSpline->size().width(); int height = pSpline->size().height(); if (pSpline->size().width() < 200 && pSpline->size().height() < 200) { pSpline->resize(600,400); //resize histogram to be readable with default size } else { width = pSpline->size().width(); //keeps the size of the histogram height = pSpline->size().height(); pSpline->resize(width,height); } return; } case MetaTreeItemTypes::RTDataTimeInterval: { int value = index.model()->data(index, MetaTreeItemRoles::RTDataTimeInterval).toInt(); QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); pSpinBox->setValue(value); break; } case MetaTreeItemTypes::RTDataVisualizationType: { QString visType = index.model()->data(index, MetaTreeItemRoles::RTDataVisualizationType).toString(); QComboBox* pComboBox = static_cast<QComboBox*>(editor); pComboBox->setCurrentText(visType); break; } case MetaTreeItemTypes::SurfaceColor: { QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColor).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::PointColor: { QColor color = index.model()->data(index, MetaTreeItemRoles::PointColor).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::RTDataNumberAverages: { int value = index.model()->data(index, MetaTreeItemRoles::RTDataNumberAverages).toInt(); QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); pSpinBox->setValue(value); break; } case MetaTreeItemTypes::SurfaceAlpha: { int value = index.model()->data(index, MetaTreeItemRoles::SurfaceAlpha).toDouble(); QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); pSpinBox->setValue(value); break; } case MetaTreeItemTypes::SurfaceTranslateX: { double value = index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateX).toDouble(); QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); pDoubleSpinBox->setValue(value); break; } case MetaTreeItemTypes::SurfaceTranslateY: { double value = index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateY).toDouble(); QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); pDoubleSpinBox->setValue(value); break; } case MetaTreeItemTypes::SurfaceTranslateZ: { double value = index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateZ).toDouble(); QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); pDoubleSpinBox->setValue(value); break; } case MetaTreeItemTypes::NetworkThreshold: { Spline* pSpline = static_cast<Spline*>(editor); int width = pSpline->size().width(); int height = pSpline->size().height(); if (pSpline->size().width() < 200 && pSpline->size().height() < 200) //pSpline initializes with size (137,15) { pSpline->resize(800,600); //resize histogram to be readable with default size } else { width = pSpline->size().width(); //keeps the size of the histogram height = pSpline->size().height(); pSpline->resize(width,height); } return; } default: // do nothing; break; } QItemDelegate::setEditorData(editor, index); }
void Data3DTreeDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model()); const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index)); // Only catch non-standard Qt types such as QColorDialog or items which need special handling for display role (e.g. Thresholding) etc. switch(pAbstractItem->type()) { case MetaTreeItemTypes::SurfaceColorGyri: { QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColorGyri).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::SurfaceColorSulci: { QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColorSulci).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::Color: { QColor color = index.model()->data(index, MetaTreeItemRoles::Color).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::DataThreshold: { if(Spline* pSpline = static_cast<Spline*>(editor)) { //Find the parent and retreive real-time data to calcualte the histogram if(AbstractTreeItem* pParentItem = static_cast<AbstractTreeItem*>(pAbstractItem->QStandardItem::parent())) { QModelIndex indexParent = pData3DTreeModel->indexFromItem(pParentItem); //Get data MatrixXd matRTData; QVariant data; data = index.model()->data(indexParent, Data3DTreeModelItemRoles::Data); if(data.canConvert<MatrixXd>()) { matRTData = data.value<MatrixXd>(); matRTData = matRTData.cwiseAbs(); //Calcualte histogram Eigen::VectorXd resultClassLimit; Eigen::VectorXi resultFrequency; MNEMath::histcounts(matRTData, false, 50, resultClassLimit, resultFrequency, 0.0, 0.0); //Create histogram plot pSpline->setData(resultClassLimit, resultFrequency); QVector3D vecThresholdValues = index.model()->data(index, MetaTreeItemRoles::DataThreshold).value<QVector3D>(); pSpline->setThreshold(vecThresholdValues); QList<QStandardItem*> pColormapItem = pParentItem->findChildren(MetaTreeItemTypes::ColormapType); for(int i = 0; i < pColormapItem.size(); ++i) { if(pColormapItem.at(i)) { QModelIndex indexColormapItem = pData3DTreeModel->indexFromItem(pColormapItem.at(i)); QString colorMap = index.model()->data(indexColormapItem, MetaTreeItemRoles::ColormapType).value<QString>(); pSpline->setColorMap(colorMap); } } } } pSpline->resize(600,400); } break; } // Handle basic types (QString, int, double, etc.) by default via QItemDelegate::setEditorData default: { QItemDelegate::setEditorData(editor, index); } } }