2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtGraphicalEffects 1.15
|
2022-02-04 13:07:48 +00:00
|
|
|
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2024-09-27 16:05:23 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2022-02-04 13:07:48 +00:00
|
|
|
|
2024-09-27 16:05:23 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
2022-02-04 13:07:48 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
Popup {
|
|
|
|
id: root
|
|
|
|
|
2022-10-18 09:06:18 +00:00
|
|
|
anchors.centerIn: Overlay.overlay
|
|
|
|
|
2022-02-04 13:07:48 +00:00
|
|
|
width: 400
|
|
|
|
height: 300
|
|
|
|
|
2024-09-27 16:05:23 +00:00
|
|
|
required property var model
|
2022-02-04 13:07:48 +00:00
|
|
|
|
|
|
|
property string searchBoxPlaceholder: qsTr("Search...")
|
|
|
|
|
2024-09-27 16:05:23 +00:00
|
|
|
signal selected(string sectionId, string chatId)
|
2022-02-04 13:07:48 +00:00
|
|
|
|
|
|
|
background: Rectangle {
|
2024-10-15 19:26:12 +00:00
|
|
|
radius: Theme.radius
|
|
|
|
color: Theme.palette.background
|
|
|
|
border.color: Theme.palette.border
|
2022-02-04 13:07:48 +00:00
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
verticalOffset: 3
|
|
|
|
radius: 8
|
|
|
|
samples: 15
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: "#22000000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: searchBox
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2022-07-22 10:28:04 +00:00
|
|
|
placeholderText: root.searchBoxPlaceholder
|
2022-09-18 12:31:44 +00:00
|
|
|
input.asset.name: "search"
|
2022-02-04 13:07:48 +00:00
|
|
|
|
|
|
|
function goToNextAvailableIndex(up) {
|
|
|
|
var currentIndex = listView.currentIndex
|
|
|
|
for (var i = 0; i < listView.count; i++) {
|
|
|
|
currentIndex = up ? (currentIndex === 0 ? listView.count - 1 : currentIndex - 1)
|
|
|
|
: (currentIndex === listView.count - 1 ? 0 : currentIndex + 1)
|
|
|
|
listView.currentIndex = currentIndex
|
|
|
|
if (listView.currentItem.visible) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
listView.currentIndex = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
Keys.onReleased: {
|
|
|
|
listView.selectByHover = false
|
|
|
|
|
|
|
|
if (event.key === Qt.Key_Down) {
|
|
|
|
searchBox.goToNextAvailableIndex(false)
|
|
|
|
}
|
|
|
|
if (event.key === Qt.Key_Up) {
|
|
|
|
searchBox.goToNextAvailableIndex(true)
|
|
|
|
}
|
|
|
|
if (event.key === Qt.Key_Escape) {
|
|
|
|
return root.close()
|
|
|
|
}
|
|
|
|
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
2024-09-27 16:05:23 +00:00
|
|
|
return listView.currentItem.selectThisItem()
|
2022-02-04 13:07:48 +00:00
|
|
|
}
|
|
|
|
if (!listView.currentItem.visible) {
|
|
|
|
goToNextAvailableIndex(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onTextChanged: if (text === "") listView.currentIndex = 0
|
|
|
|
}
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2022-02-04 13:07:48 +00:00
|
|
|
id: listView
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
property bool selectByHover: false
|
|
|
|
|
|
|
|
highlightMoveDuration: 200
|
|
|
|
|
2024-09-27 16:05:23 +00:00
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.model
|
2022-02-04 13:07:48 +00:00
|
|
|
|
2024-09-27 16:05:23 +00:00
|
|
|
filters: AnyOf {
|
|
|
|
SearchFilter {
|
|
|
|
roleName: "sectionName"
|
|
|
|
searchPhrase: searchBox.text
|
|
|
|
}
|
|
|
|
SearchFilter {
|
|
|
|
roleName: "name"
|
|
|
|
searchPhrase: searchBox.text
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-04 13:07:48 +00:00
|
|
|
|
2024-09-27 16:05:23 +00:00
|
|
|
delegate: StatusListItem {
|
|
|
|
id: listItem
|
2022-02-04 13:07:48 +00:00
|
|
|
|
2024-09-27 16:05:23 +00:00
|
|
|
function selectThisItem() {
|
|
|
|
root.selected(model.sectionId, model.chatId)
|
|
|
|
}
|
2022-02-04 13:07:48 +00:00
|
|
|
|
2024-09-27 16:05:23 +00:00
|
|
|
title: model ? model.name : ""
|
|
|
|
label: model? model.sectionName : ""
|
|
|
|
highlighted: ListView.isCurrentItem
|
|
|
|
width: ListView.view.width
|
|
|
|
sensor.hoverEnabled: false
|
|
|
|
statusListItemIcon {
|
|
|
|
name: model ? model.name : ""
|
|
|
|
active: true
|
2022-02-04 13:07:48 +00:00
|
|
|
}
|
2024-09-27 16:05:23 +00:00
|
|
|
asset.width: 30
|
|
|
|
asset.height: 30
|
|
|
|
asset.color: model ? model.color ? model.color : Utils.colorForColorId(model.colorId) : ""
|
|
|
|
asset.name: model ? model.icon : ""
|
|
|
|
asset.charactersLen: 2
|
|
|
|
asset.letterSize: asset._twoLettersSize
|
|
|
|
ringSettings.ringSpecModel: model ? model.colorHash : undefined
|
2022-02-04 13:07:48 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: (mouse) => {
|
2024-09-27 16:05:23 +00:00
|
|
|
listView.currentIndex = index
|
|
|
|
listItem.selectThisItem()
|
|
|
|
mouse.accepted = false
|
|
|
|
}
|
2022-02-04 13:07:48 +00:00
|
|
|
onContainsMouseChanged: if (containsMouse) listView.currentIndex = index
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
anchors.fill: parent
|
|
|
|
active: !listView.selectByHover
|
|
|
|
|
|
|
|
sourceComponent: MouseArea {
|
|
|
|
hoverEnabled: true
|
|
|
|
onPositionChanged: listView.selectByHover = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onAboutToShow: {
|
|
|
|
listView.currentIndex = 0
|
|
|
|
listView.selectByHover = false
|
|
|
|
searchBox.text = ""
|
|
|
|
searchBox.input.edit.forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|