Further improvements to the ChatBox API
Further improvements to the ChatBox API so that outside components no longer access the ChatBar item directly.
This commit is contained in:
@@ -195,7 +195,7 @@ QQC2.Control {
|
|||||||
x: textField.cursorRectangle.x
|
x: textField.cursorRectangle.x
|
||||||
y: textField.cursorRectangle.y - height
|
y: textField.cursorRectangle.y - height
|
||||||
|
|
||||||
onFormattingSelected: chatBar.formatText(format, selectionStart, selectionEnd)
|
onFormattingSelected: root.formatText(format, selectionStart, selectionEnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onDeletePressed: {
|
Keys.onDeletePressed: {
|
||||||
@@ -218,7 +218,7 @@ QQC2.Control {
|
|||||||
} else if (event.modifiers & Qt.ShiftModifier || Kirigami.Settings.isMobile) {
|
} else if (event.modifiers & Qt.ShiftModifier || Kirigami.Settings.isMobile) {
|
||||||
textField.insert(cursorPosition, "\n")
|
textField.insert(cursorPosition, "\n")
|
||||||
} else {
|
} else {
|
||||||
chatBar.postMessage();
|
root.postMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keys.onReturnPressed: {
|
Keys.onReturnPressed: {
|
||||||
@@ -227,7 +227,7 @@ QQC2.Control {
|
|||||||
} else if (event.modifiers & Qt.ShiftModifier || Kirigami.Settings.isMobile) {
|
} else if (event.modifiers & Qt.ShiftModifier || Kirigami.Settings.isMobile) {
|
||||||
textField.insert(cursorPosition, "\n")
|
textField.insert(cursorPosition, "\n")
|
||||||
} else {
|
} else {
|
||||||
chatBar.postMessage();
|
root.postMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keys.onTabPressed: {
|
Keys.onTabPressed: {
|
||||||
@@ -237,7 +237,7 @@ QQC2.Control {
|
|||||||
}
|
}
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
if (event.key === Qt.Key_V && event.modifiers & Qt.ControlModifier) {
|
if (event.key === Qt.Key_V && event.modifiers & Qt.ControlModifier) {
|
||||||
chatBar.pasteImage();
|
root.pasteImage();
|
||||||
} else if (event.key === Qt.Key_Up && event.modifiers & Qt.ControlModifier) {
|
} else if (event.key === Qt.Key_Up && event.modifiers & Qt.ControlModifier) {
|
||||||
currentRoom.replyLastMessage();
|
currentRoom.replyLastMessage();
|
||||||
} else if (event.key === Qt.Key_Up && textField.text.length === 0) {
|
} else if (event.key === Qt.Key_Up && textField.text.length === 0) {
|
||||||
|
|||||||
@@ -37,16 +37,20 @@ ColumnLayout {
|
|||||||
*/
|
*/
|
||||||
property NeoChatRoom currentRoom
|
property NeoChatRoom currentRoom
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The chatBar object
|
|
||||||
*/
|
|
||||||
property alias chatBar: chatBar
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A message has been sent from the chat bar.
|
* @brief A message has been sent from the chat bar.
|
||||||
*/
|
*/
|
||||||
signal messageSent()
|
signal messageSent()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert the given text into the ChatBar.
|
||||||
|
*
|
||||||
|
* The text is inserted at the current cursor location.
|
||||||
|
*/
|
||||||
|
function insertText(text) {
|
||||||
|
chatBar.insertText(text)
|
||||||
|
}
|
||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||||
@@ -86,4 +90,6 @@ ColumnLayout {
|
|||||||
chatBox.messageSent();
|
chatBox.messageSent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onActiveFocusChanged: chatBar.forceActiveFocus()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ Kirigami.Page {
|
|||||||
timelineViewLoader.item.positionViewAtBeginning();
|
timelineViewLoader.item.positionViewAtBeginning();
|
||||||
hasScrolledUpBefore = false;
|
hasScrolledUpBefore = false;
|
||||||
if (!Kirigami.Settings.isMobile && chatBoxLoader.item) {
|
if (!Kirigami.Settings.isMobile && chatBoxLoader.item) {
|
||||||
chatBoxLoader.item.chatBar.forceActiveFocus();
|
chatBoxLoader.item.forceActiveFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ Kirigami.Page {
|
|||||||
currentRoom: root.currentRoom
|
currentRoom: root.currentRoom
|
||||||
onFocusChatBox: {
|
onFocusChatBox: {
|
||||||
if (chatBoxLoader.item) {
|
if (chatBoxLoader.item) {
|
||||||
chatBoxLoader.item.chatBar.forceActiveFocus()
|
chatBoxLoader.item.forceActiveFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,8 +151,8 @@ Kirigami.Page {
|
|||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
if (!(event.modifiers & Qt.ControlModifier) && event.key < Qt.Key_Escape) {
|
if (!(event.modifiers & Qt.ControlModifier) && event.key < Qt.Key_Escape) {
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
chatBoxLoader.item.chatBar.insertText(event.text);
|
chatBoxLoader.item.insertText(event.text);
|
||||||
chatBoxLoader.item.chatBar.forceActiveFocus();
|
chatBoxLoader.item.forceActiveFocus();
|
||||||
return;
|
return;
|
||||||
} else if (event.key === Qt.Key_PageUp) {
|
} else if (event.key === Qt.Key_PageUp) {
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user