| 450 | // VisionMLModelSelect |
| 451 | |
| 452 | VisionMLModelSelect::VisionMLModelSelect(QSharedPointer<VisionModels> models, |
| 453 | VisionMLTask task, |
| 454 | bool showFolderButton, |
| 455 | QWidget *parent) |
| 456 | : KisOptionCollectionWidgetWithHeader(i18n("Model"), parent) |
| 457 | , m_shared(std::move(models)) |
| 458 | , m_task(task) |
| 459 | { |
| 460 | QWidget *widget = new QWidget; |
| 461 | QHBoxLayout *layout = new QHBoxLayout(widget); |
| 462 | layout->setContentsMargins(0, 0, 0, 0); |
| 463 | |
| 464 | m_select = new QComboBox; |
| 465 | updateModels(); |
| 466 | updateModel(m_task, m_shared->modelName(m_task)); |
| 467 | connect(m_select, SIGNAL(currentIndexChanged(int)), this, SLOT(switchModel(int))); |
| 468 | connect(m_shared.get(), &VisionModels::modelNameChanged, this, &VisionMLModelSelect::updateModel); |
| 469 | layout->addWidget(m_select); |
| 470 | |
| 471 | if (showFolderButton) { |
| 472 | QToolButton *folderButton = new QToolButton; |
| 473 | folderButton->setIcon(KisIconUtils::loadIcon("document-open")); |
| 474 | folderButton->setFixedSize(24, 24); |
| 475 | folderButton->setToolTip(i18n("Open models folder")); |
| 476 | connect(folderButton, &QToolButton::clicked, this, &VisionMLModelSelect::openModelsFolder); |
| 477 | layout->addWidget(folderButton); |
| 478 | } |
| 479 | |
| 480 | m_fileWatcher = new QFileSystemWatcher(this); |
| 481 | m_fileWatcher->addPath(findModelPath(m_task)); |
| 482 | connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &VisionMLModelSelect::updateModels); |
| 483 | |
| 484 | setPrimaryWidget(widget); |
| 485 | } |
| 486 | |
| 487 | void VisionMLModelSelect::updateModels() |
| 488 | { |
nothing calls this directly
no test coverage detected