Skip to content

Commit

Permalink
Merge branch 'main' of https://gitee.com/opguess/QSyncUi
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Porter committed Jul 10, 2024
2 parents 40e4368 + 22f2db4 commit 9b0aaa6
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 17 deletions.
8 changes: 4 additions & 4 deletions cosclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ bool COSClient::save2Local(const QString &path, const QString &localpath, const
{
QMap<QString, QString> tempHeaders;
QByteArray data = getObject(path, versionId, tempHeaders);

qDebug()<<data.size();
QFile file(localpath);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
if (!file.open(QIODevice::WriteOnly))
{
qDebug() << "无法创建文件:" << localpath;
return false;
Expand All @@ -144,7 +144,7 @@ bool COSClient::save2Local(const QString &path, const QString &localpath, const
return true;
}

preResponse COSClient::headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader)
QMap<QString,QString> COSClient::headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader)
{
preRequest request;
if(!versionId.isEmpty()) {
Expand All @@ -163,7 +163,7 @@ preResponse COSClient::headObject(const QString &path, const QString &localpath,
request.customHeaders.insert("If-None-Match", reqHeader.ifNoneMatch);
}
preResponse response = invokeHeadRequest(path, request);
return response;
return response.headers;
}

bool COSClient::deleteObject(const QString &path, const QString &versionId)
Expand Down
2 changes: 1 addition & 1 deletion cosclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class COSClient : public QObject
QString completeMultipartUpload(QString path, QString uploadId, QMap<int, QString> partEtagMap);
QByteArray getObject(const QString &path,const QString &versionId, QMap<QString,QString> &respHeaders);
bool save2Local(const QString &path, const QString &localpath,const QString &versionId, QMap<QString,QString> &respMetaDatas);
preResponse headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader);
QMap<QString,QString> headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader);
bool deleteObject(const QString &path, const QString &versionId);
QString multiUpload(const QString &path, const QString &localpath, QMap<QString,QString> metaDatas=QMap<QString,QString>());

