diff options
author | 2022-05-07 21:08:01 +0530 | |
---|---|---|
committer | 2022-05-07 21:08:01 +0530 | |
commit | 419ffb29d24e50c2d0a222ec8003fa35050cf1ac (patch) | |
tree | ce91ddcc00021af5acd949a215bba0142b75aa14 /src/utils.cpp | |
parent | dfb5b9ca7c8d234fc7ac19b0c354c1228b0270e4 (diff) | |
download | whatsie-419ffb29d24e50c2d0a222ec8003fa35050cf1ac.tar.gz whatsie-419ffb29d24e50c2d0a222ec8003fa35050cf1ac.zip |
feat: add open downloads directory button in download widget
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(); + }); +} |