git repos / SagoImageBrowser

blame: src/thumbnailworker.h

normal view · raw

14cf904f Poul Sander 2026-06-22 18:18 1
/*
14cf904f Poul Sander 2026-06-22 18:18 2
MIT License
14cf904f Poul Sander 2026-06-22 18:18 3
14cf904f Poul Sander 2026-06-22 18:18 4
Copyright (c) 2026 Poul Sander
14cf904f Poul Sander 2026-06-22 18:18 5
14cf904f Poul Sander 2026-06-22 18:18 6
Permission is hereby granted, free of charge, to any person obtaining a copy
14cf904f Poul Sander 2026-06-22 18:18 7
of this software and associated documentation files (the "Software"), to deal
14cf904f Poul Sander 2026-06-22 18:18 8
in the Software without restriction, including without limitation the rights
14cf904f Poul Sander 2026-06-22 18:18 9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14cf904f Poul Sander 2026-06-22 18:18 10
copies of the Software, and to permit persons to whom the Software is
14cf904f Poul Sander 2026-06-22 18:18 11
furnished to do so, subject to the following conditions:
14cf904f Poul Sander 2026-06-22 18:18 12
14cf904f Poul Sander 2026-06-22 18:18 13
The above copyright notice and this permission notice shall be included in all
14cf904f Poul Sander 2026-06-22 18:18 14
copies or substantial portions of the Software.
14cf904f Poul Sander 2026-06-22 18:18 15
14cf904f Poul Sander 2026-06-22 18:18 16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14cf904f Poul Sander 2026-06-22 18:18 17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14cf904f Poul Sander 2026-06-22 18:18 18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14cf904f Poul Sander 2026-06-22 18:18 19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14cf904f Poul Sander 2026-06-22 18:18 20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
14cf904f Poul Sander 2026-06-22 18:18 21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
14cf904f Poul Sander 2026-06-22 18:18 22
SOFTWARE.
14cf904f Poul Sander 2026-06-22 18:18 23
14cf904f Poul Sander 2026-06-22 18:18 24
*/
14cf904f Poul Sander 2026-06-22 18:18 25
cec3b5da Poul Sander 2026-02-19 19:17 26
#pragma once
cec3b5da Poul Sander 2026-02-19 19:17 27
ac476ca8 Poul Sander 2026-05-18 16:47 28
#include "thumbnailcache.h"
ac476ca8 Poul Sander 2026-05-18 16:47 29
80a9926d Poul Sander 2026-05-19 20:28 30
#include <QByteArray>
cec3b5da Poul Sander 2026-02-19 19:17 31
#include <QRunnable>
cec3b5da Poul Sander 2026-02-19 19:17 32
#include <QObject>
6fcd6c90 Poul Sander 2026-02-19 21:12 33
#include <QImage>
6fcd6c90 Poul Sander 2026-02-19 21:12 34
#include <atomic>
cec3b5da Poul Sander 2026-02-19 19:17 35
cec3b5da Poul Sander 2026-02-19 19:17 36
class ThumbnailWorker : public QObject, public QRunnable
cec3b5da Poul Sander 2026-02-19 19:17 37
{
cec3b5da Poul Sander 2026-02-19 19:17 38
    Q_OBJECT
cec3b5da Poul Sander 2026-02-19 19:17 39
cec3b5da Poul Sander 2026-02-19 19:17 40
public:
80a9926d Poul Sander 2026-05-19 20:28 41
    ThumbnailWorker(const QByteArray &path,
6fcd6c90 Poul Sander 2026-02-19 21:12 42
                    int row,
ac476ca8 Poul Sander 2026-05-18 16:47 43
                    ThumbnailCache::Size size,
6fcd6c90 Poul Sander 2026-02-19 21:12 44
                    std::atomic_bool *cancelFlag);
cec3b5da Poul Sander 2026-02-19 19:17 45
cec3b5da Poul Sander 2026-02-19 19:17 46
    void run() override;
cec3b5da Poul Sander 2026-02-19 19:17 47
cec3b5da Poul Sander 2026-02-19 19:17 48
signals:
6fcd6c90 Poul Sander 2026-02-19 21:12 49
    void finished(int row, const QImage &image);
cec3b5da Poul Sander 2026-02-19 19:17 50
cec3b5da Poul Sander 2026-02-19 19:17 51
private:
80a9926d Poul Sander 2026-05-19 20:28 52
    QByteArray m_path;
cec3b5da Poul Sander 2026-02-19 19:17 53
    int m_row;
ac476ca8 Poul Sander 2026-05-18 16:47 54
    ThumbnailCache::Size m_size;
6fcd6c90 Poul Sander 2026-02-19 21:12 55
    std::atomic_bool *m_cancelFlag;
cec3b5da Poul Sander 2026-02-19 19:17 56
};
1970-01-01 00:00 57