forked from qt-creator/qt-creator
QtSupport: Remove {Designer,Linguist}ExternalEditorFactory classes
... again, use the editors themselves, which are singletons. Change-Id: I8ec7bce58414a23169831956c00bbdd73c6bfec3 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include "externaleditors.h"
|
#include "externaleditors.h"
|
||||||
|
|
||||||
#include <coreplugin/editormanager/iexternaleditor.h>
|
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
@@ -37,14 +35,10 @@ enum { debug = 0 };
|
|||||||
|
|
||||||
namespace QtSupport::Internal {
|
namespace QtSupport::Internal {
|
||||||
|
|
||||||
struct Tr
|
struct Tr {
|
||||||
{
|
|
||||||
Q_DECLARE_TR_FUNCTIONS(::QmakeProjectManager)
|
Q_DECLARE_TR_FUNCTIONS(::QmakeProjectManager)
|
||||||
};
|
};
|
||||||
|
|
||||||
const char designerDisplayName[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "Qt Designer");
|
|
||||||
const char linguistDisplayName[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "Qt Linguist");
|
|
||||||
|
|
||||||
static QString msgStartFailed(const QString &binary, QStringList arguments)
|
static QString msgStartFailed(const QString &binary, QStringList arguments)
|
||||||
{
|
{
|
||||||
arguments.push_front(binary);
|
arguments.push_front(binary);
|
||||||
@@ -160,28 +154,12 @@ static bool startEditorProcess(const LaunchData &data, QString *errorMessage)
|
|||||||
|
|
||||||
// DesignerExternalEditor with Designer Tcp remote control.
|
// DesignerExternalEditor with Designer Tcp remote control.
|
||||||
|
|
||||||
class DesignerExternalEditor : public Core::IExternalEditor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DesignerExternalEditor()
|
|
||||||
{
|
|
||||||
setId("Qt.Designer");
|
|
||||||
setDisplayName(designerDisplayName);
|
|
||||||
setMimeTypes({ProjectExplorer::Constants::FORM_MIMETYPE});
|
|
||||||
}
|
|
||||||
|
|
||||||
bool startEditor(const FilePath &filePath, QString *errorMessage) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void processTerminated(const QString &binary);
|
|
||||||
|
|
||||||
// A per-binary entry containing the socket
|
// A per-binary entry containing the socket
|
||||||
using ProcessCache = QMap<QString, QTcpSocket*>;
|
using ProcessCache = QMap<QString, QTcpSocket*>;
|
||||||
|
|
||||||
ProcessCache m_processCache;
|
static ProcessCache m_processCache;
|
||||||
};
|
|
||||||
|
|
||||||
void DesignerExternalEditor::processTerminated(const QString &binary)
|
static void processTerminated(const QString &binary)
|
||||||
{
|
{
|
||||||
const ProcessCache::iterator it = m_processCache.find(binary);
|
const ProcessCache::iterator it = m_processCache.find(binary);
|
||||||
if (it == m_processCache.end())
|
if (it == m_processCache.end())
|
||||||
@@ -196,6 +174,13 @@ void DesignerExternalEditor::processTerminated(const QString &binary)
|
|||||||
socket->deleteLater();
|
socket->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DesignerExternalEditor::DesignerExternalEditor()
|
||||||
|
{
|
||||||
|
setId("Qt.Designer");
|
||||||
|
setDisplayName(QT_TRANSLATE_NOOP("OpenWith::Editors", "Qt Designer"));
|
||||||
|
setMimeTypes({ProjectExplorer::Constants::FORM_MIMETYPE});
|
||||||
|
}
|
||||||
|
|
||||||
bool DesignerExternalEditor::startEditor(const FilePath &filePath, QString *errorMessage)
|
bool DesignerExternalEditor::startEditor(const FilePath &filePath, QString *errorMessage)
|
||||||
{
|
{
|
||||||
LaunchData data;
|
LaunchData data;
|
||||||
@@ -246,19 +231,13 @@ bool DesignerExternalEditor::startEditor(const FilePath &filePath, QString *erro
|
|||||||
socket->setParent(this);
|
socket->setParent(this);
|
||||||
const QString binary = data.binary;
|
const QString binary = data.binary;
|
||||||
m_processCache.insert(binary, socket);
|
m_processCache.insert(binary, socket);
|
||||||
auto mapSlot = [this, binary] { processTerminated(binary); };
|
auto mapSlot = [binary] { processTerminated(binary); };
|
||||||
connect(socket, &QAbstractSocket::disconnected, this, mapSlot);
|
connect(socket, &QAbstractSocket::disconnected, this, mapSlot);
|
||||||
connect(socket, &QAbstractSocket::errorOccurred, this, mapSlot);
|
connect(socket, &QAbstractSocket::errorOccurred, this, mapSlot);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DesignerEditorFactory::DesignerEditorFactory()
|
|
||||||
{
|
|
||||||
auto editor = new DesignerExternalEditor;
|
|
||||||
editor->setParent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Linguist
|
// Linguist
|
||||||
|
|
||||||
static QString linguistBinary(const QtSupport::QtVersion *qtVersion)
|
static QString linguistBinary(const QtSupport::QtVersion *qtVersion)
|
||||||
@@ -268,28 +247,18 @@ static QString linguistBinary(const QtSupport::QtVersion *qtVersion)
|
|||||||
return QLatin1String(HostOsInfo::isMacHost() ? "Linguist" : "linguist");
|
return QLatin1String(HostOsInfo::isMacHost() ? "Linguist" : "linguist");
|
||||||
}
|
}
|
||||||
|
|
||||||
class LinguistEditor : public Core::IExternalEditor
|
LinguistEditor::LinguistEditor()
|
||||||
{
|
|
||||||
public:
|
|
||||||
LinguistEditor()
|
|
||||||
{
|
{
|
||||||
setId("Qt.Linguist");
|
setId("Qt.Linguist");
|
||||||
setDisplayName(linguistDisplayName);
|
setDisplayName(QT_TRANSLATE_NOOP("OpenWith::Editors", "Qt Linguist"));
|
||||||
setMimeTypes({ProjectExplorer::Constants::LINGUIST_MIMETYPE});
|
setMimeTypes({ProjectExplorer::Constants::LINGUIST_MIMETYPE});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool startEditor(const FilePath &filePath, QString *errorMessage) override
|
bool LinguistEditor::startEditor(const Utils::FilePath &filePath, QString *errorMessage)
|
||||||
{
|
{
|
||||||
LaunchData data;
|
LaunchData data;
|
||||||
return getEditorLaunchData(linguistBinary, filePath, &data, errorMessage)
|
return getEditorLaunchData(linguistBinary, filePath, &data, errorMessage)
|
||||||
&& startEditorProcess(data, errorMessage);
|
&& startEditorProcess(data, errorMessage);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
LinguistEditorFactory::LinguistEditorFactory()
|
|
||||||
{
|
|
||||||
auto editor = new LinguistEditor;
|
|
||||||
editor->setParent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // QtSupport::Internal
|
} // QtSupport::Internal
|
||||||
|
|||||||
@@ -3,20 +3,24 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <coreplugin/editormanager/iexternaleditor.h>
|
||||||
|
|
||||||
namespace QtSupport::Internal {
|
namespace QtSupport::Internal {
|
||||||
|
|
||||||
class DesignerEditorFactory : public QObject
|
class DesignerExternalEditor : public Core::IExternalEditor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DesignerEditorFactory();
|
DesignerExternalEditor();
|
||||||
|
|
||||||
|
bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) final;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LinguistEditorFactory : public QObject
|
class LinguistEditor : public Core::IExternalEditor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LinguistEditorFactory();
|
LinguistEditor();
|
||||||
|
|
||||||
|
bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) final;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // QtSupport::Internal
|
} // QtSupport::Internal
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ public:
|
|||||||
UicGeneratorFactory uicGeneratorFactory;
|
UicGeneratorFactory uicGeneratorFactory;
|
||||||
QScxmlcGeneratorFactory qscxmlcGeneratorFactory;
|
QScxmlcGeneratorFactory qscxmlcGeneratorFactory;
|
||||||
|
|
||||||
DesignerEditorFactory designerEditorFactory;
|
DesignerExternalEditor designerEditor;
|
||||||
LinguistEditorFactory linguistEditorFactory;
|
LinguistEditor linguistEditor;
|
||||||
};
|
};
|
||||||
|
|
||||||
QtSupportPlugin::~QtSupportPlugin()
|
QtSupportPlugin::~QtSupportPlugin()
|
||||||
|
|||||||
Reference in New Issue
Block a user