Skip to content

Commit

Permalink
初步构建正在同步界面的文件列表,添加filecard类
Browse files Browse the repository at this point in the history
  • Loading branch information
Firefly-26710 committed Jul 8, 2024
1 parent ef667f5 commit b61035f
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
avatarImage.qrc
filequeue.h filequeue.cpp
storage.h storage.cpp
filecard.h filecard.cpp


)
Expand Down
58 changes: 58 additions & 0 deletions filecard.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "filecard.h"

#include<QVBoxLayout>
#include"ElaCheckBox.h"
#include"ElaIconButton.h"
#include"ElaProgressBar.h"
FileCard::FileCard(QString f, QString d,QString s,QString p)
{
filename=new ElaText(f);
datasize=new ElaText(d);
speed=new ElaText(s);
progress=new ElaText(p);

_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);

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

proBar = new ElaProgressBar(this);
proBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
proBar->setFixedSize(100,15);
proBar->setMinimum(0);
proBar->setMaximum(0);
progress->setTextSize(16);
QVBoxLayout*proBarArea=new QVBoxLayout();
proBarArea->addWidget(progress,0,Qt::AlignCenter);
proBarArea->addWidget(proBar,0,Qt::AlignCenter);
proBarArea->setAlignment(Qt::AlignCenter);

modifyBtn=new ElaIconButton(ElaIconType::CalendarLinesPen);
pauseBtn=new ElaIconButton(ElaIconType::Pause);
relieveBtn=new ElaIconButton(ElaIconType::Xmark);
modifyBtn->setFixedSize(30,30);
pauseBtn->setFixedSize(30,30);
relieveBtn->setFixedSize(30,30);

QHBoxLayout*actionArea=new QHBoxLayout();
actionArea->addWidget(modifyBtn);
actionArea->addWidget(pauseBtn);
actionArea->addWidget(relieveBtn);
actionArea->setAlignment(Qt::AlignCenter);

QHBoxLayout*FileCardArea=new QHBoxLayout(this);
FileCardArea->addLayout(checkBoxArea,Qt::AlignCenter);
FileCardArea->addLayout(dataSizeArea,Qt::AlignCenter);
FileCardArea->addLayout(speedArea,Qt::AlignCenter);
FileCardArea->addLayout(proBarArea,Qt::AlignCenter);
FileCardArea->addLayout(actionArea,Qt::AlignCenter);
FileCardArea->addStretch();

}
26 changes: 26 additions & 0 deletions filecard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef FILECARD_H
#define FILECARD_H

#include"ElaScrollPageArea.h"
#include"ElaText.h"

class ElaCheckBox;
class ElaIconButton;
class ElaProgressBar;
class FileCard : public ElaScrollPageArea
{
public:
explicit FileCard(QString f, QString d,QString s,QString p);

ElaCheckBox* _checkBox{nullptr};
ElaText *filename;
ElaText *datasize;
ElaText *speed;
ElaText*progress;
ElaIconButton*modifyBtn;
ElaIconButton*pauseBtn;
ElaIconButton*relieveBtn;
ElaProgressBar*proBar;
};

#endif // FILECARD_H
41 changes: 40 additions & 1 deletion syncing_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "ElaPushButton.h"
#include "ElaToggleButton.h"
#include <QVBoxLayout>
#include"filecard.h"
#include"ElaScrollArea.h"

SyncingPage::SyncingPage(QWidget* parent)
: ElaScrollPage(parent)
Expand Down Expand Up @@ -83,10 +85,41 @@ SyncingPage::SyncingPage(QWidget* parent)
catalogueLayout->addWidget(catalogueText4);
catalogueLayout->addWidget(catalogueText5);

ElaScrollArea* scrollArea = new ElaScrollArea();
scrollArea->viewport()->setStyleSheet("background:transparent;");//设置背景透明
FileCard*FileCardArea1=new FileCard("文件1","3.5GB","1MB/s","0%");
FileCard*FileCardArea2=new FileCard("文件2","3.5GB","2MB/s","0%");
FileCard*FileCardArea3=new FileCard("文件3","3.5GB","3MB/s","0%");
FileCard*FileCardArea4=new FileCard("文件4","3.5GB","4MB/s","0%");
FileCard*FileCardArea5=new FileCard("文件5","3.5GB","5MB/s","0%");
FileCard*FileCardArea6=new FileCard("文件6","3.5GB","6MB/s","0%");
FileCard*FileCardArea7=new FileCard("文件7","3.5GB","7MB/s","0%");
FileCard*FileCardArea8=new FileCard("文件8","3.5GB","8MB/s","0%");
FileCard*FileCardArea9=new FileCard("文件9","3.5GB","9MB/s","0%");
FileCard*FileCardArea10=new FileCard("文件10","3.5GB","10MB/s","0%");


QWidget* filesWidget=new QWidget();
filesLayout=new QVBoxLayout(filesWidget);
filesLayout->addWidget(FileCardArea1);
filesLayout->addWidget(FileCardArea2);
filesLayout->addWidget(FileCardArea3);
filesLayout->addWidget(FileCardArea4);
filesLayout->addWidget(FileCardArea5);
filesLayout->addWidget(FileCardArea6);
filesLayout->addWidget(FileCardArea7);
filesLayout->addWidget(FileCardArea8);
filesLayout->addWidget(FileCardArea9);
filesLayout->addWidget(FileCardArea10);
filesLayout->setAlignment(Qt::AlignTop);

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

centerVLayout->addWidget(progressBarArea); // 将上方固定区域添加到布局中
centerVLayout->addWidget(pushButtonArea); // 将切换按钮容器添加到布局中
centerVLayout->addWidget(catalogueArea); // 将目录文本添加到布局中
centerVLayout->addStretch(); // 在布局的末尾添加一个弹性空间
centerVLayout->addWidget(scrollArea);

this->addCentralWidget(centralWidget); // 将中心部件添加到窗口中
}
Expand All @@ -95,3 +128,9 @@ SyncingPage::~SyncingPage()
{

}

void SyncingPage::addFile(QString filename, QString datasize,QString speed,QString progress)
{
FileCard*firecard=new FileCard(filename,datasize,speed,progress);
filesLayout->addWidget(firecard);
}
5 changes: 4 additions & 1 deletion syncing_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@

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

class ElaToggleButton;
class ElaPushButton;
class QVBoxLayout;
class SyncingPage : public ElaScrollPage
{
public:
SyncingPage(QWidget* parent = nullptr);
~SyncingPage();
void addFile(QString filename, QString datasize,QString speed,QString progress);
QVBoxLayout*filesLayout;
private:
ElaProgressBar* _progressBar{nullptr};
ElaPushButton* _pushButton{nullptr};
Expand Down

0 comments on commit b61035f

Please sign in to comment.