/** * @RDE_HEADER@ * $Id: tpm_exported_scripts_model.h 53111 2021-03-22 08:21:29Z wille_m $ * $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/tpm_exported_scripts_model.h $ * $Author: wille_m $ * * Created by Mike Wille, SLTE, 2024-01-11 */ #include "tpm_process_dialog.h" #include #include namespace TakeHomePackageManager { ProcessOverlay::ProcessOverlay(QWidget *parent) : QWidget(parent) , m_ui(new Ui::ProcessOverlay) { m_ui->setupUi(this); connect(m_ui->pbCancel, &QPushButton::clicked, this, [this]() { m_ui->pbCancel->setEnabled(false); emit signalCancel(); }); } ProcessOverlay::~ProcessOverlay() { delete m_ui; } void ProcessOverlay::setCancelEnabled(bool enabled) { m_ui->pbCancel->setEnabled(enabled); } void ProcessOverlay::setStatus(const QString &text) { if (!text.isEmpty()) // only set new text if not empty (we dont want to send the text on every update.. m_ui->lblStatus->setText(text); } void ProcessOverlay::setFileProgress(qint64 bytesCopiedFile, qint64 bytesCopiedAll) { qWarning() << "setFileProgress" << "bytesCopiedFile" << bytesCopiedFile << "bytesCopiedAll" << bytesCopiedAll; double progressBytes = (m_bytesTotalFile == 0) ? 0 : ((double)bytesCopiedFile / (double)m_bytesTotalFile); double progressTotal = (m_bytesTotalAll == 0) ? 0 : (double)bytesCopiedAll / (double)m_bytesTotalAll; qWarning() << "progressTotal" << progressTotal << "progressBytes" << progressBytes; m_ui->pbarBytes->setValue(qRound(progressBytes * 100)); m_ui->pbarProgress->setValue(qRound(progressTotal * 100)); const QLocale l; m_ui->lblBytes->setText((m_bytesTotalFile == 0) ? QStringLiteral(" - ") : QStringLiteral("%1 / %2 %3").arg(l.toString(bytesCopiedFile)).arg(l.toString(m_bytesTotalFile)).arg(tr("bytes"))); m_ui->lblAllBytes->setText((m_bytesTotalAll == 0) ? QStringLiteral(" - ") : QStringLiteral("%1 / %2 %3").arg(l.toString(bytesCopiedAll)).arg(l.toString(m_bytesTotalAll)).arg(tr("bytes"))); } void ProcessOverlay::setNewFile(int currentFile, qint64 bytesTotalFile, const QString &filename) { qWarning() << "setNewFile" << "currentFile" << currentFile << "bytesTotalFile" << bytesTotalFile << "filename" << filename; m_bytesTotalFile = bytesTotalFile; m_currentFile = currentFile; m_progressFiles = (m_fileCount == 0) ? 0 : (((double)m_currentFile - 1) / (double)m_fileCount); m_ui->pbarFiles->setValue(qRound(m_progressFiles * 100)); m_ui->lblFilename->setText(filename); const QLocale l; m_ui->lblFiles->setText((m_currentFile == 0) ? QStringLiteral(" - ") : QStringLiteral("%1 / %2").arg(l.toString(m_currentFile)).arg(l.toString(m_fileCount))); } void ProcessOverlay::setStarted(int fileCount, qint64 bytesTotalAll) { qWarning() << "setStarted" << "fileCount" << fileCount << "bytesTotalAll" << bytesTotalAll; m_fileCount = fileCount; m_bytesTotalAll = bytesTotalAll; setFileProgress(0, 0); // so that the user sees some initial information before file transfer starts } } // namespace TakehomePackageManager