#pragma once #include #include #include #include //Qt Creator 需要在xxx.pro 内部增加静态库的链接声明 //LIBS += -L$$PWD -lm3u8d-impl struct RunDownload_Req{ std::string M3u8Url; std::string HostType; bool Insecure; std::string SaveDir; std::string FileName; int32_t SkipTsCountFromHead; std::string SetProxy; std::map> HeaderMap; RunDownload_Req(): Insecure(false),SkipTsCountFromHead(0){} }; struct RunDownload_Resp{ std::string ErrMsg; bool IsSkipped; bool IsCancel; std::string SaveFileTo; RunDownload_Resp(): IsSkipped(false),IsCancel(false){} }; RunDownload_Resp RunDownload(RunDownload_Req in0); void CloseOldEnv(); struct GetProgress_Resp{ int32_t Percent; std::string Title; GetProgress_Resp(): Percent(0){} }; GetProgress_Resp GetProgress(); std::string GetWd(); struct ParseCurl_Resp{ std::string ErrMsg; RunDownload_Req DownloadReq; }; ParseCurl_Resp ParseCurlStr(std::string in0); std::string RunDownload_Req_ToCurlStr(RunDownload_Req in0); #include #include #include #include #include #include class RunOnUiThread : public QObject { Q_OBJECT public: explicit RunOnUiThread(QObject *parent = nullptr); virtual ~RunOnUiThread(); void AddRunFnOn_OtherThread(std::function fn); // !!!注意,fn可能被调用,也可能由于RunOnUiThread被析构不被调用 // 依赖于在fn里delete回收内存, 关闭文件等操作可能造成内存泄露 void AddRunFnOn_UiThread(std::function fn); signals: void signal_newFn(); private slots: void slot_newFn(); private: bool m_done; QVector> m_funcList; QMutex m_Mutex; QThreadPool m_pool; }; // Thanks: https://github.com/live-in-a-dream/Qt-Toast #include #include class QTimer; class QLabel; class QWidget; namespace Ui { class Toast; } class Toast : public QObject { Q_OBJECT public: explicit Toast(QObject *parent = nullptr); static Toast* Instance(); //错误 void SetError(const QString &text,const int & mestime = 3000); //成功 void SetSuccess(const QString &text,const int & mestime = 3000); //警告 void SetWaring(const QString &text,const int & mestime = 3000); //提示 void SetTips(const QString &text,const int & mestime = 3000); private slots: void onTimerStayOut(); private: void setText(const QString &color="FFFFFF",const QString &bgcolor = "000000",const int & mestime=3000,const QString &textconst=""); private: QWidget *m_myWidget; QLabel *m_label; QTimer *m_timer; Ui::Toast *ui; };