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