fix: ISSUE #I68566 下载列表错位,图标错误

DownloadItem 原始定义高度为 54px,上下边距各 4px;然而图片 label 高度定义为 48,且宽度未定义,明显放不下;DownloadListWidget 中添加 item 时,设置每个 item sizeHint 高度只有 50px,与 item 高度不一致

Log: 固定 DownloadItem 高度为 56px;修改 DownloadListWidget 添加 item 时每个 item 的 sizeHint 高度;使用 DLabel 替换 QLabel 用于单个 item 中应用名称显示,使用 setElideMode 保证名称过长时右边显示省略号,并添加鼠标悬浮提示
This commit is contained in:
zty199 2022-12-31 23:05:36 +08:00
parent 4120af7e24
commit c636e0882b
4 changed files with 75 additions and 33 deletions

@ -22,6 +22,8 @@ DownloadItem::DownloadItem(QWidget *parent) : QWidget(parent),
ui->pushButton_3->hide();
ui->widget_spinner->start();
ui->widget_spinner->hide();
ui->label->setElideMode(Qt::TextElideMode::ElideRight);
}
DownloadItem::~DownloadItem()
@ -48,6 +50,7 @@ void DownloadItem::setMax(qint64 max)
void DownloadItem::setName(QString name)
{
ui->label->setText(name);
ui->label->setToolTip(name);
}
QString DownloadItem::getName()

@ -7,13 +7,25 @@
<x>0</x>
<y>0</y>
<width>666</width>
<height>54</height>
<height>56</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>56</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>54</height>
<height>56</height>
</size>
</property>
<property name="windowTitle">
@ -40,10 +52,22 @@
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>48</width>
<height>16777215</height>
<height>48</height>
</size>
</property>
<property name="text">
@ -52,6 +76,9 @@
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
@ -70,6 +97,31 @@
</property>
</spacer>
</item>
<item>
<widget class="DLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>48</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>48</height>
</size>
</property>
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_filename">
<property name="maximumSize">
@ -83,33 +135,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>13</pointsize>
</font>
</property>
<property name="text">
<string>Name</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@ -153,11 +178,14 @@
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
<number>8</number>
</property>
<item>
<widget class="QProgressBar" name="progressBar">
@ -297,6 +325,11 @@
<header location="global">dspinner.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>DLabel</class>
<extends>QLabel</extends>
<header>dlabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

@ -91,7 +91,7 @@ void DownloadListWidget::addItem(QString name, QString fileName, QString pkgName
di->pkgName = pkgName;
di->seticon(icon);
QListWidgetItem *pItem = new QListWidgetItem();
pItem->setSizeHint(QSize(240, 50));
pItem->setSizeHint(QSize(240, 56)); // ui 中单个 downloaditem 高度固定 56px上下 margin 8px图片固定 48x48
ui->listWidget->addItem(pItem);
ui->listWidget->setItemWidget(pItem, di);
if (!isBusy)

@ -85,7 +85,7 @@ QListWidget::item::selected
}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
@ -99,9 +99,15 @@ QListWidget::item::selected
<property name="autoScrollMargin">
<number>10</number>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="resizeMode">
<enum>QListView::Fixed</enum>
</property>
<property name="spacing">
<number>4</number>
</property>
</widget>
</item>
<item>