Attemt at copy/pasting in LineEdit

This adds a small toolbar to the focused lineedit with copy and paste
buttons. Selection, TextInput.canPaste, etc are taken into account when
showing.

Works surprisingly well already, but should become a bit less intrusive.
This commit is contained in:
Sebastian Kügler 2011-11-23 05:26:33 +01:00
parent c7fdfe41c4
commit c2a1cf238a

View File

@ -19,6 +19,7 @@
import QtQuick 1.1 import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.qtextracomponents 0.1
Item { Item {
id: textField id: textField
@ -111,7 +112,7 @@ Item {
MouseArea { MouseArea {
id: mouseWatcher id: mouseWatcher
anchors.fill: hover anchors.fill: hover
hoverEnabled: true hoverEnabled: false
} }
Text { Text {
@ -140,6 +141,45 @@ Item {
font.wordSpacing: theme.defaultFont.wordSpacing font.wordSpacing: theme.defaultFont.wordSpacing
} }
PlasmaCore.FrameSvgItem {
id: editBubble
objectName: "editBubble"
property int iconSize: 32;
//anchors.fill: parent
imagePath: "dialogs/background"
width: (iconSize*2) + 24
height: 48
z: 1
anchors { top: parent.bottom; right: parent.right; topMargin: -8; }
visible: textInput.activeFocus && (textInput.selectedText != "" || textInput.canPaste)
Row {
id: buttonRow
spacing: 4
anchors {fill: parent; margins: 8; }
height: editBubble.iconSize
QIconItem {
icon: QIcon("edit-paste")
width: editBubble.iconSize
height: editBubble.iconSize
enabled: textInput.canPaste
MouseArea {
anchors.fill: parent;
onClicked: textField.paste();
}
}
QIconItem {
icon: QIcon("edit-copy")
width: editBubble.iconSize
height: editBubble.iconSize
enabled: textInput.selectedText != ""
MouseArea {
anchors.fill: parent;
onClicked: textField.copy();
}
}
}
}
TextInput { TextInput {
id: textInput id: textInput