diff --git a/src/libs/utils/commandline.cpp b/src/libs/utils/commandline.cpp index 503f0c90776..78f003f1979 100644 --- a/src/libs/utils/commandline.cpp +++ b/src/libs/utils/commandline.cpp @@ -1508,6 +1508,11 @@ QString CommandLine::toUserOutput() const return res; } +QString CommandLine::displayName() const +{ + return m_executable.displayName(m_arguments); +} + QStringList CommandLine::splitArguments() const { return ProcessArgs::splitArgs(m_arguments, m_executable.osType()); diff --git a/src/libs/utils/commandline.h b/src/libs/utils/commandline.h index 3bffd8d7865..c8476ab95ed 100644 --- a/src/libs/utils/commandline.h +++ b/src/libs/utils/commandline.h @@ -152,6 +152,7 @@ public: void addCommandLineAsArgs(const CommandLine &cmd, RawType); QString toUserOutput() const; + QString displayName() const; FilePath executable() const { return m_executable; } void setExecutable(const FilePath &executable) { m_executable = executable; } diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index 07c76f7f753..3823f7974f7 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -921,6 +921,29 @@ FilePath FilePath::normalizedPathName() const return result; } +QString FilePath::displayName(const QString &args) const +{ + QString deviceName; + if (needsDevice()) { + QTC_ASSERT(s_deviceHooks.deviceDisplayName, return m_data); + deviceName = s_deviceHooks.deviceDisplayName(*this); + } + + if (args.isEmpty()) { + if (deviceName.isEmpty()) + return m_data; + + return QCoreApplication::translate("Utils::FileUtils", "%1 on %2", "File on device") + .arg(m_data, deviceName); + } + + if (deviceName.isEmpty()) + return m_data + ' ' + args; + + return QCoreApplication::translate("Utils::FileUtils", "%1 %2 on %3", "File and args on device") + .arg(m_data, args, deviceName); +} + /// Constructs a FilePath from \a filename /// \a filename is not checked for validity. FilePath FilePath::fromString(const QString &filepath) diff --git a/src/libs/utils/filepath.h b/src/libs/utils/filepath.h index ecd61beec1f..faf61ee66fb 100644 --- a/src/libs/utils/filepath.h +++ b/src/libs/utils/filepath.h @@ -175,6 +175,7 @@ public: // on Windows and macOS. This is rarely needed. [[nodiscard]] FilePath normalizedPathName() const; + QString displayName(const QString &args = {}) const; QString nativePath() const; QString shortNativePath() const; bool startsWithDriveLetter() const; diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index dbcc10019ac..995ebfb78b0 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -86,6 +86,7 @@ public: std::function environment; std::function fileSize; std::function bytesAvailable; + std::function deviceDisplayName; template using Continuation = std::function; std::function &, const FilePath &, const FilePath &)> asyncCopyFile; diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp index e97bd096969..deb96f14291 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp @@ -595,6 +595,12 @@ DeviceManager::DeviceManager(bool isInstance) : d(std::make_uniquebytesAvailable(filePath); }; + deviceHooks.deviceDisplayName = [](const FilePath &filePath) { + auto device = DeviceManager::deviceForPath(filePath); + QTC_ASSERT(device, return QString()); + return device->displayName(); + }; + FileUtils::setDeviceFileHooks(deviceHooks); DeviceProcessHooks processHooks; diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 910e8271615..bd7714546a8 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -1520,7 +1520,7 @@ void SimpleTargetRunnerPrivate::forwardDone() { if (m_stopReported) return; - const QString executable = m_command.executable().toUserOutput(); + const QString executable = m_command.executable().displayName(); QString msg = tr("%1 exited with code %2").arg(executable).arg(m_resultData.m_exitCode); if (m_resultData.m_exitStatus == QProcess::CrashExit) msg = tr("%1 crashed.").arg(executable); @@ -1570,7 +1570,7 @@ void SimpleTargetRunner::start() d->m_process.setTerminalMode(useTerminal ? Utils::TerminalMode::On : Utils::TerminalMode::Off); d->m_runAsRoot = runAsRoot; - const QString msg = RunControl::tr("Starting %1...").arg(d->m_command.toUserOutput()); + const QString msg = RunControl::tr("Starting %1...").arg(d->m_command.displayName()); appendMessage(msg, NormalMessageFormat); const bool isDesktop = !d->m_command.executable().needsDevice();