From 55b3959546a947e87df81df1d98c3d39829d997a Mon Sep 17 00:00:00 2001 From: zhaominyong Date: Tue, 28 Jun 2022 14:21:01 +0800 Subject: [PATCH] =?UTF-8?q?125541=20=E3=80=90=E4=BA=91=E6=A1=8C=E9=9D=A2?= =?UTF-8?q?=E3=80=91=E3=80=90=E5=A4=87=E4=BB=BD=E8=BF=98=E5=8E=9F=E3=80=91?= =?UTF-8?q?=E6=8B=96=E6=94=BE=E6=96=87=E4=BB=B6=E5=A4=B9=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=EF=BC=8C=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kybackup/component/backuplistwidget.cpp | 15 +++++++++------ kybackup/component/backuppositionselectdialog.cpp | 2 +- kybackup/component/myfileselect.cpp | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/kybackup/component/backuplistwidget.cpp b/kybackup/component/backuplistwidget.cpp index 05c2e5a..97bfa90 100755 --- a/kybackup/component/backuplistwidget.cpp +++ b/kybackup/component/backuplistwidget.cpp @@ -140,16 +140,22 @@ BackupListWidget::BackupListWidget(QWidget *parent /*= nullptr*/, QHBoxLayout *p setLayout(vlayout); connect(this, &BackupListWidget::currentItemChanged, this, [=](QListWidgetItem *current, QListWidgetItem *previous) { + int row = this->currentRow(); if (current) { MyItemWidget *widget = qobject_cast(this->itemWidget(current)); - if (widget) - emit widget->selected(true); + if (widget) { + if (-1 == row) + emit widget->selected(false); + else + emit widget->selected(true); + } } if (previous) { MyItemWidget *widget = qobject_cast(this->itemWidget(previous)); - if (widget) + if (widget) { emit widget->selected(false); + } } }); } @@ -180,7 +186,6 @@ bool BackupListWidget::appendItem(const QString &text) item->setSizeHint(QSize(this->width() - 5, WIDTH_ITEM)); MyItemWidget *widget = new MyItemWidget; this->setItemWidget(item, widget); - this->setCurrentRow(-1); // 必须将scrollToBottom等这种滚动条操作放到判断滚动条是否显示isVisible之前 this->scrollToBottom(); @@ -204,7 +209,6 @@ bool BackupListWidget::appendItem(const QString &text) this->removeItemWidget(item); this->takeItem(this->row(item)); delete item; - this->setCurrentRow(-1); this->scrollToBottom(); if (this->count() == 0) { this->m_plusLogo->setVisible(true); @@ -223,7 +227,6 @@ bool BackupListWidget::appendItem(const QString &text) m_plusLogo->setVisible(false); m_plusText->setVisible(false); emit this->addedItem(); - return true; } diff --git a/kybackup/component/backuppositionselectdialog.cpp b/kybackup/component/backuppositionselectdialog.cpp index f6b19d8..0b93e56 100644 --- a/kybackup/component/backuppositionselectdialog.cpp +++ b/kybackup/component/backuppositionselectdialog.cpp @@ -6,7 +6,7 @@ BackupPositionSelectDialog::BackupPositionSelectDialog(QWidget* parent) : QFileDialog(parent) { setWindowTitle(tr("Please select a path")); - setViewMode(QFileDialog::List); + setViewMode(QFileDialog::Detail); setFileMode(QFileDialog::DirectoryOnly); setFilter(QDir::Dirs | QDir::NoDotAndDotDot); QList siderUrls; diff --git a/kybackup/component/myfileselect.cpp b/kybackup/component/myfileselect.cpp index 4686689..c88cc06 100755 --- a/kybackup/component/myfileselect.cpp +++ b/kybackup/component/myfileselect.cpp @@ -6,7 +6,7 @@ MyFileSelect::MyFileSelect(QWidget* parent) : QFileDialog(parent) { - this->setViewMode(QFileDialog::List); + this->setViewMode(QFileDialog::Detail); this->setFileMode(QFileDialog::ExistingFiles); this->setFilter(QDir::System | QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);