新增模型补全空洞
This commit is contained in:
68
client/gui/dialogs/InpaintPreviewDialog.cpp
Normal file
68
client/gui/dialogs/InpaintPreviewDialog.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "dialogs/InpaintPreviewDialog.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QScrollArea>
|
||||
#include <QSplitter>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
static QLabel* makeImageLabel(QWidget* parent) {
|
||||
auto* lab = new QLabel(parent);
|
||||
lab->setBackgroundRole(QPalette::Base);
|
||||
lab->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||
lab->setScaledContents(false);
|
||||
lab->setAlignment(Qt::AlignCenter);
|
||||
return lab;
|
||||
}
|
||||
|
||||
static QScrollArea* wrapScroll(QWidget* child, QWidget* parent) {
|
||||
auto* sc = new QScrollArea(parent);
|
||||
sc->setWidget(child);
|
||||
sc->setWidgetResizable(true);
|
||||
sc->setBackgroundRole(QPalette::Dark);
|
||||
return sc;
|
||||
}
|
||||
|
||||
InpaintPreviewDialog::InpaintPreviewDialog(const QString& title, QWidget* parent)
|
||||
: QDialog(parent) {
|
||||
setModal(true);
|
||||
setMinimumSize(860, 520);
|
||||
setWindowTitle(title);
|
||||
|
||||
auto* root = new QVBoxLayout(this);
|
||||
root->setContentsMargins(8, 8, 8, 8);
|
||||
root->setSpacing(8);
|
||||
|
||||
m_beforeLabel = makeImageLabel(this);
|
||||
m_afterLabel = makeImageLabel(this);
|
||||
m_beforeScroll = wrapScroll(m_beforeLabel, this);
|
||||
m_afterScroll = wrapScroll(m_afterLabel, this);
|
||||
|
||||
auto* splitter = new QSplitter(Qt::Horizontal, this);
|
||||
splitter->addWidget(m_beforeScroll);
|
||||
splitter->addWidget(m_afterScroll);
|
||||
splitter->setStretchFactor(0, 1);
|
||||
splitter->setStretchFactor(1, 1);
|
||||
root->addWidget(splitter, 1);
|
||||
|
||||
auto* btns = new QDialogButtonBox(this);
|
||||
btns->addButton(QStringLiteral("取消"), QDialogButtonBox::RejectRole);
|
||||
btns->addButton(QStringLiteral("接受并写回"), QDialogButtonBox::AcceptRole);
|
||||
connect(btns, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(btns, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
root->addWidget(btns);
|
||||
}
|
||||
|
||||
void InpaintPreviewDialog::setImages(const QImage& before, const QImage& after) {
|
||||
if (m_beforeLabel) {
|
||||
m_beforeLabel->setPixmap(QPixmap::fromImage(before));
|
||||
m_beforeLabel->adjustSize();
|
||||
}
|
||||
if (m_afterLabel) {
|
||||
m_afterLabel->setPixmap(QPixmap::fromImage(after));
|
||||
m_afterLabel->adjustSize();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user