2015-06-11 22:35:46 +00:00
|
|
|
/*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
|
2021-10-18 03:50:59 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
2015-06-11 22:35:46 +00:00
|
|
|
*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2015-06-11 22:35:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.4
|
|
|
|
|
import QtQuick.Layouts 1.1
|
2015-09-10 14:53:01 +00:00
|
|
|
import QtQuick.Window 2.2
|
2020-02-05 19:25:52 +00:00
|
|
|
import QtGraphicalEffects 1.12
|
2015-06-11 22:35:46 +00:00
|
|
|
|
2016-06-27 16:34:20 +00:00
|
|
|
import org.kde.taskmanager 0.1 as TaskManager
|
2015-06-11 22:35:46 +00:00
|
|
|
import org.kde.plasma.plasmoid 2.0
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
|
import org.kde.kquickcontrolsaddons 2.0
|
|
|
|
|
|
2020-06-26 21:18:04 +00:00
|
|
|
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
|
2020-07-22 15:17:10 +00:00
|
|
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
2021-02-24 01:05:41 +00:00
|
|
|
import org.kde.plasma.phone.taskpanel 1.0 as TaskPanel
|
2020-07-22 15:17:10 +00:00
|
|
|
|
2015-06-18 23:31:26 +00:00
|
|
|
PlasmaCore.ColorScope {
|
|
|
|
|
id: root
|
2021-02-28 05:23:09 +00:00
|
|
|
colorGroup: showingApp ? PlasmaCore.Theme.HeaderColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
|
2021-12-25 03:31:33 +00:00
|
|
|
|
2019-10-11 09:49:18 +00:00
|
|
|
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
|
|
|
|
|
|
2021-12-29 05:08:32 +00:00
|
|
|
readonly property color backgroundColor: PlasmaCore.ColorScope.backgroundColor
|
2020-07-30 10:39:13 +00:00
|
|
|
readonly property bool showingApp: !plasmoid.nativeInterface.allMinimized
|
2020-07-16 14:22:57 +00:00
|
|
|
|
|
|
|
|
readonly property bool hasTasks: tasksModel.count > 0
|
2017-09-05 15:02:30 +00:00
|
|
|
|
2021-12-25 03:31:33 +00:00
|
|
|
property var taskSwitcher: MobileShell.HomeScreenControls.taskSwitcher
|
2015-09-16 11:35:55 +00:00
|
|
|
|
2021-12-25 03:31:33 +00:00
|
|
|
//BEGIN API implementation
|
2020-07-22 12:22:10 +00:00
|
|
|
|
2021-12-25 03:31:33 +00:00
|
|
|
Binding {
|
|
|
|
|
target: MobileShell.TaskPanelControls
|
|
|
|
|
property: "isPortrait"
|
|
|
|
|
value: Screen.width <= Screen.height
|
2020-07-22 12:22:10 +00:00
|
|
|
}
|
2021-12-25 03:31:33 +00:00
|
|
|
Binding {
|
|
|
|
|
target: MobileShell.TaskPanelControls
|
|
|
|
|
property: "panelHeight"
|
|
|
|
|
value: root.height
|
|
|
|
|
}
|
|
|
|
|
Binding {
|
|
|
|
|
target: MobileShell.TaskPanelControls
|
|
|
|
|
property: "panelWidth"
|
|
|
|
|
value: root.width
|
2021-10-31 04:11:10 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-25 03:31:33 +00:00
|
|
|
//END API implementation
|
|
|
|
|
|
2021-10-31 04:11:10 +00:00
|
|
|
Connections {
|
|
|
|
|
target: plasmoid.nativeInterface
|
|
|
|
|
function onAllMinimizedChanged() {
|
|
|
|
|
MobileShell.HomeScreenControls.homeScreenVisible = plasmoid.nativeInterface.allMinimized
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-22 12:22:10 +00:00
|
|
|
|
2019-10-11 09:49:18 +00:00
|
|
|
TaskManager.TasksModel {
|
|
|
|
|
id: tasksModel
|
|
|
|
|
groupMode: TaskManager.TasksModel.GroupDisabled
|
|
|
|
|
|
|
|
|
|
screenGeometry: plasmoid.screenGeometry
|
2020-07-16 14:22:57 +00:00
|
|
|
sortMode: TaskManager.TasksModel.SortAlpha
|
|
|
|
|
|
|
|
|
|
virtualDesktop: virtualDesktopInfo.currentDesktop
|
|
|
|
|
activity: activityInfo.currentActivity
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TaskManager.VirtualDesktopInfo {
|
|
|
|
|
id: virtualDesktopInfo
|
|
|
|
|
}
|
2019-10-11 09:49:18 +00:00
|
|
|
|
2020-07-16 14:22:57 +00:00
|
|
|
TaskManager.ActivityInfo {
|
|
|
|
|
id: activityInfo
|
2019-10-11 09:49:18 +00:00
|
|
|
}
|
2021-10-31 04:11:10 +00:00
|
|
|
|
|
|
|
|
Window.onWindowChanged: {
|
|
|
|
|
if (!Window.window)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Window.window.offset = Qt.binding(() => {
|
|
|
|
|
return plasmoid.formFactor === PlasmaCore.Types.Vertical ? MobileShell.TopPanelControls.panelHeight : 0
|
|
|
|
|
});
|
|
|
|
|
}
|
2019-10-11 09:49:18 +00:00
|
|
|
|
2021-12-25 05:11:28 +00:00
|
|
|
// navigation panel actions
|
|
|
|
|
MobileShell.NavigationPanelAction {
|
|
|
|
|
id: taskSwitcherAction
|
|
|
|
|
|
|
|
|
|
enabled: hasTasks || taskSwitcher.visible
|
|
|
|
|
iconSource: "mobile-task-switcher"
|
|
|
|
|
iconSizeFactor: 0.75
|
|
|
|
|
|
|
|
|
|
onTriggered: {
|
|
|
|
|
plasmoid.nativeInterface.showDesktop = false;
|
|
|
|
|
|
|
|
|
|
if (!taskSwitcher.visible) {
|
|
|
|
|
taskSwitcher.show(true);
|
|
|
|
|
} else {
|
|
|
|
|
// when task switcher is open
|
2021-12-27 06:32:24 +00:00
|
|
|
if (taskSwitcher.taskSwitcherState.wasInActiveTask) {
|
2021-12-25 05:11:28 +00:00
|
|
|
// restore active window
|
2021-12-27 06:32:24 +00:00
|
|
|
taskSwitcher.activateWindow(taskSwitcher.taskSwitcherState.currentTaskIndex);
|
2021-12-25 05:11:28 +00:00
|
|
|
} else {
|
|
|
|
|
taskSwitcher.hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MobileShell.NavigationPanelAction {
|
|
|
|
|
id: homeAction
|
|
|
|
|
|
|
|
|
|
enabled: true
|
|
|
|
|
iconSource: "start-here-kde"
|
|
|
|
|
iconSizeFactor: 1
|
|
|
|
|
onTriggered: {
|
|
|
|
|
MobileShell.HomeScreenControls.openHomeScreen();
|
|
|
|
|
plasmoid.nativeInterface.allMinimizedChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MobileShell.NavigationPanelAction {
|
|
|
|
|
id: closeAppAction
|
|
|
|
|
|
|
|
|
|
enabled: MobileShell.KWinVirtualKeyboard.visible || taskSwitcher.visible || plasmoid.nativeInterface.hasCloseableActiveWindow
|
|
|
|
|
// mobile-close-app (from plasma-frameworks) seems to have less margins than icons from breeze-icons
|
|
|
|
|
iconSizeFactor: MobileShell.KWinVirtualKeyboard.visible ? 1 : 0.75
|
|
|
|
|
iconSource: MobileShell.KWinVirtualKeyboard.visible ? "go-down-symbolic" : "mobile-close-app"
|
|
|
|
|
|
|
|
|
|
onTriggered: {
|
|
|
|
|
if (MobileShell.KWinVirtualKeyboard.active) {
|
|
|
|
|
// close keyboard if it is open
|
|
|
|
|
MobileShell.KWinVirtualKeyboard.active = false;
|
|
|
|
|
} else if (taskSwitcher.visible) {
|
|
|
|
|
|
|
|
|
|
// if task switcher is open, close the current window shown
|
2022-02-12 14:36:34 +00:00
|
|
|
taskSwitcher.tasksModel.requestClose(taskSwitcher.tasksModel.index(taskSwitcher.currentTaskIndex, 0));
|
2021-12-25 05:11:28 +00:00
|
|
|
|
|
|
|
|
} else if (plasmoid.nativeInterface.hasCloseableActiveWindow) {
|
|
|
|
|
|
|
|
|
|
// if task switcher is closed, but there is an active window
|
2022-02-12 14:36:34 +00:00
|
|
|
var index = taskSwitcher.tasksModel.activeTask;
|
2021-12-25 05:11:28 +00:00
|
|
|
if (index) {
|
2022-02-12 14:36:34 +00:00
|
|
|
taskSwitcher.tasksModel.requestClose(index);
|
2021-12-25 05:11:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-31 04:11:10 +00:00
|
|
|
// bottom navigation panel
|
2021-12-25 00:18:38 +00:00
|
|
|
MobileShell.NavigationPanel {
|
2021-10-31 04:11:10 +00:00
|
|
|
id: panel
|
|
|
|
|
anchors.fill: parent
|
2021-12-25 03:31:33 +00:00
|
|
|
taskSwitcher: root.taskSwitcher
|
|
|
|
|
|
|
|
|
|
backgroundColor: {
|
|
|
|
|
if (taskSwitcher.visible) {
|
|
|
|
|
return Qt.rgba(0, 0, 0, 0.1);
|
|
|
|
|
} else {
|
|
|
|
|
return root.showingApp ? root.backgroundColor : "transparent";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foregroundColorGroup: (!taskSwitcher.visible && root.showingApp) ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
|
2021-10-31 04:11:10 +00:00
|
|
|
|
2021-12-25 03:31:33 +00:00
|
|
|
// do not enable drag gesture when task switcher is already open
|
|
|
|
|
// also don't disable drag gesture mid-drag
|
2021-12-27 06:32:24 +00:00
|
|
|
dragGestureEnabled: !taskSwitcher.visible || taskSwitcher.taskSwitcherState.currentlyBeingOpened
|
2021-10-31 04:11:10 +00:00
|
|
|
|
2021-12-25 05:11:28 +00:00
|
|
|
leftAction: taskSwitcherAction
|
|
|
|
|
middleAction: homeAction
|
|
|
|
|
rightAction: closeAppAction
|
2015-06-11 22:35:46 +00:00
|
|
|
}
|
2021-10-31 04:11:10 +00:00
|
|
|
|
|
|
|
|
states: [
|
|
|
|
|
State {
|
|
|
|
|
name: "landscape"
|
|
|
|
|
when: Screen.width > Screen.height
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: plasmoid.nativeInterface
|
|
|
|
|
location: PlasmaCore.Types.RightEdge
|
|
|
|
|
}
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: plasmoid
|
|
|
|
|
width: PlasmaCore.Units.gridUnit
|
|
|
|
|
height: PlasmaCore.Units.gridUnit
|
|
|
|
|
}
|
|
|
|
|
}, State {
|
|
|
|
|
name: "portrait"
|
|
|
|
|
when: Screen.width <= Screen.height
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: plasmoid
|
|
|
|
|
height: PlasmaCore.Units.gridUnit
|
|
|
|
|
}
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: plasmoid.nativeInterface
|
|
|
|
|
location: PlasmaCore.Types.BottomEdge
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
2015-06-12 22:18:24 +00:00
|
|
|
}
|