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 9, 2024
2 parents 0081ce4 + 6a18de4 commit 03df6dd
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
filecard.h filecard.cpp
signhelper.h signhelper.cpp
historycard.h historycard.cpp
historyview.h historyview.cpp
historyviewcard.h historyviewcard.cpp
cosclient.h cosclient.cpp
setexcludeditems_view.h setexcludeditems_view.cpp
xmlprocesser.h xmlprocesser.cpp
Expand Down
1 change: 1 addition & 0 deletions historysync_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "ElaProgressBar.h"
#include "ElaScrollPage.h"
#include "ElaScrollPageArea.h"
#include"ElaPushButton.h"

class QVBoxLayout;
class HistorysyncPage : public ElaScrollPage
Expand Down
110 changes: 110 additions & 0 deletions historyview.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#include"historyview.h"
#include<QVBoxLayout>
#include"ElaText.h"
#include<QHBoxLayout>
#include"ElaWidget.h"
#include"ElaText.h"
#include"ElaPushButton.h"
#include"ElaToggleButton.h"
#include"ElaScrollArea.h"

#include"historyviewcard.h"

HistoryViewPage::HistoryViewPage(QWidget* parent): ElaScrollPage(parent)
{
QWidget* centralWidget = new QWidget(this); // 创建中心部件
QVBoxLayout* centerVLayout = new QVBoxLayout(centralWidget); // 为中心部件设置垂直布局
centerVLayout->setContentsMargins(0, 0, 5, 0); // 设置布局边距,5为到右边的距离
centralWidget->setWindowTitle("查看历史"); // 设置窗口标题

// 创建一个 ElaProgressBar 对象,用作进度条
_progressBar = new ElaProgressBar(this);
// 设置QProgressBar的大小策略为水平方向可扩展,垂直方向固定
_progressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
// 设置最小尺寸,可以适当调整宽度以减少填充效果
_progressBar->setMinimumSize(100, 20); // 调整最小宽度为100,最小高度20
// 设置进度条的最小值和最大值
_progressBar->setMinimum(0);
_progressBar->setMaximum(0); // 表示不确定的进度
QWidget* progressBarArea = new QWidget();
progressBarArea->setWindowFlags(Qt::FramelessWindowHint); // 去除窗口边框
progressBarArea->setAttribute(Qt::WA_TranslucentBackground); // 设置背景透明
// 创建一个 ElaScrollPageArea 对象,用作进度条的容器
//ElaScrollPageArea* progressBarArea = new ElaScrollPageArea(this);
// 为进度条容器设置水平布局
QHBoxLayout* progressBarLayout = new QHBoxLayout(progressBarArea);
progressBarLayout->setContentsMargins(50, 0, 55, 0); // 设置布局的边距
// 创建一个 ElaText 对象,用于显示进度条的文本标签
ElaText* progressBarText = new ElaText("总进度:", this);
// 设置进度条文本标签的字体大小为 15
progressBarText->setTextSize(15);
// 将进度条文本标签和进度条控件添加到布局中
progressBarLayout->addWidget(progressBarText);
progressBarLayout->addWidget(_progressBar);

QWidget* catalogueArea = new QWidget();
catalogueArea->setWindowFlags(Qt::FramelessWindowHint); // 去除窗口边框
catalogueArea->setAttribute(Qt::WA_TranslucentBackground); // 设置背景透明
//ElaScrollPageArea* catalogueArea = new ElaScrollPageArea(this);
QHBoxLayout* catalogueLayout = new QHBoxLayout(catalogueArea);
catalogueLayout->setContentsMargins(10, 0, 15, 0);
ElaText* catalogueText1 = new ElaText("版本名", this);
catalogueText1->setTextSize(15);
catalogueText1->setAlignment(Qt::AlignCenter); // 设置文本居中对齐
ElaText* catalogueText2 = new ElaText("数据大小", this);
catalogueText2->setTextSize(15);
catalogueText2->setAlignment(Qt::AlignCenter); // 设置文本居中对齐
ElaText* catalogueText3 = new ElaText("同步时间", this);
catalogueText3->setTextSize(15);
catalogueText3->setAlignment(Qt::AlignCenter); // 设置文本居中对齐
ElaText* catalogueText4 = new ElaText("操作", this);
catalogueText4->setTextSize(15);
catalogueText4->setAlignment(Qt::AlignCenter); // 设置文本居中对齐
catalogueLayout->addWidget(catalogueText1);
catalogueLayout->addWidget(catalogueText2);
catalogueLayout->addWidget(catalogueText3);
catalogueLayout->addWidget(catalogueText4);

ElaScrollArea* scrollArea = new ElaScrollArea();
scrollArea->viewport()->setStyleSheet("background:transparent;");//设置背景透明

HistoryViewCard *HistoryViewCard1 = new HistoryViewCard("历史版本1","3.5G","2024.7.2");
HistoryViewCard *HistoryViewCard2 = new HistoryViewCard("历史版本2","3.5G","2024.5.3");
HistoryViewCard *HistoryViewCard3 = new HistoryViewCard("历史版本3","3.5G","2024.12.6");
HistoryViewCard *HistoryViewCard4 = new HistoryViewCard("历史版本4","3.5G","2024.1.6");
HistoryViewCard *HistoryViewCard5 = new HistoryViewCard("历史版本5","3.5G","2024.1.26");
HistoryViewCard *HistoryViewCard6 = new HistoryViewCard("历史版本6","3.5G","2024.7.9");
HistoryViewCard *HistoryViewCard7 = new HistoryViewCard("历史版本7","3.5G","2024.7.17");
HistoryViewCard *HistoryViewCard8 = new HistoryViewCard("历史版本8","3.5G","2024.8.8");
HistoryViewCard *HistoryViewCard9 = new HistoryViewCard("历史版本9","3.5G","2024.6.9");
HistoryViewCard *HistoryViewCard10 = new HistoryViewCard("历史版本10","3.5G","2024.10.10");
HistoryViewCard *HistoryViewCard11 = new HistoryViewCard("历史版本11","45.14G","1919.8.10");
QWidget* filesWidget=new QWidget();
filesLayout=new QVBoxLayout(filesWidget);
filesLayout->addWidget(HistoryViewCard1);
filesLayout->addWidget(HistoryViewCard2);
filesLayout->addWidget(HistoryViewCard3);
filesLayout->addWidget(HistoryViewCard4);
filesLayout->addWidget(HistoryViewCard5);
filesLayout->addWidget(HistoryViewCard6);
filesLayout->addWidget(HistoryViewCard7);
filesLayout->addWidget(HistoryViewCard8);
filesLayout->addWidget(HistoryViewCard9);
filesLayout->addWidget(HistoryViewCard10);
filesLayout->addWidget(HistoryViewCard11);

scrollArea->setWidget(filesWidget); // 设置scrollArea的内容部件
scrollArea->setWidgetResizable(true); // 允许scrollArea根据内容自动调整大小

centerVLayout->addWidget(progressBarArea); // 将上方固定区域添加到布局中
centerVLayout->addWidget(catalogueArea); // 将目录文本添加到布局中
centerVLayout->addWidget(scrollArea); // 将scrollArea添加到布局中

this->addCentralWidget(centralWidget); // 将中心部件添加到窗口
}

