void ColourSelector::sliderValueChanged (Slider*) { if (sliders[0] != nullptr) setCurrentColour (Colour ((uint8) sliders[0]->getValue(), (uint8) sliders[1]->getValue(), (uint8) sliders[2]->getValue(), (uint8) sliders[3]->getValue())); }
// Constructor GridColourPopup::GridColourPopup(AtenWindow& parent, TMenuButton* buttonParent, bool primary, int colourWidgetOptions) : TPopupWidget(buttonParent), parent_(parent) { ui.setupUi(this); connect(ui.ColourWidget, SIGNAL(colourChanged(QColor)), this, SLOT(colourChanged(QColor))); ui.ColourWidget->setOptions(colourWidgetOptions); setCurrentColour(Qt::blue); updateParentButtonIcon(Qt::blue); primary_ = primary; }
// Call named method associated to popup bool GridColourPopup::callMethod(QString methodName, ReturnValue& rv) { bool result = true; if (methodName == "TEST") return true; else if (methodName == "currentColour") { QColor newColor = ui.ColourWidget->currentColour(); double colour[4]; colour[0] = newColor.redF(); colour[1] = newColor.greenF(); colour[2] = newColor.blueF(); colour[3] = newColor.alphaF(); rv.setArray(VTypes::DoubleData, colour, 4); return true; } else if (methodName == "setCurrentColour") { bool success; QColor newColour; newColour.setRedF(rv.asDouble(0, success)); if (success) newColour.setGreenF(rv.asDouble(1, success)); if (success) newColour.setBlueF(rv.asDouble(2, success)); if (success) newColour.setAlphaF(rv.asDouble(3, success)); if (!success) { printf("Failed to get colour information from supplied ReturnValue.\n"); return false; } setCurrentColour(newColour); updateParentButtonIcon(newColour); return true; } else if (methodName == "hideEvent") { updateParentButtonIcon(ui.ColourWidget->currentColour()); return true; } else { printf("No method called '%s' is available in this popup.\n", qPrintable(methodName)); result = false; } return result; }