taskpanel: Try to ensure dimension bindings are always set

This commit is contained in:
Devin Lin 2022-04-07 22:08:36 -04:00
parent b3884be926
commit 635f86e02f
2 changed files with 43 additions and 27 deletions

View file

@ -38,6 +38,7 @@ PlasmaCore.ColorScope {
// 3 - VisibilityMode.WindowsGoBelow
value: MobileShell.MobileShellSettings.navigationPanelEnabled ? 0 : 3
}
Binding {
target: plasmoid.Window.window // assumed to be plasma-workspace "PanelView" component
property: "thickness"
@ -47,6 +48,46 @@ PlasmaCore.ColorScope {
value: MobileShell.MobileShellSettings.navigationPanelEnabled ? PlasmaCore.Units.gridUnit * 2 : 8
}
Binding {
target: plasmoid.Window.window
property: "location"
value: {
if (MobileShell.Shell.orientation === MobileShell.Shell.Portrait) {
return PlasmaCore.Types.BottomEdge;
} else if (MobileShell.Shell.orientation === MobileShell.Shell.Landscape) {
return MobileShell.MobileShellSettings.navigationPanelEnabled ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge
}
}
}
// HACK: really really really make sure the dimensions are set properly
function setBindings() {
plasmoid.Window.window.offset = Qt.binding(() => {
return (MobileShell.Shell.orientation === MobileShell.Shell.Landscape) ? MobileShell.TopPanelControls.panelHeight : 0;
});
plasmoid.Window.window.thickness = Qt.binding(() => {
return MobileShell.MobileShellSettings.navigationPanelEnabled ? PlasmaCore.Units.gridUnit * 2 : 8
});
plasmoid.Window.window.length = Qt.binding(() => {
return MobileShell.Shell.orientation === MobileShell.Shell.Portrait ? Screen.width : Screen.height;
});
plasmoid.Window.window.maximumLength = Qt.binding(() => {
return MobileShell.Shell.orientation === MobileShell.Shell.Portrait ? Screen.width : Screen.height;
});
plasmoid.Window.window.minimumLength = Qt.binding(() => {
return MobileShell.Shell.orientation === MobileShell.Shell.Portrait ? Screen.width : Screen.height;
});
}
Connections {
target: plasmoid.Window.window
function onThicknessChanged() {
root.setBindings();
}
}
Component.onCompleted: setBindings();
//BEGIN API implementation
Binding {
@ -75,13 +116,9 @@ PlasmaCore.ColorScope {
//END API implementation
Window.onWindowChanged: {
if (!Window.window)
if (!Window.window) {
return;
// set offset from top panel
Window.window.offset = Qt.binding(() => {
return (root.state === "landscape") ? MobileShell.TopPanelControls.panelHeight : 0
});
}
}
// bottom navigation panel component
@ -106,24 +143,4 @@ PlasmaCore.ColorScope {
anchors.fill: parent
sourceComponent: MobileShell.MobileShellSettings.navigationPanelEnabled ? navigationPanel : navigationGesture
}
// landscape vs. portrait orientation of panel
states: [
State {
name: "landscape"
when: MobileShell.Shell.orientation === MobileShell.Shell.Landscape
PropertyChanges {
target: plasmoid.nativeInterface
// only show on right edge if gestures are not enabled
location: MobileShell.MobileShellSettings.navigationPanelEnabled ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge
}
}, State {
name: "portrait"
when: MobileShell.Shell.orientation === MobileShell.Shell.Portrait
PropertyChanges {
target: plasmoid.nativeInterface
location: PlasmaCore.Types.BottomEdge
}
}
]
}

View file

@ -29,7 +29,6 @@ class TaskPanel : public Plasma::Containment
{
Q_OBJECT
Q_PROPERTY(QWindow *panel READ panel WRITE setPanel NOTIFY panelChanged)
Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged)
public:
TaskPanel(QObject *parent, const QVariantList &args);