utils.h 1.31 KB
Newer Older
Thiago Santini's avatar
Thiago Santini committed
1 2 3 4 5 6 7 8 9 10 11 12 13
#ifndef UTILS_H
#define UTILS_H

#include <iostream>
#include <atomic>

#include <QElapsedTimer>
#include <QDebug>
#include <QDateTime>
#include <QFile>
#include <QTextStream>
#include <QMutex>
#include <QCameraViewfinderSettings>
14

Thiago Santini's avatar
Thiago Santini committed
15
#include <QCameraInfo>
16 17
Q_DECLARE_METATYPE(QCameraInfo)

Thiago Santini's avatar
Thiago Santini committed
18 19
#include <QWidget>
#include <QSettings>
20
#include <QSoundEffect>
Thiago Santini's avatar
Thiago Santini committed
21

Thiago Santini's avatar
Thiago Santini committed
22 23
#include "LogWidget.h"

Thiago Santini's avatar
Thiago Santini committed
24
typedef qint64 Timestamp;
25
extern const Timestamp maxTimestamp;
26
Q_DECLARE_METATYPE(Timestamp)
Thiago Santini's avatar
Thiago Santini committed
27

28 29 30 31 32 33 34
// useful common tokens for data
class Token {
public:
	static const char Delimiter = '\t';
	static const char Newline = '\n';
};

Thiago Santini's avatar
Thiago Santini committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
/*
 * Utility functions
 */

QDebug operator<<(QDebug dbg, const QCameraViewfinderSettings &p);

void logInitBanner();
void logExitBanner();
void logMessages(QtMsgType type, const QMessageLogContext &context, const QString &msg);

QString toQString(QVideoFrame::PixelFormat format);
QString toQString(QCameraViewfinderSettings setting);

QString iniStr(QString str);

50
void delay(const int &thMs);
Thiago Santini's avatar
Thiago Santini committed
51 52 53 54 55 56 57 58 59 60

template<typename T> void set(const QSettings *settings, const QString key, T &v)
{
    if (!settings)
        return;
    QVariant variant = settings->value(key);
    if (variant.isValid())
        v = qvariant_cast<T>(variant);
}

61
void loadSoundEffect(const QString &fileName, const QString &exeDir, QSoundEffect &effect);
62

Thiago Santini's avatar
Thiago Santini committed
63
#endif // UTILS_H