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