Commit d6ddff93 authored by Eike Ziller's avatar Eike Ziller

EditorManager: Move close split button updating to editor areas

No need to have editor manager being responsible for that.

Change-Id: I25f06a38fc2a543749fa1f10a7fa3f2e37c60cf0
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 62acde46
......@@ -52,9 +52,11 @@ EditorArea::EditorArea()
ICore::addContextObject(m_context);
setCurrentView(view());
updateCloseSplitButton();
connect(qApp, &QApplication::focusChanged,
this, &EditorArea::focusChanged);
connect(this, &SplitterOrView::splitStateChanged, this, &EditorArea::updateCloseSplitButton);
}
EditorArea::~EditorArea()
......@@ -123,5 +125,11 @@ void EditorArea::updateCurrentEditor(IEditor *editor)
emit windowTitleNeedsUpdate();
}
void EditorArea::updateCloseSplitButton()
{
if (EditorView *v = view())
v->setCloseSplitEnabled(false);
}
} // Internal
} // Core
......@@ -57,6 +57,7 @@ private:
void focusChanged(QWidget *old, QWidget *now);
void setCurrentView(EditorView *view);
void updateCurrentEditor(IEditor *editor);
void updateCloseSplitButton();
IContext *m_context;
QPointer<EditorView> m_currentView;
......
......@@ -1240,19 +1240,6 @@ void EditorManagerPrivate::updateAutoSave()
d->m_autoSaveTimer->stop();
}
void EditorManagerPrivate::setCloseSplitEnabled(SplitterOrView *splitterOrView, bool enable)
{
if (splitterOrView->isView())
splitterOrView->view()->setCloseSplitEnabled(enable);
QSplitter *splitter = splitterOrView->splitter();
if (splitter) {
for (int i = 0; i < splitter->count(); ++i) {
if (SplitterOrView *subSplitterOrView = qobject_cast<SplitterOrView*>(splitter->widget(i)))
setCloseSplitEnabled(subSplitterOrView, enable);
}
}
}
void EditorManagerPrivate::updateMakeWritableWarning()
{
IDocument *document = EditorManager::currentDocument();
......@@ -1324,9 +1311,6 @@ void EditorManagerPrivate::updateActions()
if (curDocument)
updateMakeWritableWarning();
foreach (EditorArea *area, d->m_editorAreas)
setCloseSplitEnabled(area, area->isSplitter());
QString quotedName;
if (curDocument)
quotedName = QLatin1Char('"') + curDocument->displayName() + QLatin1Char('"');
......
......@@ -166,7 +166,6 @@ private:
static IEditor *pickUnusedEditor(Internal::EditorView **foundView = 0);
static void addDocumentToRecentFiles(IDocument *document);
static void updateAutoSave();
static void setCloseSplitEnabled(Internal::SplitterOrView *splitterOrView, bool enable);
static void updateMakeWritableWarning();
static void setupSaveActions(IDocument *document, QAction *saveAction,
QAction *saveAsAction, QAction *revertToSavedAction);
......
......@@ -644,6 +644,7 @@ void SplitterOrView::split(Qt::Orientation orientation)
m_layout->addWidget(m_splitter);
m_layout->removeWidget(m_view);
EditorView *editorView = m_view;
editorView->setCloseSplitEnabled(true); // might have been disabled for root view
m_view = 0;
IEditor *e = editorView->currentEditor();
......@@ -670,6 +671,7 @@ void SplitterOrView::split(Qt::Orientation orientation)
EditorManagerPrivate::activateEditor(otherView->view(), e);
else
EditorManagerPrivate::setCurrentView(otherView->view());
emit splitStateChanged();
}
void SplitterOrView::unsplitAll()
......@@ -706,6 +708,7 @@ void SplitterOrView::unsplitAll()
else
m_view->setFocus();
}
emit splitStateChanged();
}
void SplitterOrView::unsplitAll_helper()
......@@ -769,6 +772,7 @@ void SplitterOrView::unsplit()
}
delete oldSplitter;
EditorManagerPrivate::setCurrentView(findFirstView());
emit splitStateChanged();
}
......
......@@ -199,6 +199,9 @@ public:
void unsplitAll();
signals:
void splitStateChanged();
private:
void unsplitAll_helper();
QStackedLayout *m_layout;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment