/
alexashkin
/
telegraph
Обзор
Документация
Войти
/
alexashkin
/
telegraph
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/device/fileservice.cpp
46 строк
1 KB
mbarashkov
Добавился fileService
19 фев 2025, 18:40
19 фев 2025, 18:40
cc35402
Код
Авторство
О чём код?
#include "fileservice.h" #include <QStandardPaths> FileService::FileService(QObject *parent): QObject(parent) { } void FileService::copyFileToDownloads(const QString &filePath, bool openAfterCopy) { QFileInfo fileInfo(filePath); if (fileInfo.exists()) { QString downloadFilePath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/" + fileInfo.fileName(); if (QFile::exists(downloadFilePath)) { if (openAfterCopy) { openFileOnDevice(downloadFilePath); } else { emit copyToDownloadsSuccessful(fileInfo.fileName(), downloadFilePath); } } else { if (QFile::copy(filePath, downloadFilePath)) { if (openAfterCopy) openFileOnDevice(downloadFilePath); else emit copyToDownloadsSuccessful(fileInfo.fileName(), downloadFilePath); } else { emit copyToDownloadsError(fileInfo.fileName(), downloadFilePath); } } } else { emit copyToDownloadsError(fileInfo.fileName(), filePath); } } void FileService::openFileOnDevice(const QString &filePath) { emit openFileExternally(filePath); }