void HistoryViewPage::addHistoryViewCard(QString filename,QString datasize,QString bingtime)
{
HistoryViewCard*newHV=new HistoryViewCard(filename,datasize,bingtime);
filesLayout->addWidget(newHV);
}
22 changes: 22 additions & 0 deletions historyview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef HISTORYVIEW_H
#define HISTORYVIEW_H

#include "ElaScrollPage.h"
#include"ElaProgressBar.h"

class ElaToggleButton;
class ElaPushButton;
class DirCard;
class QVBoxLayout;
class HistoryViewPage : public ElaScrollPage
{
public:
explicit HistoryViewPage(QWidget* parent);
QVBoxLayout*filesLayout;
void addHistoryViewCard(QString filename,QString datasize,QString bingtime);

private:
ElaProgressBar* _progressBar{nullptr};
};

#endif // HISTORYVIEW_H
37 changes: 37 additions & 0 deletions historyviewcard.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "historyviewcard.h"
#include<QVBoxLayout>
#include"ElaCheckBox.h"


HistoryViewCard::HistoryViewCard(QString f, QString d,QString t)
{
filename=new ElaText(f);
datasize=new ElaText(d);
time=new ElaText(t);

_checkBox = new ElaCheckBox(filename->text(), this);
QVBoxLayout*checkBoxArea=new QVBoxLayout();
checkBoxArea->addWidget(_checkBox,0,Qt::AlignCenter);

datasize->setTextSize(16);
QVBoxLayout*dataSizeArea=new QVBoxLayout();
dataSizeArea->addWidget(datasize,0,Qt::AlignCenter);

time->setTextSize(16);
QVBoxLayout*timeArea=new QVBoxLayout();

timeArea->addWidget(time,0,Qt::AlignCenter);

rollback = new ElaPushButton(this);
rollback->setFixedSize(100,40);
rollback->setText("回滚到此版本");
QVBoxLayout*rollbackArea = new QVBoxLayout();
rollbackArea->addWidget(rollback,0,Qt::AlignCenter);

QHBoxLayout*FileCardArea=new QHBoxLayout(this);
FileCardArea->addLayout(checkBoxArea,Qt::AlignCenter);
FileCardArea->addLayout(dataSizeArea,Qt::AlignCenter);
FileCardArea->addLayout(timeArea,Qt::AlignCenter);
FileCardArea->addLayout(rollbackArea,Qt::AlignCenter);
FileCardArea->addStretch();
}
21 changes: 21 additions & 0 deletions historyviewcard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef HISTORYVIEWCARD_H
#define HISTORYVIEWCARD_H
#include"ElaScrollPageArea.h"
#include"ElaText.h"
#include"ElaPushButton.h"

