swipe gesture working

This commit is contained in:
Marco Martin 2019-12-12 16:52:53 +01:00
parent 55635e5687
commit 434501dcd9
3 changed files with 105 additions and 42 deletions

View file

@ -31,15 +31,16 @@ PlasmaCore.Dialog {
flags: Qt.X11BypassWindowManagerHint flags: Qt.X11BypassWindowManagerHint
backgroundHints: PlasmaCore.Dialog.NoBackground backgroundHints: PlasmaCore.Dialog.NoBackground
function closeWindowList() { property alias view: view
hideAnim.running = true;
function open() {
dialog.visible = true;
showAnim.restart();
}
function close() {
hideAnim.restart();
} }
onVisibleChanged: {
if (visible) {
showAnim.running = true;
}
}
mainItem: Rectangle { mainItem: Rectangle {
width: workspace.virtualScreenSize.width width: workspace.virtualScreenSize.width
height: workspace.virtualScreenSize.height height: workspace.virtualScreenSize.height
@ -70,8 +71,9 @@ PlasmaCore.Dialog {
id: view id: view
anchors.fill: parent anchors.fill: parent
cacheBuffer: 9999 cacheBuffer: 9999
cellWidth: units.gridUnit * 20 cellWidth: units.gridUnit * 20
cellHeight: units.gridUnit * 20 // (view.width / view.height) cellHeight: cellWidth / (view.width / view.height) + units.gridUnit * 3
model: KWinScripting.ClientModel { model: KWinScripting.ClientModel {
id: clientModel id: clientModel
exclusions: KWinScripting.ClientModel.NotAcceptingFocusExclusion | exclusions: KWinScripting.ClientModel.NotAcceptingFocusExclusion |
@ -79,7 +81,15 @@ PlasmaCore.Dialog {
KWinScripting.ClientModel.DockWindowsExclusion | KWinScripting.ClientModel.DockWindowsExclusion |
KWinScripting.ClientModel.SwitchSwitcherExclusion KWinScripting.ClientModel.SwitchSwitcherExclusion
} }
MouseArea {
parent: view.contentItem
anchors.fill: parent
onClicked: dialog.close()
}
onMovingChanged: { onMovingChanged: {
if (moving) {
return;
}
if (contentY < -view.height/2) { if (contentY < -view.height/2) {
hideAnim.running = true hideAnim.running = true
} else if (contentY >= -view.height/2 && contentY < 0) { } else if (contentY >= -view.height/2 && contentY < 0) {
@ -93,17 +103,33 @@ PlasmaCore.Dialog {
delegate: MouseArea { delegate: MouseArea {
width: view.cellWidth width: view.cellWidth
height: view.cellHeight height: view.cellHeight
PlasmaComponents.ToolButton { Rectangle {
anchors.right: parent.right anchors {
iconSource: "window-close" fill: parent
flat: false margins: units.smallSpacing
onClicked: model.client.closeWindow() }
visible: model.client.closeable radius: 3
}
KWinScripting.ThumbnailItem { PlasmaComponents.ToolButton {
anchors.fill: parent id: closeButton
//parentWindow: dialog.windowId anchors.right: parent.right
client: model.client iconSource: "window-close"
onClicked: model.client.closeWindow()
visible: model.client.closeable
}
KWinScripting.ThumbnailItem {
anchors {
left: parent.left
top: parent.top
right: parent.right
bottom: parent.bottom
margins: units.smallSpacing
topMargin: closeButton.height
}
//parentWindow: dialog.windowId
client: model.client
}
} }
onClicked: { onClicked: {
workspace.activeClient = model.client workspace.activeClient = model.client

View file

@ -23,31 +23,33 @@ import org.kde.kwin 2.0;
Item { Item {
id: root id: root
function peekWindowList(amount) {
switcher.view.contentY = amount;
switcher.visible = true;
//panelLoader.item.raise();
}
function showWindowList() { function showWindowList() {
if (!mainItemLoader.item) { switcher.open();
mainItemLoader.source = "switcher.qml"; //panelLoader.item.raise();
}
mainItemLoader.item.visible = true;
panelLoader.item.raise();
} }
function closeWindowList() { function closeWindowList() {
if (mainItemLoader.item) { switcher.close();
mainItemLoader.item.closeWindowList()
}
} }
Loader { Switcher {
id: mainItemLoader id: switcher
} }
Connections { Connections {
target: workspace target: workspace
onCurrentDesktopChanged: { onCurrentDesktopChanged: {
if (!mainItemLoader.item) { if (!switcher) {
mainItemLoader.source = "switcher.qml"; mainItemLoader.source = "switcher.qml";
} }
mainItemLoader.item.visible = true; switcher.visible = true;
} }
} }

View file

@ -28,38 +28,73 @@ PlasmaCore.Dialog {
y: workspace.virtualScreenSize.height - height y: workspace.virtualScreenSize.height - height
flags: Qt.X11BypassWindowManagerHint flags: Qt.X11BypassWindowManagerHint
type: PlasmaCore.Dialog.Dock type: PlasmaCore.Dialog.Dock
backgroundHints: PlasmaCore.Dialog.NoBackground
mainItem: MouseArea { mainItem: MouseArea {
width: workspace.virtualScreenSize.width width: workspace.virtualScreenSize.width
height: units.iconSizes.medium height: units.iconSizes.medium
property int startY
property bool dragging
onPressed: {
startY = mouse.y;
dragging = false
}
onPositionChanged: {
if (Math.abs(mouse.y - startY) > height) {
dragging = true;
}
if (dragging) {
root.peekWindowList(-workspace.virtualScreenSize.height - mouse.y);
}
}
onReleased: {
if (dragging) {
if (mouse.y < -workspace.virtualScreenSize.height/2) {
root.showWindowList();
} else {
root.closeWindowList();
}
return;
}
var button = layout.childAt(mouse.x, mouse.y);
print("AAAA"+button.source)
if (button) {
button.click();
}
}
Rectangle {
anchors.fill: parent
color: theme.backgroundColor
}
RowLayout { RowLayout {
id: layout
anchors.fill: parent anchors.fill: parent
PlasmaComponents.ToolButton { PlasmaCore.IconItem {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
icon.name: "applications-other" source: "box"
onClicked: root.showWindowList(); function click() { root.showWindowList();}
} }
PlasmaComponents.ToolButton { PlasmaCore.IconItem {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
icon.name: "go-home" source: "start-here-kde"
onClicked: { function click() {
root.closeWindowList(); root.closeWindowList();
workspace.slotToggleShowDesktop(); workspace.slotToggleShowDesktop();
} }
} }
PlasmaComponents.ToolButton { PlasmaCore.IconItem {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
icon.name: "window-close" source: "paint-none"
enabled: workspace.activeClient enabled: workspace.activeClient
onClicked: workspace.activeClient.closeWindow(); function click() { workspace.activeClient.closeWindow();}
} }
} }
} }