mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03: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 <KIOWidgets/KRun>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
ApplicationListModel::ApplicationListModel(HomeScreen *parent)
|
ApplicationListModel::ApplicationListModel(HomeScreen *parent)
|
||||||
: QAbstractListModel(parent),
|
: QAbstractListModel(parent),
|
||||||
m_homeScreen(parent)
|
m_homeScreen(parent)
|
||||||
|
|
@ -47,6 +48,8 @@ ApplicationListModel::ApplicationListModel(HomeScreen *parent)
|
||||||
m_favorites = m_homeScreen->config().readEntry("Favorites", QStringList());
|
m_favorites = m_homeScreen->config().readEntry("Favorites", QStringList());
|
||||||
m_desktopItems = m_homeScreen->config().readEntry("DesktopItems", QStringList()).toSet();
|
m_desktopItems = m_homeScreen->config().readEntry("DesktopItems", QStringList()).toSet();
|
||||||
m_appOrder = m_homeScreen->config().readEntry("AppOrder", QStringList());
|
m_appOrder = m_homeScreen->config().readEntry("AppOrder", QStringList());
|
||||||
|
m_maxFavoriteCount = m_homeScreen->config().readEntry("MaxFavoriteCount", 5);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto app : m_appOrder) {
|
for (auto app : m_appOrder) {
|
||||||
m_appPositions[app] = i;
|
m_appPositions[app] = i;
|
||||||
|
|
@ -270,7 +273,7 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location)
|
||||||
}
|
}
|
||||||
|
|
||||||
data.location = location;
|
data.location = location;
|
||||||
|
emit m_homeScreen->configNeedsSaving();
|
||||||
emit dataChanged(index(row, 0), index(row, 0));
|
emit dataChanged(index(row, 0), index(row, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -331,7 +334,7 @@ void ApplicationListModel::setMaxFavoriteCount(int count)
|
||||||
if (m_maxFavoriteCount == count) {
|
if (m_maxFavoriteCount == count) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qWarning()<<"NEW FAVORITE COUNT"<<count;
|
|
||||||
if (m_maxFavoriteCount > count) {
|
if (m_maxFavoriteCount > count) {
|
||||||
while (m_favorites.size() > count && m_favorites.count() > 0) {
|
while (m_favorites.size() > count && m_favorites.count() > 0) {
|
||||||
m_favorites.pop_back();
|
m_favorites.pop_back();
|
||||||
|
|
@ -349,6 +352,7 @@ qWarning()<<"NEW FAVORITE COUNT"<<count;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_maxFavoriteCount = count;
|
m_maxFavoriteCount = count;
|
||||||
|
m_homeScreen->config().writeEntry("MaxFavoriteCount", m_maxFavoriteCount);
|
||||||
|
|
||||||
emit maxFavoriteCountChanged();
|
emit maxFavoriteCountChanged();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ private:
|
||||||
QList<ApplicationData> m_applicationList;
|
QList<ApplicationData> m_applicationList;
|
||||||
|
|
||||||
HomeScreen *m_homeScreen = nullptr;
|
HomeScreen *m_homeScreen = nullptr;
|
||||||
int m_maxFavoriteCount = 5;
|
int m_maxFavoriteCount = 0;
|
||||||
QStringList m_appOrder;
|
QStringList m_appOrder;
|
||||||
QStringList m_favorites;
|
QStringList m_favorites;
|
||||||
QSet<QString> m_desktopItems;
|
QSet<QString> m_desktopItems;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ LauncherContainer {
|
||||||
flow.flow: Flow.TopToBottom
|
flow.flow: Flow.TopToBottom
|
||||||
favoriteStrip: root
|
favoriteStrip: root
|
||||||
|
|
||||||
visible: flow.children.length > 0 || plasmoid.editMode
|
visible: flow.children.length > 0 || launcherDragManager.active
|
||||||
|
|
||||||
height: launcherGrid.cellHeight + topPadding + bottomPadding
|
height: launcherGrid.cellHeight + topPadding + bottomPadding
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function containerForItem(item, dragCenterX, dragCenterY) {
|
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) {
|
&& plasmoid.nativeInterface.applicationListModel.favoriteCount < plasmoid.nativeInterface.applicationListModel.maxFavoriteCount) {
|
||||||
return favoriteStrip;
|
return favoriteStrip;
|
||||||
} else if (appletsLayout.contains(appletsLayout.mapFromItem(item, dragCenterX, dragCenterY))) {
|
} 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 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 cellWidth: root.flow.width / Math.floor(root.flow.width / ((availableCellHeight - reservedSpaceForLabel) + units.smallSpacing*4))
|
||||||
readonly property int cellHeight: availableCellHeight
|
readonly property int cellHeight: availableCellHeight
|
||||||
|
|
||||||
launcherGrid: root
|
launcherGrid: root
|
||||||
|
|
||||||
frame.width: width
|
frame.width: width
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,24 @@ Item {
|
||||||
scrollUpIndicator.opacity = 0;
|
scrollUpIndicator.opacity = 0;
|
||||||
scrollDownIndicator.opacity = 0;
|
scrollDownIndicator.opacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function recalculateMaxFavoriteCount() {
|
||||||
|
if (!componentComplete) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
plasmoid.nativeInterface.applicationListModel.maxFavoriteCount = Math.floor(Math.min(width, height) / launcher.cellWidth);
|
||||||
|
}
|
||||||
//END functions
|
//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 {
|
Timer {
|
||||||
id: autoScrollTimer
|
id: autoScrollTimer
|
||||||
|
|
@ -136,10 +150,11 @@ Item {
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: mainFlickable
|
id: mainFlickable
|
||||||
|
width: parent.width
|
||||||
anchors {
|
anchors {
|
||||||
fill: parent
|
fill: parent
|
||||||
topMargin: plasmoid.availableScreenRect.y + krunner.inputHeight
|
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
|
bottomMargin: favoriteStrip.height
|
||||||
|
|
@ -173,14 +188,17 @@ Item {
|
||||||
easing.type: Easing.InOutQuad
|
easing.type: Easing.InOutQuad
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
Column {
|
||||||
id: flickableContents
|
id: flickableContents
|
||||||
width: parent.width
|
width: mainFlickable.width
|
||||||
spacing: Math.max(0, favoriteStrip.frame.height - mainFlickable.contentY)
|
spacing: Math.max(0, favoriteStrip.frame.height - mainFlickable.contentY)
|
||||||
|
|
||||||
DragDrop.DropArea {
|
DragDrop.DropArea {
|
||||||
Layout.fillWidth: true
|
anchors {
|
||||||
Layout.preferredHeight: mainFlickable.height - favoriteStrip.frame.height //TODO: multiple widgets pages
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
height: mainFlickable.height - favoriteStrip.frame.height //TODO: multiple widgets pages
|
||||||
|
|
||||||
onDragEnter: {
|
onDragEnter: {
|
||||||
event.accept(event.proposedAction);
|
event.accept(event.proposedAction);
|
||||||
|
|
@ -281,7 +299,10 @@ Item {
|
||||||
|
|
||||||
Launcher.LauncherGrid {
|
Launcher.LauncherGrid {
|
||||||
id: launcher
|
id: launcher
|
||||||
Layout.fillWidth: true
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
|
||||||
favoriteStrip: favoriteStrip
|
favoriteStrip: favoriteStrip
|
||||||
appletsLayout: appletsLayout
|
appletsLayout: appletsLayout
|
||||||
|
|
@ -312,7 +333,7 @@ Item {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
bottomMargin: root.height - plasmoid.availableScreenRect.height - plasmoid.availableScreenRect.y
|
bottomMargin: plasmoid.screenGeometry.height - plasmoid.availableScreenRect.height - plasmoid.availableScreenRect.y
|
||||||
}
|
}
|
||||||
appletsLayout: appletsLayout
|
appletsLayout: appletsLayout
|
||||||
launcherGrid: launcher
|
launcherGrid: launcher
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue