Remove duplicated code in QuickSwitcher for RoomDelegate
This commit is contained in:
@@ -6,9 +6,11 @@ import QtQuick.Controls 2.15 as QQC2
|
|||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
import org.kde.kirigami 2.20 as Kirigami
|
import org.kde.kirigami 2.20 as Kirigami
|
||||||
|
import org.kde.kirigamiaddons.delegates 1.0 as Delegates
|
||||||
import org.kde.kitemmodels 1.0
|
import org.kde.kitemmodels 1.0
|
||||||
|
|
||||||
import org.kde.neochat 1.0
|
import org.kde.neochat 1.0
|
||||||
|
import './RoomList' as RoomList
|
||||||
|
|
||||||
QQC2.Dialog {
|
QQC2.Dialog {
|
||||||
id: root
|
id: root
|
||||||
@@ -86,48 +88,23 @@ QQC2.Dialog {
|
|||||||
connection: Controller.activeConnection
|
connection: Controller.activeConnection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delegate: Kirigami.BasicListItem {
|
|
||||||
id: roomListItem
|
|
||||||
|
|
||||||
required property NeoChatRoom currentRoom
|
delegate: RoomList.RoomDelegate {
|
||||||
required property string displayName
|
filterText: searchField.text
|
||||||
required property int index
|
|
||||||
required property int notificationCount
|
|
||||||
required property string subtitleText
|
|
||||||
required property string avatar
|
|
||||||
|
|
||||||
topPadding: Kirigami.Units.largeSpacing
|
|
||||||
bottomPadding: Kirigami.Units.largeSpacing
|
|
||||||
highlighted: roomList.currentIndex === roomListItem.index
|
|
||||||
focus: true
|
|
||||||
icon: undefined
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
RoomManager.enterRoom(roomListItem.currentRoom);
|
RoomManager.enterRoom(currentRoom);
|
||||||
root.close()
|
root.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onEnterPressed: {
|
Keys.onEnterPressed: {
|
||||||
RoomManager.enterRoom(roomListItem.currentRoom);
|
RoomManager.enterRoom(currentRoom);
|
||||||
root.close();
|
root.close();
|
||||||
}
|
}
|
||||||
Keys.onReturnPressed: {
|
|
||||||
RoomManager.enterRoom(roomListItem.currentRoom);
|
|
||||||
root.close();
|
|
||||||
}
|
|
||||||
@BASICLISTITEM_BOLD@: roomListItem.notificationCount > 0
|
|
||||||
label: roomListItem.displayName ?? ""
|
|
||||||
labelItem.textFormat: Text.PlainText
|
|
||||||
subtitle: roomListItem.subtitleText
|
|
||||||
subtitleItem.textFormat: Text.PlainText
|
|
||||||
onPressAndHold: {
|
|
||||||
createRoomListContextMenu()
|
|
||||||
}
|
|
||||||
|
|
||||||
leading: Kirigami.Avatar {
|
Keys.onReturnPressed: {
|
||||||
source: roomListItem.avatar ? "image://mxc/" + roomListItem.avatar : ""
|
RoomManager.enterRoom(currentRoom);
|
||||||
name: roomListItem.displayName
|
root.close();
|
||||||
implicitWidth: height
|
|
||||||
sourceSize.width: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing * 2
|
|
||||||
sourceSize.height: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing * 2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,6 +240,15 @@ Kirigami.Page {
|
|||||||
|
|
||||||
RoomList.RoomDelegate {
|
RoomList.RoomDelegate {
|
||||||
filterText: sortFilterRoomListModel.filterText
|
filterText: sortFilterRoomListModel.filterText
|
||||||
|
|
||||||
|
height: visible ? implicitHeight : 0
|
||||||
|
|
||||||
|
visible: categoryVisible || filterText.length > 0 || Config.mergeRoomList
|
||||||
|
|
||||||
|
onClicked: RoomManager.enterRoom(currentRoom)
|
||||||
|
|
||||||
|
Keys.onEnterPressed: RoomManager.enterRoom(currentRoom)
|
||||||
|
Keys.onReturnPressed: RoomManager.enterRoom(currentRoom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,16 +30,8 @@ Delegates.RoundedItemDelegate {
|
|||||||
|
|
||||||
readonly property bool hasNotifications: notificationCount > 0
|
readonly property bool hasNotifications: notificationCount > 0
|
||||||
|
|
||||||
height: visible ? implicitHeight : 0
|
|
||||||
|
|
||||||
visible: root.categoryVisible || root.filterText.length > 0 || Config.mergeRoomList
|
|
||||||
|
|
||||||
onClicked: RoomManager.enterRoom(root.currentRoom)
|
|
||||||
onPressAndHold: createRoomListContextMenu()
|
onPressAndHold: createRoomListContextMenu()
|
||||||
|
|
||||||
Keys.onEnterPressed: RoomManager.enterRoom(root.currentRoom)
|
|
||||||
Keys.onReturnPressed: RoomManager.enterRoom(root.currentRoom)
|
|
||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
acceptedDevices: PointerDevice.Mouse
|
acceptedDevices: PointerDevice.Mouse
|
||||||
|
|||||||
Reference in New Issue
Block a user