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
14 changes: 12 additions & 2 deletions src/plugins/cooperation/core/gui/dialogs/transferdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -7,6 +7,7 @@
#include <QMovie>

#include <maincontroller/maincontroller.h>
#include "common/commonutils.h"

using namespace cooperation_core;
#ifdef linux
Expand Down Expand Up @@ -118,6 +119,10 @@ void TransferDialog::createProgressPage()
font.setPixelSize(14);
titleLabel->setFont(font);

fileNameLabel = new CooperationLabel(this);
fileNameLabel->setAlignment(Qt::AlignHCenter);
fileNameLabel->setFont(font);

progressBar = new QProgressBar(this);
progressBar->setRange(0, 100);
progressBar->setValue(1);
Expand All @@ -130,6 +135,8 @@ void TransferDialog::createProgressPage()
progressMsgLael->setFont(font);

vLayout->addWidget(titleLabel);
vLayout->addSpacing(8);
vLayout->addWidget(fileNameLabel);
vLayout->addSpacing(20);
vLayout->addWidget(progressBar);
vLayout->addSpacing(18);
Expand Down Expand Up @@ -192,11 +199,14 @@ void TransferDialog::switchProgressPage(const QString &title)
okBtn->setVisible(true);
}

void TransferDialog::updateProgress(int value, const QString &remainTime)
void TransferDialog::updateProgress(int value, const QString &remainTime, const QString &filename)
{
if (progressBar->value() < value)
progressBar->setValue(value);

if (!filename.isEmpty())
fileNameLabel->setText(CommonUitls::elidedText(filename, Qt::ElideMiddle, 30));

QString remainTimeMsg(tr("Remaining time %1 | %2%").arg(remainTime, QString::number(value)));
progressMsgLael->setText(remainTimeMsg);
}
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/cooperation/core/gui/dialogs/transferdialog.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -27,7 +27,7 @@ class TransferDialog : public CooperationDialog
bool isInProgress() const;

public Q_SLOTS:
void updateProgress(int value, const QString &remainTime);
void updateProgress(int value, const QString &remainTime, const QString &filename = QString());

Q_SIGNALS:
void cancel();
Expand All @@ -49,6 +49,7 @@ public Q_SLOTS:
CooperationLabel *iconLabel { nullptr };
CooperationLabel *msgLabel { nullptr };
CooperationLabel *titleLabel { nullptr };
CooperationLabel *fileNameLabel { nullptr };
CooperationLabel *progressMsgLael { nullptr };
QProgressBar *progressBar { nullptr };
bool result { false };
Expand Down
19 changes: 15 additions & 4 deletions src/plugins/cooperation/core/proxy/cooperationdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "cooperationdialog.h"

#include <QHBoxLayout>
#include <QCloseEvent>
#include <QFont>
#include "common/commonutils.h"

using namespace cooperation_core;

Expand Down Expand Up @@ -50,8 +52,10 @@ void ProgressWidget::setTitle(const QString &title)
titleLabel->setText(title);
}

