| 1 |
/* |
| 2 |
* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd. |
| 3 |
* |
| 4 |
* Author: ZhangYong <[email protected]> |
| 5 |
* |
| 6 |
* Maintainer: ZhangYong <[email protected]> |
| 7 |
* |
| 8 |
* This program is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* This program is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
#ifndef IMAGEDEMOTHREAD_H |
| 22 |
#define IMAGEDEMOTHREAD_H |
| 23 |
|
| 24 |
#include <unionimage.h> |
| 25 |
#include <QObject> |
| 26 |
#include <QVector> |
| 27 |
#include <QList> |
| 28 |
#include <QHash> |
| 29 |
#include <QRunnable> |
| 30 |
#include <QThreadPool> |
| 31 |
#include <QImage> |
| 32 |
#include <QDebug> |
| 33 |
#include <QTimer> |
| 34 |
|
| 35 |
struct RotateSaveRequest { |
| 36 |
double angel; |
| 37 |
QImage image; |
| 38 |
QString path; |
| 39 |
}; |
| 40 |
|
| 41 |
class RotateSaveThread : public QRunnable |
| 42 |
{ |
| 43 |
public: |
| 44 |
RotateSaveThread(); |
| 45 |
void setDatas(QHash<QString, RotateSaveRequest> requests_bar); |
| 46 |
protected: |
| 47 |
void run(); |
| 48 |
private: |
| 49 |
QVector<RotateSaveRequest> m_requests; |
| 50 |
}; |
| 51 |
|
| 52 |
class ImageDemoThreadControler : public QObject |
| 53 |
{ |
| 54 |
Q_OBJECT |
| 55 |
public: |
| 56 |
ImageDemoThreadControler(); |
| 57 |
~ImageDemoThreadControler(); |
| 58 |
signals: |
| 59 |
void updateRotate(int angel); |
| 60 |
public slots: |
| 61 |
/** |
| 62 |
* @brief addRotateAndSave |
| 63 |
* @param request |
| 64 |
* @param time_gap |
| 65 |
* @author DJH |
| 66 |
* 添加旋转请求队列,并设置队列清空等待时间,等待时间结束后,会执行队列所有命令 |
| 67 |
*/ |
| 68 |
void addRotateAndSave(RotateSaveRequest request, int time_gap); |
| 69 |
void startSave(); |
| 70 |
|
| 71 |
private: |
| 72 |
QTimer *wait; |
| 73 |
QThreadPool rotateThreadPool; |
| 74 |
//QList<RotateSaveThread *> rotateThreads; |
| 75 |
QHash<QString, RotateSaveRequest> NoRepeatRequest; |
| 76 |
}; |
| 77 |
|
| 78 |
#endif // IMAGEDEMOTHREAD_H |