fix: 修复下载列表中进度提示文字显示不完整的问题

QLabel 未处理文字过长的问题

Log: 控件提升为 DLabel,设置文字过长时右侧显示省略号;添加鼠标悬浮提示;固定 item 中应用名称宽度未 120px,保证进度条显示位置对齐
This commit is contained in:
zty199 2023-01-03 21:37:21 +08:00
parent 116f14845e
commit 8b2a61e4b2
2 changed files with 11 additions and 3 deletions

View File

@ -24,6 +24,7 @@ DownloadItem::DownloadItem(QWidget *parent) : QWidget(parent),
ui->widget_spinner->hide();
ui->label->setElideMode(Qt::TextElideMode::ElideRight);
ui->label_2->setElideMode(Qt::TextElideMode::ElideRight);
}
DownloadItem::~DownloadItem()
@ -35,10 +36,12 @@ void DownloadItem::setValue(qint64 value)
{
ui->progressBar->setValue(qint32(value));
ui->label_2->setText(QString::number(double(value) / 100) + "% (" + speed + ")");
ui->label_2->setToolTip(QString::number(double(value) / 100) + "% (" + speed + ")");
if (ui->label_2->text().left(4) == "100%")
{
download = 1;
ui->label_2->setText(tr("Download Complete."));
ui->label_2->setToolTip(tr("Download Complete."));
}
}
@ -99,6 +102,7 @@ void DownloadItem::install(int t)
ui->widget_spinner->show();
qDebug() << "/tmp/spark-store/" + ui->label_filename->text().toUtf8();
ui->label_2->setText(tr("Installing"));
ui->label_2->setToolTip(tr("Installing"));
QtConcurrent::run([=]()
{
@ -143,6 +147,7 @@ void DownloadItem::install(int t)
ui->pushButton_install->hide();
Utils::sendNotification("spark-store",tr("Spark Store"),ui->label->text() + " " + tr("Installation complete."));
ui->label_2->setText(tr("Finish"));
ui->label_2->setToolTip(tr("Finish"));
download = 3;
ui->pushButton_3->show();
}
@ -153,6 +158,7 @@ void DownloadItem::install(int t)
download = 1;
Utils::sendNotification("spark-store",tr("Spark Store"),tr("Error happened in dpkg progress , you can try it again."));
ui->label_2->setText(tr("Error happened in dpkg progress , you can try it again"));
ui->label_2->setToolTip(tr("Error happened in dpkg progress , you can try it again"));
ui->pushButton_3->show();
}
@ -160,6 +166,7 @@ void DownloadItem::install(int t)
{
Utils::sendNotification("spark-store",tr("Spark Store"),tr("dpkg progress had been abortedyou can retry installation."));
ui->label_2->setText(tr("dpkg progress had been abortedyou can retry installation"));
ui->label_2->setToolTip(tr("dpkg progress had been abortedyou can retry installation"));
ui->pushButton_install->show();
ui->pushButton_3->hide();
}
@ -180,6 +187,7 @@ void DownloadItem::on_pushButton_install_clicked()
void DownloadItem::on_pushButton_2_clicked()
{
ui->label_2->setText(tr("Download canceled"));
ui->label_2->setToolTip(tr("Download canceled"));
download = 2;
ui->pushButton_2->setEnabled(false);
ui->progressBar->hide();

View File

@ -100,14 +100,14 @@
<item>
<widget class="DLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<width>120</width>
<height>48</height>
</size>
</property>
@ -216,7 +216,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="DLabel" name="label_2">
<property name="font">
<font>
<pointsize>9</pointsize>