mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 03:10:10 +08:00
update
This commit is contained in:
parent
db805ef85d
commit
be7b2dcc34
@ -11,10 +11,6 @@ FluScrollablePage{
|
||||
|
||||
title:"Http"
|
||||
|
||||
Component.onDestruction: {
|
||||
console.debug("T_Http -> onDestruction")
|
||||
}
|
||||
|
||||
FluHttp{
|
||||
id:http_get
|
||||
url:"https://api.github.com/search/repositories"
|
||||
@ -60,7 +56,7 @@ FluScrollablePage{
|
||||
FluHttp{
|
||||
id:http_download
|
||||
url:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
|
||||
// url:"https://www.w3school.com.cn/example/html5/mov_bbb.mp4"
|
||||
// url:"https://www.w3school.com.cn/example/html5/mov_bbb.mp4"
|
||||
onStart: {
|
||||
btn_download.disabled = true
|
||||
}
|
||||
@ -119,7 +115,7 @@ FluScrollablePage{
|
||||
id: file_dialog
|
||||
currentFolder: StandardPaths.standardLocations(StandardPaths.DownloadLocation)[0]
|
||||
onAccepted: {
|
||||
var path = currentFolder.toString().replace(FluTools.isMacos() ? "file://" : "file:///","") + "/big_buck_bunny.mp4"
|
||||
var path = FluTools.toLocalPath(currentFolder)+ "/big_buck_bunny.mp4"
|
||||
http_download.download(path)
|
||||
}
|
||||
}
|
||||
@ -131,7 +127,6 @@ FluScrollablePage{
|
||||
height: 400
|
||||
Item{
|
||||
anchors.fill: parent
|
||||
|
||||
Flickable{
|
||||
id:scrollview
|
||||
width: parent.width
|
||||
@ -149,7 +144,4 @@ FluScrollablePage{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ void FluHttp::post(QVariantMap params,QVariantMap headers){
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QString errorString = reply->errorString();
|
||||
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||
_cache.removeOne(reply);
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
if (isSuccess) {
|
||||
@ -101,6 +102,7 @@ void FluHttp::postString(QString params,QVariantMap headers){
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QString errorString = reply->errorString();
|
||||
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||
_cache.removeOne(reply);
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
if (isSuccess) {
|
||||
@ -139,6 +141,7 @@ void FluHttp::postJson(QVariantMap params,QVariantMap headers){
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QString errorString = reply->errorString();
|
||||
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||
_cache.removeOne(reply);
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
if (isSuccess) {
|
||||
@ -176,6 +179,7 @@ void FluHttp::get(QVariantMap params,QVariantMap headers){
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QString errorString = reply->errorString();
|
||||
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||
_cache.removeOne(reply);
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
if (isSuccess) {
|
||||
@ -228,6 +232,7 @@ void FluHttp::download(QString path,QVariantMap params,QVariantMap headers){
|
||||
}else{
|
||||
Q_EMIT error(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(),reply->errorString());
|
||||
}
|
||||
_cache.removeOne(reply);
|
||||
file->close();
|
||||
file->deleteLater();
|
||||
reply->deleteLater();
|
||||
|
@ -94,3 +94,7 @@ void FluTools::deleteItem(QObject *p){
|
||||
p = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
QString FluTools::toLocalPath(const QUrl& url){
|
||||
return url.toLocalFile();
|
||||
}
|
||||
|
@ -23,6 +23,37 @@ public:
|
||||
return getInstance();
|
||||
}
|
||||
static FluTools *getInstance();
|
||||
|
||||
/**
|
||||
* @brief qtMajor Qt Major版本
|
||||
* @return
|
||||
*/
|
||||
Q_INVOKABLE int qtMajor();
|
||||
|
||||
/**
|
||||
* @brief qtMajor Qt Minor版本
|
||||
* @return
|
||||
*/
|
||||
Q_INVOKABLE int qtMinor();
|
||||
|
||||
/**
|
||||
* @brief isMacos 是否是Macos系统
|
||||
* @return
|
||||
*/
|
||||
Q_INVOKABLE bool isMacos();
|
||||
|
||||
/**
|
||||
* @brief isLinux 是否是Linux系统
|
||||
* @return
|
||||
*/
|
||||
Q_INVOKABLE bool isLinux();
|
||||
|
||||
/**
|
||||
* @brief isWin 是否是Windows系统
|
||||
* @return
|
||||
*/
|
||||
Q_INVOKABLE bool isWin();
|
||||
|
||||
/**
|
||||
* @brief clipText 将字符串添加到剪切板
|
||||
* @param text
|
||||
@ -40,25 +71,39 @@ public:
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
Q_INVOKABLE QString readFile(const QString &fileName);
|
||||
|
||||
Q_INVOKABLE bool isMacos();
|
||||
|
||||
Q_INVOKABLE bool isLinux();
|
||||
|
||||
Q_INVOKABLE bool isWin();
|
||||
Q_INVOKABLE QString readFile(const QString& fileName);
|
||||
|
||||
/**
|
||||
* @brief setQuitOnLastWindowClosed 设置关闭最后一个窗口是否退出程序
|
||||
* @param val
|
||||
*/
|
||||
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
|
||||
|
||||
Q_INVOKABLE int qtMajor();
|
||||
|
||||
Q_INVOKABLE int qtMinor();
|
||||
|
||||
/**
|
||||
* @brief setOverrideCursor 设置全局鼠标样式
|
||||
* @param shape
|
||||
*/
|
||||
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
|
||||
|
||||
/**
|
||||
* @brief restoreOverrideCursor 还原全局鼠标样式
|
||||
*/
|
||||
Q_INVOKABLE void restoreOverrideCursor();
|
||||
|
||||
/**
|
||||
* @brief toLocalPath 获取文件路径,可以去掉windows系统下的file:///,macos下的file://
|
||||
* @param url
|
||||
* @return 返回文件路径
|
||||
*/
|
||||
Q_INVOKABLE QString toLocalPath(const QUrl& url);
|
||||
|
||||
/**
|
||||
* @brief deleteItem 销毁Item对象
|
||||
* @param p
|
||||
*/
|
||||
Q_INVOKABLE void deleteItem(QObject *p);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // FLUTOOLS_H
|
||||
|
Loading…
Reference in New Issue
Block a user