Skip to content

Commit 29c8b0e

Browse files
committed
fix: improve file manager command handling
1. Changed command strings to QStringList for better argument handling 2. Fixed typo in pin_screenshots module (changed "select how-item" to correct "--show-item") 3. Improved consistency across different modules for file manager commands 4. Added missing QtCore/qcontainerfwd.h include for QStringList support These changes make the file manager command execution more reliable and maintainable by: - Using proper argument separation with QStringList instead of comma- separated strings - Ensuring consistent behavior across different parts of the application - Fixing a typo that could cause the file manager to fail - Adding required header for QStringList operations fix: 改进文件管理器命令处理 1. 将命令字符串改为 QStringList 以更好地处理参数 2. 修复 pin_screenshots 模块中的拼写错误(将 "select how-item" 改为正确 的 "--show-item") 3. 提高不同模块间文件管理器命令的一致性 4. 添加缺失的 QtCore/qcontainerfwd.h 头文件以支持 QStringList 这些改进通过以下方式使文件管理器命令执行更可靠和可维护: - 使用 QStringList 而不是逗号分隔的字符串来正确分离参数 - 确保应用程序不同部分行为一致 - 修复可能导致文件管理器失败的拼写错误 - 添加 QStringList 操作所需的头文件 pms: BUG-317649
1 parent ac42bf7 commit 29c8b0e

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/main_window.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,13 +3453,16 @@ void MainWindow::sendNotify(SaveAction saveAction, QString saveFilePath, const b
34533453
// QString fileDir = QUrl::fromLocalFile(QFileInfo(saveFilePath).absoluteDir().absolutePath()).toString();
34543454
// QString filePath = QUrl::fromLocalFile(saveFilePath).toString();
34553455

3456-
QString command, savepathcommand;
3457-
3456+
QStringList command, savepathcommand;
3457+
34583458
tips = QString(tr("Saved to %1")).arg(saveFilePath);
34593459
if (!QStandardPaths::findExecutable("dde-file-manager").isEmpty()) {
3460-
savepathcommand = QString("dde-file-manager,--show-item,%1").arg(saveFilePath);
3460+
savepathcommand << "dde-file-manager";
3461+
savepathcommand << "--show-item";
3462+
savepathcommand << saveFilePath;
34613463
}
3462-
command = QString("xdg-open,%1").arg(saveFilePath);
3464+
command << "xdg-open";
3465+
command << saveFilePath;
34633466
qDebug() << "command:" << command;
34643467

34653468
hints["x-deepin-action-_open"] = command;

src/pin_screenshots/mainwindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,9 @@ void MainWindow::sendNotify(QString savePath, bool bSaveState)
641641
actions << "_open" << tr("View");
642642
if (!QStandardPaths::findExecutable("dde-file-manager").isEmpty()) {
643643
qDebug() << QFileInfo(savePath).path();
644-
hints["x-deepin-action-_open"] = QString("dde-file-manager,--show-item,%1").arg(savePath);
644+
hints["x-deepin-action-_open"] = QStringList{"dde-file-manager", "--show-item", savePath};
645645
} else {
646-
hints["x-deepin-action-_open"] = QString("xdg-open,%1").arg(savePath);
646+
hints["x-deepin-action-_open"] = QStringList{"xdg-open", savePath};
647647
}
648648
body = QString(tr("Saved to %1")).arg(savePath);
649649
}

src/record_process.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,8 @@ void RecordProcess::exitRecord(QString newSavePath)
806806
actions << "_open1" << tr("Open Folder");
807807

808808
QVariantMap hints;
809-
hints["x-deepin-action-_open"] = QString("xdg-open,%1").arg(newSavePath);
810-
QString savepathcommand = QString("dde-file-manager,--show-item,%1").arg(newSavePath);
809+
hints["x-deepin-action-_open"] = QStringList{"xdg-open", newSavePath};
810+
QStringList savepathcommand = QStringList{"dde-file-manager", "--show-item", newSavePath};
811811
hints["x-deepin-action-_open1"] = savepathcommand;
812812
int timeout = -1;
813813
unsigned int id = 0;

0 commit comments

Comments
 (0)