Expand Down
38 changes: 35 additions & 3 deletions linknewfolder_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,41 @@ linkNewFolder_window::linkNewFolder_window(QWidget *parent)
_checkBox->setFixedSize(130, 20); // 设置按钮的固定大小
lineEditLayout2->addWidget(folderName2, 1); // 将输入框添加到布局中
lineEditLayout2->addWidget(_checkBox); // 将按钮添加到布局中
connect(_checkBox, &QCheckBox::stateChanged, [=](int state) {
// 首先,定义一个用于显示错误信息的标签
QLabel* errorLabel = new QLabel(lineEditArea2);
errorLabel->setText("输入格式错误:只能包含大小写字母、数字、'-'和'/',且必须以'/'结尾");
errorLabel->setStyleSheet("QLabel { color : red; }"); // 设置错误信息为红色字体
//errorLabel->setAlignment(Qt::AlignCenter); // 设置文本居中显示
errorLabel->setFixedSize(500,20);
errorLabel->hide(); // 默认隐藏错误信息标签
// 然后,为folderName2添加失焦事件的处理
connect(folderName2, &ElaLineEdit::focusOut, [=]() {
QString inputText = folderName2->text();
QRegularExpression re("^[a-zA-Z0-9/-]+/$");
if (!re.match(inputText).hasMatch()) {
// 如果输入不符合要求,显示错误信息标签
errorLabel->show();
} else {
// 如果输入符合要求,隐藏错误信息标签
errorLabel->hide();
}
});
// 为checkBox添加状态改变事件的处理
connect(_checkBox, &ElaCheckBox::stateChanged, [=](int state) {
if (state == Qt::Checked) {
// 如果_checkBox被选中,复制folderName1的内容到folderName2
folderName2->setText(folderName1->text());
QString folderName1Text = folderName1->text();
int lastSlashIndex = folderName1Text.lastIndexOf('/');
// 如果找到了'/',则复制其后的内容到folderName2
if (lastSlashIndex != -1) {
QString lastPart = folderName1Text.mid(lastSlashIndex + 1); // 包含最后一个'/'及其后的所有内容
folderName2->setText(lastPart + "/"); // 在folderName2中设置文本,并在末尾加上一个'/'
QString inputText = folderName2->text();
QRegularExpression re("^[a-zA-Z0-9/-]+/$");
if (!re.match(inputText).hasMatch())
errorLabel->show();
else
errorLabel->hide();
}
}
});

Expand Down Expand Up @@ -104,6 +135,7 @@ linkNewFolder_window::linkNewFolder_window(QWidget *parent)

centerVLayout->addWidget(Title);
centerVLayout->addWidget(lineEditArea1);
//centerVLayout->addWidget(errorLabel);
centerVLayout->addWidget(lineEditArea2);
centerVLayout->addWidget(_comboBox);
centerVLayout->addWidget(buttonArea);
Expand Down
33 changes: 24 additions & 9 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ int main(int argc, char *argv[])
User loginuser("enrolluser@example.com","123456");
loginuser.enroll();
loginuser.login();
/*
loginuser.addTask("E:/","home/",1,22,22);


//loginuser.addTask("E:/","home/",1,22,22);
TaskToken tt=loginuser.getTaskTokenByRemote("home/");
//request: https://qsync-1320107701.cos.ap-nanjing.myqcloud.com/?prefix=home
QNetworkRequest request(QUrl("https://qsync-1320107701.cos.ap-nanjing.myqcloud.com/?prefix=home"));
Expand All @@ -31,21 +32,35 @@ int main(int argc, char *argv[])
QString token=tt.sessionToken;
QDateTime expiredTime=tt.expiredTime;
COSClient cosclient(bucketName,appId,region,secretId,secretKey,token,expiredTime);
QString xmlstr=cosclient.listObjects("home/","");
qDebug()<<cosclient.putLocalObject("/home/1.jpg","C:/Users/33327/Documents/Tencent Files/3332770186/Image/Group2/LN/[B/LN[BMJILV2RA]X6$X49XPGS.jpg");
qDebug()<<cosclient.multiUpload("/home/2.mp4","E:\\Game Recording\\Yuan Shen 原神\\3.mp4");
XmlProcesser xp;
Bucket bucket=xp.processXml(xmlstr);
QMap<QString, QString> myMap;
headHeader hh;
//qDebug()<<"save to local:"<<cosclient.save2Local("home/1.txt","C:/Users/work123/Desktop/1.txt","",myMap);
/*QMap<QString,QString> metaDatas;
QMap<QString,QString> headers=cosclient.headObject("home/1.txt","C:/Users/work123/Desktop/1.txt","",hh);
for(auto it=headers.begin();it!=headers.end();it++){
if(it.key().startsWith("x-cos-meta-")){
metaDatas[it.key().mid(11)]=it.value();
}
}
qDebug()<<"metaDatas:"<<metaDatas;*/
//qDebug()<<cosclient.deleteObject("/home/1.jpg","");


//QString xmlstr=cosclient.listObjects("home/","");
//qDebug()<<cosclient.putLocalObject("/home/1.jpg","C:/Users/33327/Documents/Tencent Files/3332770186/Image/Group2/LN/[B/LN[BMJILV2RA]X6$X49XPGS.jpg");
//qDebug()<<cosclient.multiUpload("/home/2.mp4","E:\\Game Recording\\Yuan Shen 原神\\3.mp4");
//XmlProcesser xp;
//Bucket bucket=xp.processXml(xmlstr);
/*
//sh.generateSignature(request,60);
//qDebug() <<"s3 location:"<< loginuser.getS3Location();
SyncTaskDatabaseManager stm(&loginuser);
SyncTask mytask("E:/","/home/",1);
SyncCore sc(&a);
//sc.addTask(&mytask);
//stm.addTask(mytask);
//qDebug()<<stm.queryTask(mytask);
*/
//qDebug()<<stm.queryTask(mytask);*/

ElaApplication::getInstance()->init();
MainWindow w;
w.show();
Expand Down
2 changes: 2 additions & 0 deletions setexcludeditems_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ setExcludedItems_view::setExcludedItems_view(QWidget *parent)
this->setWindowModality(Qt::ApplicationModal); // 设置窗口模态
this->hide(); // 初始隐藏当前窗口
this->setWindowButtonFlag(ElaAppBarType::StayTopButtonHint,false);
this->setWindowButtonFlag(ElaAppBarType::MinimizeButtonHint,false);
this->setWindowButtonFlag(ElaAppBarType::MaximizeButtonHint,false);
QWidget*centerarea=new QWidget(); // 创建一个新的QWidget对象作为主区域
QVBoxLayout* centerVLayout = new QVBoxLayout(centerarea); // 为中心部件设置垂直布局
centerVLayout->setContentsMargins(60, 15, 60, 30); // 设置布局边距
Expand Down

0 comments on commit 9b0aaa6

Please sign in to comment.