class ElaCheckBox;
class ElaProgressBar;
class HistoryViewCard : public ElaScrollPageArea
{
public:
explicit HistoryViewCard(QString f, QString d,QString t);

ElaCheckBox* _checkBox{nullptr};
ElaText *filename;
ElaText *datasize;
ElaText *time;
ElaPushButton *rollback;
};

#endif // HISTORYVIEWCARD_H
7 changes: 6 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "signhelper.h"
#include "tasktoken.h"
#include "cosclient.h"
#include "xmlprocesser.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Expand All @@ -26,7 +28,10 @@ int main(int argc, char *argv[])
QString token=tt.sessionToken;
QDateTime expiredTime=tt.expiredTime;
COSClient cosclient(bucketName,appId,region,secretId,secretKey,token,expiredTime);
qDebug()<<cosclient.listObjects("home/","");
QString xmlstr=cosclient.listObjects("home/","");
XmlProcesser xp;
Bucket bucket=xp.processXml(xmlstr);

//sh.generateSignature(request,60);
//qDebug() <<"s3 location:"<< loginuser.getS3Location();
SyncTaskDatabaseManager stm(&loginuser);
Expand Down
8 changes: 5 additions & 3 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "syncing_view.h"
#include"filemange_view.h"
#include "historysync_view.h"
#include"historyview.h"

MainWindow::MainWindow(QWidget *parent)
: ElaWindow(parent)
Expand All @@ -40,6 +41,7 @@ MainWindow::MainWindow(QWidget *parent)
_filemanagePage=new FileManagePage(this);
_historysyncPage = new HistorysyncPage(this);
_userinfopage = new UserInfoPage(this);
_historyviewPage = new HistoryViewPage(this);

connect(this, &ElaWindow::userInfoCardClicked, [=]() {
if(CurrentUser==nullptr)
Expand Down Expand Up @@ -78,7 +80,7 @@ MainWindow::MainWindow(QWidget *parent)
addPageNode("历史同步",_historysyncPage,testKey_2,ElaIconType::CheckToSlot);
addPageNode("同步文件夹管理",_filemanagePage,testKey_2,ElaIconType::FolderClosed);
addExpanderNode("版本控制",testKey_3,ElaIconType::EnvelopeOpenText);
addPageNode("查看历史",new QWidget(this),testKey_3,ElaIconType::CalendarClock);
addPageNode("查看历史",_historyviewPage,testKey_3,ElaIconType::CalendarClock);
addExpanderNode("个人功能",testKey_4,ElaIconType::User);
addPageNode("修改信息",_userinfopage,testKey_4,ElaIconType::Text);
addPageNode("注销账号",new QWidget(this),testKey_4,ElaIconType::UserSlash);
Expand Down Expand Up @@ -153,11 +155,11 @@ MainWindow::MainWindow(QWidget *parent)
MainWindow::~MainWindow() {}
void MainWindow::onUserLoggedIn(User user)
{
setUserInfoCardTitle(user.getUsername());
setUserInfoCardSubTitle(user.getEmail());
CurrentUser=new User(user);
_userinfopage->currentUser=CurrentUser;
db->insertUser(user.getEmail(),user.gethashedPassword());
setUserInfoCardTitle(user.getUsername());
setUserInfoCardSubTitle(user.getEmail());
}

void MainWindow::onNeedPassword(const QString &account)
Expand Down
2 changes: 2 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class T_Icon;
class T_ElaScreen;
class T_BaseComponents;
class T_TabWidget;
class HistoryViewPage;
class MainWindow : public ElaWindow
{
Q_OBJECT
Expand All @@ -43,6 +44,7 @@ public slots:
SyncingPage *_syncingPage{nullptr};
FileManagePage*_filemanagePage{nullptr};
HistorysyncPage *_historysyncPage{nullptr};
HistoryViewPage *_historyviewPage{nullptr};
T_ElaScreen *_elaScreenPage{nullptr};
T_Icon *_iconPage{nullptr};
T_BaseComponents *_baseComponentsPage{nullptr};
Expand Down
9 changes: 9 additions & 0 deletions userinfopage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ UserInfoPage::UserInfoPage(QWidget *parent) : QWidget(parent)
newPasswordEdit_->setPlaceholderText("新密码");
confirmNewPasswordEdit_->setPlaceholderText("确认密码");

// 设置样式
QString styleSheet = "QLineEdit { background-color: #e5e5e5; border: 1px solid #ccc; padding: 5px; }";
newIdEdit_->setStyleSheet(styleSheet);
newPasswordEdit_->setStyleSheet(styleSheet);
confirmNewPasswordEdit_->setStyleSheet(styleSheet);

// 重新设置布局边距和间距
layout->setContentsMargins(40, 20, 40, 20);
layout->setSpacing(10);

// 连接信号与槽
connect(confirmButton_, &ElaPushButton::clicked, this, &UserInfoPage::onConfirmButtonClicked);
Expand Down

0 comments on commit 03df6dd

Please sign in to comment.