From 71948fd9f3ad5295292991d4f99a5304d3ab9b21 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 30 Jul 2019 13:39:07 +0200 Subject: [PATCH] first prototype of icons in desktop --- .../homescreen2/applicationlistmodel.cpp | 5 +- .../package/contents/ui/launcher/Delegate.qml | 19 +- .../contents/ui/launcher/LauncherGrid.qml | 12 +- .../homescreen2/package/contents/ui/main.qml | 179 ++++++++++-------- 4 files changed, 130 insertions(+), 85 deletions(-) diff --git a/containments/homescreen2/applicationlistmodel.cpp b/containments/homescreen2/applicationlistmodel.cpp index 8fb71751..80e61b7b 100644 --- a/containments/homescreen2/applicationlistmodel.cpp +++ b/containments/homescreen2/applicationlistmodel.cpp @@ -182,6 +182,8 @@ QVariant ApplicationListModel::data(const QModelIndex &index, int role) const return m_applicationList.at(index.row()).entryPath; case ApplicationOriginalRowRole: return index.row(); + case ApplicationOnDesktopRole: + return m_applicationList.at(index.row()).desktop; default: return QVariant(); @@ -221,7 +223,7 @@ void ApplicationListModel::setFavoriteItem(int row, bool favorite) } data.favorite = favorite; -qWarning()< height ? "ItemGeometries" : "ItemGeometriesVertical" - containment: plasmoid - editModeCondition: plasmoid.immutable - ? ContainmentLayoutManager.AppletsLayout.Manual - : ContainmentLayoutManager.AppletsLayout.AfterPressAndHold - - // Sets the containment in edit mode when we go in edit mode as well - onEditModeChanged: plasmoid.editMode = editMode - - minimumItemWidth: units.gridUnit * 3 - minimumItemHeight: minimumItemWidth - - defaultItemWidth: units.gridUnit * 6 - defaultItemHeight: defaultItemWidth - - cellWidth: units.iconSizes.small - cellHeight: cellWidth - - acceptsAppletCallback: function(applet, x, y) { - print("Applet: "+applet+" "+x+" "+y) - return true; + onDragEnter: { + event.accept(event.proposedAction); + } + onDragMove: { + appletsLayout.showPlaceHolderAt( + Qt.rect(event.x - appletsLayout.defaultItemWidth / 2, + event.y - appletsLayout.defaultItemHeight / 2, + appletsLayout.defaultItemWidth, + appletsLayout.defaultItemHeight) + ); } - appletContainerComponent: ContainmentLayoutManager.BasicAppletContainer { - id: appletContainer - configOverlayComponent: ConfigOverlay {} - onEditModeChanged: { - if (editMode) { - plasmoid.editMode = true; + onDragLeave: { + appletsLayout.hidePlaceHolder(); + } + + preventStealing: true + + onDrop: { + plasmoid.processMimeData(event.mimeData, + event.x - appletsLayout.placeHolder.width / 2, event.y - appletsLayout.placeHolder.height / 2); + event.accept(event.proposedAction); + appletsLayout.hidePlaceHolder(); + } + + PlasmaCore.Svg { + id: arrowsSvg + imagePath: "widgets/arrows" + colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + } + PlasmaCore.SvgItem { + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + bottomMargin: favoriteStrip.height + } + z: 2 + svg: arrowsSvg + elementId: "up-arrow" + width: units.iconSizes.large + height: width + } + + ContainmentLayoutManager.AppletsLayout { + id: appletsLayout + + anchors.fill: parent + + configKey: width > height ? "ItemGeometriesHorizontal" : "ItemGeometriesVertical" + containment: plasmoid + editModeCondition: plasmoid.immutable + ? ContainmentLayoutManager.AppletsLayout.Manual + : ContainmentLayoutManager.AppletsLayout.AfterPressAndHold + + // Sets the containment in edit mode when we go in edit mode as well + onEditModeChanged: plasmoid.editMode = editMode + + minimumItemWidth: units.gridUnit * 3 + minimumItemHeight: minimumItemWidth + + defaultItemWidth: units.gridUnit * 6 + defaultItemHeight: defaultItemWidth + + cellWidth: units.iconSizes.small + cellHeight: cellWidth + + acceptsAppletCallback: function(applet, x, y) { + print("Applet: "+applet+" "+x+" "+y) + return true; + } + + appletContainerComponent: ContainmentLayoutManager.BasicAppletContainer { + id: appletContainer + configOverlayComponent: ConfigOverlay {} + onEditModeChanged: { + if (editMode) { + plasmoid.editMode = true; + } } } - } - placeHolder: ContainmentLayoutManager.PlaceHolder {} - - Launcher.LauncherGrid { - id: launcher - favoriteStrip: favoriteStrip - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } + placeHolder: ContainmentLayoutManager.PlaceHolder {} } } + Launcher.LauncherGrid { + id: launcher + Layout.fillWidth: true + + favoriteStrip: favoriteStrip + appletsLayout: appletsLayout + } } } Launcher.FavoriteStrip { id: favoriteStrip + anchors.horizontalCenter: parent.horizontalCenter + width: Math.min(root.width, units.gridUnit * 30) launcherGrid: launcher - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } + y: Math.max(0, root.height - height - mainFlickable.contentY) } }