| 282 | // ───────────────────────────────────── GradientEditorDialog ─────────────── |
| 283 | |
| 284 | GradientEditorDialog::GradientEditorDialog(const QString& tokenName, |
| 285 | const ThemeGradient& initial, |
| 286 | QWidget* parent) |
| 287 | : PersistentDialog(QStringLiteral("Edit gradient — %1").arg(tokenName), |
| 288 | QStringLiteral("GradientEditorDialogGeometry"), |
| 289 | parent), |
| 290 | m_tokenName(tokenName), m_gradient(initial) |
| 291 | { |
| 292 | theme::setContainer(this, QStringLiteral("dialog/gradientEditor")); |
| 293 | setModal(true); |
| 294 | setMinimumSize(520, 420); |
| 295 | applyAppTheme(this); |
| 296 | // Inherit the global FramelessWindow setting so the chrome matches |
| 297 | // whatever the main window + Theme Editor are showing. PersistentDialog |
| 298 | // owns the title-bar widget, so all we do is flip the mode here. |
| 299 | setFramelessMode(AppSettings::instance() |
| 300 | .value("FramelessWindow", "True").toString() == "True"); |
| 301 | |
| 302 | auto* root = new QVBoxLayout(bodyWidget()); |
| 303 | root->setContentsMargins(10, 10, 10, 10); |
| 304 | root->setSpacing(8); |
| 305 | |
| 306 | auto* hdr = new QLabel(QStringLiteral( |
| 307 | "<b>%1</b><br>Click a stop to recolor it, drag along the strip " |
| 308 | "to reposition, right-click to delete, or double-click an empty " |
| 309 | "spot to add a new stop.").arg(tokenName.toHtmlEscaped()), bodyWidget()); |
| 310 | hdr->setWordWrap(true); |
| 311 | root->addWidget(hdr); |
| 312 | |
| 313 | m_strip = new GradientStrip(bodyWidget()); |
| 314 | root->addWidget(m_strip); |
| 315 | |
| 316 | // Stop list + per-stop buttons row. |
| 317 | auto* listRow = new QHBoxLayout; |
| 318 | m_stopList = new QListWidget(bodyWidget()); |
| 319 | m_stopList->setIconSize(QSize(18, 18)); |
| 320 | m_stopList->setSelectionMode(QAbstractItemView::SingleSelection); |
| 321 | m_stopList->setMinimumHeight(140); |
| 322 | listRow->addWidget(m_stopList, 1); |
| 323 | |
| 324 | auto* stopBtnCol = new QVBoxLayout; |
| 325 | auto* addBtn = new QPushButton(QStringLiteral("+ Add stop"), bodyWidget()); |
| 326 | auto* delBtn = new QPushButton(QStringLiteral("− Delete stop"), bodyWidget()); |
| 327 | auto* editBtn = new QPushButton(QStringLiteral("Edit color…"), bodyWidget()); |
| 328 | stopBtnCol->addWidget(addBtn); |
| 329 | stopBtnCol->addWidget(delBtn); |
| 330 | stopBtnCol->addWidget(editBtn); |
| 331 | stopBtnCol->addStretch(1); |
| 332 | listRow->addLayout(stopBtnCol); |
| 333 | root->addLayout(listRow); |
| 334 | |
| 335 | // Angle row — only meaningful for linear gradients. |
| 336 | auto* angleRow = new QHBoxLayout; |
| 337 | m_angleLabel = new QLabel(QStringLiteral("Angle:"), bodyWidget()); |
| 338 | angleRow->addWidget(m_angleLabel); |
| 339 | m_angleSpin = new QSpinBox(bodyWidget()); |
| 340 | m_angleSpin->setRange(0, 360); |
| 341 | m_angleSpin->setSuffix(QStringLiteral("°")); |
nothing calls this directly
no test coverage detected