CuteLogger
Fast and simple logging solution for Qt based applications
util.h
1 /*
2  * Copyright (c) 2014-2024 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef UTIL_H
19 #define UTIL_H
20 
21 #include <MltProperties.h>
22 #include <QFileDialog>
23 #include <QPalette>
24 #include <QString>
25 #include <QUrl>
26 
27 class QWidget;
28 class QDoubleSpinBox;
29 class QTemporaryFile;
30 
31 namespace Mlt {
32 class Producer;
33 }
34 
35 class Util
36 {
37 private:
38  Util() {}
39 
40 public:
41  static QString baseName(const QString &filePath, bool trimQuery = false);
42  static void setColorsToHighlight(QWidget *widget, QPalette::ColorRole role = QPalette::Window);
43  static void showInFolder(const QString &path);
44  static bool warnIfNotWritable(const QString &filePath, QWidget *parent, const QString &caption);
45  static QString producerTitle(const Mlt::Producer &producer);
46  static QString removeFileScheme(QUrl &url, bool fromPercentEncoding = true);
47  static const QStringList sortedFileList(const QList<QUrl> &urls);
48  static int coerceMultiple(int value, int multiple = 2);
49  static QList<QUrl> expandDirectories(const QList<QUrl> &urls);
50  static bool isDecimalPoint(QChar ch);
51  static bool isNumeric(QString &str);
52  static bool convertNumericString(QString &str, QChar decimalPoint);
53  static bool convertDecimalPoints(QString &str, QChar decimalPoint);
54  static void showFrameRateDialog(const QString &caption,
55  int numerator,
56  QDoubleSpinBox *spinner,
57  QWidget *parent = Q_NULLPTR);
58  static QTemporaryFile *writableTemporaryFile(const QString &filePath = QString(),
59  const QString &templateName = QString());
60  static void applyCustomProperties(Mlt::Producer &destination,
61  Mlt::Producer &source,
62  int in,
63  int out);
64  static QString getFileHash(const QString &path);
65  static QString getHash(Mlt::Properties &properties);
66  static bool hasDriveLetter(const QString &path);
67  static QFileDialog::Options getFileDialogOptions();
68  static bool isMemoryLow();
69  static QString removeQueryString(const QString &s);
70  static int greatestCommonDivisor(int m, int n);
71  static void normalizeFrameRate(double fps, int &numerator, int &denominator);
72  static QString textColor(const QColor &color);
73  static void cameraFrameRateSize(const QByteArray &deviceName, qreal &frameRate, QSize &size);
74  static bool ProducerIsTimewarp(Mlt::Producer *producer);
75  static QString GetFilenameFromProducer(Mlt::Producer *producer, bool useOriginal = true);
76  static double GetSpeedFromProducer(Mlt::Producer *producer);
77  static QString updateCaption(Mlt::Producer *producer);
78  static void passProducerProperties(Mlt::Producer *src, Mlt::Producer *dst);
79  static bool warnIfLowDiskSpace(const QString &path);
80  static bool isFpsDifferent(double a, double b);
81  static QString getNextFile(const QString &filePath);
82  static QString trcString(int trc);
83  static bool trcIsCompatible(int trc);
84  static QString getConversionAdvice(Mlt::Producer *producer);
85  static mlt_color mltColorFromQColor(const QColor &color);
86  static void offerSingleFileConversion(QString &message,
87  Mlt::Producer *producer,
88  QWidget *parent);
89  static double getAndroidFrameRate(Mlt::Producer *producer);
90  static double getSuggestedFrameRate(Mlt::Producer *producer);
91  static Mlt::Producer openMltVirtualClip(const QString &path);
92 };
93 
94 #endif // UTIL_H