diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index 1ee5bcbc18a..3304013b3d4 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -162,6 +162,24 @@ void EditorView::setCloseSplitIcon(const QIcon &icon) m_toolBar->setCloseSplitIcon(icon); } +void EditorView::paintEvent(QPaintEvent *) +{ + SplitterOrView *splitterOrView = ICore::editorManager()->currentSplitterOrView(); + if (!splitterOrView || !splitterOrView->view() || splitterOrView->view() != this) + return; + + if (editorCount() > 0) + return; + + // Discreet indication where an editor would be if there is none + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(Qt::NoPen); + painter.setBrush(palette().color(QPalette::Background).darker(107)); + const int r = 3; + painter.drawRoundedRect(m_container->geometry().adjusted(r , r, -r, -r), r * 2, r * 2); +} + void EditorView::addEditor(IEditor *editor) { if (m_editors.contains(editor)) @@ -301,12 +319,6 @@ void EditorView::updateEditorHistory(IEditor *editor) m_editorHistory.prepend(location); } -QRect EditorView::editorArea() const -{ - const QRect cRect = m_container->rect(); - return QRect(m_container->mapToGlobal(cRect.topLeft()), cRect.size()); -} - void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QByteArray &saveState) { if (editor && editor != currentEditor()) @@ -481,25 +493,6 @@ void SplitterOrView::mousePressEvent(QMouseEvent *e) ICore::editorManager()->setCurrentView(this); } -void SplitterOrView::paintEvent(QPaintEvent *) -{ - if (ICore::editorManager()->currentSplitterOrView() != this) - return; - - if (!m_view || hasEditors()) - return; - - // Discreet indication where an editor would be if there is none - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(Qt::NoPen); - painter.setBrush(palette().color(QPalette::Background).darker(107)); - const int r = 3; - const QRect areaGlobal(view()->editorArea()); - const QRect areaLocal(mapFromGlobal(areaGlobal.topLeft()), areaGlobal.size()); - painter.drawRoundedRect(areaLocal.adjusted(r , r, -r, -r), r * 2, r * 2); -} - SplitterOrView *SplitterOrView::findFirstView() { if (m_splitter) { diff --git a/src/plugins/coreplugin/editormanager/editorview.h b/src/plugins/coreplugin/editormanager/editorview.h index dbec41701f5..53c04d638e5 100644 --- a/src/plugins/coreplugin/editormanager/editorview.h +++ b/src/plugins/coreplugin/editormanager/editorview.h @@ -95,6 +95,9 @@ public: void setCloseSplitEnabled(bool enable); void setCloseSplitIcon(const QIcon &icon); +protected: + void paintEvent(QPaintEvent *); + private slots: void closeView(); void listSelectionActivated(int index); @@ -140,7 +143,6 @@ public: void copyNavigationHistoryFrom(EditorView* other); void updateEditorHistory(IEditor *editor); - QRect editorArea() const; }; class SplitterOrView : public QWidget @@ -185,7 +187,6 @@ public: void unsplitAll(); protected: - void paintEvent(QPaintEvent *); void mousePressEvent(QMouseEvent *e); private: