MCPcopy Create free account
hub / github.com/Geant4/geant4 / ChangeColorCallback

Method ChangeColorCallback

source/interfaces/implementation/src/G4UIQt.cc:5694–5725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5692}
5693
5694void G4UIQt::ChangeColorCallback(QWidget* widget)
5695{
5696 if (widget == nullptr) {
5697 return;
5698 }
5699
5700 auto button = dynamic_cast<QPushButton*>(widget);
5701 if (button == nullptr) {
5702 return;
5703 }
5704 QString value = button->accessibleName();
5705
5706 QColor old;
5707 old.setRgbF(value.section(" ", 0, 1).toDouble(), value.section(" ", 1, 2).toDouble(),
5708 value.section(" ", 2, 3).toDouble());
5709 QColor color =
5710 QColorDialog::getColor(old, fUITabWidget, "Change color", QColorDialog::ShowAlphaChannel);
5711
5712 if (color.isValid()) {
5713 // rebuild the widget icon
5714 QPixmap pixmap = QPixmap(QSize(16, 16));
5715 pixmap.fill(color);
5716 QPainter painter(&pixmap);
5717 painter.setPen(Qt::black);
5718 painter.drawRect(0, 0, 15, 15); // Draw contour
5719
5720 button->setAccessibleName(QString::number(color.redF()) + " " +
5721 QString::number(color.greenF()) + " " +
5722 QString::number(color.blueF()) + " ");
5723 button->setIcon(pixmap);
5724 }
5725}
5726
5727void G4UIQt::ChangeCursorAction(const QString& action)
5728{

Callers 1

CreateCommandWidgetMethod · 0.95

Calls 2

QPixmapClass · 0.85
fillMethod · 0.45

Tested by

no test coverage detected