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

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

123 lines
4.1 KiB
QML
Raw Normal View History

2023-03-06 06:38:43 +00:00
// SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick 2.4
import QtQuick.Layouts 1.1
import QtQuick.Window 2.15
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.workspace.keyboardlayout 1.0 as Keyboards
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
2023-03-06 06:38:43 +00:00
import org.kde.taskmanager 0.1 as TaskManager
MobileShell.NavigationPanel {
id: root
required property bool opaqueBar
// background is:
// - opaque if an app is shown or vkbd is shown
// - translucent if the task switcher is open
// - transparent if on the homescreen
2023-03-06 06:38:43 +00:00
backgroundColor: (Keyboards.KWinVirtualKeyboard.visible || opaqueBar) ? PlasmaCore.ColorScope.backgroundColor : "transparent";
foregroundColorGroup: opaqueBar ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
shadow: !opaqueBar
// do not enable drag gesture when task switcher is already open
// also don't disable drag gesture mid-drag
2023-03-06 06:38:43 +00:00
dragGestureEnabled: false // !root.taskSwitcher.visible || root.taskSwitcher.taskSwitcherState.currentlyBeingOpened
2023-03-06 06:38:43 +00:00
TaskManager.VirtualDesktopInfo {
id: virtualDesktopInfo
}
TaskManager.ActivityInfo {
id: activityInfo
}
TaskManager.TasksModel {
id: tasksModel
filterByVirtualDesktop: true
filterByActivity: true
filterNotMaximized: true
filterByScreen: true
filterHidden: true
virtualDesktop: virtualDesktopInfo.currentDesktop
activity: activityInfo.currentActivity
groupMode: TaskManager.TasksModel.GroupDisabled
}
// ~~~~
// navigation panel actions
// toggle task switcher button
leftAction: MobileShell.NavigationPanelAction {
id: taskSwitcherAction
2023-03-06 06:38:43 +00:00
enabled: true
iconSource: "mobile-task-switcher"
iconSizeFactor: 0.75
onTriggered: {
2023-03-06 06:38:43 +00:00
plasmoid.nativeInterface.triggerTaskSwitcher();
}
}
// home button
middleAction: MobileShell.NavigationPanelAction {
id: homeAction
enabled: true
iconSource: "start-here-kde"
iconSizeFactor: 1
onTriggered: {
MobileShellState.HomeScreenControls.openHomeScreen();
MobileShell.WindowUtil.allWindowsMinimizedChanged();
}
}
// close app/keyboard button
rightAction: MobileShell.NavigationPanelAction {
id: closeAppAction
2023-03-06 06:38:43 +00:00
enabled: Keyboards.KWinVirtualKeyboard.visible || MobileShell.WindowUtil.hasCloseableActiveWindow
iconSource: Keyboards.KWinVirtualKeyboard.visible ? "go-down-symbolic" : "mobile-close-app"
// mobile-close-app (from plasma-frameworks) seems to have less margins than icons from breeze-icons
iconSizeFactor: Keyboards.KWinVirtualKeyboard.visible ? 1 : 0.75
onTriggered: {
if (Keyboards.KWinVirtualKeyboard.active) {
// close keyboard if it is open
Keyboards.KWinVirtualKeyboard.active = false;
} else if (MobileShell.WindowUtil.hasCloseableActiveWindow) {
// if task switcher is closed, but there is an active window
2023-03-06 06:38:43 +00:00
if (tasksModel.activeTask !== 0) {
tasksModel.requestClose(tasksModel.activeTask);
}
MobileShellState.Shell.closeAppLaunchAnimation();
}
}
}
rightCornerAction: MobileShell.NavigationPanelAction {
id: keyboardToggleAction
visible: Keyboards.KWinVirtualKeyboard.available && !Keyboards.KWinVirtualKeyboard.activeClientSupportsTextInput
enabled: true
iconSource: "input-keyboard-virtual-symbolic"
iconSizeFactor: 0.75
onTriggered: {
if (Keyboards.KWinVirtualKeyboard.visible) {
Keyboards.KWinVirtualKeyboard.active = false;
} else {
Keyboards.KWinVirtualKeyboard.forceActivate();
}
}
}
}