Commit ef7a78cf authored by Marco Martin's avatar Marco Martin

single mousearea on bottom

parent 0c6d19e8
...@@ -24,22 +24,24 @@ import org.kde.plasma.core 2.0 as PlasmaCore ...@@ -24,22 +24,24 @@ 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
import org.kde.kquickcontrolsaddons 2.0 import org.kde.kquickcontrolsaddons 2.0
MouseArea { Item {
id: button id: button
width: Math.min(parent.width, parent.height) width: Math.min(parent.width, parent.height)
height: width height: width
property MouseArea mouseArea
readonly property bool pressed: mouseArea.pressed && mouseArea.activeButton == button
property alias iconSource: icon.source property alias iconSource: icon.source
property bool checked signal clicked()
property bool checkable
property bool clickable
Rectangle { Rectangle {
radius: height/2 radius: height/2
anchors.fill: parent anchors.fill: parent
opacity: button.pressed && button.containsMouse && button.clickable ? 0.1 : 0 opacity: button.pressed && button.enabled ? 0.1 : 0
color: PlasmaCore.ColorScope.textColor color: PlasmaCore.ColorScope.textColor
Behavior on opacity { Behavior on opacity {
OpacityAnimator { //an OpacityAnimator causes stuttering in task switcher dragging
NumberAnimation {
duration: units.longDuration duration: units.longDuration
easing.type: Easing.InOutQuad easing.type: Easing.InOutQuad
} }
...@@ -49,11 +51,6 @@ MouseArea { ...@@ -49,11 +51,6 @@ MouseArea {
id: icon id: icon
anchors.fill: parent anchors.fill: parent
colorGroup: PlasmaCore.ColorScope.colorGroup colorGroup: PlasmaCore.ColorScope.colorGroup
enabled: button.enabled && button.clickable //enabled: button.enabled && button.clickable
}
onClicked: {
if (checkable) {
checked = !checked;
}
} }
} }
...@@ -110,12 +110,18 @@ PlasmaCore.ColorScope { ...@@ -110,12 +110,18 @@ PlasmaCore.ColorScope {
property bool isDragging: false property bool isDragging: false
property bool opening: false property bool opening: false
drag.filterChildren: true drag.filterChildren: true
function managePressed(mouse) { property Button activeButton
onPressed: {
startMouseY = oldMouseY = mouse.y; startMouseY = oldMouseY = mouse.y;
taskSwitcher.offset = -taskSwitcher.height taskSwitcher.offset = -taskSwitcher.height;
activeButton = icons.childAt(mouse.x, mouse.y);
} }
onPressed: managePressed(mouse);
onPositionChanged: { onPositionChanged: {
let newButton = icons.childAt(mouse.x, mouse.y);
if (newButton != activeButton) {
activeButton = null;
}
if (!isDragging && Math.abs(startMouseY - oldMouseY) < root.height) { if (!isDragging && Math.abs(startMouseY - oldMouseY) < root.height) {
oldMouseY = mouse.y; oldMouseY = mouse.y;
return; return;
...@@ -127,6 +133,7 @@ PlasmaCore.ColorScope { ...@@ -127,6 +133,7 @@ PlasmaCore.ColorScope {
opening = oldMouseY > mouse.y; opening = oldMouseY > mouse.y;
if (taskSwitcher.visibility == Window.Hidden && taskSwitcher.offset > -taskSwitcher.height + units.gridUnit && taskSwitcher.tasksCount) { if (taskSwitcher.visibility == Window.Hidden && taskSwitcher.offset > -taskSwitcher.height + units.gridUnit && taskSwitcher.tasksCount) {
activeButton = null;
taskSwitcher.showFullScreen(); taskSwitcher.showFullScreen();
//no tasks, let's scroll up the homescreen instead //no tasks, let's scroll up the homescreen instead
} else if (taskSwitcher.tasksCount === 0) { } else if (taskSwitcher.tasksCount === 0) {
...@@ -135,16 +142,21 @@ PlasmaCore.ColorScope { ...@@ -135,16 +142,21 @@ PlasmaCore.ColorScope {
oldMouseY = mouse.y; oldMouseY = mouse.y;
} }
onReleased: { onReleased: {
if (!isDragging) {
return;
}
if (taskSwitcher.visibility == Window.Hidden) { if (taskSwitcher.visibility == Window.Hidden) {
if (taskSwitcher.tasksCount === 0) { if (taskSwitcher.tasksCount === 0) {
MobileShell.HomeScreenControls.snapHomeScreenPosition(); MobileShell.HomeScreenControls.snapHomeScreenPosition();
} }
if (activeButton) {
activeButton.clicked();
}
return; return;
} }
if (!isDragging) {
return;
}
if (opening) { if (opening) {
taskSwitcher.show(); taskSwitcher.show();
} else { } else {
...@@ -187,19 +199,16 @@ PlasmaCore.ColorScope { ...@@ -187,19 +199,16 @@ PlasmaCore.ColorScope {
anchors.left: parent.left anchors.left: parent.left
height: parent.height height: parent.height
width: parent.width/3 width: parent.width/3
mouseArea: mainMouseArea
enabled: root.hasTasks enabled: root.hasTasks
clickable: root.hasTasks && !taskSwitcher.visible
iconSource: "box" iconSource: "box"
onClicked: { onClicked: {
if (!clickable) { if (!enabled) {
return; return;
} }
plasmoid.nativeInterface.showDesktop = false; plasmoid.nativeInterface.showDesktop = false;
taskSwitcher.visible ? taskSwitcher.hide() : taskSwitcher.show(); taskSwitcher.visible ? taskSwitcher.hide() : taskSwitcher.show();
} }
onPressed: mainMouseArea.managePressed(mouse);
onPositionChanged: mainMouseArea.positionChanged(mouse);
onReleased: mainMouseArea.released(mouse);
} }
Button { Button {
...@@ -207,28 +216,16 @@ PlasmaCore.ColorScope { ...@@ -207,28 +216,16 @@ PlasmaCore.ColorScope {
height: parent.height height: parent.height
width: parent.width/3 width: parent.width/3
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
mouseArea: mainMouseArea
iconSource: "start-here-kde" iconSource: "start-here-kde"
clickable: !taskSwitcher.visible && (root.showingApp || MobileShell.HomeScreenControls.homeScreenPosition != 0) enabled: !taskSwitcher.visible && (root.showingApp || MobileShell.HomeScreenControls.homeScreenPosition != 0)
//checkable: true
onClicked: { onClicked: {
if (!clickable) { if (!enabled) {
return; return;
} }
root.minimizeAll(); root.minimizeAll();
MobileShell.HomeScreenControls.resetHomeScreenPosition(); MobileShell.HomeScreenControls.resetHomeScreenPosition();
plasmoid.nativeInterface.allMinimizedChanged(); plasmoid.nativeInterface.allMinimizedChanged();
//plasmoid.nativeInterface.showDesktop = checked;
}
onPressed: mainMouseArea.managePressed(mouse);
onPositionChanged: mainMouseArea.positionChanged(mouse);
onReleased: mainMouseArea.released(mouse);
Connections {
target: root.taskSwitcher
onCurrentTaskIndexChanged: {
if (root.taskSwitcher.currentTaskIndex < 0) {
showDesktopButton.checked = false;
}
}
} }
} }
...@@ -236,11 +233,11 @@ PlasmaCore.ColorScope { ...@@ -236,11 +233,11 @@ PlasmaCore.ColorScope {
height: parent.height height: parent.height
width: parent.width/3 width: parent.width/3
anchors.right: parent.right anchors.right: parent.right
mouseArea: mainMouseArea
iconSource: "paint-none" iconSource: "paint-none"
//FIXME:Qt.UserRole+9 is IsWindow Qt.UserRole+15 is IsClosable. We can't reach that enum from QML enabled: plasmoid.nativeInterface.hasCloseableActiveWindow && !taskSwitcher.visible
clickable: plasmoid.nativeInterface.hasCloseableActiveWindow && !taskSwitcher.visible
onClicked: { onClicked: {
if (!clickable) { if (!enabled) {
return; return;
} }
if (!plasmoid.nativeInterface.hasCloseableActiveWindow) { if (!plasmoid.nativeInterface.hasCloseableActiveWindow) {
...@@ -251,9 +248,6 @@ PlasmaCore.ColorScope { ...@@ -251,9 +248,6 @@ PlasmaCore.ColorScope {
taskSwitcher.model.requestClose(index); taskSwitcher.model.requestClose(index);
} }
} }
onPressed: mainMouseArea.managePressed(mouse);
onPositionChanged: mainMouseArea.positionChanged(mouse);
onReleased: mainMouseArea.released(mouse);
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment