-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Timeline: hand back the focus to the input line ASAP
There is no doubt that the most clicked widget is the timeline. We click it to open pictures, to bring the window forward, to select text, etc. Unfortunately, these actions ended up with unfocused input line which was my primary reason to go ape on Quaternion. This patch introduces a strict focus policy on the timeline which means the timeline won't keep the focus for long, it will hand back to the input line when possible, when pressed mouse buttons are released. At the same time we had to implement our own TextEdit text selection mechanism because the original didn't pass through required mouse events. Added bonus that the selected text will be unselected when new selection starts.
- Loading branch information
Showing
12 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ import QtQuick 2.2 | |
|
||
MouseArea { | ||
onWheel: chatView.onWheel(wheel) | ||
onReleased: controller.focusInput() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import QtQuick 2.2 | ||
|
||
/* | ||
* Unfortunately, TextEdit captures LeftButton events for text selection in a way which | ||
* is not compatible with our focus-cancelling mechanism, so we took over the task here. | ||
*/ | ||
MouseArea { | ||
property var textEdit: parent | ||
property var selectionMode: TextEdit.SelectCharacters | ||
|
||
anchors.fill: parent | ||
acceptedButtons: Qt.LeftButton | ||
|
||
onPressed: { | ||
var x = mouse.x | ||
var y = mouse.y | ||
if (textEdit.flickableItem) { | ||
x += textEdit.flickableItem.contentX | ||
y += textEdit.flickableItem.contentY | ||
} | ||
var hasSelection = textEdit.selectionEnd > textEdit.selectionStart | ||
if (hasSelection && controller.getModifierKeys() & Qt.ShiftModifier) { | ||
textEdit.moveCursorSelection(textEdit.positionAt(x, y), selectionMode) | ||
} else { | ||
textEdit.cursorPosition = textEdit.positionAt(x, y) | ||
if (chatView.textEditWithSelection) | ||
chatView.textEditWithSelection.deselect() | ||
} | ||
} | ||
onDoubleClicked: { | ||
selectionMode = TextEdit.SelectWords | ||
textEdit.selectWord() | ||
} | ||
onReleased: { | ||
selectionMode = TextEdit.SelectCharacters | ||
controller.setGlobalSelectionBuffer(textEdit.selectedText) | ||
chatView.textEditWithSelection = textEdit | ||
|
||
controller.focusInput() | ||
} | ||
onPositionChanged: { | ||
var x = mouse.x | ||
var y = mouse.y | ||
if (textEdit.flickableItem) { | ||
x += textEdit.flickableItem.contentX | ||
y += textEdit.flickableItem.contentY | ||
} | ||
textEdit.moveCursorSelection(textEdit.positionAt(x, y), selectionMode) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters