diff --git a/containments/taskpanel/package/contents/ui/Button.qml b/containments/taskpanel/package/contents/ui/Button.qml index db16efc0..e5e58b6b 100644 --- a/containments/taskpanel/package/contents/ui/Button.qml +++ b/containments/taskpanel/package/contents/ui/Button.qml @@ -68,7 +68,7 @@ Item { id: icon anchors { fill: parent - margins: Math.round((parent.height - parent.height * iconSizeFactor * 0.6) / 2) + margins: button.width < button.height ? 0 : Math.round((parent.height - parent.height * iconSizeFactor * 0.6) / 2) } colorGroup: PlasmaCore.ColorScope.colorGroup //enabled: button.enabled && button.clickable diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml index 926d4d18..281de739 100644 --- a/containments/taskpanel/package/contents/ui/main.qml +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -172,6 +172,7 @@ PlasmaCore.ColorScope { anchors.fill: parent visible: plasmoid.configuration.PanelButtonsVisible + property real buttonLength: 0 Rectangle { anchors.fill: parent @@ -188,13 +189,7 @@ PlasmaCore.ColorScope { } Button { - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - leftMargin: parent.width * 0.1 - } - height: parent.height - width: parent.width*0.8/3 + id: tasksButton mouseArea: mainMouseArea enabled: root.hasTasks onClicked: { @@ -211,12 +206,7 @@ PlasmaCore.ColorScope { Button { id: showDesktopButton - anchors { - verticalCenter: parent.verticalCenter - horizontalCenter: parent.horizontalCenter - } - height: parent.height - width: parent.width*0.8/3 + anchors.centerIn: parent mouseArea: mainMouseArea onClicked: { if (!enabled) { @@ -232,13 +222,7 @@ PlasmaCore.ColorScope { } Button { - anchors { - verticalCenter: parent.verticalCenter - right: parent.right - rightMargin: parent.width * 0.1 - } - height: parent.height - width: parent.width*0.8/3 + id: closeTaskButton mouseArea: mainMouseArea enabled: TaskPanel.KWinVirtualKeyboard.visible || (plasmoid.nativeInterface.hasCloseableActiveWindow && !taskSwitcher.visible) onClicked: { @@ -264,5 +248,116 @@ PlasmaCore.ColorScope { colorGroup: root.showingApp ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup } } + + function resetOffsets() { + if (!Window.window) + return; + + if (state === "landscape") { + // FIXME: find a more precise way to determine the top panel height + Window.window.offset = PlasmaCore.Units.gridUnit + PlasmaCore.Units.smallSpacing + } else { + Window.window.offset = 0 + } + } + Window.onWindowChanged: resetOffsets() + onStateChanged: resetOffsets() + + 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 + } + PropertyChanges { + target: icons + buttonLength: icons.height * 0.8 / 3 + } + AnchorChanges { + target: tasksButton + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.top + } + } + PropertyChanges { + target: tasksButton + width: parent.width + height: icons.buttonLength + anchors.topMargin: parent.height * 0.1 + } + PropertyChanges { + target: showDesktopButton + width: parent.width + height: icons.buttonLength + } + AnchorChanges { + target: closeTaskButton + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + } + } + PropertyChanges { + target: closeTaskButton + height: icons.buttonLength + width: icons.width + anchors.bottomMargin: parent.height * 0.1 + } + }, State { + name: "portrait" + when: Screen.width <= Screen.height + PropertyChanges { + target: plasmoid + height: PlasmaCore.Units.gridUnit + } + PropertyChanges { + target: plasmoid.nativeInterface + location: PlasmaCore.Types.BottomEdge + } + PropertyChanges { + target: icons + buttonLength: icons.width * 0.8 / 3 + } + AnchorChanges { + target: tasksButton + anchors { + verticalCenter: parent.verticalCenter + left: parent.left + } + } + PropertyChanges { + target: tasksButton + height: parent.height + width: icons.buttonLength + anchors.leftMargin: parent.width * 0.1 + } + PropertyChanges { + target: showDesktopButton + height: parent.height + width: icons.buttonLength + } + AnchorChanges { + target: closeTaskButton + anchors { + verticalCenter: parent.verticalCenter + right: parent.right + } + } + PropertyChanges { + target: closeTaskButton + height: parent.height + width: icons.buttonLength + anchors.rightMargin: parent.width * 0.1 + } + } + ] } } diff --git a/containments/taskpanel/taskpanel.cpp b/containments/taskpanel/taskpanel.cpp index 15a7aae5..804c5eb7 100644 --- a/containments/taskpanel/taskpanel.cpp +++ b/containments/taskpanel/taskpanel.cpp @@ -56,6 +56,12 @@ TaskPanel::TaskPanel(QObject *parent, const QVariantList &args) [](QQmlEngine *, QJSEngine *) -> QObject * { return new KwinVirtualKeyboardInterface; }); + + connect(this, &Plasma::Containment::locationChanged, this, &TaskPanel::locationChanged); + connect(this, &Plasma::Containment::locationChanged, this, [this] { + auto l = location(); + setFormFactor(l == Plasma::Types::LeftEdge || l == Plasma::Types::RightEdge ? Plasma::Types::Vertical : Plasma::Types::Horizontal); + }); } TaskPanel::~TaskPanel() = default; diff --git a/containments/taskpanel/taskpanel.h b/containments/taskpanel/taskpanel.h index 1ea8e587..408f2999 100644 --- a/containments/taskpanel/taskpanel.h +++ b/containments/taskpanel/taskpanel.h @@ -30,6 +30,7 @@ class TaskPanel : public Plasma::Containment Q_PROPERTY(bool allMinimized READ allMinimized NOTIFY allMinimizedChanged) Q_PROPERTY(bool hasCloseableActiveWindow READ hasCloseableActiveWindow NOTIFY hasCloseableActiveWindowChanged) 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); @@ -60,6 +61,7 @@ Q_SIGNALS: void hasCloseableActiveWindowChanged(); void panelChanged(); void allMinimizedChanged(); + void locationChanged(); private: void initWayland(); diff --git a/shell/contents/layout.js b/shell/contents/layout.js index 39283afa..da81e74d 100644 --- a/shell/contents/layout.js +++ b/shell/contents/layout.js @@ -9,10 +9,4 @@ panel.addWidget("org.kde.plasma.notifications"); panel.addWidget("org.kde.plasma.mediacontroller"); panel.height = 1 * gridUnit; -var bottomPanel = new Panel("org.kde.phone.taskpanel"); -bottomPanel.location = "bottom"; - -if (screenGeometry(bottomPanel.screen).height > screenGeometry(bottomPanel.screen).width) - bottomPanel.height = 2 * gridUnit; -else - bottomPanel.height = 1 * gridUnit; +var bottomPanel = new Panel("org.kde.phone.taskpanel")