| 5692 | } |
| 5693 | |
| 5694 | void 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 | |
| 5727 | void G4UIQt::ChangeCursorAction(const QString& action) |
| 5728 | { |
no test coverage detected