forked from qt-creator/qt-creator
Core: Signal duplicated editors
FakeVim needs some notification even in cases where the duplication is triggered outside the EditorManager as in QmlDesigner's qml-editor. Fixes: QTCREATORBUG-22344 Change-Id: Ia4950ff4b02d3f89779f03ff4c106a07ccff2106 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -59,6 +59,9 @@ public:
|
||||
|
||||
virtual bool isDesignModePreferred() const { return false; }
|
||||
|
||||
signals:
|
||||
void editorDuplicated(IEditor *duplicate);
|
||||
|
||||
private:
|
||||
bool m_duplicateSupported;
|
||||
};
|
||||
|
@@ -286,6 +286,8 @@ Core::IEditor *DiffEditor::duplicate()
|
||||
QTC_ASSERT(view, view = editor->currentView());
|
||||
editor->setupView(view);
|
||||
|
||||
emit editorDuplicated(editor);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
@@ -1551,6 +1551,14 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
|
||||
else
|
||||
return;
|
||||
|
||||
// Duplicated editors are not signalled by the EditorManager. Track them nevertheless.
|
||||
connect(editor, &IEditor::editorDuplicated, this, [this, editor](IEditor *duplicate) {
|
||||
editorOpened(duplicate);
|
||||
connect(duplicate, &QObject::destroyed, this, [this, duplicate] {
|
||||
m_editorToHandler.remove(duplicate);
|
||||
});
|
||||
});
|
||||
|
||||
auto tew = TextEditorWidget::fromEditor(editor);
|
||||
|
||||
//qDebug() << "OPENING: " << editor << editor->widget()
|
||||
|
@@ -189,6 +189,9 @@ Core::IEditor *ImageViewer::duplicate()
|
||||
other->d->imageView->createScene();
|
||||
other->updateToolButtons();
|
||||
other->d->ui_toolbar.labelImageSize->setText(d->ui_toolbar.labelImageSize->text());
|
||||
|
||||
emit editorDuplicated(other);
|
||||
|
||||
return other;
|
||||
}
|
||||
|
||||
|
@@ -8869,8 +8869,11 @@ BaseTextEditor *TextEditorFactoryPrivate::createEditorHelper(const TextDocumentP
|
||||
IEditor *BaseTextEditor::duplicate()
|
||||
{
|
||||
// Use new standard setup if that's available.
|
||||
if (d->m_origin)
|
||||
return d->m_origin->duplicateTextEditor(this);
|
||||
if (d->m_origin) {
|
||||
IEditor *dup = d->m_origin->duplicateTextEditor(this);
|
||||
emit editorDuplicated(dup);
|
||||
return dup;
|
||||
}
|
||||
|
||||
// If neither is sufficient, you need to implement 'YourEditor::duplicate'.
|
||||
QTC_CHECK(false);
|
||||
|
Reference in New Issue
Block a user