diff --git a/core_support/fileconfigdecode/fileconfigdecode.cpp b/core_support/fileconfigdecode/fileconfigdecode.cpp index 4fd288d..cc065dc 100644 --- a/core_support/fileconfigdecode/fileconfigdecode.cpp +++ b/core_support/fileconfigdecode/fileconfigdecode.cpp @@ -81,6 +81,7 @@ void FileConfigDecode::setAutoCopy(bool value) void FileConfigDecode::fileWrite(QString path, QString address, quint16 port, bool autosetup, bool rename, bool timerename, bool autocopy) { +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QSettings* config = new QSettings(path, QSettings::IniFormat); config->setIniCodec(QTextCodec::codecForName("utf-8")); QString section = QString("config"); @@ -93,6 +94,20 @@ void FileConfigDecode::fileWrite(QString path, QString address, quint16 port, bo config->setValue("autocopy", autocopy); config->endGroup(); delete config; +#else + QSettings* config = new QSettings(path, QSettings::IniFormat); + + QString section = QString("config"); + config->beginGroup(section); + config->setValue("address", address); + config->setValue("port", port); + config->setValue("autosetup", autosetup); + config->setValue("rename", rename); + config->setValue("timerename", timerename); + config->setValue("autocopy", autocopy); + config->endGroup(); + delete config; +#endif } void FileConfigDecode::initFile() @@ -103,7 +118,6 @@ void FileConfigDecode::initFile() QFile file(addFilePath); if (file.exists()) { QSettings* config = new QSettings(addFilePath, QSettings::IniFormat); - config->setIniCodec(QTextCodec::codecForName("utf-8")); QString section = "config/"; this->address = config->value(section + "address").toString(); diff --git a/core_support/fileconfigdecode/fileconfigdecode.h b/core_support/fileconfigdecode/fileconfigdecode.h index e01f352..5a8694f 100644 --- a/core_support/fileconfigdecode/fileconfigdecode.h +++ b/core_support/fileconfigdecode/fileconfigdecode.h @@ -6,7 +6,9 @@ #include #include #include +#if (QT_VERSION <= QT_VERSION_CHECK(6, 0, 0)) #include +#endif class FileConfigDecode { diff --git a/core_support/tchttpservice/tchttpservice.cpp b/core_support/tchttpservice/tchttpservice.cpp index 2a9f78e..f6cb466 100644 --- a/core_support/tchttpservice/tchttpservice.cpp +++ b/core_support/tchttpservice/tchttpservice.cpp @@ -16,14 +16,14 @@ void TCHttpService::apiLogin() QString md5Hex = pwdMd5.toHex(); QString urlStr; -// if (m_enableSsl) + if (m_enableSsl) urlStr = "https://" + m_domain + "/api/login"; -// else -// urlStr = "http://" + m_domain + "/api/login"; + else + urlStr = "http://" + m_domain + "/api/login"; QUrl url(urlStr); QJsonObject jsonObj; - jsonObj["user"]="test1"; + jsonObj["user"]=m_userName; jsonObj["pwd"]=md5Hex; QJsonDocument jsonDoc(jsonObj); QByteArray jsonData = jsonDoc.toJson(); @@ -31,15 +31,17 @@ void TCHttpService::apiLogin() headers.insert("Content-Type", "application/json"); QNetworkReply* reply = nullptr; -// qDebug() < headers; headers.insert("Content-Type", "application/json"); - QString bodyStr = QString("\"%1\":\"%2\",\"%3\":\"%4\"").arg("token").arg(m_token).arg("user").arg(m_userName); + QMap params; params.insert("cmd", "count"); -// QNetworkReply* reply = Post(urlStr, headers, params, bodyStr.toUtf8()); + QUrl url = encodeUrl(urlStr, params); + QJsonObject jsonObj; + jsonObj["token"] = m_token; + jsonObj["user"] = m_userName; + QJsonDocument jsonDoc(jsonObj); + QByteArray jsonData = jsonDoc.toJson(); -// QObject::connect(reply, &QNetworkReply::finished, [this, reply]{ + QNetworkRequest request(url); + for (auto ite = headers.constBegin(); ite != headers.constEnd(); ite++){ + request.setRawHeader(ite.key().toUtf8(), ite.value().toUtf8()); + } -// QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll()); -// QJsonObject jsonObj = jsonDoc.object(); - -// int code = jsonObj["code"].toInt(); - -// if (code == 0) { -// int total = jsonObj["total"].toInt(); -// this->m_total = total; -// } - -// reply->deleteLater(); -// }); + QNetworkReply* reply = nullptr; + reply = m_manager.post(request, jsonData); + QObject::connect(reply, &QNetworkReply::finished, [this, reply](){ + emit requestFinished(reply, "myfilecount"); + }); } void TCHttpService::apiMyfileNormal() @@ -87,28 +90,28 @@ void TCHttpService::apiMyfileNormal() QMap params; params.insert("cmd", "normal"); - QString bodyStr = QString("\"%1\":\"%2\",\"%3\":\"%4\",\"%5\":\"%6\",\"%7\":\"%8\"").arg("token").arg(m_token). - arg("user").arg(m_userName).arg("count").arg(m_total).arg("start").arg(0); -// QNetworkReply* reply = Post(QUrl(urlStr), headers, params, bodyStr.toUtf8()); -// QObject::connect(reply, &QNetworkReply::finished, [this, reply]{ -// QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll()); -// QJsonObject jsonObj = jsonDoc.object(); + QUrl url = encodeUrl(urlStr, params); + QNetworkRequest request(url); + for (auto ite = headers.constBegin(); ite != headers.constEnd(); ite++){ + request.setRawHeader(ite.key().toUtf8(), ite.value().toUtf8()); + } -// int code = jsonObj["code"].toInt(); -// if (code == 0) { -// int count = jsonObj["count"].toInt(); -// if (count != 0) { -// QJsonArray array = jsonObj["files"].toArray(); -// for (const QJsonValue& value : array) { -// QJsonObject item = value.toObject(); -// updateFileMap(item); -// } -// } -// } + QJsonObject jsonObj; + jsonObj["token"] = m_token; + jsonObj["user"] = m_userName; + jsonObj["count"] = m_total; + jsonObj["start"] = 0; -// reply->deleteLater(); -// }); + QJsonDocument jsonDoc(jsonObj); + QByteArray jsonData = jsonDoc.toJson(); + + QNetworkReply* reply = nullptr; + reply = m_manager.post(request, jsonData); + QObject::connect(reply, &QNetworkReply::finished, [this, reply](){ + + emit requestFinished(reply, "myfilenormal"); + }); } void TCHttpService::apiMd5(const QString& filePath) @@ -137,20 +140,7 @@ void TCHttpService::apiMd5(const QString& filePath) QString bodyStr = QString("\"%1\":\"%2\",\"%3\":\"%4\",\"%5\":\"%6\",\"%7\":\"%8\"").arg("token").arg(m_token). arg("md5").arg(md5Str).arg("filename").arg(QFileInfo(file).fileName()).arg("user").arg(m_userName); file.close(); -// QNetworkReply* reply = Post(urlStr, headers, {}, bodyStr.toUtf8()); -// QObject::connect(reply, &QNetworkReply::finished, [this, reply, filePath, md5Str]{ -// QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll()); -// QJsonObject jsonObj = jsonDoc.object(); -// int code = jsonObj["code"].toInt(); -// switch (code) { -// case 0: -// break; -// case 1: -// apiUpload(filePath, md5Str); -// break; -// } -// }); } void TCHttpService::apiUpload(const QString &filePath, const QString &md5Str) @@ -236,18 +226,6 @@ void TCHttpService::apiSharePicShare(const QString &fileName, const QString &md5 params.insert("cmd", "share"); -// QNetworkReply* reply = Post(QUrl(urlStr), headers, params, bodyStr.toUtf8()); - -// QObject::connect(reply, &QNetworkReply::finished, [this, reply]{ -// QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll()); -// QJsonObject jsonObj = jsonDoc.object(); - -// int code = jsonObj["code"].toInt(); -// if (code == 0) { -// emit signal_shareSuc(); -// } -// reply->deleteLater(); -// }); } void TCHttpService::setConfiguration(QString userName, QString firstPwd, QString domain) @@ -256,9 +234,35 @@ void TCHttpService::setConfiguration(QString userName, QString firstPwd, QString this->m_domain = domain; this->m_userName = userName; this->m_firstPwd = firstPwd; - connect(this, &TCHttpService::requestFinished, [](QNetworkReply* reply){ - qDebug() << "readall"; - qDebug() <readAll(); + connect(this, &TCHttpService::requestFinished, [this](QNetworkReply* reply, QString api){ + QByteArray rawData = reply->readAll(); + if (api == "login") { + + QJsonDocument jsonDoc = QJsonDocument::fromJson(rawData); + if (jsonDoc.isEmpty()) + return; + QJsonObject jsonObj = jsonDoc.object(); + int code = jsonObj["code"].toInt(); + if (code == 0) { + this->m_token = jsonObj["token"].toString(); + qDebug() << this->m_token; + } + } + if (api == "myfilecount") { + QJsonDocument jsonDoc = QJsonDocument::fromJson(rawData); + if (jsonDoc.isEmpty()) + return; + QJsonObject jsonObj = jsonDoc.object(); + int code = jsonObj["code"].toInt(); + + if (code == 0) { + int total = jsonObj["total"].toInt(); + this->m_total = total; + } + } + if (api == "myfilenormal") { + + } reply->deleteLater(); }); apiLogin(); @@ -270,68 +274,19 @@ void TCHttpService::setSsl(bool enable) this->m_enableSsl = enable; } -QNetworkReply *TCHttpService::Get(const QUrl &url, const QMap headers, const QMap params) +QUrl TCHttpService::encodeUrl(QString urlStr, QMap params) { QUrlQuery query; - for (auto ite = params.constBegin(); ite != params.constEnd(); ite++) { + for(auto ite = params.constBegin(); ite != params.constEnd(); ite++){ query.addQueryItem(ite.key(), ite.value()); } - QUrl requestUrl = url; - requestUrl.setQuery(query); + QUrl url(urlStr); + url.setQuery(query); - QNetworkRequest request(requestUrl); - - for (auto ite = headers.constBegin(); ite != headers.constEnd(); ite++) { - request.setRawHeader(ite.key().toUtf8(), ite.value().toUtf8()); - } - - QNetworkReply* reply = m_manager.get(request); - - return reply; + return url; } -QNetworkReply *TCHttpService::Post(const QUrl &url, const QMap headers, const QMap params, const QByteArray body) -{ - -} - -QByteArray TCHttpService::Post(QUrl url, QMap headers, QMap params, QByteArray body, int i) -{ - QUrlQuery query; - for (auto ite = params.constBegin(); ite != params.constEnd(); ite++) { - query.addQueryItem(ite.key(), ite.value()); - } - - QUrl requestUrl = url; - requestUrl.setQuery(query); - qDebug() << requestUrl; - QNetworkRequest request(url); - -// for (auto ite = headers.constBegin(); ite != headers.constEnd(); ite++) { -// request.setRawHeader(ite.key().toUtf8(), ite.value().toUtf8()); -// } - qDebug() << 1; - QJsonObject jsonObj; - jsonObj["user"]="test1"; - jsonObj["pwd"]="e10adc3949ba59abbe56e057f20f883e"; - QJsonDocument jsonDoc(jsonObj); - QByteArray jsonData = jsonDoc.toJson(); - qDebug() << 2; - QNetworkReply* reply = nullptr; - qDebug() << 3; - reply = m_manager.post(request, jsonData); - qDebug() << 4; - QObject::connect(reply, &QNetworkReply::finished, [this, reply](){ -// QByteArray respData = reply->readAll(); -// qDebug() <deleteLater(); - qDebug() << "emit requestFinished"; -// emit requestFinished(reply); - }); - -} void TCHttpService::updateFileMap(QJsonObject jsonObj) { diff --git a/core_support/tchttpservice/tchttpservice.h b/core_support/tchttpservice/tchttpservice.h index 7b0396a..2bb42a4 100644 --- a/core_support/tchttpservice/tchttpservice.h +++ b/core_support/tchttpservice/tchttpservice.h @@ -32,20 +32,14 @@ public: private: - QNetworkReply* Get(const QUrl& url, const QMap headers = {}, - const QMap params = {}); - QNetworkReply* Post(const QUrl& url, const QMap headers = {}, - const QMap params = {}, const QByteArray body =QByteArray()); - - QByteArray Post(QUrl url, QMap headers = {}, - QMap params = {}, QByteArray body =QByteArray(), int i = 1); + QUrl encodeUrl(QString url, QMap params); void updateFileMap(QJsonObject jsonObj); signals: void signal_loginSuc(); void signal_uploadSuc(); void signal_shareSuc(); - void requestFinished(QNetworkReply* reply); + void requestFinished(QNetworkReply* reply, QString api); private: explicit TCHttpService(QObject *parent = nullptr); diff --git a/picpanel.pro.user b/picpanel.pro.user index 5f44ba9..3c1d0cb 100644 --- a/picpanel.pro.user +++ b/picpanel.pro.user @@ -1,14 +1,14 @@ - + EnvironmentId - {4f2ec396-c2e0-4f3d-a369-5968ecaf5cee} + {eff88622-f1f6-485c-90af-dd46e6d2c022} ProjectExplorer.Project.ActiveTarget - 0 + 0 ProjectExplorer.Project.EditorSettings @@ -28,285 +28,237 @@ QmlJSGlobal - 2 + 2 UTF-8 false 4 false + 0 80 true true 1 + 0 + false true false - 0 + 2 true true 0 8 true + false 1 true true true + *.md, *.MD, Makefile false + true + true ProjectExplorer.Project.PluginSettings - - -fno-delayed-template-parsing - - true + + true + false + true + true + true + true + + false + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 8 + true + + + + true + ProjectExplorer.Project.Target.0 - Desktop Qt 5.14.2 MinGW 64-bit - Desktop Qt 5.14.2 MinGW 64-bit - qt.qt5.5142.win64_mingw73_kit - 0 - 0 - 0 + Desktop + Qt 6.7.3 for macOS + Qt 6.7.3 for macOS + qt.qt6.673.clang_64_kit + 0 + 0 + 0 - D:/Workspaces/build-picpanel-Desktop_Qt_5_14_2_MinGW_64_bit-Debug + 0 + /Users/lenn/Workspace/picpanel/build/Qt_6_7_3_for_macOS-Debug + /Users/lenn/Workspace/picpanel/build/Qt_6_7_3_for_macOS-Debug true QtProjectManager.QMakeBuildStep - true - false - false - false + true Qt4ProjectManager.MakeStep - - false - - - false - 2 - Build - Build + 2 + 构建 + 构建 ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep - - true clean - - false - 1 - Clean - Clean + 1 + 清除 + 清除 ProjectExplorer.BuildSteps.Clean 2 false + + false Debug Qt4ProjectManager.Qt4BuildConfiguration 2 - D:/Workspaces/build-picpanel-Desktop_Qt_5_14_2_MinGW_64_bit-Release + /Users/lenn/Workspace/picpanel/build/Qt_6_7_3_for_macOS-Release + /Users/lenn/Workspace/picpanel/build/Qt_6_7_3_for_macOS-Release true QtProjectManager.QMakeBuildStep - false - false - false - true + true Qt4ProjectManager.MakeStep - - false - - - false - 2 - Build - Build + 2 + 构建 + 构建 ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep - - true clean - - false - 1 - Clean - Clean + 1 + 清除 + 清除 ProjectExplorer.BuildSteps.Clean 2 false + + false Release Qt4ProjectManager.Qt4BuildConfiguration 0 + 0 - D:/Workspaces/build-picpanel-Desktop_Qt_5_14_2_MinGW_64_bit-Profile + 0 + /Users/lenn/Workspace/picpanel/build/Qt_6_7_3_for_macOS-Profile + /Users/lenn/Workspace/picpanel/build/Qt_6_7_3_for_macOS-Profile true QtProjectManager.QMakeBuildStep - true - false - true - true + true Qt4ProjectManager.MakeStep - - false - - - false - 2 - Build - Build + 2 + 构建 + 构建 ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep - - true clean - - false - 1 - Clean - Clean + 1 + 清除 + 清除 ProjectExplorer.BuildSteps.Clean 2 false + + false Profile Qt4ProjectManager.Qt4BuildConfiguration 0 + 0 + 0 - 3 + 3 - 0 - Deploy - Deploy + 0 + 部署 + 部署 ProjectExplorer.BuildSteps.Deploy 1 + + false ProjectExplorer.DefaultDeployConfiguration - 1 - + 1 - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F true - 4096 - false - false - 1000 - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 + 0 true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - + 2 - Qt4ProjectManager.Qt4RunConfiguration:D:/Workspaces/picpanel/picpanel.pro - D:/Workspaces/picpanel/picpanel.pro - - false - - false + false + -e cpu-cycles --call-graph dwarf,4096 -F 250 + + Qt4ProjectManager.Qt4RunConfiguration: + /Users/lenn/Workspace/picpanel/picpanel.pro + false true true - false - false true - - D:/Workspaces/build-picpanel-Desktop_Qt_5_14_2_MinGW_64_bit-Debug + /Users/lenn/Workspace/picpanel/build/Qt_6_7_3_for_macOS-Debug/picpanel.app/Contents/MacOS - 1 + 1 ProjectExplorer.Project.TargetCount - 1 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/picpanel.pro.user.4f2ec39 b/picpanel.pro.user.4f2ec39 new file mode 100644 index 0000000..5f44ba9 --- /dev/null +++ b/picpanel.pro.user.4f2ec39 @@ -0,0 +1,319 @@ + + + + + + EnvironmentId + {4f2ec396-c2e0-4f3d-a369-5968ecaf5cee} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.14.2 MinGW 64-bit + Desktop Qt 5.14.2 MinGW 64-bit + qt.qt5.5142.win64_mingw73_kit + 0 + 0 + 0 + + D:/Workspaces/build-picpanel-Desktop_Qt_5_14_2_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + D:/Workspaces/build-picpanel-Desktop_Qt_5_14_2_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + D:/Workspaces/build-picpanel-Desktop_Qt_5_14_2_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:D:/Workspaces/picpanel/picpanel.pro + D:/Workspaces/picpanel/picpanel.pro + + false + + false + true + true + false + false + true + + D:/Workspaces/build-picpanel-Desktop_Qt_5_14_2_MinGW_64_bit-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/widget.cpp b/widget.cpp index a5ae1c3..809f7dd 100644 --- a/widget.cpp +++ b/widget.cpp @@ -133,7 +133,11 @@ void Widget::paintEvent(QPaintEvent *event) // QWidget::paintEvent(event); QStyleOption opt; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) opt.init(this); +#else + opt.initFrom(this); +#endif QPainter painter(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); } @@ -264,7 +268,11 @@ void Widget::initLeftMenu() labAbout->installEventFilter(this); buttomLayout->addWidget(labAbout); buttomLayout->addSpacerItem(horizenSpacer); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) buttomLayout->setMargin(0); +#else + buttomLayout->setContentsMargins(0, 0, 0, 0); +#endif frameLayout->addItem(buttomLayout); frameLayout->setSpacing(40);