diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index b9d692136bd..fc96a5b57ad 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -2942,7 +2942,7 @@ void EditorManager::populateOpenWithMenu(QMenu *menu, const QString &fileName) QAction *action = menu->addAction(externalEditor->displayName()); Utils::Id editorId = externalEditor->id(); connect(action, &QAction::triggered, [fileName, editorId]() { - EditorManager::openExternalEditor(fileName, editorId); + EditorManager::openExternalEditor(FilePath::fromString(fileName), editorId); }); } } @@ -3173,7 +3173,7 @@ bool EditorManager::isAutoSaveFile(const QString &filePath) } /*! - Opens the document specified by \a fileName in the external editor specified + Opens the document specified by \a filePath in the external editor specified by \a editorId. Returns \c false and displays an error message if \a editorId is not the ID @@ -3181,7 +3181,7 @@ bool EditorManager::isAutoSaveFile(const QString &filePath) \sa openEditor() */ -bool EditorManager::openExternalEditor(const QString &fileName, Id editorId) +bool EditorManager::openExternalEditor(const FilePath &filePath, Id editorId) { IExternalEditor *ee = Utils::findOrDefault(IExternalEditor::allExternalEditors(), Utils::equal(&IExternalEditor::id, editorId)); @@ -3189,7 +3189,7 @@ bool EditorManager::openExternalEditor(const QString &fileName, Id editorId) return false; QString errorMessage; QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - const bool ok = ee->startEditor(fileName, &errorMessage); + const bool ok = ee->startEditor(filePath, &errorMessage); QApplication::restoreOverrideCursor(); if (!ok) QMessageBox::critical(ICore::dialogParent(), tr("Opening File"), errorMessage); diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index bcfb3be9a99..1bea80ceca8 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -116,7 +116,7 @@ public: static bool skipOpeningBigTextFile(const Utils::FilePath &filePath); static void clearUniqueId(IDocument *document); - static bool openExternalEditor(const QString &fileName, Utils::Id editorId); + static bool openExternalEditor(const Utils::FilePath &filePath, Utils::Id editorId); static void addCloseEditorListener(const std::function &listener); static QStringList getOpenFileNames(); diff --git a/src/plugins/coreplugin/editormanager/iexternaleditor.h b/src/plugins/coreplugin/editormanager/iexternaleditor.h index fea99e35f33..b105f376405 100644 --- a/src/plugins/coreplugin/editormanager/iexternaleditor.h +++ b/src/plugins/coreplugin/editormanager/iexternaleditor.h @@ -32,6 +32,8 @@ #include +namespace Utils { class FilePath; } + namespace Core { class IExternalEditor; @@ -52,7 +54,7 @@ public: virtual QStringList mimeTypes() const = 0; virtual Utils::Id id() const = 0; virtual QString displayName() const = 0; - virtual bool startEditor(const QString &fileName, QString *errorMessage) = 0; + virtual bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) = 0; }; } // namespace Core diff --git a/src/plugins/coreplugin/editormanager/systemeditor.cpp b/src/plugins/coreplugin/editormanager/systemeditor.cpp index c8ccd88ca7e..30840881006 100644 --- a/src/plugins/coreplugin/editormanager/systemeditor.cpp +++ b/src/plugins/coreplugin/editormanager/systemeditor.cpp @@ -25,6 +25,8 @@ #include "systemeditor.h" +#include + #include #include #include @@ -53,11 +55,11 @@ QString SystemEditor::displayName() const return tr("System Editor"); } -bool SystemEditor::startEditor(const QString &fileName, QString *errorMessage) +bool SystemEditor::startEditor(const FilePath &filePath, QString *errorMessage) { Q_UNUSED(errorMessage) QUrl url; - url.setPath(fileName); + url.setPath(filePath.toString()); url.setScheme(QLatin1String("file")); if (!QDesktopServices::openUrl(url)) { if (errorMessage) diff --git a/src/plugins/coreplugin/editormanager/systemeditor.h b/src/plugins/coreplugin/editormanager/systemeditor.h index 9d260def056..870bc5c3158 100644 --- a/src/plugins/coreplugin/editormanager/systemeditor.h +++ b/src/plugins/coreplugin/editormanager/systemeditor.h @@ -41,7 +41,7 @@ public: Utils::Id id() const override; QString displayName() const override; - bool startEditor(const QString &fileName, QString *errorMessage) override; + bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) override; }; } // namespace Internal diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index b8d788196ea..ec73da4afaa 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -948,7 +948,7 @@ void MainWindow::openFileWith() if (!editorId.isValid()) continue; if (isExternal) - EditorManager::openExternalEditor(fileName, editorId); + EditorManager::openExternalEditor(FilePath::fromString(fileName), editorId); else EditorManagerPrivate::openEditorWith(FilePath::fromString(fileName), editorId); } diff --git a/src/plugins/qmakeprojectmanager/externaleditors.cpp b/src/plugins/qmakeprojectmanager/externaleditors.cpp index 1a7c79d5527..fd7f6bc149b 100644 --- a/src/plugins/qmakeprojectmanager/externaleditors.cpp +++ b/src/plugins/qmakeprojectmanager/externaleditors.cpp @@ -156,7 +156,7 @@ static QString findFirstCommand(QVector qtVersions, return QString(); } -bool ExternalQtEditor::getEditorLaunchData(const QString &fileName, +bool ExternalQtEditor::getEditorLaunchData(const Utils::FilePath &filePath, LaunchData *data, QString *errorMessage) const { @@ -168,7 +168,7 @@ bool ExternalQtEditor::getEditorLaunchData(const QString &fileName, // As fallback check PATH data->workingDirectory.clear(); QVector qtVersionsToCheck; // deduplicated after being filled - if (const Project *project = SessionManager::projectForFile(Utils::FilePath::fromString(fileName))) { + if (const Project *project = SessionManager::projectForFile(filePath)) { data->workingDirectory = project->projectDirectory().toString(); // active kit if (const Target *target = project->activeTarget()) { @@ -193,7 +193,7 @@ bool ExternalQtEditor::getEditorLaunchData(const QString &fileName, return false; } // Setup binary + arguments, use Mac Open if appropriate - data->arguments.push_back(fileName); + data->arguments.push_back(filePath.toString()); if (Utils::HostOsInfo::isMacHost()) *data = createMacOpenCommand(*data); if (debug) @@ -201,10 +201,10 @@ bool ExternalQtEditor::getEditorLaunchData(const QString &fileName, return true; } -bool ExternalQtEditor::startEditor(const QString &fileName, QString *errorMessage) +bool ExternalQtEditor::startEditor(const Utils::FilePath &filePath, QString *errorMessage) { LaunchData data; - return getEditorLaunchData(fileName, &data, errorMessage) + return getEditorLaunchData(filePath, &data, errorMessage) && startEditorProcess(data, errorMessage); } @@ -244,11 +244,11 @@ void DesignerExternalEditor::processTerminated(const QString &binary) socket->deleteLater(); } -bool DesignerExternalEditor::startEditor(const QString &fileName, QString *errorMessage) +bool DesignerExternalEditor::startEditor(const Utils::FilePath &filePath, QString *errorMessage) { LaunchData data; // Find the editor binary - if (!getEditorLaunchData(fileName, &data, errorMessage)) { + if (!getEditorLaunchData(filePath, &data, errorMessage)) { return false; } // Known one? @@ -256,9 +256,9 @@ bool DesignerExternalEditor::startEditor(const QString &fileName, QString *error if (it != m_processCache.end()) { // Process is known, write to its socket to cause it to open the file if (debug) - qDebug() << Q_FUNC_INFO << "\nWriting to socket:" << data.binary << fileName; + qDebug() << Q_FUNC_INFO << "\nWriting to socket:" << data.binary << filePath; QTcpSocket *socket = it.value(); - if (!socket->write(fileName.toUtf8() + '\n')) { + if (!socket->write(filePath.toString().toUtf8() + '\n')) { *errorMessage = tr("Qt Designer is not responding (%1).").arg(socket->errorString()); return false; } @@ -272,7 +272,7 @@ bool DesignerExternalEditor::startEditor(const QString &fileName, QString *error } const quint16 port = server.serverPort(); if (debug) - qDebug() << Q_FUNC_INFO << "\nLaunching server:" << port << data.binary << fileName; + qDebug() << Q_FUNC_INFO << "\nLaunching server:" << port << data.binary << filePath; // Start first one with file and socket as '-client port file' // Wait for the socket listening data.arguments.push_front(QString::number(port)); diff --git a/src/plugins/qmakeprojectmanager/externaleditors.h b/src/plugins/qmakeprojectmanager/externaleditors.h index cea0b62a7f6..8a750f6a2d8 100644 --- a/src/plugins/qmakeprojectmanager/externaleditors.h +++ b/src/plugins/qmakeprojectmanager/externaleditors.h @@ -62,7 +62,7 @@ public: Utils::Id id() const override; QString displayName() const override; - bool startEditor(const QString &fileName, QString *errorMessage) override; + bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) override; // Data required to launch the editor struct LaunchData { @@ -79,7 +79,7 @@ protected: // Try to retrieve the binary of the editor from the Qt version, // prepare arguments accordingly (Mac "open" if desired) - bool getEditorLaunchData(const QString &fileName, + bool getEditorLaunchData(const Utils::FilePath &filePath, LaunchData *data, QString *errorMessage) const; @@ -104,7 +104,7 @@ class DesignerExternalEditor : public ExternalQtEditor public: DesignerExternalEditor(); - bool startEditor(const QString &fileName, QString *errorMessage) override; + bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) override; private: void processTerminated(const QString &binary);