Commit aa7e6f10 authored by Marco Martin's avatar Marco Martin

better dragging around behavior

parent bd7e936d
......@@ -240,32 +240,31 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location)
return;
}
if (location == Favorites) {
if (row >= m_maxFavoriteCount) {
if (location == Favorites) {qWarning()<<"favoriting"<<row<<data.name;
// Deny favorites when full
if (row >= m_maxFavoriteCount || m_favorites.count() >= m_maxFavoriteCount) {
return;
}
m_favorites.insert(row, data.storageId);
qWarning()<<"AAAAAAAAAAAAA111"<<m_maxFavoriteCount<<m_applicationList.count();
if (m_applicationList[m_maxFavoriteCount].location == Favorites) {
m_applicationList[m_maxFavoriteCount].location = Grid;
qWarning()<<"bbbbbb2222";
m_favorites.pop_back();
emit dataChanged(index(m_maxFavoriteCount, 0), index(m_maxFavoriteCount, 0));
qWarning()<<"cccc3333";
}
m_homeScreen->config().writeEntry("Favorites", m_favorites);
emit favoriteCountChanged();
// Out of favorites
} else if (data.location == Favorites) {
m_favorites.removeAll(data.storageId);
m_homeScreen->config().writeEntry("Favorites", m_favorites);
emit favoriteCountChanged();
}
// In Desktop
if (location == Desktop) {
m_desktopItems.insert(data.storageId);
m_homeScreen->config().writeEntry("DesktopItems", m_desktopItems.toList());
} else if (data.location == Favorites) {
// Out of Desktop
} else if (data.location == Desktop) {
m_desktopItems.remove(data.storageId);
m_homeScreen->config().writeEntry("DesktopItems", m_desktopItems.toList());
}
......@@ -290,6 +289,7 @@ void ApplicationListModel::moveItem(int row, int destination)
ApplicationData data = m_applicationList.at(row);
m_applicationList.insert(destination, data);
m_applicationList.takeAt(row);
} else {
ApplicationData data = m_applicationList.takeAt(row);
m_applicationList.insert(destination, data);
......@@ -331,11 +331,12 @@ void ApplicationListModel::setMaxFavoriteCount(int count)
if (m_maxFavoriteCount == count) {
return;
}
qWarning()<<"NEW FAVORITE COUNT"<<count;
if (m_maxFavoriteCount > count) {
while (m_favorites.size() > count && m_favorites.count() > 0) {
m_favorites.pop_back();
}
emit favoriteCountChanged();
int i = 0;
for (auto &app : m_applicationList) {
......
......@@ -34,9 +34,9 @@ LauncherContainer {
flow.flow: Flow.TopToBottom
favoriteStrip: root
visible: plasmoid.nativeInterface.applicationListModel.favoriteCount > 0 || plasmoid.editMode
visible: flow.children.length > 0 || plasmoid.editMode
height: launcherGrid.cellHeight + topPadding + bottomPadding
frame.implicitWidth: launcherGrid.cellWidth * Math.max(1, plasmoid.nativeInterface.applicationListModel.favoriteCount) + frame.leftPadding + frame.rightPadding
frame.implicitWidth: launcherGrid.cellWidth * Math.max(1, flow.children.length) + frame.leftPadding + frame.rightPadding
}
......@@ -52,7 +52,7 @@ Item {
var pos = favoriteStrip.flow.mapFromItem(delegate, 0, 0);
newRow = Math.floor((pos.x + dragCenterX) / delegate.width);
plasmoid.nativeInterface.applicationListModel.setLocation(delegate.modelData.index, ApplicationListModel.Favorites);
//plasmoid.nativeInterface.applicationListModel.setLocation(delegate.modelData.index, ApplicationListModel.Favorites);
internal.showSpacer(delegate, dragCenterX, dragCenterY);
plasmoid.nativeInterface.applicationListModel.moveItem(delegate.modelData.index, newRow);
......@@ -60,7 +60,7 @@ Item {
// Put it on desktop
} else if (newContainer == appletsLayout) {
var pos = appletsLayout.mapFromItem(delegate, 0, 0);
plasmoid.nativeInterface.applicationListModel.setLocation(delegate.modelData.index, ApplicationListModel.Desktop);
//plasmoid.nativeInterface.applicationListModel.setLocation(delegate.modelData.index, ApplicationListModel.Desktop);
internal.showSpacer(delegate, dragCenterX, dragCenterY);
return;
......@@ -69,7 +69,7 @@ Item {
} else {
newRow = Math.round(newContainer.flow.width / delegate.width) * Math.floor((delegate.y + dragCenterY) / delegate.height) + Math.floor((delegate.x + dragCenterX) / delegate.width) + favoriteStrip.count;
plasmoid.nativeInterface.applicationListModel.setLocation(delegate.modelData.index, ApplicationListModel.Grid);
//plasmoid.nativeInterface.applicationListModel.setLocation(delegate.modelData.index, ApplicationListModel.Grid);
internal.showSpacer(delegate, dragCenterX, dragCenterY);
plasmoid.nativeInterface.applicationListModel.moveItem(delegate.modelData.index, newRow);
......@@ -99,7 +99,8 @@ Item {
}
function containerForItem(item, dragCenterX, dragCenterY) {
if (favoriteStrip.contains(favoriteStrip.mapFromItem(item, dragCenterX, dragCenterY))) {
if (favoriteStrip.contains(favoriteStrip.mapFromItem(item, dragCenterX, dragCenterY))
&& plasmoid.nativeInterface.applicationListModel.favoriteCount < plasmoid.nativeInterface.applicationListModel.maxFavoriteCount) {
return favoriteStrip;
} else if (appletsLayout.contains(appletsLayout.mapFromItem(item, dragCenterX, dragCenterY))) {
return appletsLayout;
......@@ -211,13 +212,19 @@ Item {
raiseContainer(container);
if (container == appletsLayout) {
plasmoid.nativeInterface.applicationListModel.setLocation(item.modelData.index, ApplicationListModel.Desktop);
var pos = appletsLayout.mapFromItem(item, 0, 0);
item.parent = appletsLayout;
item.x = pos.x;
item.y = pos.y;
appletsLayout.hidePlaceHolder();
appletsLayout.positionItem(item);
return;
} else if (container == favoriteStrip) {
plasmoid.nativeInterface.applicationListModel.setLocation(item.modelData.index, ApplicationListModel.Favorites);
} else {
plasmoid.nativeInterface.applicationListModel.setLocation(item.modelData.index, ApplicationListModel.Grid);
}
spacer.visible = false;
......
......@@ -212,17 +212,24 @@ Item {
imagePath: "widgets/arrows"
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
}
PlasmaCore.SvgItem {
PlasmaCore.IconItem {
z: 9
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
//bottomMargin: favoriteStrip.height
}
z: 2
svg: arrowsSvg
elementId: "up-arrow"
width: units.iconSizes.large
source: "arrow-up"
width: units.iconSizes.medium
height: width
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
MouseArea {
anchors {
fill: parent
margins: -units.smallSpacing
}
onClicked: mainFlickable.flick(0, -mainFlickable.height)
}
}
ContainmentLayoutManager.AppletsLayout {
......@@ -305,7 +312,7 @@ Item {
left: parent.left
right: parent.right
bottom: parent.bottom
bottomMargin: root.height - plamsoid.availableScreenRect.height - plasmoid.availableScreenRect.y
bottomMargin: root.height - plasmoid.availableScreenRect.height - plasmoid.availableScreenRect.y
}
appletsLayout: appletsLayout
launcherGrid: launcher
......
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