void ProgressWidget::setProgress(int value, const QString &msg)
void ProgressWidget::setProgress(int value, const QString &msg, const QString &filename)
{
if (!filename.isEmpty())
fileNameLabel->setText(CommonUitls::elidedText(filename, Qt::ElideMiddle, 30));
progressBar->setValue(value);
QString remainTimeMsg(tr("Remaining time %1 | %2%").arg(msg, QString::number(value)));
msgLabel->setText(remainTimeMsg);
Expand All @@ -60,8 +64,14 @@ void ProgressWidget::setProgress(int value, const QString &msg)
void ProgressWidget::init()
{
titleLabel = new CooperationLabel(this);
fileNameLabel = new CooperationLabel(this);
msgLabel = new CooperationLabel(this);

QFont font;
font.setWeight(QFont::DemiBold);
font.setPixelSize(14);
fileNameLabel->setFont(font);

progressBar = new QProgressBar(this);
progressBar->setRange(0, 100);
progressBar->setTextVisible(false);
Expand All @@ -72,6 +82,7 @@ void ProgressWidget::init()

QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(titleLabel, 1, Qt::AlignHCenter);
mainLayout->addWidget(fileNameLabel, 1, Qt::AlignHCenter);
mainLayout->addWidget(progressBar, 1);
mainLayout->addWidget(msgLabel, 1, Qt::AlignHCenter);
mainLayout->addWidget(cancelBtn, 1);
Expand Down Expand Up @@ -151,9 +162,9 @@ void CooperationTransDialog::showProgressDialog(const QString &title)
setHidden(false);
}

void CooperationTransDialog::updateProgressData(int value, const QString &msg)
void CooperationTransDialog::updateProgressData(int value, const QString &msg, const QString &filename)
{
progressWidget->setProgress(value, msg);
progressWidget->setProgress(value, msg, filename);
}

void CooperationTransDialog::closeEvent(QCloseEvent *e)
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/cooperation/core/proxy/cooperationdialog.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -41,7 +41,7 @@ class ProgressWidget : public QWidget
explicit ProgressWidget(QWidget *parent = nullptr);

void setTitle(const QString &title);
void setProgress(int value, const QString &msg);
void setProgress(int value, const QString &msg, const QString &filename = QString());

Q_SIGNALS:
void canceled();
Expand All @@ -50,6 +50,7 @@ class ProgressWidget : public QWidget
void init();

CooperationLabel *titleLabel { nullptr };
CooperationLabel *fileNameLabel { nullptr };
CooperationLabel *msgLabel { nullptr };
QProgressBar *progressBar { nullptr };
QPushButton *cancelBtn { nullptr };
Expand Down Expand Up @@ -85,7 +86,7 @@ class CooperationTransDialog : public QDialog
void showConfirmDialog(const QString &name);
void showResultDialog(bool success, const QString &msg);
void showProgressDialog(const QString &title);
void updateProgressData(int value, const QString &msg);
void updateProgressData(int value, const QString &msg, const QString &filename = QString());

protected:
void closeEvent(QCloseEvent *e) override;
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/cooperation/core/proxy/cooperationproxy.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -17,6 +17,7 @@
#include "ipc/proto/backend.h"

#include <QDir>
#include <QFileInfo>
#include <QUrl>
#include <QTime>
#include <QTimer>
Expand Down Expand Up @@ -148,7 +149,8 @@ void CooperationProxy::onFileTransStatusChanged(const QString &status)
LOG_IF(FLG_log_detail) << "progressbar: " << progressValue << " remain_time=" << remain_time;
LOG_IF(FLG_log_detail) << "totalSize: " << transferInfo.totalSize << " transferSize=" << transferInfo.transferSize;

updateProgress(progressValue, time.toString("hh:mm:ss"));
QString fileName = QFileInfo(QString(param.name.c_str())).fileName();
updateProgress(progressValue, time.toString("hh:mm:ss"), fileName);
}

void CooperationProxy::onConfirmTimeout()
Expand Down Expand Up @@ -347,9 +349,9 @@ void CooperationProxy::showTransResult(bool success, const QString &msg)
cooperationDialog()->showResultDialog(success, msg);
}

void CooperationProxy::updateProgress(int value, const QString &msg)
void CooperationProxy::updateProgress(int value, const QString &msg, const QString &filename)
{
static QString title(tr("Receiving files from \"%1\""));
cooperationDialog()->showProgressDialog(title.arg(CommonUitls::elidedText(fromWho, Qt::ElideMiddle, 15)));
cooperationDialog()->updateProgressData(value, msg);
cooperationDialog()->updateProgressData(value, msg, filename);
}
4 changes: 2 additions & 2 deletions src/plugins/cooperation/core/proxy/cooperationproxy.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -57,7 +57,7 @@ public Q_SLOTS:
CooperationTransDialog *cooperationDialog();

void showTransResult(bool success, const QString &msg);
void updateProgress(int value, const QString &msg);
void updateProgress(int value, const QString &msg, const QString &filename = QString());

private:
FrontendService *frontendIpcSer { nullptr };
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/cooperation/core/transfer/transferhelper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -19,6 +19,7 @@
#include <QDesktopServices>
#include <QApplication>
#include <QFileDialog>
#include <QFileInfo>
#include <QStandardPaths>
#include <QTime>
#include <QTimer>
Expand Down Expand Up @@ -199,11 +200,11 @@ void TransferHelperPrivate::transferResult(bool result, const QString &msg)
reportTransferResult(result);
}

