shift-shell/containments/taskpanel/package/contents/ui/main.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

206 lines
6.6 KiB
QML
Raw Normal View History

/*
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>
*
2021-03-01 20:03:25 +00:00
* SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.4
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
2020-02-05 19:25:52 +00:00
import QtGraphicalEffects 1.12
import org.kde.taskmanager 0.1 as TaskManager
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kquickcontrolsaddons 2.0
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
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
colorGroup: showingApp ? PlasmaCore.Theme.HeaderColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
readonly property color backgroundColor: PlasmaCore.ColorScope.backgroundColor
readonly property bool showingApp: !plasmoid.nativeInterface.allMinimized
readonly property bool hasTasks: tasksModel.count > 0
property var taskSwitcher: MobileShell.HomeScreenControls.taskSwitcher
//BEGIN API implementation
Binding {
target: MobileShell.TaskPanelControls
property: "isPortrait"
value: Screen.width <= Screen.height
}
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
}
//END API implementation
2021-10-31 04:11:10 +00:00
Connections {
target: plasmoid.nativeInterface
function onAllMinimizedChanged() {
MobileShell.HomeScreenControls.homeScreenVisible = plasmoid.nativeInterface.allMinimized
}
}
TaskManager.TasksModel {
id: tasksModel
groupMode: TaskManager.TasksModel.GroupDisabled
screenGeometry: plasmoid.screenGeometry
sortMode: TaskManager.TasksModel.SortAlpha
virtualDesktop: virtualDesktopInfo.currentDesktop
activity: activityInfo.currentActivity
}
TaskManager.VirtualDesktopInfo {
id: virtualDesktopInfo
}
TaskManager.ActivityInfo {
id: activityInfo
}
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
});
}
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
if (taskSwitcher.taskSwitcherState.wasInActiveTask) {
2021-12-25 05:11:28 +00:00
// restore active window
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
MobileShell.NavigationPanel {
2021-10-31 04:11:10 +00:00
id: panel
anchors.fill: parent
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
// do not enable drag gesture when task switcher is already open
// also don't disable drag gesture mid-drag
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
}
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
}
}
]
}