summaryrefslogtreecommitdiffstats
path: root/helper.h
blob: 747f57e012b6cfbd30339cdfdb8662583bcb5de4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
72
73
/*
  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version
  2 of the License, or (at your option) any later version.
*/

#ifndef HELPER_H
#define HELPER_H

#include <QPair>
#include <QStringList>
#include <QVariant>
#include <QList>
#include <QMetaType>
#include <QJsonDocument>

#include <magic.h>
#include <pictureviewer2.h>

#ifndef MAGICKCORE_QUANTUM_DEPTH
#define MAGICKCORE_QUANTUM_DEPTH 16
#endif

#ifndef MAGICKCORE_HDRI_ENABLE
#define MAGICKCORE_HDRI_ENABLE 1
#endif

#include <ImageMagick-6/Magick++.h>

class QString;
class QFileInfo;
class QPixmap;

namespace Helper {
	const QString mimeType(const QString &path);
	const QString md5Sum(const QString &path);
    const QString moveToArchive(const QString &path, const QString &md5, bool copy = false);
	bool removeFromArchive(const QString &filename, const QString &md5);
	const QString createArchivePath(const QString &path, const QString &md5, bool withMd5 = false);
    const QString createUSBPath(const QString &filename, const QString &seriesName, const QString &subtitle, int dvdNo, int seriesNo);
	QPair<QString, QStringList> programData(const QString &prefix, const QString &preferred = QString());
	const QString durationFromSecs(qint64 secs);
	QVariant bytesFromUnit(QVariant number, const QString unit);
	const QStringList toStringList(const QList<QVariant> &list);
	const QString colorToHtml(const QColor &color);
    QVariantMap ffmpegData(const QString &path);
    QJsonDocument streamData(const QString &path);
    QPixmap preview(const QString &path);
    QImage snapshot(const QString &path, int where);
    QVariant picSize(const QString &path);
    PicData convertArchivefileToPng(PicData data);
    class Duration {
        public:
            Duration();
            Duration(qint64 seconds);
            Duration(const QString &dur);
            Duration operator+(const Duration &dur) const;
            const QString toString() const;
            bool isNull() const;
            qint64 toSeconds() const;

        private:
            int mHours;
            int mMinutes;
            int mSeconds;
    };
}

Q_DECLARE_METATYPE(Helper::Duration)

#endif