forked from qt-creator/qt-creator
Do not show external editors in mime settings
External editors are never used to open files, except on explicit request with "Open with", so should not be considered in the settings' "Handler" column Change-Id: I8fe7b9d260754ce84d52db554d6ee25d1af3bfe2 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -952,7 +952,7 @@ Id EditorManagerPrivate::getOpenWithEditorId(const QString &fileName, bool *isEx
|
|||||||
allEditorDisplayNames.push_back(editors.at(i)->displayName());
|
allEditorDisplayNames.push_back(editors.at(i)->displayName());
|
||||||
}
|
}
|
||||||
// External editors
|
// External editors
|
||||||
const ExternalEditorList exEditors = IExternalEditor::externalEditors(mt, false);
|
const ExternalEditorList exEditors = IExternalEditor::externalEditors(mt);
|
||||||
const int esize = exEditors.size();
|
const int esize = exEditors.size();
|
||||||
for (int i = 0; i < esize; i++) {
|
for (int i = 0; i < esize; i++) {
|
||||||
externalEditorIds.push_back(exEditors.at(i)->id());
|
externalEditorIds.push_back(exEditors.at(i)->id());
|
||||||
@@ -2475,7 +2475,7 @@ void EditorManager::populateOpenWithMenu(QMenu *menu, const QString &fileName)
|
|||||||
const Utils::MimeType mt = Utils::mimeTypeForFile(fileName);
|
const Utils::MimeType mt = Utils::mimeTypeForFile(fileName);
|
||||||
if (mt.isValid()) {
|
if (mt.isValid()) {
|
||||||
const EditorFactoryList factories = IEditorFactory::editorFactories(mt, false);
|
const EditorFactoryList factories = IEditorFactory::editorFactories(mt, false);
|
||||||
const ExternalEditorList extEditors = IExternalEditor::externalEditors(mt, false);
|
const ExternalEditorList extEditors = IExternalEditor::externalEditors(mt);
|
||||||
anyMatches = !factories.empty() || !extEditors.empty();
|
anyMatches = !factories.empty() || !extEditors.empty();
|
||||||
if (anyMatches) {
|
if (anyMatches) {
|
||||||
// Add all suitable editors
|
// Add all suitable editors
|
||||||
|
|||||||
@@ -73,12 +73,11 @@ const ExternalEditorList IExternalEditor::allExternalEditors()
|
|||||||
return g_externalEditors;
|
return g_externalEditors;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExternalEditorList IExternalEditor::externalEditors(const Utils::MimeType &mimeType,
|
const ExternalEditorList IExternalEditor::externalEditors(const Utils::MimeType &mimeType)
|
||||||
bool bestMatchOnly)
|
|
||||||
{
|
{
|
||||||
ExternalEditorList rc;
|
ExternalEditorList rc;
|
||||||
const ExternalEditorList allEditors = IExternalEditor::allExternalEditors();
|
const ExternalEditorList allEditors = IExternalEditor::allExternalEditors();
|
||||||
Internal::mimeTypeFactoryLookup(mimeType, allEditors, bestMatchOnly, &rc);
|
Internal::mimeTypeFactoryLookup(mimeType, allEditors, /*bestmatchonly=*/false, &rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ public:
|
|||||||
~IExternalEditor() override;
|
~IExternalEditor() override;
|
||||||
|
|
||||||
static const ExternalEditorList allExternalEditors();
|
static const ExternalEditorList allExternalEditors();
|
||||||
static const ExternalEditorList externalEditors(const Utils::MimeType &mimeType,
|
static const ExternalEditorList externalEditors(const Utils::MimeType &mimeType);
|
||||||
bool bestMatchOnly = true);
|
|
||||||
|
|
||||||
virtual QStringList mimeTypes() const = 0;
|
virtual QStringList mimeTypes() const = 0;
|
||||||
virtual Id id() const = 0;
|
virtual Id id() const = 0;
|
||||||
|
|||||||
@@ -143,18 +143,8 @@ void MimeTypeSettingsModel::load()
|
|||||||
});
|
});
|
||||||
|
|
||||||
foreach (const Utils::MimeType &mimeType, m_mimeTypes) {
|
foreach (const Utils::MimeType &mimeType, m_mimeTypes) {
|
||||||
QString value;
|
|
||||||
const QList<IEditorFactory *> factories = IEditorFactory::editorFactories(mimeType);
|
const QList<IEditorFactory *> factories = IEditorFactory::editorFactories(mimeType);
|
||||||
if (!factories.isEmpty()) {
|
const QString value = factories.isEmpty() ? "" : factories.front()->displayName();
|
||||||
value = factories.front()->displayName();
|
|
||||||
} else {
|
|
||||||
const QList<IExternalEditor *> externalEditors = IExternalEditor::externalEditors(
|
|
||||||
mimeType);
|
|
||||||
if (!externalEditors.isEmpty())
|
|
||||||
value = externalEditors.front()->displayName();
|
|
||||||
else
|
|
||||||
value = tr("Undefined");
|
|
||||||
}
|
|
||||||
m_handlersByMimeType.insert(mimeType.name(), value);
|
m_handlersByMimeType.insert(mimeType.name(), value);
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|||||||
Reference in New Issue
Block a user