Skip to content

Commit

Permalink
增加正在同步界面的动态移除
Browse files Browse the repository at this point in the history
  • Loading branch information
Firefly-26710 committed Jul 9, 2024
1 parent b7f12d4 commit 103815e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
filecard.h filecard.cpp
signhelper.h signhelper.cpp
historycard.h historycard.cpp
xmlprocesser.h xmlprocesser.cpp
#xmlprocesser.h xmlprocesser.cpp

)
# Define target properties for Android with Qt 6 as:
Expand Down
6 changes: 6 additions & 0 deletions filecard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ FileCard::FileCard(QString f, QString d,QString s,QString p)
FileCardArea->addLayout(actionArea,Qt::AlignCenter);
FileCardArea->addStretch();

connect(relieveBtn,&ElaIconButton::clicked,this,&FileCard::on_relieveBtn_clicked);
}

void FileCard::on_relieveBtn_clicked()
{
emit Relieve();
}
6 changes: 6 additions & 0 deletions filecard.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ElaIconButton;
class ElaProgressBar;
class FileCard : public ElaScrollPageArea
{
Q_OBJECT
public:
explicit FileCard(QString f, QString d,QString s,QString p);

Expand All @@ -21,6 +22,11 @@ class FileCard : public ElaScrollPageArea
ElaIconButton*pauseBtn;
ElaIconButton*relieveBtn;
ElaProgressBar*proBar;

private slots:
void on_relieveBtn_clicked();
signals:
void Relieve();
};

#endif // FILECARD_H
21 changes: 21 additions & 0 deletions syncing_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ SyncingPage::SyncingPage(QWidget* parent)
FileCard*FileCardArea9=new FileCard("文件9","3.5GB","9MB/s","0%");
FileCard*FileCardArea10=new FileCard("文件10","3.5GB","10MB/s","0%");

connect(FileCardArea1,&FileCard::Relieve,this,&SyncingPage::removeFile);
connect(FileCardArea2,&FileCard::Relieve,this,&SyncingPage::removeFile);
connect(FileCardArea3,&FileCard::Relieve,this,&SyncingPage::removeFile);
connect(FileCardArea4,&FileCard::Relieve,this,&SyncingPage::removeFile);
connect(FileCardArea5,&FileCard::Relieve,this,&SyncingPage::removeFile);
connect(FileCardArea6,&FileCard::Relieve,this,&SyncingPage::removeFile);
connect(FileCardArea7,&FileCard::Relieve,this,&SyncingPage::removeFile);
connect(FileCardArea8,&FileCard::Relieve,this,&SyncingPage::removeFile);
connect(FileCardArea9,&FileCard::Relieve,this,&SyncingPage::removeFile);
connect(FileCardArea10,&FileCard::Relieve,this,&SyncingPage::removeFile);

QWidget* filesWidget=new QWidget();
filesLayout=new QVBoxLayout(filesWidget);
Expand Down Expand Up @@ -132,5 +142,16 @@ SyncingPage::~SyncingPage()
void SyncingPage::addFile(QString filename, QString datasize,QString speed,QString progress)
{
FileCard*firecard=new FileCard(filename,datasize,speed,progress);
connect(firecard,&FileCard::Relieve,this,&SyncingPage::removeFile);
filesLayout->addWidget(firecard);
}

void SyncingPage::removeFile()
{
FileCard *card = qobject_cast<FileCard*>(sender());
if (card)
{
layout()->removeWidget(card);
delete card;
}
}
1 change: 1 addition & 0 deletions syncing_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SyncingPage : public ElaScrollPage
SyncingPage(QWidget* parent = nullptr);
~SyncingPage();
void addFile(QString filename, QString datasize,QString speed,QString progress);
void removeFile();
QVBoxLayout*filesLayout;
private:
ElaProgressBar* _progressBar{nullptr};
Expand Down

0 comments on commit 103815e

Please sign in to comment.