@@ -80,3 +80,12 @@ FileTaskType FileTask::type() const | |||||
{ | { | ||||
return mType; | return mType; | ||||
} | } | ||||
string FileTask::getTaskTypeDes() const | |||||
{ | |||||
if (mType == FileTaskType::Upload) | |||||
return "发送"; | |||||
else if (mType == FileTaskType::Download) | |||||
return "接收"; | |||||
return ""; | |||||
} |
@@ -6,6 +6,7 @@ | |||||
#include <memory> | #include <memory> | ||||
#include <functional> | #include <functional> | ||||
#include "fellow.h" | #include "fellow.h" | ||||
#include <string> | |||||
using namespace std; | using namespace std; | ||||
enum class FileTaskType{ | enum class FileTaskType{ | ||||
@@ -48,6 +49,7 @@ public: | |||||
string getDetailInfo() const; | string getDetailInfo() const; | ||||
shared_ptr<FileContent> getContent() const; | shared_ptr<FileContent> getContent() const; | ||||
FileTaskType type() const; | FileTaskType type() const; | ||||
string getTaskTypeDes() const; | |||||
private: | private: | ||||
shared_ptr<Fellow> mFellow;//要发送给的用户,或文件来自该用户 | shared_ptr<Fellow> mFellow;//要发送给的用户,或文件来自该用户 | ||||
int mProcess=0; | int mProcess=0; | ||||
@@ -147,6 +147,20 @@ void MainWindow::showResult(pair<bool, string> ret, const Content* content) | |||||
void MainWindow::onStateChanged(FileTask *fileTask) | 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()) | if (mDownloadFileDlg->isVisible()) | ||||
{ | { | ||||
emit statChanged(fileTask); | emit statChanged(fileTask); | ||||