| 1163 | // ──────────────────────────────────────────────────────── reset / OK ──── |
| 1164 | |
| 1165 | void TokenEditorWidget::onResetClicked() |
| 1166 | { |
| 1167 | if (m_currentToken.isEmpty()) return; |
| 1168 | auto& tm = ThemeManager::instance(); |
| 1169 | |
| 1170 | // Nested scope: Reset means "clear my override here" so the |
| 1171 | // scope falls back to inheriting from its parent. Mirrors the |
| 1172 | // right-click → Clear Override action on the scope-chain column |
| 1173 | // (ThemeEditorDialog::showTokenContextMenu). The previous |
| 1174 | // behaviour — loading the bundled factory value into the buffer |
| 1175 | // and writing a new override on OK — has been confusing here |
| 1176 | // since the v2 scope tree landed (per #3184). |
| 1177 | if (!m_activeContainerPath.isEmpty()) { |
| 1178 | if (!tm.isOverriddenAt(m_activeContainerPath, m_currentToken)) return; |
| 1179 | tm.removeOverride(m_activeContainerPath, m_currentToken); |
| 1180 | // Reload the editor's buffer + controls from the now-inherited |
| 1181 | // value so there's no stale pending edit. setToken clears |
| 1182 | // m_dirty / disables OK + Cancel internally. |
| 1183 | setToken(m_currentToken); |
| 1184 | // Trigger the parent dialog to repopulate the matching token-list |
| 1185 | // row so the scope-chain column flips to italic "inherited" and |
| 1186 | // the Value column shows the now-resolved value instead of the |
| 1187 | // stale override. onTokenEditedByEditor finds the row by token |
| 1188 | // key and calls populateRow on it. |
| 1189 | emit tokenChanged(m_currentToken); |
| 1190 | return; |
| 1191 | } |
| 1192 | |
| 1193 | // Root scope: existing behaviour — load the bundled factory value |
| 1194 | // into the edit buffer for the user to confirm via OK. |
| 1195 | if (!tm.hasFactoryValue(m_currentToken)) return; |
| 1196 | |
| 1197 | m_settingControlsFromToken = true; |
| 1198 | if (m_target == TargetScalarColor) { |
| 1199 | const QColor c = tm.factoryColor(m_currentToken); |
| 1200 | if (c.isValid()) { |
| 1201 | m_bufferColor = c; |
| 1202 | QSignalBlocker block(m_colorPicker); |
| 1203 | m_colorPicker->setColor(c); |
| 1204 | } |
| 1205 | } else if (m_target == TargetGradient) { |
| 1206 | const ThemeGradient g = tm.factoryGradient(m_currentToken); |
| 1207 | if (!g.stops.isEmpty()) { |
| 1208 | m_gradientBuf = g; |
| 1209 | QSignalBlocker bAngle(m_gradAngleSpin); |
| 1210 | m_gradAngleSpin->setValue(static_cast<int>( |
| 1211 | std::round(g.angle)) % 361); |
| 1212 | syncGradientStripAndList(); |
| 1213 | if (!m_gradientBuf.stops.isEmpty()) selectGradientStop(0); |
| 1214 | } |
| 1215 | } else if (m_target == TargetFontFamily) { |
| 1216 | const QString f = tm.factoryString(m_currentToken); |
| 1217 | if (!f.isEmpty()) { |
| 1218 | m_bufferFontFamily = f; |
| 1219 | QSignalBlocker block(m_fontCombo); |
| 1220 | m_fontCombo->setCurrentFont(QFont(f)); |
| 1221 | } |
| 1222 | } else if (m_target == TargetNumeric) { |
nothing calls this directly
no test coverage detected