shift-shell/kwinmultitasking/contents/ui/panel.qml

107 lines
3.3 KiB
QML
Raw Normal View History

2015-06-04 22:14:26 +00:00
/********************************************************************
This file is part of the KDE project.
Copyright (C) 2015 Marco MArtin <mart@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
import QtQuick 2.0
2019-12-11 22:00:38 +00:00
import QtQuick.Layouts 1.4
2015-06-05 00:01:08 +00:00
import QtQuick.Window 2.0
2015-06-04 22:14:26 +00:00
import org.kde.plasma.core 2.0 as PlasmaCore
2019-12-11 22:00:38 +00:00
import org.kde.plasma.components 3.0 as PlasmaComponents
2015-06-05 00:01:08 +00:00
import org.kde.kwin 2.0
2015-06-04 22:14:26 +00:00
PlasmaCore.Dialog {
id: panel
y: workspace.virtualScreenSize.height - height
flags: Qt.X11BypassWindowManagerHint
type: PlasmaCore.Dialog.Dock
2019-12-12 15:52:53 +00:00
backgroundHints: PlasmaCore.Dialog.NoBackground
2019-12-11 22:00:38 +00:00
mainItem: MouseArea {
2015-06-04 22:14:26 +00:00
width: workspace.virtualScreenSize.width
height: units.iconSizes.medium
2019-12-12 15:52:53 +00:00
property int startY
property bool dragging
2015-06-04 22:14:26 +00:00
2019-12-12 15:52:53 +00:00
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);
if (button) {
button.click();
}
}
Rectangle {
anchors.fill: parent
color: theme.backgroundColor
}
2019-12-11 22:00:38 +00:00
RowLayout {
2019-12-12 15:52:53 +00:00
id: layout
2019-12-11 22:00:38 +00:00
anchors.fill: parent
2019-12-12 15:52:53 +00:00
PlasmaCore.IconItem {
2019-12-11 22:00:38 +00:00
Layout.fillWidth: true
Layout.fillHeight: true
2019-12-12 15:52:53 +00:00
source: "box"
function click() { root.showWindowList();}
2019-12-11 22:00:38 +00:00
}
2019-12-12 15:52:53 +00:00
PlasmaCore.IconItem {
2019-12-11 22:00:38 +00:00
Layout.fillWidth: true
Layout.fillHeight: true
2019-12-12 15:52:53 +00:00
source: "start-here-kde"
function click() {
2019-12-11 22:00:38 +00:00
root.closeWindowList();
workspace.slotToggleShowDesktop();
}
}
2019-12-12 15:52:53 +00:00
PlasmaCore.IconItem {
2019-12-11 22:00:38 +00:00
Layout.fillWidth: true
Layout.fillHeight: true
2019-12-12 15:52:53 +00:00
source: "paint-none"
2019-12-11 22:00:38 +00:00
enabled: workspace.activeClient
2019-12-12 15:52:53 +00:00
function click() { workspace.activeClient.closeWindow();}
2019-12-11 22:00:38 +00:00
}
2015-06-09 02:17:10 +00:00
}
2015-06-04 22:14:26 +00:00
}
Component.onCompleted: {
2015-06-05 00:01:08 +00:00
KWin.registerWindow(panel);
2015-06-04 22:14:26 +00:00
panel.visible = true;
2015-06-05 00:01:08 +00:00
panel.y = workspace.virtualScreenSize.height - height
2015-06-04 22:14:26 +00:00
}
}