Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Init type error / disable drag in processing. #104

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions libimageviewer/service/aimodelservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ QString AIModelService::imageProcessing(const QString &filePath, int modelID, co
ptr->state = Loading;
dptr->enhanceCache.insert(ptr->output, ptr);

qInfo() << QString("Call enhance processing %1, %2").arg(dptr->lastOutput).arg(modelID);
qInfo() << QString("Call enhance processing %1, %2").arg(dptr->lastOutput).arg(model);

QFuture<EnhancePtr> f = QtConcurrent::run([=]() -> EnhancePtr {
if (AIModelService::Cancel == ptr->state.loadAcquire()) {
Expand Down Expand Up @@ -582,7 +582,11 @@ void AIModelService::timerEvent(QTimerEvent *e)
// 触发超时
dptr->stopDBusTimer();
// 获取最近的输出图片
onDBusEnhanceEnd(dptr->lastOutput, AIModelServiceData::DBusFailed);
auto ptr = dptr->enhanceCache.value(dptr->lastOutput);
if (ptr) {
ptr->state.storeRelease(AIModelService::LoadTimeout);
Q_EMIT enhanceEnd(ptr->source, ptr->output, LoadFailed);
}
}

QObject::timerEvent(e);
Expand Down Expand Up @@ -706,7 +710,7 @@ bool AIModelServiceData::sendImageEnhance(const QString &source, const QString &
bool ret = reply.value().toBool();

if (!ret) {
qWarning() << QString("[Enhance DBus] Call %1 error: value(%2)").arg(s_EnhanceProcMethod).arg(ret);
qWarning() << QString("[Enhance DBus] Call %1 error: value(%2)").arg(procMethod).arg(ret);
}
return ret;
}
Expand All @@ -732,7 +736,8 @@ void AIModelService::onDBusEnhanceEnd(const QString &output, int error)
}

State state = static_cast<State>(ptr->state.loadAcquire());
if (Cancel == state) {
if (Cancel == state
|| LoadTimeout == state) {
// 处理终止,不继续处理
return;
} else if (Loading != state) {
Expand Down
7 changes: 7 additions & 0 deletions libimageviewer/viewpanel/contents/imgviewlistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ void LibImgViewListView::slotCurrentImgFlush(QPixmap pix, const QSize &originalS
data.imgOriginalWidth = originalSize.width();
data.imgOriginalHeight = originalSize.height();
data.image = pix.toImage();

// FIX:暂时修复,用于解决某些场景下初始化,图片全数据还未处理完成(多线程处理)
// data.imageType 还未设置的情况
if (data.imageType == imageViewerSpace::ImageTypeBlank) {
data.imageType = LibUnionImage_NameSpace::getImageType(data.path);
}

QVariant meta;
meta.setValue(data);
m_model->setData(currentIndex, meta, Qt::DisplayRole);
Expand Down
23 changes: 14 additions & 9 deletions libimageviewer/viewpanel/scen/imagegraphicsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1526,42 +1526,47 @@ void LibImageGraphicsView::addLoadSpinner(bool enhanceImage)
m_spinner = new DSpinner(this);
m_spinner->setFixedSize(SPINNER_SIZE);

QWidget *w = new QWidget(this);
w->setFixedSize(SPINNER_SIZE);
m_spinnerCtx = new QWidget(this);
m_spinnerCtx->setFixedSize(SPINNER_SIZE);
QVBoxLayout *hLayout = new QVBoxLayout;
hLayout->setMargin(0);
hLayout->setSpacing(0);
hLayout->addWidget(m_spinner, 0, Qt::AlignCenter);

// 图像增强增加文案,默认隐藏
w->setFixedWidth(300);
w->setFixedHeight(70);
m_spinnerLabel = new QLabel(w);
m_spinnerCtx->setFixedWidth(300);
m_spinnerCtx->setFixedHeight(70);
m_spinnerLabel = new QLabel(m_spinnerCtx);
m_spinnerLabel->setText(tr("AI retouching in progress, please wait..."));
m_spinnerLabel->setVisible(false);
hLayout->addWidget(m_spinnerLabel, 1, Qt::AlignBottom | Qt::AlignHCenter);

w->setLayout(hLayout);
m_spinnerCtx->setLayout(hLayout);

if (!this->layout()) {
QVBoxLayout *lay = new QVBoxLayout;
lay->setAlignment(Qt::AlignCenter);
this->setLayout(lay);
}
this->layout()->addWidget(w);
this->layout()->addWidget(m_spinnerCtx);
}

m_spinnerLabel->setVisible(enhanceImage);
m_spinner->start();

m_spinnerCtx->setVisible(true);
m_spinner->setVisible(true);
m_spinner->start();
m_spinnerLabel->setVisible(enhanceImage);
}

/**
@brief 隐藏加载图标和提示
*/
void LibImageGraphicsView::hideSpinner()
{
if (m_spinnerCtx) {
m_spinnerCtx->hide();
}

if (m_spinner) {
m_spinner->stop();
m_spinner->hide();
Expand Down
3 changes: 2 additions & 1 deletion libimageviewer/viewpanel/scen/imagegraphicsview.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ private slots:
bool m_isFistOpen = true;

//加载旋转
DSpinner *m_spinner{nullptr};
QWidget *m_spinnerCtx = nullptr; // 旋转控制窗口
DSpinner *m_spinner = nullptr;
QLabel *m_spinnerLabel = nullptr;
int TITLEBAR_HEIGHT = 50;

Expand Down
21 changes: 14 additions & 7 deletions libimageviewer/viewpanel/viewpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,13 +1436,6 @@
slotBottomMove();
}

bool LibViewPanel::event(QEvent *e)
{


return QFrame::event(e);
}

bool LibViewPanel::slotOcrPicture()
{
if (!m_ocrInterface) {
Expand Down Expand Up @@ -2114,6 +2107,10 @@

void LibViewPanel::dragEnterEvent(QDragEnterEvent *event)
{
if (m_AIEnhancing) {
return;
}

const QMimeData *mimeData = event->mimeData();
if (!pluginUtils::base::checkMimeData(mimeData)) {
return;
Expand All @@ -2129,8 +2126,12 @@
event->accept();
}

void LibViewPanel::dropEvent(QDropEvent *event)

Check warning on line 2129 in libimageviewer/viewpanel/viewpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'dropEvent' is never used.
{
if (m_AIEnhancing) {
return;
}

QList<QUrl> urls = event->mimeData()->urls();
if (urls.isEmpty()) {
return;
Expand Down Expand Up @@ -2331,6 +2332,12 @@
{
m_AIEnhancing = true;

// 复位界面,隐藏导航窗口,显示标题/工具栏
if (m_nav->isVisible()) {
m_nav->setVisible(false);
}
Q_EMIT m_view->sigImageOutTitleBar(false);

blockInputControl(true);
setAIBtnVisible(false);
}
Expand Down
2 changes: 0 additions & 2 deletions libimageviewer/viewpanel/viewpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ public slots:
void slotChangeShowTopBottom();

protected:
bool event(QEvent *e) override;

void resizeEvent(QResizeEvent *e) override;
void showEvent(QShowEvent *e) override;
void paintEvent(QPaintEvent *event) override;
Expand Down