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: {
|
||||
applicationWindow().hoverLinkIndicator.text = "";
|
||||
messageListView.positionViewAtBeginning();
|
||||
@@ -120,26 +117,8 @@ Kirigami.ScrollablePage {
|
||||
|
||||
focus: true
|
||||
|
||||
Keys.onTabPressed: {
|
||||
if (event.modifiers & Qt.ControlModifier) {
|
||||
switchRoomDown();
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onBacktabPressed: {
|
||||
if (event.modifiers & Qt.ControlModifier) {
|
||||
switchRoomUp();
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key === Qt.Key_PageDown && (event.modifiers & Qt.ControlModifier)) {
|
||||
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) {
|
||||
if (!(event.modifiers & Qt.ControlModifier) && event.key < Qt.Key_Escape) {
|
||||
event.accepted = true;
|
||||
chatBox.chatBar.insertText(event.text);
|
||||
chatBox.chatBar.forceActiveFocus();
|
||||
|
||||
@@ -317,12 +317,16 @@ Kirigami.ApplicationWindow {
|
||||
RoomListPage {
|
||||
id: roomList
|
||||
|
||||
Connections {
|
||||
target: root.roomPage
|
||||
function onSwitchRoomUp() {
|
||||
Shortcut {
|
||||
sequences: ["Ctrl+PgUp", "Ctrl+Backtab"]
|
||||
onActivated: {
|
||||
roomList.goToPreviousRoom();
|
||||
}
|
||||
function onSwitchRoomDown() {
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
sequences: ["Ctrl+PgDown", "Ctrl+Tab"]
|
||||
onActivated: {
|
||||
roomList.goToNextRoom();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user