Skip to content

Commit

Permalink
优化了DirCard类的布局
Browse files Browse the repository at this point in the history
  • Loading branch information
Firefly-26710 committed Jul 6, 2024
1 parent 1b65259 commit 35b8b4a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 47 deletions.
90 changes: 47 additions & 43 deletions thirdParty/ElaWidgetTools/DirCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,60 @@

#include"ElaCheckBox.h"
#include "private/DirCardPrivate.h"
#include"ElaText.h"
#include"ElaPushButton.h"
#include"ElaToggleButton.h"

DirCard::DirCard(QString filename, QString datasize,QString bingtime)
DirCard::DirCard(QString f, QString d,QString b)
{
//ElaScrollPageArea*DirCardArea=new ElaScrollPageArea(this);
this->setMaximumHeight(25);
int DirCardWidth=this->width();

QHBoxLayout*DirCardLayout=new QHBoxLayout(this);

_checkBox = new ElaCheckBox(filename, this);
_checkBox->setFont(QFont("",10));

ElaText* dataSize = new ElaText(datasize, this);
filename=new ElaText(f);
datasize=new ElaText(d);
bindtime=new ElaText(b);
QFont font("宋体",10);
font.setBold(true);

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

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

bindtime->setTextSize(12);
bindtime->setFont(font);
QVBoxLayout*bindTimeArea=new QVBoxLayout();
ElaText*text=new ElaText("绑定于",this);
ElaText*bindTime=new ElaText(bingtime,this);

dataSize->setTextSize(10);
text->setTextSize(10);
bindTime->setTextSize(10);

DirCardLayout->addWidget(_checkBox);

int index1=DirCardLayout->count();
DirCardLayout->insertSpacing(index1,DirCardWidth/6);

DirCardLayout->addWidget(dataSize);

int index2=DirCardLayout->count();
DirCardLayout->insertSpacing(index2,DirCardWidth/4*3);

DirCardLayout->addWidget(text);
DirCardLayout->addWidget(bindTime);

int index3=DirCardLayout->count();
DirCardLayout->insertSpacing(index3,DirCardWidth/5);

ElaToggleButton*pause=new ElaToggleButton("暂时停止");
pause->setFixedSize(70,25);
pause->setFont(QFont("",10));

ElaPushButton*relieve=new ElaPushButton("解除绑定");
relieve->setFixedSize(70,25);
relieve->setFont(QFont("",10));

DirCardLayout->addWidget(pause);
DirCardLayout->addWidget(relieve);
DirCardLayout->addStretch();
text->setTextSize(12);
text->setFont(font);
bindTimeArea->addWidget(text,0,Qt::AlignCenter);
bindTimeArea->setSpacing(0);
bindTimeArea->addWidget(bindtime,0,Qt::AlignCenter);

QVBoxLayout*pauseArea=new QVBoxLayout();
ElaToggleButton*pauseBtn=new ElaToggleButton("暂时停止");
pauseBtn->setFixedSize(70,25);
pauseBtn->setFont(font);
pauseArea->addWidget(pauseBtn,0,Qt::AlignCenter);

QVBoxLayout*relieveArea=new QVBoxLayout();
ElaPushButton*relieveBtn=new ElaPushButton("解除绑定");
relieveBtn->setFixedSize(70,25);
relieveBtn->setFont(font);
relieveArea->addWidget(relieveBtn,0,Qt::AlignCenter);

QHBoxLayout*prArea=new QHBoxLayout();
prArea->addLayout(pauseArea,Qt::AlignCenter);
prArea->addLayout(relieveArea,Qt::AlignCenter);

QHBoxLayout*DirCardArea=new QHBoxLayout(this);
DirCardArea->addLayout(checkBoxArea,Qt::AlignCenter);
DirCardArea->addLayout(dataSizeArea,Qt::AlignCenter);
DirCardArea->addLayout(bindTimeArea,Qt::AlignCenter);
DirCardArea->addLayout(prArea,Qt::AlignCenter);
}

DirCard::~DirCard() {}
9 changes: 5 additions & 4 deletions thirdParty/ElaWidgetTools/include/DirCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@

#include <QPushButton>
#include"ElaScrollPageArea.h"
#include"ElaText.h"

#include "stdafx.h"
class ElaCheckBox;
class DirCardPrivate;
class ELA_EXPORT DirCard : public ElaScrollPageArea
{
public:
explicit DirCard(QString filename,QString datasize,QString bingtime);
explicit DirCard(QString f, QString d,QString b);
~DirCard();
private:
ElaCheckBox* _checkBox{nullptr};
QString filename;
QString datasize;
QString bingtime;
ElaText *filename;
ElaText *datasize;
ElaText *bindtime;
};

#endif // ELAREMINDERCARD_H

0 comments on commit 35b8b4a

Please sign in to comment.