homescreens/halcyon: Fix some layouting issues and simplify

This commit is contained in:
Devin Lin 2023-04-10 22:16:43 -07:00
parent 6fb0eb6170
commit 2af706d197
5 changed files with 21 additions and 29 deletions

View file

@ -22,9 +22,6 @@ Item {
id: delegate id: delegate
property int visualIndex: 0 property int visualIndex: 0
property real leftPadding
property real rightPadding
property real dragFolderAnimationProgress: 0 property real dragFolderAnimationProgress: 0
property list<Kirigami.Action> menuActions property list<Kirigami.Action> menuActions
@ -119,8 +116,6 @@ Item {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: delegate.leftPadding
anchors.rightMargin: delegate.rightPadding
property bool inDrag: false property bool inDrag: false
@ -135,7 +130,7 @@ Item {
// grow/shrink animation // grow/shrink animation
property real zoomScale: 1 property real zoomScale: 1
transform: Scale { transform: Scale {
origin.x: mouseArea.width / 2; origin.x: mouseArea.width / 2;
origin.y: mouseArea.height / 2; origin.y: mouseArea.height / 2;
xScale: mouseArea.zoomScale xScale: mouseArea.zoomScale
@ -180,12 +175,12 @@ Item {
// launch app handled by press animation // launch app handled by press animation
onClicked: mouse => { onClicked: mouse => {
if (mouse.button === Qt.RightButton) { if (mouse.button === Qt.RightButton) {
openContextMenu(); openContextMenu();
} else { } else {
launchAppRequested = true; launchAppRequested = true;
} }
} }
HoverHandler { HoverHandler {
id: hoverHandler id: hoverHandler

View file

@ -21,8 +21,6 @@ MobileShell.GridView {
required property var searchWidget required property var searchWidget
// don't set anchors.margins since we want everywhere to be draggable // don't set anchors.margins since we want everywhere to be draggable
required property real leftMargin
required property real rightMargin
required property bool twoColumn required property bool twoColumn
signal openConfigureRequested() signal openConfigureRequested()
@ -64,8 +62,8 @@ MobileShell.GridView {
header: MobileShell.BaseItem { header: MobileShell.BaseItem {
topPadding: Math.round(root.height * 0.2) topPadding: Math.round(root.height * 0.2)
bottomPadding: PlasmaCore.Units.largeSpacing bottomPadding: PlasmaCore.Units.largeSpacing
leftPadding: root.leftMargin // leftPadding: root.leftMargin
rightPadding: root.rightMargin // rightPadding: root.rightMargin
implicitWidth: root.width implicitWidth: root.width
background: Rectangle { 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 implicitWidth: root.cellWidth
implicitHeight: visible ? root.cellHeight : 0 implicitHeight: visible ? root.cellHeight : 0

View file

@ -22,15 +22,15 @@ Item {
required property bool interactive required property bool interactive
required property var searchWidget 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 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 cellHeight: delegateHeight
readonly property real leftMargin: Math.round(parent.width * 0.1) readonly property real leftMargin: Math.round(width * 0.1)
readonly property real rightMargin: Math.round(parent.width * 0.1) readonly property real rightMargin: Math.round(width * 0.1)
readonly property real delegateHeight: PlasmaCore.Units.gridUnit * 3 readonly property real delegateHeight: Math.round(PlasmaCore.Units.gridUnit * 3.25)
property bool folderShown: false property bool folderShown: false
@ -91,8 +91,8 @@ Item {
visible: opacity !== 0 visible: opacity !== 0
rightEdgeCallback: () => { rightEdgeCallback: () => {
pageForwardRequested(); pageForwardRequested();
} }
} }
FolderGrid { FolderGrid {

View file

@ -252,5 +252,6 @@ Plasma::Applet *PinnedModel::applet()
void PinnedModel::setApplet(Plasma::Applet *applet) void PinnedModel::setApplet(Plasma::Applet *applet)
{ {
m_applet = applet; m_applet = applet;
Q_EMIT appletChanged();
load(); load();
} }

View file

@ -25,7 +25,7 @@
class PinnedModel : public QAbstractListModel class PinnedModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(Plasma::Applet *applet READ applet WRITE setApplet CONSTANT) Q_PROPERTY(Plasma::Applet *applet READ applet WRITE setApplet NOTIFY appletChanged)
public: public:
enum Roles { IsFolderRole = Qt::UserRole + 1, ApplicationRole, FolderRole }; enum Roles { IsFolderRole = Qt::UserRole + 1, ApplicationRole, FolderRole };
@ -54,6 +54,9 @@ public:
public Q_SLOTS: public Q_SLOTS:
void addAppFromFolder(const QString &storageId); void addAppFromFolder(const QString &storageId);
Q_SIGNALS:
void appletChanged();
private: private:
void load(); void load();