This commit is contained in:
2026-05-15 00:06:14 +08:00
parent 83c2c26e89
commit b4c7697e8a
6 changed files with 174 additions and 45 deletions
+62 -5
View File
@@ -3,13 +3,18 @@
#include <QDialogButtonBox>
#include <QFrame>
#include <QLabel>
#include <QMessageBox>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QRadioButton>
#include <QStackedWidget>
#include <QVBoxLayout>
namespace {
const QString kDefaultFluxInpaintPrompt = QStringLiteral(
"这是一幅中国山水画的一部分,mask是被我去除的一个人物,现在需要在原来的位置填充与周围画布连贯的背景");
QPushButton* makeAlgoButton(const QString& title, QWidget* parent) {
auto* btn = new QPushButton(parent);
btn->setCheckable(false);
@@ -41,6 +46,13 @@ BlackholeResolveDialog::BlackholeResolveDialog(const QString& blackholeName, QWi
m_pages->setCurrentWidget(m_pageSelect);
}
QString BlackholeResolveDialog::inpaintModelKey() const {
if (m_radioFlux && m_radioFlux->isChecked()) {
return QStringLiteral("flux_fill");
}
return QStringLiteral("lama");
}
QString BlackholeResolveDialog::promptText() const {
return m_promptEdit ? m_promptEdit->toPlainText().trimmed() : QString();
}
@@ -104,7 +116,7 @@ void BlackholeResolveDialog::buildDetailPage() {
auto* pLay = new QVBoxLayout(panel);
pLay->setSpacing(8);
auto* tip = new QLabel(QStringLiteral("应用后在画布拖取样"), panel);
auto* tip = new QLabel(QStringLiteral("在画布拖取样。"), panel);
tip->setStyleSheet("color: palette(mid);");
pLay->addWidget(tip);
cLay->addWidget(panel);
@@ -116,13 +128,13 @@ void BlackholeResolveDialog::buildDetailPage() {
{
auto* oLay = new QVBoxLayout(m_originalDetail);
oLay->setSpacing(8);
auto* desc = new QLabel(QStringLiteral("仅隐藏黑洞,不改动背景文件"), m_originalDetail);
auto* desc = new QLabel(QStringLiteral("不修改背景原图"), m_originalDetail);
desc->setWordWrap(true);
oLay->addWidget(desc);
oLay->addStretch(1);
}
// 详情页 C:模型补全(提示词)
// 详情页 C:模型补全
m_modelDetail = new QWidget(m_algoDetails);
{
auto* mLay = new QVBoxLayout(m_modelDetail);
@@ -133,11 +145,49 @@ void BlackholeResolveDialog::buildDetailPage() {
auto* pLay = new QVBoxLayout(panel);
pLay->setSpacing(8);
m_radioLama = new QRadioButton(QStringLiteral("LaMa"), panel);
m_radioFlux = new QRadioButton(QStringLiteral("FLUX Fill"), panel);
m_radioLama->setChecked(true);
pLay->addWidget(m_radioLama);
pLay->addWidget(m_radioFlux);
m_promptLabel = new QLabel(QStringLiteral("提示词"), panel);
pLay->addWidget(m_promptLabel);
m_promptEdit = new QPlainTextEdit(panel);
m_promptEdit->setPlaceholderText(QStringLiteral("可选"));
m_promptEdit->setMinimumHeight(72);
m_promptLabel->setVisible(false);
m_promptEdit->setVisible(false);
pLay->addWidget(m_promptEdit);
auto syncPromptUi = [this]() {
if (!m_promptEdit || !m_promptLabel) {
return;
}
const bool flux = m_radioFlux && m_radioFlux->isChecked();
m_promptLabel->setVisible(flux);
m_promptEdit->setVisible(flux);
if (flux) {
m_promptEdit->setEnabled(true);
if (m_promptEdit->toPlainText().trimmed().isEmpty()) {
m_promptEdit->setPlainText(kDefaultFluxInpaintPrompt);
}
} else {
m_promptEdit->setEnabled(false);
}
};
connect(m_radioLama, &QRadioButton::toggled, this, [syncPromptUi](bool on) {
if (on) {
syncPromptUi();
}
});
connect(m_radioFlux, &QRadioButton::toggled, this, [syncPromptUi](bool on) {
if (on) {
syncPromptUi();
}
});
syncPromptUi();
mLay->addWidget(panel);
mLay->addStretch(1);
}
@@ -154,7 +204,14 @@ void BlackholeResolveDialog::buildDetailPage() {
connect(btnBack, &QPushButton::clicked, this, [this]() {
m_pages->setCurrentWidget(m_pageSelect);
});
connect(btnApply, &QPushButton::clicked, this, &QDialog::accept);
connect(btnApply, &QPushButton::clicked, this, [this]() {
if (m_selectedAlgorithm == Algorithm::ModelInpaint && m_radioFlux && m_radioFlux->isChecked() &&
promptText().isEmpty()) {
QMessageBox::warning(this, QStringLiteral("模型补全"), QStringLiteral("请填写提示词。"));
return;
}
accept();
});
connect(btnCancel, &QPushButton::clicked, this, &QDialog::reject);
layout->addWidget(btns);