Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions view/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2016 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2016 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -19,12 +19,13 @@
#include <QTextBrowser>
#include <QFile>
#include <QDebug>
#include <QMouseEvent>

Check warning on line 22 in view/mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QMouseEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QApplication>

Check warning on line 23 in view/mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtConcurrent>

Check warning on line 24 in view/mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtConcurrent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QProcess>

Check warning on line 25 in view/mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QProcess> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DWindowManagerHelper>

Check warning on line 26 in view/mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DWindowManagerHelper> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include "dialogs/messagedialog.h"

Check warning on line 27 in view/mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dialogs/messagedialog.h" not found.
#include "utils/udisksutils.h"

Check warning on line 28 in view/mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "utils/udisksutils.h" not found.

#include <dblockdevice.h>
#include <ddiskmanager.h>
Expand Down Expand Up @@ -117,13 +118,28 @@
else if (m_job->operation().contains("mkfs")) {
QTimer *timer = new QTimer();
m_simulationProgressValue = 0;
m_watchdogRetryCount = 0;
connect(timer, &QTimer::timeout, [this, timer]() {
m_simulationProgressValue += 0.06;
if (m_simulationProgressValue < 1) {
timer->start(300);
m_formatingPage->setProgress(m_simulationProgressValue);
m_simulationProgressValue += 0.06;
if (m_simulationProgressValue < 1) {
m_formatingPage->setProgress(m_simulationProgressValue);
} else {
m_formatingPage->setProgress(0.99);
timer->start(5000);
}
} else {
m_formatingPage->setProgress(0.99);
int ret = QProcess::execute("pgrep", QStringList() << "-f" << QString("mkfs.*%1").arg(m_formatPath));
if (ret == 1) {
timer->stop();
m_formatingPage->setProgress(1);
disconnect(m_job.data(), &DUDisksJob::completed, nullptr, nullptr);
this->onFormatingFinished(true);
} else if (++m_watchdogRetryCount >= 60) {
timer->stop();
disconnect(m_job.data(), &DUDisksJob::completed, nullptr, nullptr);
this->onFormatingFinished(false);
}
}
});
timer->start(300);
Expand Down
4 changes: 3 additions & 1 deletion view/mainwindow.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2016 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2016 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -85,6 +85,8 @@ public slots:

//模拟进度值
double m_simulationProgressValue;
//看门狗重试计数
int m_watchdogRetryCount = 0;
};

#endif // DIALOG_H
Loading