Use Shortcut for keyboard room switching
This allows to use the room switching shortcuts like Ctrl+PgUp/PgDn even when the RoomPage doesn't currently have the focus. It's also a nice code simplification.
This commit is contained in:
@@ -44,9 +44,6 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signal switchRoomUp()
|
|
||||||
signal switchRoomDown()
|
|
||||||
|
|
||||||
onCurrentRoomChanged: {
|
onCurrentRoomChanged: {
|
||||||
applicationWindow().hoverLinkIndicator.text = "";
|
applicationWindow().hoverLinkIndicator.text = "";
|
||||||
messageListView.positionViewAtBeginning();
|
messageListView.positionViewAtBeginning();
|
||||||
@@ -120,26 +117,8 @@ Kirigami.ScrollablePage {
|
|||||||
|
|
||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
Keys.onTabPressed: {
|
|
||||||
if (event.modifiers & Qt.ControlModifier) {
|
|
||||||
switchRoomDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onBacktabPressed: {
|
|
||||||
if (event.modifiers & Qt.ControlModifier) {
|
|
||||||
switchRoomUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
if (event.key === Qt.Key_PageDown && (event.modifiers & Qt.ControlModifier)) {
|
if (!(event.modifiers & Qt.ControlModifier) && event.key < Qt.Key_Escape) {
|
||||||
event.accepted = true;
|
|
||||||
switchRoomDown();
|
|
||||||
} else if (event.key === Qt.Key_PageUp && (event.modifiers & Qt.ControlModifier)) {
|
|
||||||
event.accepted = true;
|
|
||||||
switchRoomUp();
|
|
||||||
} else if (!(event.modifiers & Qt.ControlModifier) && event.key < Qt.Key_Escape) {
|
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
chatBox.chatBar.insertText(event.text);
|
chatBox.chatBar.insertText(event.text);
|
||||||
chatBox.chatBar.forceActiveFocus();
|
chatBox.chatBar.forceActiveFocus();
|
||||||
|
|||||||
@@ -317,12 +317,16 @@ Kirigami.ApplicationWindow {
|
|||||||
RoomListPage {
|
RoomListPage {
|
||||||
id: roomList
|
id: roomList
|
||||||
|
|
||||||
Connections {
|
Shortcut {
|
||||||
target: root.roomPage
|
sequences: ["Ctrl+PgUp", "Ctrl+Backtab"]
|
||||||
function onSwitchRoomUp() {
|
onActivated: {
|
||||||
roomList.goToPreviousRoom();
|
roomList.goToPreviousRoom();
|
||||||
}
|
}
|
||||||
function onSwitchRoomDown() {
|
}
|
||||||
|
|
||||||
|
Shortcut {
|
||||||
|
sequences: ["Ctrl+PgDown", "Ctrl+Tab"]
|
||||||
|
onActivated: {
|
||||||
roomList.goToNextRoom();
|
roomList.goToNextRoom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user