mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
correct restore and placement of favorites
This commit is contained in:
parent
aa7e6f10c4
commit
6ede8da8d7
6 changed files with 39 additions and 15 deletions
|
|
@ -37,6 +37,7 @@
|
|||
#include <KIOWidgets/KRun>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
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;
|
||||
|
||||
if (m_maxFavoriteCount > count) {
|
||||
while (m_favorites.size() > count && m_favorites.count() > 0) {
|
||||
m_favorites.pop_back();
|
||||
|
|
@ -349,6 +352,7 @@ qWarning()<<"NEW FAVORITE COUNT"<<count;
|
|||
}
|
||||
|
||||
m_maxFavoriteCount = count;
|
||||
m_homeScreen->config().writeEntry("MaxFavoriteCount", m_maxFavoriteCount);
|
||||
|
||||
emit maxFavoriteCountChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ private:
|
|||
QList<ApplicationData> m_applicationList;
|
||||
|
||||
HomeScreen *m_homeScreen = nullptr;
|
||||
int m_maxFavoriteCount = 5;
|
||||
int m_maxFavoriteCount = 0;
|
||||
QStringList m_appOrder;
|
||||
QStringList m_favorites;
|
||||
QSet<QString> m_desktopItems;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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))) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue