添加调用系统程序打开文件接口

main
wuyize 2023-07-07 01:05:12 +08:00
parent 5928e49884
commit bfb2adb7f9
3 changed files with 9 additions and 1 deletions

View File

@ -6,7 +6,7 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
find_package(Qt6 COMPONENTS Quick WebEngineQuick REQUIRED) find_package(Qt6 COMPONENTS Gui Quick WebEngineQuick REQUIRED)
#Cpp #Cpp
file(GLOB_RECURSE CPP_FILES src/*.cpp src/*.h) file(GLOB_RECURSE CPP_FILES src/*.cpp src/*.h)

View File

@ -8,6 +8,7 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include <fstream> #include <fstream>
#include <QDesktopServices>
static const std::string baseUrl = "https://api.hammer-hfut.tk:233/aics/file/"; static const std::string baseUrl = "https://api.hammer-hfut.tk:233/aics/file/";
//static const std::string baseUrl = "http://127.0.0.1:4523/m1/2914957-0-6e5f2db1/"; //static const std::string baseUrl = "http://127.0.0.1:4523/m1/2914957-0-6e5f2db1/";
@ -426,3 +427,8 @@ void FileTransferManager::getMarkdown(const QString &fileId)
}); });
} }
void FileTransferManager::openLocalFile(const QString &fileName)
{
QDesktopServices::openUrl(QUrl::fromLocalFile("D:\\Downloads\\"+ fileName));
}

View File

@ -32,6 +32,8 @@ public:
Q_INVOKABLE void getMarkdown(const QString &fileId); Q_INVOKABLE void getMarkdown(const QString &fileId);
Q_INVOKABLE void openLocalFile(const QString &fileName);
signals: signals:
void transferComplete(bool download, QString fileId, QString fileName); void transferComplete(bool download, QString fileId, QString fileName);
void markdownData(QString data); void markdownData(QString data);