Skip to content
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
5 changes: 5 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Files: .github/*
Copyright: None
License: CC0-1.0

# config
Files: config.h.in
Copyright: None
License: CC0-1.0

# gitignore
Files: .gitignore
Copyright: None
Expand Down
35 changes: 29 additions & 6 deletions src/music-player/mainFrame/footerwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd.
// Copyright (C) 2020 ~ 2026 Uniontech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
Expand All @@ -15,12 +15,13 @@
#include <QDBusReply>
#include <QGSettings>
#include <QFrame>
#include <QShortcut>

Check warning on line 18 in src/music-player/mainFrame/footerwidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QShortcut> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QFileInfo>

Check warning on line 19 in src/music-player/mainFrame/footerwidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QFileInfo> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTimer>

Check warning on line 20 in src/music-player/mainFrame/footerwidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDir>

Check warning on line 21 in src/music-player/mainFrame/footerwidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDir> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <DHiDPIHelper>

Check warning on line 23 in src/music-player/mainFrame/footerwidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DHiDPIHelper> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DPushButton>

Check warning on line 24 in src/music-player/mainFrame/footerwidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DPushButton> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DProgressBar>
#include <DFloatingWidget>
#include <DPalette>
Expand Down Expand Up @@ -927,13 +928,35 @@

void FooterWidget::slotFlushBackground()
{
QImage cover = QImage(":/icons/deepin/builtin/actions/info_cover_142px.svg");
QString imagesDirPath = Global::cacheDir() + "/images/" + Player::getInstance()->getActiveMeta().hash + ".jpg";
auto clearBackground = [this]() {
m_forwardWidget->setSourceImage(QImage());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段代码出现了两次,建议:提取为辅助函数或使用 lambda

m_forwardWidget->update();
};

QString cacheDir = Global::cacheDir();
if (cacheDir.isEmpty()) {
qWarning() << "Cache directory is invalid, clearing background";
clearBackground();
return;
}

QString imagesDirPath = QDir(cacheDir).filePath(
QString("images/%1.jpg").arg(Player::getInstance()->getActiveMeta().hash)
);

QFileInfo file(imagesDirPath);
if (file.exists()) {
cover = QImage(Global::cacheDir() + "/images/" + Player::getInstance()->getActiveMeta().hash + ".jpg");
if (!file.exists()) {
clearBackground();
return;
}


QImage cover(imagesDirPath);
if (cover.isNull() || cover.size().isEmpty()) {
qWarning() << "Failed to load cover image or invalid size:" << imagesDirPath;
clearBackground();
return;
}

double windowScale = (width() * 1.0) / height();
int imageWidth = static_cast<int>(cover.height() * windowScale);
QImage coverImage;
Expand Down
Loading