diff --git a/containments/homescreen2/applicationlistmodel.cpp b/containments/homescreen2/applicationlistmodel.cpp index e1121fc2..cc9da077 100644 --- a/containments/homescreen2/applicationlistmodel.cpp +++ b/containments/homescreen2/applicationlistmodel.cpp @@ -37,6 +37,7 @@ #include #include + ApplicationListModel::ApplicationListModel(HomeScreen *parent) : QAbstractListModel(parent), m_homeScreen(parent) @@ -47,6 +48,8 @@ ApplicationListModel::ApplicationListModel(HomeScreen *parent) m_favorites = m_homeScreen->config().readEntry("Favorites", QStringList()); m_desktopItems = m_homeScreen->config().readEntry("DesktopItems", QStringList()).toSet(); m_appOrder = m_homeScreen->config().readEntry("AppOrder", QStringList()); + m_maxFavoriteCount = m_homeScreen->config().readEntry("MaxFavoriteCount", 5); + int i = 0; for (auto app : m_appOrder) { m_appPositions[app] = i; @@ -270,7 +273,7 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location) } data.location = location; - + emit m_homeScreen->configNeedsSaving(); emit dataChanged(index(row, 0), index(row, 0)); } @@ -331,7 +334,7 @@ void ApplicationListModel::setMaxFavoriteCount(int count) if (m_maxFavoriteCount == count) { return; } -qWarning()<<"NEW FAVORITE COUNT"< count) { while (m_favorites.size() > count && m_favorites.count() > 0) { m_favorites.pop_back(); @@ -349,6 +352,7 @@ qWarning()<<"NEW FAVORITE COUNT"<config().writeEntry("MaxFavoriteCount", m_maxFavoriteCount); emit maxFavoriteCountChanged(); } diff --git a/containments/homescreen2/applicationlistmodel.h b/containments/homescreen2/applicationlistmodel.h index 270eb07f..7e3f1ad4 100644 --- a/containments/homescreen2/applicationlistmodel.h +++ b/containments/homescreen2/applicationlistmodel.h @@ -104,7 +104,7 @@ private: QList m_applicationList; HomeScreen *m_homeScreen = nullptr; - int m_maxFavoriteCount = 5; + int m_maxFavoriteCount = 0; QStringList m_appOrder; QStringList m_favorites; QSet m_desktopItems; diff --git a/containments/homescreen2/package/contents/ui/launcher/FavoriteStrip.qml b/containments/homescreen2/package/contents/ui/launcher/FavoriteStrip.qml index d2c6e338..e6c4a269 100644 --- a/containments/homescreen2/package/contents/ui/launcher/FavoriteStrip.qml +++ b/containments/homescreen2/package/contents/ui/launcher/FavoriteStrip.qml @@ -34,7 +34,7 @@ LauncherContainer { flow.flow: Flow.TopToBottom favoriteStrip: root - visible: flow.children.length > 0 || plasmoid.editMode + visible: flow.children.length > 0 || launcherDragManager.active height: launcherGrid.cellHeight + topPadding + bottomPadding diff --git a/containments/homescreen2/package/contents/ui/launcher/LauncherDragManager.qml b/containments/homescreen2/package/contents/ui/launcher/LauncherDragManager.qml index 2d17c7bf..c61143c0 100644 --- a/containments/homescreen2/package/contents/ui/launcher/LauncherDragManager.qml +++ b/containments/homescreen2/package/contents/ui/launcher/LauncherDragManager.qml @@ -99,7 +99,7 @@ Item { } function containerForItem(item, dragCenterX, dragCenterY) { - if (favoriteStrip.contains(favoriteStrip.mapFromItem(item, dragCenterX, dragCenterY)) + if (favoriteStrip.contains(favoriteStrip.frame.mapFromItem(item, dragCenterX, dragCenterY)) && plasmoid.nativeInterface.applicationListModel.favoriteCount < plasmoid.nativeInterface.applicationListModel.maxFavoriteCount) { return favoriteStrip; } else if (appletsLayout.contains(appletsLayout.mapFromItem(item, dragCenterX, dragCenterY))) { diff --git a/containments/homescreen2/package/contents/ui/launcher/LauncherGrid.qml b/containments/homescreen2/package/contents/ui/launcher/LauncherGrid.qml index bec651ce..1322ed92 100644 --- a/containments/homescreen2/package/contents/ui/launcher/LauncherGrid.qml +++ b/containments/homescreen2/package/contents/ui/launcher/LauncherGrid.qml @@ -35,7 +35,6 @@ LauncherContainer { readonly property int columns: Math.floor(root.flow.width / cellWidth) readonly property int cellWidth: root.flow.width / Math.floor(root.flow.width / ((availableCellHeight - reservedSpaceForLabel) + units.smallSpacing*4)) readonly property int cellHeight: availableCellHeight - launcherGrid: root frame.width: width diff --git a/containments/homescreen2/package/contents/ui/main.qml b/containments/homescreen2/package/contents/ui/main.qml index 87d6cf55..b6a43101 100644 --- a/containments/homescreen2/package/contents/ui/main.qml +++ b/containments/homescreen2/package/contents/ui/main.qml @@ -72,10 +72,24 @@ Item { scrollUpIndicator.opacity = 0; scrollDownIndicator.opacity = 0; } + + function recalculateMaxFavoriteCount() { + if (!componentComplete) { + return; + } + + plasmoid.nativeInterface.applicationListModel.maxFavoriteCount = Math.floor(Math.min(width, height) / launcher.cellWidth); + } //END functions - onWidthChanged: plasmoid.nativeInterface.applicationListModel.maxFavoriteCount = Math.floor(Math.min(width, height) / launcher.cellWidth) - onHeightChanged: plasmoid.nativeInterface.applicationListModel.maxFavoriteCount = Math.floor(Math.min(width, height) / launcher.cellWidth) + + property bool componentComplete: false + onWidthChanged: recalculateMaxFavoriteCount() + onHeightChanged:recalculateMaxFavoriteCount() + Component.onCompleted: { + componentComplete = true; + recalculateMaxFavoriteCount() + } Timer { id: autoScrollTimer @@ -136,10 +150,11 @@ Item { Flickable { id: mainFlickable + width: parent.width anchors { fill: parent topMargin: plasmoid.availableScreenRect.y + krunner.inputHeight - bottomMargin: root.height - plasmoid.availableScreenRect.height - topMargin + bottomMargin: plasmoid.screenGeometry.height - plasmoid.availableScreenRect.height - plasmoid.availableScreenRect.y } bottomMargin: favoriteStrip.height @@ -173,14 +188,17 @@ Item { easing.type: Easing.InOutQuad } - ColumnLayout { + Column { id: flickableContents - width: parent.width + width: mainFlickable.width spacing: Math.max(0, favoriteStrip.frame.height - mainFlickable.contentY) DragDrop.DropArea { - Layout.fillWidth: true - Layout.preferredHeight: mainFlickable.height - favoriteStrip.frame.height //TODO: multiple widgets pages + anchors { + left: parent.left + right: parent.right + } + height: mainFlickable.height - favoriteStrip.frame.height //TODO: multiple widgets pages onDragEnter: { event.accept(event.proposedAction); @@ -281,7 +299,10 @@ Item { Launcher.LauncherGrid { id: launcher - Layout.fillWidth: true + anchors { + left: parent.left + right: parent.right + } favoriteStrip: favoriteStrip appletsLayout: appletsLayout @@ -312,7 +333,7 @@ Item { left: parent.left right: parent.right bottom: parent.bottom - bottomMargin: root.height - plasmoid.availableScreenRect.height - plasmoid.availableScreenRect.y + bottomMargin: plasmoid.screenGeometry.height - plasmoid.availableScreenRect.height - plasmoid.availableScreenRect.y } appletsLayout: appletsLayout launcherGrid: launcher