fix: save dialog resets filename and format when changing save path#204
fix: save dialog resets filename and format when changing save path#204JWWTSL wants to merge 2 commits into
Conversation
Log: setDirectory() after selectFile/selectNameFilter caused native GTK dialog to clear selections on directory change; fixed by reordering setDirectory() first and enabling DontUseNativeDialog. Pms: bug-3471613
deepin pr auto review你好!我是CodeGeeX,你的智能编程助手。我已仔细审查了你提供的Git Diff代码。这次修改主要解决了文件对话框在特定环境(特别是Linux + GTK原生对话框)下的交互Bug,并对版权信息进行了更新。 以下是我对本次代码变更的详细审查意见,分为语法逻辑、代码质量、代码性能和代码安全四个方面: 1. 语法与逻辑亮点:
改进建议:
2. 代码质量亮点:
改进建议:
3. 代码性能改进建议:
4. 代码安全改进建议:
综合修改建议代码示例针对 if (toddf) {
FileSelectDialog dialog(_borad);
// 优化:提前计算目录路径,只调用一次setDirectory
QString dirPath = file.isEmpty() ? drawApp->defaultFileDialogPath()
: QFileInfo(file).dir().absolutePath();
dialog.setDirectory(dirPath);
dialog.setNameFilters(drawApp->writableFormatNameFilters());
dialog.selectNameFilter(drawApp->defaultFileDialogNameFilter());
if (!file.isEmpty()) {
dialog.selectFile(file);
} else {
// Add a format suffix to the default filename
QString fullFileName = defaultFileName;
// ... 原有的后缀处理逻辑 ...
dialog.selectFile(fullFileName);
}
dialog.exec();针对 // 使用 DontUseNativeDialog 以避免 GTK 原生对话框在调用 setDirectory 时重置文件名和过滤器
this->setOptions(QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog);整体而言,这是一次非常针对痛点的好修复,主要逻辑正确,只需在代码细节和长期维护性上稍加打磨即可。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: JWWTSL The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Log: setDirectory() after selectFile/selectNameFilter caused native GTK dialog to clear selections on directory change; fixed by reordering setDirectory() first and enabling DontUseNativeDialog.
Pms: bug-3471613