| 1024 | } |
| 1025 | |
| 1026 | void EffectStackView::constructBuildinWidget() |
| 1027 | { |
| 1028 | // Add Flip widget |
| 1029 | m_flipH = new QPushButton(this); |
| 1030 | m_flipH->setToolTip(i18n("Horizontal Flip")); |
| 1031 | m_flipH->setIcon(QIcon::fromTheme("object-flip-horizontal")); |
| 1032 | m_flipH->setCheckable(true); |
| 1033 | m_flipH->setFlat(true); |
| 1034 | |
| 1035 | m_flipV = new QPushButton(this); |
| 1036 | m_flipV->setToolTip(i18n("Vertical Flip")); |
| 1037 | m_flipV->setIcon(QIcon::fromTheme("object-flip-vertical")); |
| 1038 | m_flipV->setCheckable(true); |
| 1039 | m_flipV->setFlat(true); |
| 1040 | |
| 1041 | QHBoxLayout *lay = new QHBoxLayout; |
| 1042 | lay->addWidget(m_flipH); |
| 1043 | lay->addWidget(m_flipV); |
| 1044 | |
| 1045 | // Add background remover |
| 1046 | lay->addStretch(10); |
| 1047 | m_removeBg = new QPushButton(i18n("Remove Background"), this); |
| 1048 | m_removeBg->setToolTip(i18n("Remove background using AI model")); |
| 1049 | m_removeBg->setCheckable(true); |
| 1050 | m_samProgressBar = new QProgressBar(this); |
| 1051 | m_samProgressBar->setVisible(false); |
| 1052 | m_samAbortButton = new QToolButton(this); |
| 1053 | m_samAbortButton->setAutoRaise(true); |
| 1054 | m_samAbortButton->setIcon(QIcon::fromTheme(QStringLiteral("process-stop"))); |
| 1055 | m_samAbortButton->setVisible(false); |
| 1056 | lay->addWidget(m_removeBg); |
| 1057 | lay->addWidget(m_samAbortButton); |
| 1058 | lay->addWidget(m_samProgressBar); |
| 1059 | |
| 1060 | QFormLayout *layout = new QFormLayout(m_builtStack); |
| 1061 | m_flipLabel = new QLabel(i18n("Flip")); |
| 1062 | layout->addRow(m_flipLabel, lay); |
| 1063 | |
| 1064 | auto flipToggled = [this](bool checked, const QString &effectName) { |
| 1065 | if (checked) { |
| 1066 | QMap<QString, QString> params; |
| 1067 | params.insert(QStringLiteral("kdenlive:builtin"), QStringLiteral("1")); |
| 1068 | params.insert(QStringLiteral("kdenlive:hiddenbuiltin"), QStringLiteral("1")); |
| 1069 | m_model->appendEffect(effectName, false, params); |
| 1070 | } else { |
| 1071 | auto item = m_model->getAssetModelById(effectName); |
| 1072 | if (item) { |
| 1073 | std::shared_ptr<EffectItemModel> sourceEffect = std::static_pointer_cast<EffectItemModel>(item); |
| 1074 | m_model->removeEffect(sourceEffect); |
| 1075 | } |
| 1076 | } |
| 1077 | }; |
| 1078 | |
| 1079 | connect(m_flipH, &QPushButton::clicked, this, [flipToggled](bool checked) { flipToggled(checked, QStringLiteral("avfilter.hflip")); }); |
| 1080 | connect(m_flipV, &QPushButton::clicked, this, [flipToggled](bool checked) { flipToggled(checked, QStringLiteral("avfilter.vflip")); }); |
| 1081 | connect(m_removeBg, &QPushButton::clicked, this, &EffectStackView::launchObjectMask); |
| 1082 | connect(m_samAbortButton, &QToolButton::clicked, this, &EffectStackView::abortSam); |
| 1083 |
nothing calls this directly
no test coverage detected