From 4eb1de51f990f69d4ded1657ad780e65b5ddf8ef Mon Sep 17 00:00:00 2001 From: Cppthx <2728347417@qq.com> Date: Tue, 9 Jul 2024 11:47:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=95=8C=E9=9D=A2UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 + historysync_view.h | 1 + historyview.cpp | 110 ++++++++++++++++++++++++++++++++++++++++++++ historyview.h | 22 +++++++++ historyviewcard.cpp | 37 +++++++++++++++ historyviewcard.h | 21 +++++++++ mainwindow.cpp | 8 ++-- mainwindow.h | 2 + userinfopage.cpp | 9 ++++ 9 files changed, 209 insertions(+), 3 deletions(-) create mode 100644 historyview.cpp create mode 100644 historyview.h create mode 100644 historyviewcard.cpp create mode 100644 historyviewcard.h diff --git a/CMakeLists.txt b/CMakeLists.txt index be83098..d185328 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,8 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) tasktoken.h tasktoken.cpp filecard.h filecard.cpp historycard.h historycard.cpp + historyview.h historyview.cpp + historyviewcard.h historyviewcard.cpp ) diff --git a/historysync_view.h b/historysync_view.h index d016b92..982e2a5 100644 --- a/historysync_view.h +++ b/historysync_view.h @@ -4,6 +4,7 @@ #include "ElaProgressBar.h" #include "ElaScrollPage.h" #include "ElaScrollPageArea.h" +#include"ElaPushButton.h" class QVBoxLayout; class HistorysyncPage : public ElaScrollPage diff --git a/historyview.cpp b/historyview.cpp new file mode 100644 index 0000000..37f3a0b --- /dev/null +++ b/historyview.cpp @@ -0,0 +1,110 @@ +#include"historyview.h" +#include +#include"ElaText.h" +#include +#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); +} diff --git a/historyview.h b/historyview.h new file mode 100644 index 0000000..2ddf986 --- /dev/null +++ b/historyview.h @@ -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 diff --git a/historyviewcard.cpp b/historyviewcard.cpp new file mode 100644 index 0000000..8185423 --- /dev/null +++ b/historyviewcard.cpp @@ -0,0 +1,37 @@ +#include "historyviewcard.h" +#include +#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(); +} diff --git a/historyviewcard.h b/historyviewcard.h new file mode 100644 index 0000000..ae9bf9a --- /dev/null +++ b/historyviewcard.h @@ -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 diff --git a/mainwindow.cpp b/mainwindow.cpp index e9ccfe4..92c735b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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) @@ -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) @@ -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); @@ -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) diff --git a/mainwindow.h b/mainwindow.h index 6c70a79..d1f0447 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -18,6 +18,7 @@ class T_Icon; class T_ElaScreen; class T_BaseComponents; class T_TabWidget; +class HistoryViewPage; class MainWindow : public ElaWindow { Q_OBJECT @@ -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}; diff --git a/userinfopage.cpp b/userinfopage.cpp index 6724b94..94bea06 100644 --- a/userinfopage.cpp +++ b/userinfopage.cpp @@ -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); From cd3b51e3bb3ad1c25a8ac5daac7661e7f8795ede Mon Sep 17 00:00:00 2001 From: Dipper209 <3611691282@qq.com> Date: Tue, 9 Jul 2024 12:03:53 +0800 Subject: [PATCH 2/2] test in main --- main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index ff7bb31..9732ccd 100644 --- a/main.cpp +++ b/main.cpp @@ -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); @@ -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()<