Commit 4c04c1a7 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Fixed mouse handling for code folding when hidden

The mouse handling for code folding wasn't deactivated when the code
folding markers were hidden.

Reviewed-by: mae
parent 9b39f38f
...@@ -749,7 +749,7 @@ void BaseTextEditor::moveLineUpDown(bool up) ...@@ -749,7 +749,7 @@ void BaseTextEditor::moveLineUpDown(bool up)
void BaseTextEditor::cleanWhitespace() void BaseTextEditor::cleanWhitespace()
{ {
d->m_document->cleanWhitespace(); d->m_document->cleanWhitespace();
} }
void BaseTextEditor::keyPressEvent(QKeyEvent *e) void BaseTextEditor::keyPressEvent(QKeyEvent *e)
...@@ -1286,7 +1286,7 @@ void BaseTextEditor::setFontSettings(const TextEditor::FontSettings &fs) ...@@ -1286,7 +1286,7 @@ void BaseTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
void BaseTextEditor::setStorageSettings(const StorageSettings &storageSettings) void BaseTextEditor::setStorageSettings(const StorageSettings &storageSettings)
{ {
d->m_document->setStorageSettings(storageSettings); d->m_document->setStorageSettings(storageSettings);
} }
//--------- BaseTextEditorPrivate ----------- //--------- BaseTextEditorPrivate -----------
...@@ -2477,17 +2477,22 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e) ...@@ -2477,17 +2477,22 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
extraAreaWidth(&markWidth); extraAreaWidth(&markWidth);
if (e->type() == QEvent::MouseMove && e->buttons() == 0) { // mouse tracking if (e->type() == QEvent::MouseMove && e->buttons() == 0) { // mouse tracking
int highlightBlockNumber = d->extraAreaHighlightCollapseBlockNumber; // Update which folder marker is highlighted
const int highlightBlockNumber = d->extraAreaHighlightCollapseBlockNumber;
d->extraAreaHighlightCollapseBlockNumber = -1; d->extraAreaHighlightCollapseBlockNumber = -1;
if (TextBlockUserData::canCollapse(cursor.block())
if (d->m_codeFoldingVisible
&& TextBlockUserData::canCollapse(cursor.block())
&& !TextBlockUserData::hasClosingCollapseInside(cursor.block().next()) && !TextBlockUserData::hasClosingCollapseInside(cursor.block().next())
&& collapseBox(cursor.block()).contains(e->pos())) && collapseBox(cursor.block()).contains(e->pos()))
d->extraAreaHighlightCollapseBlockNumber = cursor.blockNumber(); d->extraAreaHighlightCollapseBlockNumber = cursor.blockNumber();
// Set whether the mouse cursor is a hand or normal arrow
bool hand = (e->pos().x() <= markWidth || d->extraAreaHighlightCollapseBlockNumber >= 0); bool hand = (e->pos().x() <= markWidth || d->extraAreaHighlightCollapseBlockNumber >= 0);
if (hand != (d->m_extraArea->cursor().shape() == Qt::PointingHandCursor)) if (hand != (d->m_extraArea->cursor().shape() == Qt::PointingHandCursor))
d->m_extraArea->setCursor(hand ? Qt::PointingHandCursor : Qt::ArrowCursor); d->m_extraArea->setCursor(hand ? Qt::PointingHandCursor : Qt::ArrowCursor);
// Start fading in or out the highlighted folding marker
if (highlightBlockNumber != d->extraAreaHighlightCollapseBlockNumber) { if (highlightBlockNumber != d->extraAreaHighlightCollapseBlockNumber) {
d->extraAreaTimeLine->stop(); d->extraAreaTimeLine->stop();
d->extraAreaTimeLine->setDirection(d->extraAreaHighlightCollapseBlockNumber >= 0? d->extraAreaTimeLine->setDirection(d->extraAreaHighlightCollapseBlockNumber >= 0?
...@@ -2504,12 +2509,12 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e) ...@@ -2504,12 +2509,12 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) { if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) {
if (e->button() == Qt::LeftButton) { if (e->button() == Qt::LeftButton) {
if (TextBlockUserData::canCollapse(cursor.block()) if (d->m_codeFoldingVisible && TextBlockUserData::canCollapse(cursor.block())
&& !TextBlockUserData::hasClosingCollapseInside(cursor.block().next()) && !TextBlockUserData::hasClosingCollapseInside(cursor.block().next())
&& collapseBox(cursor.block()).contains(e->pos())) { && collapseBox(cursor.block()).contains(e->pos())) {
setTextCursor(cursor); setTextCursor(cursor);
toggleBlockVisible(cursor.block()); toggleBlockVisible(cursor.block());
} else if (e->pos().x() > markWidth) { } else if (d->m_marksVisible && e->pos().x() > markWidth) {
QTextCursor selection = cursor; QTextCursor selection = cursor;
selection.setVisualNavigation(true); selection.setVisualNavigation(true);
d->extraAreaSelectionAnchorBlockNumber = selection.blockNumber(); d->extraAreaSelectionAnchorBlockNumber = selection.blockNumber();
...@@ -2519,7 +2524,7 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e) ...@@ -2519,7 +2524,7 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
} else { } else {
d->extraAreaToggleMarkBlockNumber = cursor.blockNumber(); d->extraAreaToggleMarkBlockNumber = cursor.blockNumber();
} }
} else if (e->button() == Qt::RightButton) { } else if (d->m_marksVisible && e->button() == Qt::RightButton) {
QMenu * contextMenu = new QMenu(this); QMenu * contextMenu = new QMenu(this);
emit d->m_editable->markContextMenuRequested(editableInterface(), cursor.blockNumber() + 1, contextMenu); emit d->m_editable->markContextMenuRequested(editableInterface(), cursor.blockNumber() + 1, contextMenu);
if (!contextMenu->isEmpty()) if (!contextMenu->isEmpty())
......
Supports Markdown
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