• Util
  • Util Class

    class ScreenPlay::Util

    Easy to use global object to use when certain functionality is not available in QML. More...

    Header: #include <Util>

    Public Functions

    Util(QNetworkAccessManager *networkAccessManager, QObject *parent = nullptr)
    QString debugMessages() const

    Public Slots

    void copyToClipboard(const QString &text) const
    QString generateRandomString(quint32 length = 32)
    std::optional<InstalledType::InstalledType> getInstalledTypeFromString(const QString &type)
    std::optional<QVersionNumber> getVersionNumberFromString(const QString &str)
    void logToGui(QtMsgType type, const QMessageLogContext &context, const QString &msg)
    void openFolderInExplorer(const QString &url) const
    std::optional<QJsonObject> openJsonFileToObject(const QString &path)
    std::optional<QString> openJsonFileToString(const QString &path)
    std::optional<QJsonObject> parseQByteArrayToQJsonObject(const QByteArray &byteArray)
    void requestAllLicenses()
    void requestDataProtection()
    QString toString(const QStringList &list)
    bool writeJsonObjectToFile(const QString &absoluteFilePath, const QJsonObject &object, bool truncate = true)

    Signals

    void debugMessagesChanged(QString debugMessages)

    Detailed Description

    Member Function Documentation

    Util::Util(QNetworkAccessManager *networkAccessManager, QObject *parent = nullptr)

    Constructor.

    [slot] void Util::copyToClipboard(const QString &text) const

    Copies the given string to the clipboard.

    [static slot] QString Util::generateRandomString(quint32 length = 32)

    Generates a (non secure) random string with the default length of 32. Can contain:

    [static slot] std::optional<InstalledType::InstalledType> Util::getInstalledTypeFromString(const QString &type)

    .

    [static slot] std::optional<QVersionNumber> Util::getVersionNumberFromString(const QString &str)

    Parses a version from a given QString. The QString must be looke like this: 1.0.0 - Major.Minor.Patch. A fixed position is used for parsing (at 0,2,4). Return std::nullopt when not successful.

    [static slot] void Util::logToGui(QtMsgType type, const QMessageLogContext &context, const QString &msg)

    Basic logging to the GUI. No logging is done to a log file for now. This string can be copied in the settings tab in the UI.

    [slot] void Util::openFolderInExplorer(const QString &url) const

    Opens a native folder window on the given path. Windows and Mac only for now!

    [static slot] std::optional<QJsonObject> Util::openJsonFileToObject(const QString &path)

    Opens a json file (absolute path) and tries to convert it to a QJsonObject. Returns std::nullopt when not successful.

    [static slot] std::optional<QString> Util::openJsonFileToString(const QString &path)

    Opens a json file (absolute path) and tries to convert it to a QString. Returns std::nullopt when not successful.

    [static slot] std::optional<QJsonObject> Util::parseQByteArrayToQJsonObject(const QByteArray &byteArray)

    Parses a QByteArray to a QJsonObject. If returns and std::nullopt on failure.

    [slot] void Util::requestAllLicenses()

    Loads all content of the legal folder in the qrc into a property string of this class. allLicenseLoaded is emited when loading is finished.

    [slot] void Util::requestDataProtection()

    Loads all dataprotection of the legal folder in the qrc into a property string of this class. allDataProtectionLoaded is emited when loading is finished.

    [static slot] QString Util::toString(const QStringList &list)

    Helper function to append a QStringList into a QString with a space between the items.

    [static slot] bool Util::writeJsonObjectToFile(const QString &absoluteFilePath, const QJsonObject &object, bool truncate = true)

    Writes a given QJsonObject to a file. The path must be absolute. When truncate is set to true the exsisting json file will be overriten.