mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
first prototype of icons in desktop
This commit is contained in:
parent
2f0bc852ba
commit
71948fd9f3
4 changed files with 130 additions and 85 deletions
|
|
@ -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()<<m_applicationList[row].favorite;
|
||||
|
||||
emit dataChanged(index(row, 0), index(row, 0));
|
||||
}
|
||||
|
||||
|
|
@ -237,6 +239,7 @@ void ApplicationListModel::setDesktopItem(int row, bool desktop)
|
|||
}
|
||||
|
||||
data.desktop = desktop;
|
||||
qWarning()<<m_applicationList[row].desktop;
|
||||
emit dataChanged(index(row, 0), index(row, 0));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ ContainmentLayoutManager.ItemContainer {
|
|||
|
||||
opacity: dragging ? 0.4 : 1
|
||||
|
||||
editModeCondition: model.ApplicationOnDesktopRole ? ContainmentLayoutManager.ItemContainer.AfterPressAndHold: ContainmentLayoutManager.ItemContainer.Manual
|
||||
|
||||
onDraggingChanged: {
|
||||
if (dragging) {
|
||||
var pos = dragDelegate.parent.mapFromItem(delegate, 0, 0);
|
||||
|
|
@ -71,10 +73,17 @@ ContainmentLayoutManager.ItemContainer {
|
|||
}
|
||||
|
||||
onPressAndHold: {
|
||||
if (model.ApplicationOnDesktopRole) {
|
||||
mouse.accepted = false
|
||||
return
|
||||
}
|
||||
delegate.dragging = true;
|
||||
}
|
||||
|
||||
onReleased: delegate.dragging = false;
|
||||
onReleased: {
|
||||
delegate.dragging = false;
|
||||
|
||||
}
|
||||
|
||||
onCanceled: delegate.dragging = false;
|
||||
|
||||
|
|
@ -85,12 +94,20 @@ ContainmentLayoutManager.ItemContainer {
|
|||
|
||||
var newRow = 0;
|
||||
|
||||
// Put it in the favorites strip
|
||||
if (favoriteStrip.contains(favoriteStrip.mapFromItem(dragDelegate, dragDelegate.width/2, dragDelegate.height/2))) {
|
||||
newRow = Math.floor((dragDelegate.x + dragDelegate.width/2) / dragDelegate.width);
|
||||
// Put it on desktop
|
||||
} else if (appletsLayout.contains(appletsLayout.mapFromItem(dragDelegate, dragDelegate.width/2, dragDelegate.height/2))) {
|
||||
plasmoid.nativeInterface.applicationListModel.setDesktopItem(index, true);
|
||||
return;
|
||||
// Put it in the general view
|
||||
} else {
|
||||
newRow = Math.round(applicationsFlow.width / dragDelegate.width) * Math.floor((dragDelegate.y + dragDelegate.height/2) / dragDelegate.height) + Math.floor((dragDelegate.x + dragDelegate.width/2) / dragDelegate.width) + favoriteStrip.count;
|
||||
}
|
||||
|
||||
plasmoid.nativeInterface.applicationListModel.setDesktopItem(index, false);
|
||||
|
||||
plasmoid.nativeInterface.applicationListModel.moveItem(modelData.index, newRow);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore
|
|||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
import org.kde.kquickcontrolsaddons 2.0
|
||||
|
||||
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
|
||||
|
||||
Controls.Control {
|
||||
id: root
|
||||
|
|
@ -39,6 +40,7 @@ Controls.Control {
|
|||
readonly property int cellWidth: applicationsFlow.width / Math.floor(applicationsFlow.width / ((availableCellHeight - reservedSpaceForLabel) + units.smallSpacing*4))
|
||||
readonly property int cellHeight: availableCellHeight - topPadding
|
||||
|
||||
property ContainmentLayoutManager.AppletsLayout appletsLayout
|
||||
property FavoriteStrip favoriteStrip
|
||||
|
||||
signal externalDragStarted
|
||||
|
|
@ -110,7 +112,15 @@ Controls.Control {
|
|||
width: root.cellWidth
|
||||
height: root.cellHeight
|
||||
dragDelegate: dragDelegateItem
|
||||
parent: index < favoriteStrip.count ? favoriteStrip.contentItem : applicationsFlow
|
||||
parent: {
|
||||
if (model.ApplicationOnDesktopRole) {
|
||||
return appletsLayout;
|
||||
}
|
||||
if (index < favoriteStrip.count) {
|
||||
return favoriteStrip.contentItem;
|
||||
}
|
||||
return applicationsFlow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,112 +46,127 @@ Text {
|
|||
target: plasmoid
|
||||
onEditModeChanged: {
|
||||
appletsLayout.editMode = plasmoid.editMode
|
||||
if (plasmoid.editMode) {
|
||||
menuRepeater.freeLayout();
|
||||
} else {
|
||||
menuRepeater.relayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
id: mainFlickable
|
||||
anchors.fill: parent
|
||||
anchors {
|
||||
fill: parent
|
||||
// bottomMargin: favoriteStrip.height
|
||||
}
|
||||
|
||||
bottomMargin: favoriteStrip.height
|
||||
contentWidth: width
|
||||
contentHeight: appletsLayout.height
|
||||
contentHeight: flickableContents.height
|
||||
interactive: !plasmoid.editMode
|
||||
|
||||
DragDrop.DropArea {
|
||||
ColumnLayout {
|
||||
id: flickableContents
|
||||
width: parent.width
|
||||
height: mainFlickable.height + launcher.height
|
||||
DragDrop.DropArea {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: mainFlickable.height //TODO: multiple widgets pages
|
||||
|
||||
onDragEnter: {
|
||||
event.accept(event.proposedAction);
|
||||
}
|
||||
onDragMove: {
|
||||
appletsLayout.showPlaceHolderAt(
|
||||
Qt.rect(event.x - appletsLayout.defaultItemWidth / 2,
|
||||
event.y - appletsLayout.defaultItemHeight / 2,
|
||||
appletsLayout.defaultItemWidth,
|
||||
appletsLayout.defaultItemHeight)
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
ContainmentLayoutManager.AppletsLayout {
|
||||
id: appletsLayout
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
configKey: width > 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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue