From 2af706d197ab2a5d9b8b2b1ca0a6fdc58f3bf007 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Mon, 10 Apr 2023 22:16:43 -0700 Subject: [PATCH] homescreens/halcyon: Fix some layouting issues and simplify --- .../contents/ui/FavoritesAppDelegate.qml | 19 +++++++------------ .../package/contents/ui/FavoritesGrid.qml | 11 ++--------- .../package/contents/ui/FavoritesView.qml | 14 +++++++------- .../halcyon/plugin/pinnedmodel.cpp | 1 + .../homescreens/halcyon/plugin/pinnedmodel.h | 5 ++++- 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml b/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml index 0ebfc1fe..db4ad70f 100644 --- a/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml +++ b/containments/homescreens/halcyon/package/contents/ui/FavoritesAppDelegate.qml @@ -22,9 +22,6 @@ Item { id: delegate property int visualIndex: 0 - property real leftPadding - property real rightPadding - property real dragFolderAnimationProgress: 0 property list menuActions @@ -119,8 +116,6 @@ Item { id: mouseArea anchors.fill: parent - anchors.leftMargin: delegate.leftPadding - anchors.rightMargin: delegate.rightPadding property bool inDrag: false @@ -135,7 +130,7 @@ Item { // grow/shrink animation property real zoomScale: 1 - transform: Scale { + transform: Scale { origin.x: mouseArea.width / 2; origin.y: mouseArea.height / 2; xScale: mouseArea.zoomScale @@ -180,12 +175,12 @@ Item { // launch app handled by press animation onClicked: mouse => { - if (mouse.button === Qt.RightButton) { - openContextMenu(); - } else { - launchAppRequested = true; - } - } + if (mouse.button === Qt.RightButton) { + openContextMenu(); + } else { + launchAppRequested = true; + } + } HoverHandler { id: hoverHandler diff --git a/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml b/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml index a313aa1f..38f819d4 100644 --- a/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml +++ b/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml @@ -21,8 +21,6 @@ MobileShell.GridView { required property var searchWidget // don't set anchors.margins since we want everywhere to be draggable - required property real leftMargin - required property real rightMargin required property bool twoColumn signal openConfigureRequested() @@ -64,8 +62,8 @@ MobileShell.GridView { header: MobileShell.BaseItem { topPadding: Math.round(root.height * 0.2) bottomPadding: PlasmaCore.Units.largeSpacing - leftPadding: root.leftMargin - rightPadding: root.rightMargin + // leftPadding: root.leftMargin + // rightPadding: root.rightMargin implicitWidth: root.width background: Rectangle { @@ -228,11 +226,6 @@ MobileShell.GridView { } ] - readonly property bool isLeftColumn: !root.twoColumn || ((visualIndex % 2) === 0) - readonly property bool isRightColumn: !root.twoColumn || ((visualIndex % 2) !== 0) - leftPadding: isLeftColumn ? root.leftMargin : 0 - rightPadding: isRightColumn ? root.rightMargin : 0 - implicitWidth: root.cellWidth implicitHeight: visible ? root.cellHeight : 0 diff --git a/containments/homescreens/halcyon/package/contents/ui/FavoritesView.qml b/containments/homescreens/halcyon/package/contents/ui/FavoritesView.qml index adc40ac0..07987cd4 100644 --- a/containments/homescreens/halcyon/package/contents/ui/FavoritesView.qml +++ b/containments/homescreens/halcyon/package/contents/ui/FavoritesView.qml @@ -22,15 +22,15 @@ Item { required property bool interactive required property var searchWidget - readonly property real twoColumnThreshold: PlasmaCore.Units.gridUnit * 10 + readonly property real twoColumnThreshold: PlasmaCore.Units.gridUnit * 16 readonly property bool twoColumn: root.width / 2 > twoColumnThreshold - readonly property real cellWidth: twoColumn ? root.width / 2 : root.width + readonly property real cellWidth: twoColumn ? (root.width - leftMargin - rightMargin) / 2 : (root.width - leftMargin - rightMargin) readonly property real cellHeight: delegateHeight - readonly property real leftMargin: Math.round(parent.width * 0.1) - readonly property real rightMargin: Math.round(parent.width * 0.1) - readonly property real delegateHeight: PlasmaCore.Units.gridUnit * 3 + readonly property real leftMargin: Math.round(width * 0.1) + readonly property real rightMargin: Math.round(width * 0.1) + readonly property real delegateHeight: Math.round(PlasmaCore.Units.gridUnit * 3.25) property bool folderShown: false @@ -91,8 +91,8 @@ Item { visible: opacity !== 0 rightEdgeCallback: () => { - pageForwardRequested(); - } + pageForwardRequested(); + } } FolderGrid { diff --git a/containments/homescreens/halcyon/plugin/pinnedmodel.cpp b/containments/homescreens/halcyon/plugin/pinnedmodel.cpp index 8a71b8d5..e1d720dc 100644 --- a/containments/homescreens/halcyon/plugin/pinnedmodel.cpp +++ b/containments/homescreens/halcyon/plugin/pinnedmodel.cpp @@ -252,5 +252,6 @@ Plasma::Applet *PinnedModel::applet() void PinnedModel::setApplet(Plasma::Applet *applet) { m_applet = applet; + Q_EMIT appletChanged(); load(); } diff --git a/containments/homescreens/halcyon/plugin/pinnedmodel.h b/containments/homescreens/halcyon/plugin/pinnedmodel.h index a7339b77..d6678f33 100644 --- a/containments/homescreens/halcyon/plugin/pinnedmodel.h +++ b/containments/homescreens/halcyon/plugin/pinnedmodel.h @@ -25,7 +25,7 @@ class PinnedModel : public QAbstractListModel { Q_OBJECT - Q_PROPERTY(Plasma::Applet *applet READ applet WRITE setApplet CONSTANT) + Q_PROPERTY(Plasma::Applet *applet READ applet WRITE setApplet NOTIFY appletChanged) public: enum Roles { IsFolderRole = Qt::UserRole + 1, ApplicationRole, FolderRole }; @@ -54,6 +54,9 @@ public: public Q_SLOTS: void addAppFromFolder(const QString &storageId); +Q_SIGNALS: + void appletChanged(); + private: void load();