Commit 00eaeb7a authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Move expression field to footer and make the autocompletion based on

popup

This improve the user experience and both mobile and desktop by not
displaying the result of the autocompletion outside of the window (and
screen) and make on mobile the action button appear on top of the text
field.
parent 09c6f123
......@@ -173,18 +173,12 @@ Kirigami.Page {
}
}
ExpressionInput {
footer: ExpressionInput {
id: input
focus: true
Keys.onReturnPressed: {
consoleModel.addOperation(text)
}
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
}
}
}
......@@ -18,35 +18,33 @@
import QtQuick 2.0
import QtQuick.Window 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls 2.14 as QQC2
import org.kde.kirigami 2.14 as Kirigami
import org.kde.analitza 1.0
import QtQuick.Layouts 1.2
import org.kde.kalgebra.mobile 1.0
TextField
{
QQC2.TextField {
id: field
readonly property string currentWord: field.selectionStart === field.selectionEnd ? operators.lastWord(field.cursorPosition, field.text) : ""
onCurrentWordChanged: view.currentIndex = -1
Window {
height: Math.min(100, view.contentHeight)
width: field.width
flags: Qt.ToolTip
ListView {
QQC2.Popup {
x: 0
y: -height
width: parent.width
height: Math.min(Kirigami.Units.gridUnit * 10, view.contentHeight)
visible: view.count >= 0 && field.activeFocus && field.currentWord.length > 0
contentItem: ListView {
id: view
anchors {
fill: parent
margins: 1
}
ScrollBar.vertical: ScrollBar {}
currentIndex: -1
//currentIndex: -1
model: QSortFilterProxyModel {
sourceModel: OperatorsModel { id: operators }
filterRegExp: new RegExp("^" + field.currentWord)
filterRegularExpression: new RegExp("^" + field.currentWord)
}
delegate: ItemDelegate {
delegate: Kirigami.BasicListItem {
text: model.display + " - " + description
highlighted: view.currentIndex === index
width: ListView.view.width
......@@ -62,12 +60,6 @@ TextField
Keys.onReturnPressed: complete()
}
}
visible: view.count >= 0 && field.activeFocus && field.currentWord.length > 0
readonly property point globalPos: visible ? parent.mapToGlobal(field.x, field.y) : Qt.point(0,0)
x: globalPos.x
y: globalPos.y + field.height
}
placeholderText: i18n("Expression to calculate...")
......@@ -78,3 +70,4 @@ TextField
Keys.onDownPressed: view.incrementCurrentIndex()
Keys.onReturnPressed: view.currentIndex = -1
}
Markdown is supported
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