forked from qt-creator/qt-creator
EditorView: Do painting where it belongs.
Change-Id: I38cbf6d884f3034321776b135270acb5c8482321 Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
committed by
David Schulz
parent
e89c30feb8
commit
bf3d142418
@@ -162,6 +162,24 @@ void EditorView::setCloseSplitIcon(const QIcon &icon)
|
|||||||
m_toolBar->setCloseSplitIcon(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)
|
void EditorView::addEditor(IEditor *editor)
|
||||||
{
|
{
|
||||||
if (m_editors.contains(editor))
|
if (m_editors.contains(editor))
|
||||||
@@ -301,12 +319,6 @@ void EditorView::updateEditorHistory(IEditor *editor)
|
|||||||
m_editorHistory.prepend(location);
|
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)
|
void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QByteArray &saveState)
|
||||||
{
|
{
|
||||||
if (editor && editor != currentEditor())
|
if (editor && editor != currentEditor())
|
||||||
@@ -481,25 +493,6 @@ void SplitterOrView::mousePressEvent(QMouseEvent *e)
|
|||||||
ICore::editorManager()->setCurrentView(this);
|
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()
|
SplitterOrView *SplitterOrView::findFirstView()
|
||||||
{
|
{
|
||||||
if (m_splitter) {
|
if (m_splitter) {
|
||||||
|
@@ -95,6 +95,9 @@ public:
|
|||||||
void setCloseSplitEnabled(bool enable);
|
void setCloseSplitEnabled(bool enable);
|
||||||
void setCloseSplitIcon(const QIcon &icon);
|
void setCloseSplitIcon(const QIcon &icon);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void closeView();
|
void closeView();
|
||||||
void listSelectionActivated(int index);
|
void listSelectionActivated(int index);
|
||||||
@@ -140,7 +143,6 @@ public:
|
|||||||
|
|
||||||
void copyNavigationHistoryFrom(EditorView* other);
|
void copyNavigationHistoryFrom(EditorView* other);
|
||||||
void updateEditorHistory(IEditor *editor);
|
void updateEditorHistory(IEditor *editor);
|
||||||
QRect editorArea() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SplitterOrView : public QWidget
|
class SplitterOrView : public QWidget
|
||||||
@@ -185,7 +187,6 @@ public:
|
|||||||
void unsplitAll();
|
void unsplitAll();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *);
|
|
||||||
void mousePressEvent(QMouseEvent *e);
|
void mousePressEvent(QMouseEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user