mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-30 09:30:47 +03:00
Use scrollview again for input
This commit is contained in:
parent
8351cc4180
commit
78ecffb45b
1 changed files with 14 additions and 41 deletions
|
@ -1,14 +1,16 @@
|
||||||
import "./voip"
|
import "./voip"
|
||||||
import QtQuick 2.9
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
import im.nheko 1.0
|
import im.nheko 1.0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: inputBar
|
||||||
|
|
||||||
color: colors.window
|
color: colors.window
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: textInput.height + 16
|
Layout.preferredHeight: row.implicitHeight
|
||||||
Layout.minimumHeight: 40
|
Layout.minimumHeight: 40
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
|
@ -20,11 +22,9 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: inputBar
|
id: row
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 8
|
|
||||||
spacing: 16
|
|
||||||
|
|
||||||
ImageButton {
|
ImageButton {
|
||||||
visible: CallManager.callsSupported
|
visible: CallManager.callsSupported
|
||||||
|
@ -36,7 +36,7 @@ Rectangle {
|
||||||
image: CallManager.isOnCall ? ":/icons/icons/ui/end-call.png" : ":/icons/icons/ui/place-call.png"
|
image: CallManager.isOnCall ? ":/icons/icons/ui/end-call.png" : ":/icons/icons/ui/place-call.png"
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.text: CallManager.isOnCall ? qsTr("Hang up") : qsTr("Place a call")
|
ToolTip.text: CallManager.isOnCall ? qsTr("Hang up") : qsTr("Place a call")
|
||||||
Layout.leftMargin: 8
|
Layout.margins: 8
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (TimelineManager.timeline) {
|
if (TimelineManager.timeline) {
|
||||||
if (CallManager.haveCallInvite) {
|
if (CallManager.haveCallInvite) {
|
||||||
|
@ -58,7 +58,7 @@ Rectangle {
|
||||||
width: 22
|
width: 22
|
||||||
height: 22
|
height: 22
|
||||||
image: ":/icons/icons/ui/paper-clip-outline.png"
|
image: ":/icons/icons/ui/paper-clip-outline.png"
|
||||||
Layout.leftMargin: CallManager.callsSupported ? 0 : 8
|
Layout.margins: 8
|
||||||
onClicked: TimelineManager.timeline.input.openFileSelection()
|
onClicked: TimelineManager.timeline.input.openFileSelection()
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.text: qsTr("Send a file")
|
ToolTip.text: qsTr("Send a file")
|
||||||
|
@ -77,31 +77,13 @@ Rectangle {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Flickable {
|
ScrollView {
|
||||||
id: textInput
|
id: textInput
|
||||||
|
|
||||||
function ensureVisible(r) {
|
Layout.alignment: Qt.AlignBottom // | Qt.AlignHCenter
|
||||||
if (contentX >= r.x)
|
|
||||||
contentX = r.x;
|
|
||||||
else if (contentX + width <= r.x + r.width)
|
|
||||||
contentX = r.x + r.width - width;
|
|
||||||
if (contentY >= r.y)
|
|
||||||
contentY = r.y;
|
|
||||||
else if (contentY + height <= r.y + r.height)
|
|
||||||
contentY = r.y + r.height - height;
|
|
||||||
}
|
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignBottom
|
|
||||||
Layout.maximumHeight: Window.height / 4
|
Layout.maximumHeight: Window.height / 4
|
||||||
Layout.minimumHeight: Settings.fontSize
|
Layout.minimumHeight: Settings.fontSize
|
||||||
Layout.fillWidth: true
|
implicitWidth: inputBar.width - 4 * (22 + 16) - 24
|
||||||
clip: true
|
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
|
||||||
flickableDirection: Flickable.VerticalFlick
|
|
||||||
implicitWidth: messageInput.width
|
|
||||||
implicitHeight: messageInput.height
|
|
||||||
contentWidth: messageInput.width
|
|
||||||
contentHeight: messageInput.height
|
|
||||||
|
|
||||||
TextArea {
|
TextArea {
|
||||||
id: messageInput
|
id: messageInput
|
||||||
|
@ -122,18 +104,11 @@ Rectangle {
|
||||||
|
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
placeholderText: qsTr("Write a message...")
|
placeholderText: qsTr("Write a message...")
|
||||||
//placeholderTextColor: colors.buttonText
|
placeholderTextColor: colors.buttonText
|
||||||
// only set the anchors on Qt 5.12 or higher
|
|
||||||
// see https://doc.qt.io/qt-5/qml-qtquick-controls2-popup.html#anchors.centerIn-prop
|
|
||||||
Component.onCompleted: {
|
|
||||||
if (placeholderTextColor !== undefined)
|
|
||||||
placeholderTextColor = colors.buttonText;
|
|
||||||
|
|
||||||
}
|
|
||||||
color: colors.text
|
color: colors.text
|
||||||
width: textInput.width
|
width: textInput.width
|
||||||
wrapMode: TextEdit.Wrap
|
wrapMode: TextEdit.Wrap
|
||||||
padding: 0
|
padding: 8
|
||||||
focus: true
|
focus: true
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
if (TimelineManager.timeline)
|
if (TimelineManager.timeline)
|
||||||
|
@ -141,7 +116,6 @@ Rectangle {
|
||||||
|
|
||||||
forceActiveFocus();
|
forceActiveFocus();
|
||||||
}
|
}
|
||||||
onCursorRectangleChanged: textInput.ensureVisible(cursorRectangle)
|
|
||||||
onCursorPositionChanged: {
|
onCursorPositionChanged: {
|
||||||
if (!TimelineManager.timeline)
|
if (!TimelineManager.timeline)
|
||||||
return ;
|
return ;
|
||||||
|
@ -296,15 +270,13 @@ Rectangle {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageButton {
|
ImageButton {
|
||||||
id: emojiButton
|
id: emojiButton
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
||||||
|
Layout.margins: 8
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
width: 22
|
width: 22
|
||||||
height: 22
|
height: 22
|
||||||
|
@ -319,6 +291,7 @@ Rectangle {
|
||||||
|
|
||||||
ImageButton {
|
ImageButton {
|
||||||
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
||||||
|
Layout.margins: 8
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
width: 22
|
width: 22
|
||||||
height: 22
|
height: 22
|
||||||
|
|
Loading…
Reference in a new issue