Skip to content

Commit 5cd3fcb

Browse files
lichaofan2008deepin-bot[bot]
authored andcommitted
fix: Modify the parameters in the setDocName() function.
按照DDE的要求,setDocName()函数中传入的字符串不能是绝对路径也不带扩展名。 Revert b85b9d2. Bug: https://pms.uniontech.com/bug-view-329561.html https://pms.uniontech.com/bug-view-329547.html
1 parent 0d995ca commit 5cd3fcb

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/widgets/window.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,15 +2233,20 @@ void Window::popupPrintDialog()
22332233
m_pPreview = new DPrintPreviewDialog(this);
22342234
m_pPreview->setAttribute(Qt::WA_DeleteOnClose);
22352235

2236-
// 设置 QPrinter 的文档名称,保留绝对路径和文件后缀(在cups的page_log中保留完整的job-name)
2237-
// 注意和文件的输出文件路径进行区分
22382236
if (fileDir == m_blankFileDir) {
2237+
QString name = m_tabbar->currentName();
2238+
QRegularExpression reg("[^*](.+)");
2239+
QRegularExpressionMatch match = reg.match(name);
2240+
QString docName = match.captured(0);
2241+
qInfo() << __func__ << "print blank file, docName:" << docName;
22392242
qInfo() << qPrintable("Print blank file");
2240-
m_pPreview->setDocName(filePath);
2243+
m_pPreview->setDocName(docName);
22412244
} else {
22422245
qInfo() << qPrintable("Print file: ") << filePath;
22432246
QString path = currentWrapper()->textEditor()->getTruePath();
2244-
m_pPreview->setDocName(path);
2247+
QString docName = QFileInfo(path).baseName();
2248+
qInfo() << __func__ << "print normal file, docName:" << docName;
2249+
m_pPreview->setDocName(docName);
22452250
}
22462251

22472252
// 后续布局计算后再更新打印页数

0 commit comments

Comments
 (0)