diff --git a/MainWindow/UpdateVideoThumbnail.cpp b/MainWindow/UpdateVideoThumbnail.cpp
index 60968a43..42e8a20c 100644
--- a/MainWindow/UpdateVideoThumbnail.cpp
+++ b/MainWindow/UpdateVideoThumbnail.cpp
@@ -1,89 +1,89 @@
/* Copyright (C) 2012-2020 The KPhotoAlbum Development Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include "UpdateVideoThumbnail.h"
#include "Window.h"
#include
#include
#include
#include
#include
-namespace MainWindow
+namespace
{
-void UpdateVideoThumbnail::useNext(const DB::FileNameList &list)
+DB::FileName nextExistingImage(const DB::FileName &fileName, int frame, int direction)
{
- update(list, +1);
-}
-
-void UpdateVideoThumbnail::usePrevious(const DB::FileNameList &list)
-{
- update(list, -1);
-}
-
-void UpdateVideoThumbnail::update(const DB::FileNameList &list, int direction)
-{
- for (const DB::FileName &fileName : list) {
- if (Utilities::isVideo(fileName))
- update(fileName, direction);
+ for (int i = 1; i < 10; ++i) {
+ const int nextIndex = (frame + 10 + direction * i) % 10;
+ const DB::FileName file = BackgroundJobs::HandleVideoThumbnailRequestJob::frameName(fileName, nextIndex);
+ if (file.exists())
+ return file;
}
+ Q_ASSERT(false && "We should always find at least the current frame");
+ return DB::FileName();
}
-void UpdateVideoThumbnail::update(const DB::FileName &fileName, int direction)
+void update(const DB::FileName &fileName, int direction)
{
const DB::FileName baseImageName = BackgroundJobs::HandleVideoThumbnailRequestJob::pathForRequest(fileName);
QImage baseImage(baseImageName.absolute());
int frame = 0;
for (; frame < 10; ++frame) {
const DB::FileName frameFile = BackgroundJobs::HandleVideoThumbnailRequestJob::frameName(fileName, frame);
QImage frameImage(frameFile.absolute());
if (frameImage.isNull())
continue;
if (baseImage == frameImage) {
break;
}
}
const DB::FileName newImageName = nextExistingImage(fileName, frame, direction);
Utilities::copyOrOverwrite(newImageName.absolute(), baseImageName.absolute());
QImage image = QImage(newImageName.absolute()).scaled(ThumbnailView::CellGeometry::preferredIconSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
MainWindow::Window::theMainWindow()->thumbnailCache()->insert(fileName, image);
MainWindow::Window::theMainWindow()->reloadThumbnails();
}
-DB::FileName UpdateVideoThumbnail::nextExistingImage(const DB::FileName &fileName, int frame, int direction)
+void update(const DB::FileNameList &list, int direction)
{
- for (int i = 1; i < 10; ++i) {
- const int nextIndex = (frame + 10 + direction * i) % 10;
- const DB::FileName file = BackgroundJobs::HandleVideoThumbnailRequestJob::frameName(fileName, nextIndex);
- if (file.exists())
- return file;
+ for (const DB::FileName &fileName : list) {
+ if (Utilities::isVideo(fileName))
+ update(fileName, direction);
}
- Q_ASSERT(false && "We should always find at least the current frame");
- return DB::FileName();
+}
+} // namespace
+
+void MainWindow::UpdateVideoThumbnail::useNext(const DB::FileNameList &list)
+{
+ update(list, +1);
+}
+
+void MainWindow::UpdateVideoThumbnail::usePrevious(const DB::FileNameList &list)
+{
+ update(list, -1);
}
-} // namespace MainWindow
// vi:expandtab:tabstop=4 shiftwidth=4:
diff --git a/MainWindow/UpdateVideoThumbnail.h b/MainWindow/UpdateVideoThumbnail.h
index d113d542..22cac318 100644
--- a/MainWindow/UpdateVideoThumbnail.h
+++ b/MainWindow/UpdateVideoThumbnail.h
@@ -1,43 +1,37 @@
-/* Copyright 2012 Jesper K. Pedersen
+/* Copyright 2012-2020 The KPhotoAlbum Development Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#ifndef MAINWINDOW_UPDATEVIDEOTHUMBNAIL_H
#define MAINWINDOW_UPDATEVIDEOTHUMBNAIL_H
#include
namespace MainWindow
{
-class UpdateVideoThumbnail
+namespace UpdateVideoThumbnail
{
-public:
- static void useNext(const DB::FileNameList &);
- static void usePrevious(const DB::FileNameList &);
-
-private:
- static void update(const DB::FileNameList &, int direction);
- static void update(const DB::FileName &fileName, int direction);
- static DB::FileName nextExistingImage(const DB::FileName &fileName, int frame, int direction);
-};
+ void useNext(const DB::FileNameList &);
+ void usePrevious(const DB::FileNameList &);
+}
} // namespace MainWindow
#endif // MAINWINDOW_UPDATEVIDEOTHUMBNAIL_H
// vi:expandtab:tabstop=4 shiftwidth=4: