MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / setPenColor

Method setPenColor

src/api/UBWidgetUniboardAPI.cpp:150–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148
149
150void UBWidgetUniboardAPI::setPenColor(const QString& penColor)
151{
152 if (UBApplication::boardController->activeScene() != mScene.lock())
153 return;
154
155 UBSettings* settings = UBSettings::settings();
156
157 bool conversionState = false;
158
159 int index = penColor.toInt(&conversionState) - 1;
160
161 if (conversionState && index > 0 && index <= 4)
162 {
163 UBApplication::boardController->setPenColorOnDarkBackground(settings->penColors(true).at(index - 1));
164 UBApplication::boardController->setPenColorOnLightBackground(settings->penColors(false).at(index - 1));
165 }
166 else
167 {
168#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
169 QColor svgColor = QColor::fromString(penColor);
170#else
171 QColor svgColor;
172 svgColor.setNamedColor(penColor);
173#endif
174 if (svgColor.isValid())
175 {
176 UBApplication::boardController->setPenColorOnDarkBackground(svgColor);
177 UBApplication::boardController->setPenColorOnLightBackground(svgColor);
178 }
179 }
180}
181
182
183void UBWidgetUniboardAPI::setMarkerColor(const QString& penColor)

Callers 4

initUniboardFunction · 0.45
setNewColorFunction · 0.45
upSelectorFunction · 0.45
colorSelectedMethod · 0.45

Calls 6

activeSceneMethod · 0.80
lockMethod · 0.80
penColorsMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected