generated from L-Super/QtProjectTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ProgramCX/main
Create Basic UI
- Loading branch information
Showing
26 changed files
with
1,663 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "DownloadItemWidget.h" | ||
#include "ui_DownloadItemWidget.h" | ||
|
||
DownloadItemWidget::DownloadItemWidget(QWidget* parent) : QWidget(parent), ui(new Ui::DownloadItemWidget) | ||
{ | ||
ui->setupUi(this); | ||
connectSlots(); | ||
} | ||
|
||
void DownloadItemWidget::connectSlots() | ||
{ | ||
connect(ui->btnSuspend, &QPushButton::clicked, this, &DownloadItemWidget::onBtnSuspendClicked); | ||
} | ||
|
||
void DownloadItemWidget::onBtnSuspendClicked(bool checked) | ||
{ | ||
if (checked) { | ||
ui->btnSuspend->setText("继续"); | ||
//TODO:暂停下载的逻辑 | ||
} | ||
else { | ||
ui->btnSuspend->setText("暂停"); | ||
//TODO:开始下载的逻辑 | ||
} | ||
} | ||
|
||
DownloadItemWidget::~DownloadItemWidget() | ||
{ | ||
delete ui; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <QWidget> | ||
|
||
QT_BEGIN_NAMESPACE | ||
namespace Ui { | ||
class DownloadItemWidget; | ||
} | ||
QT_END_NAMESPACE | ||
|
||
class DownloadItemWidget : public QWidget { | ||
Q_OBJECT | ||
|
||
public: | ||
explicit DownloadItemWidget(QWidget* parent = nullptr); | ||
~DownloadItemWidget() override; | ||
|
||
protected slots: | ||
void onBtnSuspendClicked(bool checked); | ||
|
||
private: | ||
Ui::DownloadItemWidget* ui; | ||
|
||
void connectSlots(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>DownloadItemWidget</class> | ||
<widget class="QWidget" name="DownloadItemWidget"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>718</width> | ||
<height>178</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<item> | ||
<widget class="QFrame" name="frame"> | ||
<property name="styleSheet"> | ||
<string notr="true"/> | ||
</property> | ||
<property name="frameShape"> | ||
<enum>QFrame::Shape::StyledPanel</enum> | ||
</property> | ||
<property name="frameShadow"> | ||
<enum>QFrame::Shadow::Raised</enum> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout_2"> | ||
<item> | ||
<widget class="QLabel" name="labFileName"> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>20</width> | ||
<height>0</height> | ||
</size> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>16777215</width> | ||
<height>21</height> | ||
</size> | ||
</property> | ||
<property name="text"> | ||
<string>// 文件名称</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<spacer name="horizontalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Orientation::Horizontal</enum> | ||
</property> | ||
<property name="sizeType"> | ||
<enum>QSizePolicy::Policy::Fixed</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>200</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="btnSuspend"> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>61</width> | ||
<height>31</height> | ||
</size> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>61</width> | ||
<height>31</height> | ||
</size> | ||
</property> | ||
<property name="cursor"> | ||
<cursorShape>PointingHandCursor</cursorShape> | ||
</property> | ||
<property name="text"> | ||
<string>暂停</string> | ||
</property> | ||
<property name="checkable"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="btnDelete"> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>61</width> | ||
<height>31</height> | ||
</size> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>61</width> | ||
<height>31</height> | ||
</size> | ||
</property> | ||
<property name="cursor"> | ||
<cursorShape>PointingHandCursor</cursorShape> | ||
</property> | ||
<property name="text"> | ||
<string>删除</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout_3"> | ||
<item> | ||
<widget class="QLabel" name="labFileSize"> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>181</width> | ||
<height>21</height> | ||
</size> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>16777215</width> | ||
<height>21</height> | ||
</size> | ||
</property> | ||
<property name="text"> | ||
<string>文件大小</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="labRemainTime"> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>201</width> | ||
<height>21</height> | ||
</size> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>16777215</width> | ||
<height>21</height> | ||
</size> | ||
</property> | ||
<property name="text"> | ||
<string>剩余时间</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="labSpeed"> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>211</width> | ||
<height>21</height> | ||
</size> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>16777215</width> | ||
<height>21</height> | ||
</size> | ||
</property> | ||
<property name="text"> | ||
<string>下载速度</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<widget class="QProgressBar" name="progressBar"> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>621</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>16777215</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
<property name="value"> | ||
<number>24</number> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "DownloadListWidget.h" | ||
#include "ui_DownloadListWidget.h" | ||
|
||
#include <QListWidgetItem> | ||
|
||
#include "DownloadItemWidget.h" | ||
|
||
DownloadListWidget::DownloadListWidget(QWidget* parent) : QWidget(parent), ui(new Ui::DownloadListWidget) | ||
{ | ||
ui->setupUi(this); | ||
|
||
//仅供测试 | ||
QListWidgetItem* pItem = new QListWidgetItem(ui->listWidget); | ||
ui->listWidget->addItem(pItem); | ||
|
||
DownloadItemWidget* aCustomItem = new DownloadItemWidget; | ||
ui->listWidget->setItemWidget(pItem, aCustomItem); | ||
ui->listWidget->setCurrentItem(pItem); | ||
|
||
iniUi(); | ||
connectSlots(); | ||
} | ||
|
||
void DownloadListWidget::iniUi() | ||
{ | ||
//初次选中“下载中” | ||
ui->btnTabDownloading->setChecked(true); | ||
changeTab(0); | ||
} | ||
|
||
void DownloadListWidget::connectSlots() | ||
{ | ||
connect(ui->btnTabDownloading, &QPushButton::clicked, this, [=](bool checked) { | ||
if (checked) | ||
changeTab(0); | ||
else | ||
ui->btnTabDownloading->setChecked(true); | ||
}); | ||
connect(ui->btnTabStopped, &QPushButton::clicked, this, [=](bool checked) { | ||
if (checked) | ||
changeTab(1); | ||
else | ||
ui->btnTabStopped->setChecked(true); | ||
}); | ||
} | ||
|
||
void DownloadListWidget::changeTab(int index) | ||
{ | ||
if (index == 0) { | ||
ui->btnTabStopped->setChecked(false); | ||
//TODO:过滤下载条目 | ||
} | ||
else if (index == 1) { | ||
ui->btnTabDownloading->setChecked(false); | ||
//TODO:过滤下载条目 | ||
} | ||
} | ||
|
||
DownloadListWidget::~DownloadListWidget() | ||
{ | ||
delete ui; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <QWidget> | ||
|
||
QT_BEGIN_NAMESPACE | ||
namespace Ui { | ||
class DownloadListWidget; | ||
} | ||
QT_END_NAMESPACE | ||
|
||
class DownloadListWidget : public QWidget { | ||
Q_OBJECT | ||
|
||
public: | ||
explicit DownloadListWidget(QWidget* parent = nullptr); | ||
~DownloadListWidget() override; | ||
|
||
private: | ||
Ui::DownloadListWidget* ui; | ||
|
||
void iniUi(); | ||
void connectSlots(); | ||
void changeTab(int index); | ||
}; |
Oops, something went wrong.