优化基础属性页的文件计数更新机制,增加一个0.75s的定时更新器,避免出现长时间不更新的情况

This commit is contained in:
Yue-Lan 2022-07-11 19:39:27 +08:00
parent be6cd6297b
commit 03129324c4
2 changed files with 11 additions and 0 deletions

View File

@ -149,6 +149,11 @@ QRect PushButtonStyle::subElementRect(SubElement element, const QStyleOption *op
BasicPropertiesPage::BasicPropertiesPage(const QStringList &uris, QWidget *parent) : PropertiesWindowTabIface(parent) BasicPropertiesPage::BasicPropertiesPage(const QStringList &uris, QWidget *parent) : PropertiesWindowTabIface(parent)
{ {
m_uris = uris; m_uris = uris;
m_timer = new QTimer(this);
m_timer->setInterval(750);
connect(m_timer, &QTimer::timeout, this, [=]{
updateCountInfo(true);
});
//getFIleInfo //getFIleInfo
this->getFIleInfo(m_uris.first()); this->getFIleInfo(m_uris.first());
this->init(); this->init();
@ -618,6 +623,8 @@ void BasicPropertiesPage::onSingleFileChanged(const QString &oldUri, const QStri
void BasicPropertiesPage::countFilesAsync(const QStringList &uris) void BasicPropertiesPage::countFilesAsync(const QStringList &uris)
{ {
m_timer->start();
//old op will delete later //old op will delete later
if (m_countOp) { if (m_countOp) {
m_countOp->disconnect(); m_countOp->disconnect();
@ -650,6 +657,8 @@ void BasicPropertiesPage::countFilesAsync(const QStringList &uris)
connect(m_countOp, &FileOperation::operationPreparedOne, this, &BasicPropertiesPage::onFileCountOne, Qt::BlockingQueuedConnection); connect(m_countOp, &FileOperation::operationPreparedOne, this, &BasicPropertiesPage::onFileCountOne, Qt::BlockingQueuedConnection);
connect(m_countOp, &FileCountOperation::countDone, this, [=](quint64 file_count, quint64 hidden_file_count, quint64 total_size) { connect(m_countOp, &FileCountOperation::countDone, this, [=](quint64 file_count, quint64 hidden_file_count, quint64 total_size) {
m_timer->stop();
m_countOp = nullptr; m_countOp = nullptr;
m_folderContainFiles = file_count - m_folderContainFolders; m_folderContainFiles = file_count - m_folderContainFolders;
m_fileSizeCount = total_size; m_fileSizeCount = total_size;
@ -731,6 +740,7 @@ void BasicPropertiesPage::onFileCountOne(const QString &uri, quint64 size)
void BasicPropertiesPage::cancelCount() void BasicPropertiesPage::cancelCount()
{ {
m_timer->stop();
if (m_countOp) if (m_countOp)
m_countOp->cancel(); m_countOp->cancel();
} }

View File

@ -198,6 +198,7 @@ private:
// //
FileCountOperation *m_countOp = nullptr; FileCountOperation *m_countOp = nullptr;
QTimer *m_timer = nullptr;
}; };
class PushButtonStyle : public QProxyStyle class PushButtonStyle : public QProxyStyle