2022-08-25 18:37:24 +08:00
|
|
|
#ifndef TOOLS_H
|
|
|
|
#define TOOLS_H
|
|
|
|
|
|
|
|
#include "devicepanel.h"
|
|
|
|
#include "wDevicesManager/ledcard.h"
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QBrush>
|
|
|
|
#include <QColor>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QImageReader>
|
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
extern "C"{
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
}
|
|
|
|
const QString str0_9[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
|
|
|
|
extern QWidget *gMainWin;
|
|
|
|
extern DevicePanel *gDevicePanel;
|
|
|
|
extern QList<LedCard*> *gSelCards;
|
|
|
|
extern QTextEdit *gFdResInfo;
|
|
|
|
extern QString gProgDir;
|
|
|
|
extern int gProgWidth;
|
|
|
|
extern int gProgHeight;
|
|
|
|
|
|
|
|
class Tools : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static Tools* getInstance();
|
|
|
|
static QNetworkAccessManager &netManager() {
|
|
|
|
static QNetworkAccessManager manager;
|
|
|
|
return manager;
|
|
|
|
};
|
|
|
|
static QRectF centerRect(qreal, qreal, int, int);
|
|
|
|
static QString addSufix(QString);
|
|
|
|
static void mergeFormat(QTextEdit *textEdit, const QTextCharFormat &format);
|
|
|
|
static QString videoInfo(QByteArray url, QImage &, int64_t *dur, AVCodecID *);
|
|
|
|
static QString audioInfo(QByteArray url, int64_t *dur);
|
|
|
|
static QString readErrStr(QImageReader::ImageReaderError);
|
|
|
|
static QString fileMd5(QString);
|
|
|
|
static void saveImg(const QString&, const QFontMetrics&, const QFont&, const QColor&, QJsonObject&, const QString&, const QString&);
|
|
|
|
static void saveImg2(const QString&, const QFontMetrics&, const QFont&, const QColor&, QJsonArray&, const QString&, const QString&);
|
|
|
|
static QColor int2Color(int value);
|
|
|
|
static int color2Int(const QColor& color);
|
|
|
|
static QBrush getBrush(const QColor& color);
|
|
|
|
static QString selectStr(bool f, const QString &s0, const QString &s1 = "");
|
2022-09-06 23:40:02 +08:00
|
|
|
static QString convertFileSize(const qlonglong & bytes);
|
2022-08-25 18:37:24 +08:00
|
|
|
static QString styleSheet();
|
|
|
|
~Tools() {
|
|
|
|
killTimer(timer_id);
|
|
|
|
}
|
|
|
|
signals:
|
|
|
|
void sTick();
|
|
|
|
protected:
|
|
|
|
virtual void timerEvent(QTimerEvent *event);
|
|
|
|
private:
|
|
|
|
Tools(QObject *parent = nullptr) : QObject(parent) {
|
|
|
|
timer_id = startTimer(500, Qt::PreciseTimer);
|
|
|
|
};
|
|
|
|
int timer_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TOOLS_H
|