taskpanel: Fix rotation position

This commit is contained in:
Devin Lin 2023-10-16 22:12:44 -07:00
parent 97242ae379
commit a79290d010
2 changed files with 27 additions and 16 deletions

View file

@ -19,14 +19,21 @@ import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
ContainmentItem { ContainmentItem {
id: root id: root
// filled in by the shell (Panel.qml) with the plasma-workspace PanelView
property var panel: null
onPanelChanged: {
setWindowProperties()
}
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
// toggle visibility of navigation bar (show, or use gestures only) // toggle visibility of navigation bar (show, or use gestures only)
Binding { Binding {
target: plasmoid.Window.window // assumed to be plasma-workspace "PanelView" component target: root.panel // assumed to be plasma-workspace "PanelView" component
property: "visibilityMode" property: "visibilityMode"
// 0 - VisibilityMode.NormalPanel // 0 - VisibilityMode.NormalPanel
// 2 - VisibilityMode.LetWindowsCover HACK: TODO one day we make delete the panel component instead of making it invisible in gesture-only mode // 2 - VisibilityMode.LetWindowsCover HACK: TODO one day we delete the panel component instead of making it invisible in gesture-only mode
value: ShellSettings.Settings.navigationPanelEnabled ? 0 : 2 value: ShellSettings.Settings.navigationPanelEnabled ? 0 : 2
} }
@ -47,8 +54,8 @@ ContainmentItem {
onIntendedWindowLengthChanged: maximizeTimer.restart() // ensure it always takes up the full length of the screen onIntendedWindowLengthChanged: maximizeTimer.restart() // ensure it always takes up the full length of the screen
onIntendedWindowLocationChanged: locationChangeTimer.restart() onIntendedWindowLocationChanged: locationChangeTimer.restart()
onIntendedWindowOffsetChanged: { onIntendedWindowOffsetChanged: {
if (plasmoid && plasmoid.Window.window) { if (root.panel) {
plasmoid.Window.window.offset = intendedWindowOffset; root.panel.offset = intendedWindowOffset;
} }
} }
@ -60,8 +67,8 @@ ContainmentItem {
interval: 100 interval: 100
onTriggered: { onTriggered: {
// maximize first, then we can apply offsets (otherwise they are overridden) // maximize first, then we can apply offsets (otherwise they are overridden)
plasmoid.Window.window.maximize() root.panel.maximize()
plasmoid.Window.window.offset = intendedWindowOffset; root.panel.offset = intendedWindowOffset;
} }
} }
@ -70,33 +77,32 @@ ContainmentItem {
id: locationChangeTimer id: locationChangeTimer
running: false running: false
interval: 100 interval: 100
onTriggered: plasmoid.Window.window.location = intendedWindowLocation onTriggered: root.panel.location = intendedWindowLocation
} }
function setWindowProperties() { function setWindowProperties() {
// plasmoid.Window.window is assumed to be plasma-workspace "PanelView" component if (root.panel) {
if (plasmoid && plasmoid.Window.window) { root.panel.maximize(); // maximize first, then we can apply offsets (otherwise they are overridden)
plasmoid.Window.window.maximize(); // maximize first, then we can apply offsets (otherwise they are overridden) root.panel.offset = intendedWindowOffset;
plasmoid.Window.window.offset = intendedWindowOffset; root.panel.thickness = navigationPanelHeight;
plasmoid.Window.window.thickness = navigationPanelHeight; root.panel.location = intendedWindowLocation;
plasmoid.Window.window.location = intendedWindowLocation;
} }
} }
Connections { Connections {
target: plasmoid.Window.window target: root.panel
// HACK: There seems to be some component that overrides our initial bindings for the panel, // HACK: There seems to be some component that overrides our initial bindings for the panel,
// which is particularly problematic on first start (since the panel is misplaced) // which is particularly problematic on first start (since the panel is misplaced)
// - We set an event to override any attempts to override our bindings. // - We set an event to override any attempts to override our bindings.
function onLocationChanged() { function onLocationChanged() {
if (plasmoid.Window.window.location !== root.intendedWindowLocation) { if (root.panel.location !== root.intendedWindowLocation) {
root.setWindowProperties(); root.setWindowProperties();
} }
} }
function onThicknessChanged() { function onThicknessChanged() {
if (plasmoid.Window.window.thickness !== root.intendedWindowThickness) { if (root.panel.thickness !== root.intendedWindowThickness) {
root.setWindowProperties(); root.setWindowProperties();
} }
} }

View file

@ -21,6 +21,11 @@ Rectangle {
containment.parent = root; containment.parent = root;
containment.visible = true; containment.visible = true;
containment.anchors.fill = root; containment.anchors.fill = root;
// HACK: add PanelView into the containment so that it can be used
if (containment.panel !== undefined) {
containment.panel = panel;
}
} }
Binding { Binding {