94 lines
3.9 KiB
QML
94 lines
3.9 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import QtQuick.Controls.Material
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Quickshell.Wayland
|
|
import "services"
|
|
import "services/WindowPolicy.js" as WindowPolicy
|
|
import "components"
|
|
|
|
Item {
|
|
id: recent
|
|
Material.theme: Theme.dark ? Material.Dark : Material.Light
|
|
Material.accent: Theme.primary
|
|
signal done()
|
|
readonly property var windows: ToplevelManager.toplevels.values
|
|
readonly property var filtered: windows.filter(window =>
|
|
((window.title || "") + " " + (window.appId || "")).toLowerCase().includes(search.text.toLowerCase()))
|
|
ColumnLayout {
|
|
anchors.fill: parent
|
|
spacing: 12
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: "Открытые приложения · " + recent.windows.length
|
|
font.pixelSize: 20
|
|
color: Theme.foreground
|
|
}
|
|
TextField {
|
|
id: search
|
|
Layout.fillWidth: true
|
|
placeholderText: "Поиск среди открытых окон"
|
|
}
|
|
ScrollView {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
contentWidth: availableWidth
|
|
ColumnLayout {
|
|
width: parent.width
|
|
spacing: 10
|
|
Repeater {
|
|
model: recent.filtered
|
|
Rectangle {
|
|
id: windowCard
|
|
required property var modelData
|
|
Layout.fillWidth: true
|
|
implicitHeight: actions.implicitHeight + 24
|
|
radius: Theme.radius
|
|
color: Theme.surfaceHigh
|
|
// Gesture recognition does not steal taps from the action buttons.
|
|
DragHandler {
|
|
id: dismissDrag
|
|
target: null
|
|
xAxis.enabled: false
|
|
onActiveChanged: {
|
|
if (!active && WindowPolicy.shouldDismissSwipe(activeTranslation.x, activeTranslation.y, windowCard.width))
|
|
windowCard.modelData.close();
|
|
}
|
|
}
|
|
RowLayout {
|
|
id: actions
|
|
anchors.fill: parent
|
|
anchors.margins: 12
|
|
spacing: 8
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: windowCard.modelData.title || windowCard.modelData.appId || "Окно"
|
|
color: Theme.foreground
|
|
elide: Text.ElideRight
|
|
}
|
|
Label {
|
|
Layout.fillWidth: true
|
|
text: windowCard.modelData.appId || ""
|
|
color: Theme.outline
|
|
font.pixelSize: 12
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
ActionButton { text: "Открыть"; onClicked: { windowCard.modelData.activate(); recent.done(); } }
|
|
ActionButton { text: "Закрыть"; onClicked: windowCard.modelData.close() }
|
|
}
|
|
}
|
|
}
|
|
Label {
|
|
visible: recent.filtered.length === 0
|
|
text: search.text ? "Окна не найдены" : "Нет открытых окон"
|
|
color: Theme.foreground
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|