Commit ca2e2bb2 authored by Ivan Čukić's avatar Ivan Čukić 👁

Dedicated drop areas for assigning tasks to activities

Summary:
Instead of using a difficult to discover 'move to activity by default,
copy to activity when Control is pressed', show two drop areas when the
mouse hovers an activity item in the switcher.

If the user drops the task onto the left area, the task will be moved
to that activity. If the user drops the task onto the right area, the
task will be assigned to the new activity without removing it from the
current one.

{F8313199}

Reviewers: #plasma, ngraham, mart

Reviewed By: ngraham

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D29679
parent 854a62e5
/*
* Copyright (C) 2014-2020 Ivan Cukic <ivan.cukic(at)kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* or (at your option) any later version, as published by the Free
* Software Foundation
*
* 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, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
......@@ -5,7 +24,6 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddonsComponents
import org.kde.draganddrop 2.0 as DND
import org.kde.plasma.activityswitcher 1.0 as ActivitySwitcher
......@@ -98,13 +116,15 @@ Item {
}
Rectangle {
id: highlight
id: currentActivityHighlight
visible: root.current
border.width: root.current ? units.smallSpacing : 0
border.color: theme.highlightColor
z: 10
anchors {
fill: parent
// Hide the rounding error on the bottom of the rectangle
......@@ -112,8 +132,6 @@ Item {
}
color: "transparent"
// z: 1
}
Item {
......@@ -207,66 +225,89 @@ Item {
i18nd("plasma_shell_org.kde.plasma.desktop", "Currently being used") :
model.lastTimeUsedString
}
}
Rectangle {
id: dropHighlight
visible: moveDropAction.isHovered || copyDropAction.isHovered
onVisibleChanged: {
ActivitySwitcher.Backend.setDropMode(visible);
if (visible) {
root.state = "dropAreasShown";
} else {
root.state = "plain";
}
}
// Text {
// id: stats
//
// color : "white"
// elide : Text.ElideRight
// opacity : .6
//
// text: "6 documents, 2 applications"
// visible: false
//
// anchors {
// top : lastUsedDate.bottom
// left : parent.left
// right : parent.right
// }
// }
anchors {
fill: parent
topMargin: icon.height + 3 * units.smallSpacing
}
opacity: .75
color: theme.backgroundColor
}
DND.DropArea {
PlasmaComponents.Highlight {
id: dropHighlight
anchors.fill: parent
visible: false
TaskDropArea {
id: moveDropAction
anchors {
right: parent.horizontalCenter
left: parent.left
top: parent.top
bottom: parent.bottom
}
anchors.fill: parent
topPadding: icon.height + 3 * units.smallSpacing
actionVisible: dropHighlight.visible
preventStealing: true
enabled: true
actionTitle: i18nd("plasma_shell_org.kde.plasma.desktop", "Move to\nthis activity")
onDrop: {
ActivitySwitcher.Backend.drop(event.mimeData, event.modifiers, root.activityId);
onTaskDropped: {
ActivitySwitcher.Backend.dropMove(mimeData, root.activityId);
}
onDragEnter: {
ActivitySwitcher.Backend.setDropMode(true);
dropHighlight.visible = true;
onClicked: {
root.clicked();
}
onDragLeave: {
ActivitySwitcher.Backend.setDropMode(false);
dropHighlight.visible = false;
onEntered: {
S.showActivityItemActionsBar(root);
}
visible: ActivitySwitcher.Backend.dropEnabled
}
TaskDropArea {
id: copyDropAction
topPadding: icon.height + 3 * units.smallSpacing
actionVisible: dropHighlight.visible
anchors {
right: parent.right
left: parent.horizontalCenter
top: parent.top
bottom: parent.bottom
}
MouseArea {
id: hoverArea
actionTitle: i18nd("plasma_shell_org.kde.plasma.desktop", "Show also\nin this activity")
anchors.fill : parent
onClicked : root.clicked()
hoverEnabled : true
onEntered : S.showActivityItemActionsBar(root)
onTaskDropped: {
ActivitySwitcher.Backend.dropCopy(mimeData, root.activityId);
}
Accessible.name : root.title
Accessible.role : Accessible.Button
Accessible.selected : root.selected
Accessible.onPressAction : root.clicked()
onClicked: {
root.clicked();
}
onEntered: {
S.showActivityItemActionsBar(root);
}
visible: ActivitySwitcher.Backend.dropEnabled
}
// Controls
......@@ -351,6 +392,12 @@ Item {
name: "showingControls"
PropertyChanges { target: shade; visible: true }
PropertyChanges { target: controlBar; opacity: 1 }
},
State {
name: "dropAreasShown"
// PropertyChanges { target: shade; visible: false }
PropertyChanges { target: statsBar; visible: false }
PropertyChanges { target: controlBar; opacity: 0 }
}
]
......
/*
* Copyright (C) 2020 Ivan Cukic <ivan.cukic(at)kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* or (at your option) any later version, as published by the Free
* Software Foundation
*
* 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, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.draganddrop 2.0 as DND
DND.DropArea {
id: root
signal taskDropped(variant mimeData, variant modifiers)
signal clicked()
signal entered()
property int topPadding: 0
property string activityName: ""
property bool selected: false
property string actionTitle: ""
property bool isHovered: false
property bool actionVisible: false
PlasmaComponents.Highlight {
id: dropHighlight
anchors {
fill: parent
// topMargin: icon.height + 3 * units.smallSpacing
topMargin: root.topPadding
}
visible: root.isHovered
z: -1
}
Text {
id: dropAreaLeftText
anchors {
fill: dropHighlight
leftMargin: units.largeSpacing
rightMargin: units.largeSpacing
}
color: theme.textColor
visible: root.actionVisible
text: root.actionTitle
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
maximumLineCount: 3
}
anchors {
left: parent.left
right: parent.horizontalCenter
top: parent.top
bottom: parent.bottom
}
preventStealing: true
enabled: true
onDrop: {
root.taskDropped(event.mimeData, event.modifiers);
}
onDragEnter: {
root.isHovered = true;
}
onDragLeave: {
root.isHovered = false;
}
MouseArea {
anchors.fill : parent
onClicked : root.clicked()
hoverEnabled : true
onEntered : root.entered()
Accessible.name : root.activityName
Accessible.role : Accessible.Button
Accessible.selected : root.selected
Accessible.onPressAction : root.clicked()
}
}
......@@ -456,6 +456,16 @@ bool SwitcherBackend::dropEnabled() const
#endif
}
void SwitcherBackend::dropCopy(QMimeData* mimeData, const QVariant &activityId)
{
drop(mimeData, Qt::ControlModifier, activityId);
}
void SwitcherBackend::dropMove(QMimeData* mimeData, const QVariant &activityId)
{
drop(mimeData, 0, activityId);
}
void SwitcherBackend::drop(QMimeData* mimeData, int modifiers, const QVariant &activityId)
{
setDropMode(false);
......
......@@ -72,6 +72,8 @@ public Q_SLOTS:
void setDropMode(bool value);
void drop(QMimeData* mimeData, int modifiers, const QVariant &activityId);
void dropCopy(QMimeData* mimeData, const QVariant &activityId);
void dropMove(QMimeData* mimeData, const QVariant &activityId);
bool dropEnabled() const;
private:
......
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