Commit 71948fd9 authored by Marco Martin's avatar Marco Martin

first prototype of icons in desktop

parent 2f0bc852
......@@ -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)
);
}
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();
}
onDragLeave: {
appletsLayout.hidePlaceHolder();
}
preventStealing: true
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();
}
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
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
}
anchors.fill: parent
ContainmentLayoutManager.AppletsLayout {
id: appletsLayout
configKey: width > height ? "ItemGeometries" : "ItemGeometriesVertical"
containment: plasmoid
editModeCondition: plasmoid.immutable
? ContainmentLayoutManager.AppletsLayout.Manual
: ContainmentLayoutManager.AppletsLayout.AfterPressAndHold
anchors.fill: parent
// Sets the containment in edit mode when we go in edit mode as well
onEditModeChanged: plasmoid.editMode = editMode
configKey: width > height ? "ItemGeometriesHorizontal" : "ItemGeometriesVertical"
containment: plasmoid
editModeCondition: plasmoid.immutable
? ContainmentLayoutManager.AppletsLayout.Manual
: ContainmentLayoutManager.AppletsLayout.AfterPressAndHold
minimumItemWidth: units.gridUnit * 3
minimumItemHeight: minimumItemWidth
// Sets the containment in edit mode when we go in edit mode as well
onEditModeChanged: plasmoid.editMode = editMode
defaultItemWidth: units.gridUnit * 6
defaultItemHeight: defaultItemWidth
minimumItemWidth: units.gridUnit * 3
minimumItemHeight: minimumItemWidth
cellWidth: units.iconSizes.small
cellHeight: cellWidth
defaultItemWidth: units.gridUnit * 6
defaultItemHeight: defaultItemWidth
acceptsAppletCallback: function(applet, x, y) {
print("Applet: "+applet+" "+x+" "+y)
return true;
}
cellWidth: units.iconSizes.small
cellHeight: cellWidth
appletContainerComponent: ContainmentLayoutManager.BasicAppletContainer {
id: appletContainer
configOverlayComponent: ConfigOverlay {}
onEditModeChanged: {
if (editMode) {
plasmoid.editMode = true;
}
acceptsAppletCallback: function(applet, x, y) {
print("Applet: "+applet+" "+x+" "+y)
return true;
}
}
placeHolder: ContainmentLayoutManager.PlaceHolder {}
Launcher.LauncherGrid {
id: launcher
favoriteStrip: favoriteStrip
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
appletContainerComponent: ContainmentLayoutManager.BasicAppletContainer {
id: appletContainer
configOverlayComponent: ConfigOverlay {}
onEditModeChanged: {
if (editMode) {
plasmoid.editMode = true;
}
}
}
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)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment