diff options
Diffstat (limited to 'src/utils.cpp')
-rw-r--r-- | src/utils.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/utils.cpp b/src/utils.cpp index 0c70ef9..f8e5dda 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,10 +1,4 @@ #include "utils.h" -#include <QApplication> -#include <QDateTime> -#include <QMessageBox> -#include <QProcessEnvironment> -#include <QRandomGenerator> -#include <QRegularExpression> #include <time.h> utils::utils(QObject *parent) : QObject(parent) { setParent(parent); } @@ -268,3 +262,24 @@ QString utils::GetEnvironmentVar(const QString &variable_name) { .trimmed(); #endif } + +void utils::desktopOpenUrl(const QString str) { + QProcess *xdg_open = new QProcess(0); + xdg_open->start("xdg-open", QStringList() << str); + if (xdg_open->waitForStarted(1000) == false) { + // try using QdesktopServices + bool opened = QDesktopServices::openUrl(QUrl(str)); + if (opened == false) { + qWarning() << "failed to open url" << str; + } + } + connect(xdg_open, + static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>( + &QProcess::finished), + [xdg_open](int exitCode, QProcess::ExitStatus exitStatus) { + Q_UNUSED(exitCode); + Q_UNUSED(exitStatus); + xdg_open->close(); + xdg_open->deleteLater(); + }); +} |