File indexing completed on 2024-09-29 12:38:56
0001 // SPDX-FileCopyrightText: 2022 Nicolas Fella <nicolas.fella@gmx.de> 0002 // SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 #include "urlhelper.h" 0005 0006 #include <QFile> 0007 #include <QtGlobal> 0008 0009 #ifdef Q_OS_ANDROID 0010 #include <QDesktopServices> 0011 #else 0012 #include <KIO/OpenUrlJob> 0013 #endif 0014 0015 // QDesktopServices::openUrl doesn't support XDG activation yet, OpenUrlJob does 0016 // On Android XDG activation is not relevant, so use QDesktopServices::openUrl to avoid the heavy KIO dependency 0017 void UrlHelper::openUrl(const QUrl &url) 0018 { 0019 #ifdef Q_OS_ANDROID 0020 QDesktopServices::openUrl(url); 0021 #else 0022 auto *job = new KIO::OpenUrlJob(url); 0023 job->start(); 0024 #endif 0025 } 0026 0027 void UrlHelper::copyTo(const QUrl &origin, const QUrl &destination) 0028 { 0029 QFile originFile(origin.toLocalFile()); 0030 originFile.copy(destination.toLocalFile()); 0031 } 0032 0033 #include "moc_urlhelper.cpp"