void TransferHelperPrivate::updateProgress(int value, const QString &remainTime)
void TransferHelperPrivate::updateProgress(int value, const QString &remainTime, const QString &filename)
{
QString title = tr("Sending files to \"%1\"").arg(CommonUitls::elidedText(sendToWho, Qt::ElideMiddle, 15));
transDialog()->switchProgressPage(title);
transDialog()->updateProgress(value, remainTime);
transDialog()->updateProgress(value, remainTime, filename);
}

void TransferHelperPrivate::reportTransferResult(bool result)
Expand Down Expand Up @@ -439,7 +440,8 @@ void TransferHelper::onFileTransStatusChanged(const QString &status)
LOG_IF(FLG_log_detail) << "progressbar: " << progressValue << " remain_time=" << remain_time;
LOG_IF(FLG_log_detail) << "totalSize: " << d->transferInfo.totalSize << " transferSize=" << d->transferInfo.transferSize;

d->updateProgress(progressValue, time.toString("hh:mm:ss"));
QString fileName = QFileInfo(QString(param.name.c_str())).fileName();
d->updateProgress(progressValue, time.toString("hh:mm:ss"), fileName);
}

void TransferHelper::waitForConfirm()
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/cooperation/core/transfer/transferhelper_p.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -51,7 +51,7 @@ class TransferHelperPrivate : public QObject
void handleSearchDevice(const QString &ip);

void transferResult(bool result, const QString &msg);
void updateProgress(int value, const QString &remainTime);
void updateProgress(int value, const QString &remainTime, const QString &filename = QString());

void reportTransferResult(bool result);

Expand Down
10 changes: 7 additions & 3 deletions src/plugins/cooperation/daemon/maincontroller/maincontroller.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -23,6 +23,7 @@
#include <QVariantMap>
#include <QJsonDocument>
#include <QFontMetrics>
#include <QFileInfo>
#include <QDBusReply>
#include <QProcess>

Expand Down Expand Up @@ -88,13 +89,15 @@ void MainController::transferResult(bool result, const QString &msg)
recvNotifyId = notifyMessage(recvNotifyId, msg, actions, {}, 3 * 1000);
}

void MainController::updateProgress(int value, const QString &remainTime)
void MainController::updateProgress(int value, const QString &remainTime, const QString &filename)
{
// 在通知中心中,如果通知内容包含“%”且actions中存在“cancel”,则不会在通知中心显示
QStringList actions { NotifyCancelAction, tr("Cancel") };
// dde-session-ui 5.7.2.2 版本后,支持设置该属性使消息不进通知中心
QVariantMap hitMap { { "x-deepin-ShowInNotifyCenter", false } };
QString msg(tr("File receiving %1% | Remaining time %2").arg(QString::number(value), remainTime));
if (!filename.isEmpty())
msg = tr("%1 | File receiving %2% | Remaining time %3").arg(filename, QString::number(value), remainTime);

recvNotifyId = notifyMessage(recvNotifyId, msg, actions, hitMap, 15 * 1000);
}
Expand Down Expand Up @@ -283,7 +286,8 @@ void MainController::onFileTransStatusChanged(const QString &status)
LOG_IF(FLG_log_detail) << "progressbar: " << progressValue << " remain_time=" << remain_time;
LOG_IF(FLG_log_detail) << "totalSize: " << transferInfo.totalSize << " transferSize=" << transferInfo.transferSize;

updateProgress(progressValue, time.toString("hh:mm:ss"));
QString fileName = QFileInfo(QString(param.name.c_str())).fileName();
updateProgress(progressValue, time.toString("hh:mm:ss"), fileName);
}

void MainController::onConfirmTimeout()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -51,7 +51,7 @@ public Q_SLOTS:
uint notifyMessage(uint replacesId, const QString &body,
const QStringList &actions, QVariantMap hitMap, int expireTimeout);
void transferResult(bool result, const QString &msg);
void updateProgress(int value, const QString &remainTime);
void updateProgress(int value, const QString &remainTime, const QString &filename = QString());
void openFileLocation(const QString &path);

private:
Expand Down
Loading