diff --git a/reader/widgets/SaveDialog.cpp b/reader/widgets/SaveDialog.cpp index f9c6aad4..d926d77f 100644 --- a/reader/widgets/SaveDialog.cpp +++ b/reader/widgets/SaveDialog.cpp @@ -1,16 +1,22 @@ -// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2019 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "SaveDialog.h" #include "ddlog.h" #include +#include +#include #include DWIDGET_USE_NAMESPACE +namespace { +constexpr int kMaxFileNameWidth = 400; +} + SaveDialog::SaveDialog(QObject *parent) : QObject(parent) { @@ -20,7 +26,9 @@ SaveDialog::SaveDialog(QObject *parent) int SaveDialog::showExitDialog(QString fileName, QWidget *parent) { qCDebug(appLog) << "Showing save dialog for file:" << fileName << ", parent:" << parent; - DDialog dlg(tr("Save the changes to \"%1\"?").arg(fileName), "", parent); + QFontMetrics fm(QGuiApplication::font()); + QString showName = fm.elidedText(fileName, Qt::ElideMiddle, kMaxFileNameWidth); + DDialog dlg(tr("Save the changes to \"%1\"?").arg(showName), "", parent); dlg.setIcon(QIcon::fromTheme("deepin-reader")); dlg.addButtons(QStringList() << tr("Cancel", "button") << tr("Discard", "button")); dlg.addButton(tr("Save", "button"), true, DDialog::ButtonRecommend);