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: [tip] Prompt to add incorrect image information #91

Merged
merged 1 commit into from
Oct 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ void SlideshowScreenSaver::onUpdateImage()
}

m_pixmap.reset(new QPixmap(m_playOrder.value(m_currentIndex)));

if (m_pixmap && !m_pixmap->isNull()) {
m_invaildPath.clear();
} else {
m_invaildPath = m_playOrder.value(m_currentIndex);
qWarning() << "There is an issue with the format of the image" << m_invaildPath;
}
scaledPixmap();
update();
return;
Expand Down Expand Up @@ -139,7 +146,7 @@ void SlideshowScreenSaver::showDefaultBlack(QPaintEvent *event)
QPainter pa(&pip);
pa.setPen(Qt::white);
pa.drawText(pip.rect(), Qt::AlignCenter,
tr("Please select a valid image path in the Custom Screensaver \"Screensaver Setting\"."));
tr("Please select a valid image path in the Custom Screensaver \"Screensaver Setting\".") + m_invaildPath);

const auto &pix = pip.scaled(mapFromHandle(this->geometry().size()), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
QPainter p(this);
Expand Down Expand Up @@ -187,11 +194,8 @@ void SlideshowScreenSaver::loadSlideshowImages()
int idx = 1;
for (auto info : infoList) {
if (info.size() < IMAGE_MAX_SIZE && validSuffix.contains(info.suffix(), Qt::CaseInsensitive)) {
QScopedPointer<QPixmap> pixmapPointer(new QPixmap(info.absoluteFilePath()));
if (pixmapPointer && !pixmapPointer->isNull()){
m_imagefiles.append(info.absoluteFilePath()); // 记录图片列表
m_playOrder.insert(idx, info.absoluteFilePath());
}
m_imagefiles.append(info.absoluteFilePath()); // 记录图片列表
m_playOrder.insert(idx, info.absoluteFilePath());
idx++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private slots:
QScopedPointer<QTimer> m_timer;

QString m_path; // 图片路径
QString m_invaildPath; // 无效图片路径提示
bool m_shuffle { false }; // 随机轮播
int m_intervalTime { 0 }; // 轮播间隔
int m_currentIndex { 0 };
Expand Down
Loading