mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
homescreens/halcyon: Add ability to move out of folder
This commit is contained in:
parent
4daab15c23
commit
85e434913b
7 changed files with 54 additions and 7 deletions
|
|
@ -123,3 +123,13 @@ void ApplicationFolder::removeApp(int row)
|
|||
Q_EMIT applicationsChanged();
|
||||
Q_EMIT saveRequested();
|
||||
}
|
||||
|
||||
void ApplicationFolder::moveAppOut(int row)
|
||||
{
|
||||
if (row < 0 || row >= m_applications.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Q_EMIT moveAppOutRequested(m_applications[row]->storageId());
|
||||
removeApp(row);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,13 @@ public:
|
|||
Q_INVOKABLE void moveEntry(int fromRow, int toRow);
|
||||
Q_INVOKABLE void addApp(const QString &storageId, int row);
|
||||
Q_INVOKABLE void removeApp(int row);
|
||||
Q_INVOKABLE void moveAppOut(int row); // moves app to main page
|
||||
|
||||
Q_SIGNALS:
|
||||
void nameChanged();
|
||||
void applicationsChanged();
|
||||
void saveRequested();
|
||||
void moveAppOutRequested(const QString &storageId);
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ Item {
|
|||
|
||||
property real dragFolderAnimationProgress: 0
|
||||
|
||||
property list<Kirigami.Action> menuActions
|
||||
|
||||
// whether this delegate is a folder
|
||||
property bool isFolder
|
||||
|
||||
|
|
@ -40,7 +42,6 @@ Item {
|
|||
readonly property string applicationIcon: application ? application.icon : ""
|
||||
|
||||
signal folderOpenRequested()
|
||||
signal removeRequested()
|
||||
|
||||
property alias drag: mouseArea.drag
|
||||
Drag.active: delegate.drag.active
|
||||
|
|
@ -96,14 +97,19 @@ Item {
|
|||
active: false
|
||||
|
||||
sourceComponent: PlasmaComponents.Menu {
|
||||
id: menu
|
||||
title: label.text
|
||||
closePolicy: PlasmaComponents.Menu.CloseOnReleaseOutside | PlasmaComponents.Menu.CloseOnEscape
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
icon.name: "emblem-favorite"
|
||||
text: i18n("Remove from favourites")
|
||||
onClicked: delegate.removeRequested()
|
||||
Repeater {
|
||||
model: menuActions
|
||||
delegate: PlasmaComponents.MenuItem {
|
||||
icon.name: modelData.iconName
|
||||
text: modelData.text
|
||||
onClicked: modelData.triggered()
|
||||
}
|
||||
}
|
||||
|
||||
onClosed: dialogLoader.active = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,7 +217,14 @@ MobileShell.GridView {
|
|||
application: model.application
|
||||
|
||||
onFolderOpenRequested: root.requestOpenFolder(model.folder)
|
||||
onRemoveRequested: Halcyon.PinnedModel.removeEntry(model.index);
|
||||
|
||||
menuActions: [
|
||||
Kirigami.Action {
|
||||
iconName: "emblem-favorite"
|
||||
text: i18n("Remove from favourites")
|
||||
onTriggered: root.folder.removeApp(model.index)
|
||||
}
|
||||
]
|
||||
|
||||
readonly property bool isLeftColumn: !root.twoColumn || ((visualIndex % 2) === 0)
|
||||
readonly property bool isRightColumn: !root.twoColumn || ((visualIndex % 2) !== 0)
|
||||
|
|
|
|||
|
|
@ -123,7 +123,18 @@ MobileShell.GridView {
|
|||
isFolder: false
|
||||
application: modelData
|
||||
|
||||
onRemoveRequested: root.folder.removeApp(model.index);
|
||||
menuActions: [
|
||||
Kirigami.Action {
|
||||
iconName: "emblem-favorite"
|
||||
text: i18n("Remove from favourites")
|
||||
onTriggered: root.folder.removeApp(model.index)
|
||||
},
|
||||
Kirigami.Action {
|
||||
iconName: "document-open-folder"
|
||||
text: i18n("Move out of folder")
|
||||
onTriggered: root.folder.moveAppOut(model.index)
|
||||
}
|
||||
]
|
||||
|
||||
readonly property bool isLeftColumn: !root.twoColumn || ((visualIndex % 2) === 0)
|
||||
readonly property bool isRightColumn: !root.twoColumn || ((visualIndex % 2) !== 0)
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ void PinnedModel::addFolder(QString name, int row)
|
|||
|
||||
ApplicationFolder *folder = new ApplicationFolder(this, name);
|
||||
connect(folder, &ApplicationFolder::saveRequested, this, &PinnedModel::save);
|
||||
connect(folder, &ApplicationFolder::moveAppOutRequested, this, &PinnedModel::addAppFromFolder);
|
||||
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
m_applications.insert(row, nullptr);
|
||||
|
|
@ -146,6 +147,7 @@ void PinnedModel::createFolderFromApps(int sourceAppRow, int draggedAppRow)
|
|||
// replace source app with folder containing both apps
|
||||
ApplicationFolder *folder = new ApplicationFolder(this, i18nc("Default application folder name.", "Folder"));
|
||||
connect(folder, &ApplicationFolder::saveRequested, this, &PinnedModel::save);
|
||||
connect(folder, &ApplicationFolder::moveAppOutRequested, this, &PinnedModel::addAppFromFolder);
|
||||
|
||||
folder->addApp(m_applications[sourceAppRow]->storageId(), 0);
|
||||
folder->addApp(m_applications[draggedAppRow]->storageId(), 0);
|
||||
|
|
@ -203,6 +205,7 @@ void PinnedModel::load()
|
|||
// read folder
|
||||
ApplicationFolder *folder = ApplicationFolder::fromJson(obj, this);
|
||||
connect(folder, &ApplicationFolder::saveRequested, this, &PinnedModel::save);
|
||||
connect(folder, &ApplicationFolder::moveAppOutRequested, this, &PinnedModel::addAppFromFolder);
|
||||
|
||||
if (folder) {
|
||||
m_applications.append(nullptr);
|
||||
|
|
@ -233,3 +236,8 @@ void PinnedModel::save()
|
|||
m_applet->config().writeEntry("Pinned", QString::fromStdString(data.toStdString()));
|
||||
Q_EMIT m_applet->configNeedsSaving();
|
||||
}
|
||||
|
||||
void PinnedModel::addAppFromFolder(const QString &storageId)
|
||||
{
|
||||
addApp(storageId, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ public:
|
|||
Q_INVOKABLE void load();
|
||||
void save();
|
||||
|
||||
public Q_SLOTS:
|
||||
void addAppFromFolder(const QString &storageId);
|
||||
|
||||
private:
|
||||
QList<Application *> m_applications;
|
||||
QList<ApplicationFolder *> m_folders;
|
||||
|
|
|
|||
Loading…
Reference in a new issue