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

#include <iostream>
#include <atomic>

#ifndef M_PI
#define M_PI 	 3.14159265358979323846
#endif

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

Thiago Santini's avatar
Thiago Santini committed
19
#include <QCameraInfo>
20 21
Q_DECLARE_METATYPE(QCameraInfo)

Thiago Santini's avatar
Thiago Santini committed
22 23
#include <QWidget>
#include <QSettings>
24
#include <QSoundEffect>
Thiago Santini's avatar
Thiago Santini committed
25

Thiago Santini's avatar
Thiago Santini committed
26 27
#include "LogWidget.h"

28 29
#include "PerformanceMonitor.h"

Thiago Santini's avatar
Thiago Santini committed
30 31 32 33 34 35 36
/*
 * Global variables
 */
extern QElapsedTimer gTimer;

typedef qint64 Timestamp;
extern Timestamp maxTimestamp;
37
Q_DECLARE_METATYPE(Timestamp)
Thiago Santini's avatar
Thiago Santini committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

extern QString gExeDir;
extern QString gCfgDir;
extern char gDataSeparator;
extern char gDataNewline;

extern QList<QPair<QString, QString> > gReferenceList;

/*
 * 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);

void delay(int thMs);

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);
}

72 73
void loadSoundEffect(QSoundEffect &effect, QString fileName);

Thiago Santini's avatar
Thiago Santini committed
74 75 76
extern LogWidget *gLogWidget;
extern std::vector<QString> gLogBuffer;

77 78
extern PerformanceMonitor gPerformanceMonitor;

79
extern bool gCalibrating;
80
extern bool gFreezePreview;
81

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