diff --git a/feiqlib/filetask.cpp b/feiqlib/filetask.cpp index 1a4ba8e..85ec36d 100644 --- a/feiqlib/filetask.cpp +++ b/feiqlib/filetask.cpp @@ -80,3 +80,12 @@ FileTaskType FileTask::type() const { return mType; } + +string FileTask::getTaskTypeDes() const +{ + if (mType == FileTaskType::Upload) + return "发送"; + else if (mType == FileTaskType::Download) + return "接收"; + return ""; +} diff --git a/feiqlib/filetask.h b/feiqlib/filetask.h index cec65b6..3e50748 100644 --- a/feiqlib/filetask.h +++ b/feiqlib/filetask.h @@ -6,6 +6,7 @@ #include #include #include "fellow.h" +#include using namespace std; enum class FileTaskType{ @@ -48,6 +49,7 @@ public: string getDetailInfo() const; shared_ptr getContent() const; FileTaskType type() const; + string getTaskTypeDes() const; private: shared_ptr mFellow;//要发送给的用户,或文件来自该用户 int mProcess=0; diff --git a/mainwindow.cpp b/mainwindow.cpp index 4aa4ec4..31af3c6 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -147,6 +147,20 @@ void MainWindow::showResult(pair ret, const Content* content) void MainWindow::onStateChanged(FileTask *fileTask) { + if (fileTask->getState()==FileTaskState::Finish) + { + auto title = QString(fileTask->getTaskTypeDes().c_str())+"完成"; + PlatformDepend::instance().showNotify(title, fileTask->getContent()->filename.c_str()); + } + else if (fileTask->getState()==FileTaskState::Error) + { + auto title = QString(fileTask->getTaskTypeDes().c_str())+"失败"; + auto content = QString(fileTask->getContent()->filename.c_str()); + content += "\n"; + content += fileTask->getDetailInfo().c_str(); + PlatformDepend::instance().showNotify(title, content); + } + if (mDownloadFileDlg->isVisible()) { emit statChanged(fileTask);