diff --git a/translations/dde-device-formatter.ts b/translations/dde-device-formatter.ts index 62d8249..6453592 100644 --- a/translations/dde-device-formatter.ts +++ b/translations/dde-device-formatter.ts @@ -4,7 +4,7 @@ FinishPage - + Format successful Format successful @@ -12,7 +12,7 @@ FormatingPage - + Formatting the disk, please wait... Formatting the disk, please wait... @@ -20,22 +20,22 @@ MainPage - + Type Type - + Label Label - + Quick Format Quick Format - + Formatting will erase all data on the disk. Formatting will erase all data on the disk. @@ -43,43 +43,48 @@ MainWindow - - + + Format Format - + + Large capacity disks may take longer + Large capacity disks may take longer + + + Continue Continue - + Formatting... Formatting... - + Done Done - + Quit Quit - + Your disk has been removed Your disk has been removed - + Failed to format the device Failed to format the device - + Reformat Reformat @@ -87,7 +92,7 @@ MessageDialog - + OK OK @@ -95,17 +100,17 @@ QCoreApplication - + System Disk System Disk - + %1 Encrypted %1 Encrypted - + %1 Volume %1 Volume @@ -113,17 +118,17 @@ QObject - + dde device formatter - + Device does not exist Device does not exist - + The device is read-only The device is read-only @@ -131,7 +136,7 @@ WarnPage - + Formatting will erase all data on this disk, are you sure you want to continue? It cannot be restored. Formatting will erase all data on this disk, are you sure you want to continue? It cannot be restored. diff --git a/translations/dde-device-formatter_zh_CN.ts b/translations/dde-device-formatter_zh_CN.ts index 6f858ba..eab74bf 100644 --- a/translations/dde-device-formatter_zh_CN.ts +++ b/translations/dde-device-formatter_zh_CN.ts @@ -4,7 +4,7 @@ FinishPage - + Format successful 格式化成功 @@ -12,7 +12,7 @@ FormatingPage - + Formatting the disk, please wait... 正在格式化,请稍候…… @@ -20,22 +20,22 @@ MainPage - + Type 类型 - + Label 卷标 - + Quick Format 快速格式化 - + Formatting will erase all data on the disk. 执行格式化后会彻底清空该磁盘内容。 @@ -43,43 +43,48 @@ MainWindow - - + + Format 格式化 - + + Large capacity disks may take longer + 大容量磁盘可能需要较长时间 + + + Continue 继续 - + Formatting... 格式化中…… - + Done 完成 - + Quit 退出 - + Your disk has been removed 您的磁盘已被移除 - + Failed to format the device 格式化失败 - + Reformat 重新格式化 @@ -87,7 +92,7 @@ MessageDialog - + OK 确定 @@ -95,17 +100,17 @@ QCoreApplication - + System Disk 系统盘 - + %1 Encrypted %1 已加密 - + %1 Volume %1 卷 @@ -113,17 +118,17 @@ QObject - + dde device formatter 格式化工具 - + Device does not exist 设备不存在 - + The device is read-only 此设备为只读 @@ -131,7 +136,7 @@ WarnPage - + Formatting will erase all data on this disk, are you sure you want to continue? It cannot be restored. 格式化操作将会清除磁盘上所有内容,确定继续操作?该操作无法恢复。 diff --git a/view/formatingpage.cpp b/view/formatingpage.cpp index 260e39b..b3900c8 100755 --- a/view/formatingpage.cpp +++ b/view/formatingpage.cpp @@ -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 @@ -34,6 +34,14 @@ void FormatingPage::initUI() mainLayout->addWidget(m_progressBox, 0 , Qt::AlignHCenter); mainLayout->addSpacing(15); mainLayout->addWidget(formatingLabel, 0 , Qt::AlignHCenter); + + m_hintLabel = new QLabel(this); + m_hintLabel->setObjectName("HintLabel"); + m_hintLabel->setWordWrap(true); + m_hintLabel->setAlignment(Qt::AlignHCenter); + m_hintLabel->hide(); + mainLayout->addWidget(m_hintLabel, 0, Qt::AlignHCenter); + mainLayout->addStretch(1); setLayout(mainLayout); } @@ -46,3 +54,23 @@ void FormatingPage::setProgress(double p) } m_progressBox->setValue(int(p * 100)); } + +void FormatingPage::setHintText(const QString &text) +{ + if (m_hintLabel) { + m_hintLabel->setText(text); + m_hintLabel->show(); + } +} + +void FormatingPage::reset() +{ + if (m_hintLabel) { + m_hintLabel->clear(); + m_hintLabel->hide(); + } + // setProgress 会跳过 0 值,这里直接复位动画进度 + if (m_progressBox) { + m_progressBox->setValue(1); + } +} diff --git a/view/formatingpage.h b/view/formatingpage.h index 6c6ff97..c86268d 100755 --- a/view/formatingpage.h +++ b/view/formatingpage.h @@ -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 @@ -7,6 +7,8 @@ #include +class QLabel; + namespace Dtk { namespace Widget { class DWaterProgress; @@ -20,10 +22,13 @@ class FormatingPage : public QFrame explicit FormatingPage(QWidget *parent = 0); void initUI(); void setProgress(double p); + void setHintText(const QString &text); + void reset(); public slots: private: Dtk::Widget::DWaterProgress* m_progressBox = NULL; + QLabel* m_hintLabel = nullptr; }; #endif // FORMATINGPAGE_H diff --git a/view/mainwindow.cpp b/view/mainwindow.cpp index 870efc6..b93dd2f 100755 --- a/view/mainwindow.cpp +++ b/view/mainwindow.cpp @@ -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 @@ -124,6 +124,8 @@ void MainWindow::initConnect() m_formatingPage->setProgress(m_simulationProgressValue); } else { m_formatingPage->setProgress(0.99); + m_formatingPage->setHintText(tr("Large capacity disks may take longer")); + timer->stop(); } }); timer->start(300); @@ -173,6 +175,9 @@ void MainWindow::initConnect() void MainWindow::formatDevice() { + // 失败重试时复用同一个格式化页面,需清掉上一轮残留的进度和提示 + m_formatingPage->reset(); + DWindowManagerHelper::setMotifFunctions(windowHandle(), DWindowManagerHelper::FUNC_CLOSE, false); setCloseButtonVisible(false);