mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-02 17:54:45 +00:00
window close gesture
This commit is contained in:
parent
35e6d4c7c2
commit
40ece80841
2 changed files with 80 additions and 30 deletions
|
|
@ -17,7 +17,8 @@ GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
import QtQuick 2.0;
|
import QtQuick 2.12;
|
||||||
|
import QtQuick.Layouts 1.2
|
||||||
import QtQuick.Window 2.0;
|
import QtQuick.Window 2.0;
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore;
|
import org.kde.plasma.core 2.0 as PlasmaCore;
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents;
|
import org.kde.plasma.components 2.0 as PlasmaComponents;
|
||||||
|
|
@ -73,7 +74,7 @@ PlasmaCore.Dialog {
|
||||||
cacheBuffer: 9999
|
cacheBuffer: 9999
|
||||||
|
|
||||||
cellWidth: width / Math.floor(width / (units.gridUnit * 10))
|
cellWidth: width / Math.floor(width / (units.gridUnit * 10))
|
||||||
cellHeight: cellWidth / (view.width / view.height) + units.gridUnit * 3
|
cellHeight: cellWidth / (workspace.virtualScreenSize.width / workspace.virtualScreenSize.height) + units.gridUnit * 3
|
||||||
model: KWinScripting.ClientModel {
|
model: KWinScripting.ClientModel {
|
||||||
id: clientModel
|
id: clientModel
|
||||||
exclusions: KWinScripting.ClientModel.NotAcceptingFocusExclusion |
|
exclusions: KWinScripting.ClientModel.NotAcceptingFocusExclusion |
|
||||||
|
|
@ -83,7 +84,11 @@ PlasmaCore.Dialog {
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
parent: view.contentItem
|
parent: view.contentItem
|
||||||
anchors.fill: parent
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
height: Math.max(parent.height, view.height)
|
||||||
onClicked: dialog.close()
|
onClicked: dialog.close()
|
||||||
}
|
}
|
||||||
onMovingChanged: {
|
onMovingChanged: {
|
||||||
|
|
@ -96,38 +101,84 @@ PlasmaCore.Dialog {
|
||||||
showAnim.running = true
|
showAnim.running = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
header: Item {
|
topMargin: height
|
||||||
width: view.width
|
bottomMargin: height
|
||||||
height: view.height
|
|
||||||
}
|
|
||||||
delegate: MouseArea {
|
delegate: MouseArea {
|
||||||
width: view.cellWidth
|
width: view.cellWidth
|
||||||
height: view.cellHeight
|
height: view.cellHeight
|
||||||
Rectangle {
|
drag.target: decoration
|
||||||
anchors {
|
drag.axis: Drag.XAxis
|
||||||
fill: parent
|
|
||||||
margins: units.smallSpacing
|
|
||||||
}
|
|
||||||
radius: 3
|
|
||||||
|
|
||||||
PlasmaComponents.ToolButton {
|
onReleased: {
|
||||||
id: closeButton
|
if (decoration.x > decoration.width / 2) {
|
||||||
anchors.right: parent.right
|
windowCloseAnim.to = decoration.width
|
||||||
iconSource: "window-close"
|
windowCloseAnim.restart()
|
||||||
onClicked: model.client.closeWindow()
|
} else if (decoration.x < -decoration.width / 2) {
|
||||||
visible: model.client.closeable
|
windowCloseAnim.to = -decoration.width
|
||||||
|
windowCloseAnim.restart()
|
||||||
|
} else {
|
||||||
|
resetAnim.restart();
|
||||||
}
|
}
|
||||||
KWinScripting.ThumbnailItem {
|
}
|
||||||
anchors {
|
NumberAnimation {
|
||||||
left: parent.left
|
id: resetAnim
|
||||||
top: parent.top
|
target: decoration
|
||||||
right: parent.right
|
property: "x"
|
||||||
bottom: parent.bottom
|
from: decoration.x
|
||||||
margins: units.smallSpacing
|
to: 0
|
||||||
topMargin: closeButton.height
|
duration: units.longDuration
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
SequentialAnimation {
|
||||||
|
id: windowCloseAnim
|
||||||
|
property alias to: internalAnim.to
|
||||||
|
NumberAnimation {
|
||||||
|
id: internalAnim
|
||||||
|
property: "x"
|
||||||
|
target: decoration
|
||||||
|
duration: units.longDuration
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
ScriptAction {
|
||||||
|
script: {
|
||||||
|
model.client.closeWindow()
|
||||||
|
decoration.x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
id: decoration
|
||||||
|
opacity: 1 - Math.abs(x / width)
|
||||||
|
width: parent.width - units.smallSpacing*2
|
||||||
|
height: parent.height - units.smallSpacing*2
|
||||||
|
radius: 3
|
||||||
|
color: theme.backgroundColor
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors {
|
||||||
|
fill: parent
|
||||||
|
margins: units.smallSpacing
|
||||||
|
}
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
PlasmaComponents.Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
elide: Text.ElideRight
|
||||||
|
text: model.client.caption
|
||||||
|
}
|
||||||
|
PlasmaComponents.ToolButton {
|
||||||
|
iconSource: "window-close"
|
||||||
|
onClicked: model.client.closeWindow()
|
||||||
|
visible: model.client.closeable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KWinScripting.ThumbnailItem {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
//parentWindow: dialog.windowId
|
||||||
|
opacity: decoration.opacity
|
||||||
|
client: model.client
|
||||||
}
|
}
|
||||||
//parentWindow: dialog.windowId
|
|
||||||
client: model.client
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ PlasmaCore.Dialog {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var button = layout.childAt(mouse.x, mouse.y);
|
var button = layout.childAt(mouse.x, mouse.y);
|
||||||
print("AAAA"+button.source)
|
|
||||||
if (button) {
|
if (button) {
|
||||||
button.click();
|
button.click();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue