mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-04 02:34:45 +00:00
kinda working again
This commit is contained in:
parent
6c8ae2501a
commit
2f0bc852ba
6 changed files with 91 additions and 273 deletions
|
|
@ -43,6 +43,8 @@ ApplicationListModel::ApplicationListModel(QObject *parent)
|
||||||
//can't use the new syntax as this signal is overloaded
|
//can't use the new syntax as this signal is overloaded
|
||||||
connect(KSycoca::self(), SIGNAL(databaseChanged(const QStringList &)),
|
connect(KSycoca::self(), SIGNAL(databaseChanged(const QStringList &)),
|
||||||
this, SLOT(sycocaDbChanged(const QStringList &)));
|
this, SLOT(sycocaDbChanged(const QStringList &)));
|
||||||
|
//here or delayed?
|
||||||
|
loadApplications();
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationListModel::~ApplicationListModel()
|
ApplicationListModel::~ApplicationListModel()
|
||||||
|
|
@ -56,6 +58,8 @@ QHash<int, QByteArray> ApplicationListModel::roleNames() const
|
||||||
roleNames[ApplicationStorageIdRole] = "ApplicationStorageIdRole";
|
roleNames[ApplicationStorageIdRole] = "ApplicationStorageIdRole";
|
||||||
roleNames[ApplicationEntryPathRole] = "ApplicationEntryPathRole";
|
roleNames[ApplicationEntryPathRole] = "ApplicationEntryPathRole";
|
||||||
roleNames[ApplicationOriginalRowRole] = "ApplicationOriginalRowRole";
|
roleNames[ApplicationOriginalRowRole] = "ApplicationOriginalRowRole";
|
||||||
|
roleNames[ApplicationFavoriteRole] = "ApplicationFavoriteRole";
|
||||||
|
roleNames[ApplicationOnDesktopRole] = "ApplicationOnDesktopRole";
|
||||||
|
|
||||||
return roleNames;
|
return roleNames;
|
||||||
}
|
}
|
||||||
|
|
@ -217,6 +221,7 @@ void ApplicationListModel::setFavoriteItem(int row, bool favorite)
|
||||||
}
|
}
|
||||||
|
|
||||||
data.favorite = favorite;
|
data.favorite = favorite;
|
||||||
|
qWarning()<<m_applicationList[row].favorite;
|
||||||
emit dataChanged(index(row, 0), index(row, 0));
|
emit dataChanged(index(row, 0), index(row, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,10 +60,12 @@ public:
|
||||||
|
|
||||||
enum Roles {
|
enum Roles {
|
||||||
ApplicationNameRole = Qt::UserRole + 1,
|
ApplicationNameRole = Qt::UserRole + 1,
|
||||||
ApplicationIconRole = Qt::UserRole + 2,
|
ApplicationIconRole,
|
||||||
ApplicationStorageIdRole = Qt::UserRole + 3,
|
ApplicationStorageIdRole,
|
||||||
ApplicationEntryPathRole = Qt::UserRole + 4,
|
ApplicationEntryPathRole,
|
||||||
ApplicationOriginalRowRole = Qt::UserRole + 6
|
ApplicationOriginalRowRole,
|
||||||
|
ApplicationFavoriteRole,
|
||||||
|
ApplicationOnDesktopRole
|
||||||
};
|
};
|
||||||
|
|
||||||
QStringList appOrder() const;
|
QStringList appOrder() const;
|
||||||
|
|
|
||||||
|
|
@ -25,31 +25,28 @@ import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
import org.kde.kquickcontrolsaddons 2.0
|
import org.kde.kquickcontrolsaddons 2.0
|
||||||
|
|
||||||
|
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
|
||||||
|
|
||||||
Controls.Control {
|
ContainmentLayoutManager.ItemContainer {
|
||||||
id: delegate
|
id: delegate
|
||||||
|
|
||||||
z: dragging ? 1 : 0
|
z: dragging ? 1 : 0
|
||||||
|
|
||||||
property var modelData: typeof model !== "undefined" ? model : null
|
property var modelData: typeof model !== "undefined" ? model : null
|
||||||
property bool dragging
|
property bool dragging
|
||||||
property Controls.Control dragDelegate
|
property ContainmentLayoutManager.ItemContainer dragDelegate
|
||||||
|
|
||||||
Drag.active: false
|
leftPadding: units.smallSpacing * 2
|
||||||
Drag.hotSpot.x: delegate.width/2
|
topPadding: units.smallSpacing * 2
|
||||||
Drag.hotSpot.y: delegate.height/2
|
rightPadding: units.smallSpacing * 2
|
||||||
Drag.mimeData: { "text/uri-list": modelData ? "file://" + modelData.ApplicationDesktopRole : "" }
|
bottomPadding: units.smallSpacing * 2
|
||||||
Drag.dragType: Drag.Automatic
|
|
||||||
|
|
||||||
leftPadding: units.smallSpacing*2
|
|
||||||
topPadding: units.smallSpacing*2
|
|
||||||
rightPadding: units.smallSpacing*2
|
|
||||||
bottomPadding: units.smallSpacing*2
|
|
||||||
|
|
||||||
opacity: dragging ? 0.4 : 1
|
opacity: dragging ? 0.4 : 1
|
||||||
|
|
||||||
onDraggingChanged: {
|
onDraggingChanged: {
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
|
var pos = dragDelegate.parent.mapFromItem(delegate, 0, 0);
|
||||||
|
dragDelegate.parent = delegate.parent.parent;
|
||||||
dragDelegate.x = delegate.x
|
dragDelegate.x = delegate.x
|
||||||
dragDelegate.y = delegate.y
|
dragDelegate.y = delegate.y
|
||||||
dragDelegate.modelData = model;
|
dragDelegate.modelData = model;
|
||||||
|
|
@ -59,6 +56,7 @@ Controls.Control {
|
||||||
root.reorderingApps = false;
|
root.reorderingApps = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: MouseArea {
|
contentItem: MouseArea {
|
||||||
drag.target: dragging ? dragDelegate : null
|
drag.target: dragging ? dragDelegate : null
|
||||||
|
|
||||||
|
|
@ -85,20 +83,13 @@ Controls.Control {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dragDelegate.x + dragDelegate.width < 0
|
var newRow = 0;
|
||||||
|| dragDelegate.y + dragDelegate.height < 0
|
|
||||||
|| dragDelegate.x > applicationsFlow.width
|
|
||||||
|| dragDelegate.y > applicationsFlow.height) {
|
|
||||||
dragging = false;
|
|
||||||
delegate.grabToImage(function(result) {
|
|
||||||
root.externalDragStarted();
|
|
||||||
delegate.Drag.imageSource = result.url;
|
|
||||||
delegate.Drag.active = true;
|
|
||||||
})
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newRow = Math.round(applicationsFlow.width / dragDelegate.width) * Math.floor((dragDelegate.y+dragDelegate.height/2) / dragDelegate.height) + Math.floor((dragDelegate.x+dragDelegate.width/2) / dragDelegate.width);
|
if (favoriteStrip.contains(favoriteStrip.mapFromItem(dragDelegate, dragDelegate.width/2, dragDelegate.height/2))) {
|
||||||
|
newRow = Math.floor((dragDelegate.x + dragDelegate.width/2) / dragDelegate.width);
|
||||||
|
} else {
|
||||||
|
newRow = Math.round(applicationsFlow.width / dragDelegate.width) * Math.floor((dragDelegate.y + dragDelegate.height/2) / dragDelegate.height) + Math.floor((dragDelegate.x + dragDelegate.width/2) / dragDelegate.width) + favoriteStrip.count;
|
||||||
|
}
|
||||||
|
|
||||||
plasmoid.nativeInterface.applicationListModel.moveItem(modelData.index, newRow);
|
plasmoid.nativeInterface.applicationListModel.moveItem(modelData.index, newRow);
|
||||||
}
|
}
|
||||||
|
|
@ -106,6 +97,7 @@ Controls.Control {
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
PlasmaCore.IconItem {
|
PlasmaCore.IconItem {
|
||||||
id: icon
|
id: icon
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ Controls.Control {
|
||||||
readonly property int cellWidth: applicationsFlow.width / Math.floor(applicationsFlow.width / ((availableCellHeight - reservedSpaceForLabel) + units.smallSpacing*4))
|
readonly property int cellWidth: applicationsFlow.width / Math.floor(applicationsFlow.width / ((availableCellHeight - reservedSpaceForLabel) + units.smallSpacing*4))
|
||||||
readonly property int cellHeight: availableCellHeight - topPadding
|
readonly property int cellHeight: availableCellHeight - topPadding
|
||||||
|
|
||||||
|
property FavoriteStrip favoriteStrip
|
||||||
|
|
||||||
signal externalDragStarted
|
signal externalDragStarted
|
||||||
signal dragPositionChanged(point pos)
|
signal dragPositionChanged(point pos)
|
||||||
|
|
||||||
|
|
@ -53,19 +55,6 @@ Controls.Control {
|
||||||
id: frame
|
id: frame
|
||||||
imagePath: "widgets/background"
|
imagePath: "widgets/background"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
y: root.cellHeight + frame.margins.top
|
|
||||||
color: theme.textColor
|
|
||||||
opacity: 0.3
|
|
||||||
height: 1
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
leftMargin: frame.margins.left
|
|
||||||
rightMargin: frame.margins.right
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: Item {
|
contentItem: Item {
|
||||||
|
|
@ -84,6 +73,7 @@ Controls.Control {
|
||||||
width: root.cellWidth
|
width: root.cellWidth
|
||||||
height: root.cellHeight
|
height: root.cellHeight
|
||||||
onYChanged: dragPositionChanged(Qt.point(x, y))
|
onYChanged: dragPositionChanged(Qt.point(x, y))
|
||||||
|
opacity: 1
|
||||||
|
|
||||||
visible: modelData !== null
|
visible: modelData !== null
|
||||||
}
|
}
|
||||||
|
|
@ -120,6 +110,7 @@ Controls.Control {
|
||||||
width: root.cellWidth
|
width: root.cellWidth
|
||||||
height: root.cellHeight
|
height: root.cellHeight
|
||||||
dragDelegate: dragDelegateItem
|
dragDelegate: dragDelegateItem
|
||||||
|
parent: index < favoriteStrip.count ? favoriteStrip.contentItem : applicationsFlow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,182 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2019 Marco Martin <mart@kde.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.4
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
import QtQuick.Controls 2.3 as Controls
|
|
||||||
|
|
||||||
import org.kde.plasma.plasmoid 2.0
|
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
|
||||||
import org.kde.kquickcontrolsaddons 2.0
|
|
||||||
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property alias availableCellHeight: launcherGrid.availableCellHeight
|
|
||||||
property alias contentY: mainFlickable.contentY
|
|
||||||
property alias contentHeight: mainFlickable.contentHeight
|
|
||||||
property alias topMargin: mainFlickable.topMargin
|
|
||||||
property int leftPadding
|
|
||||||
property int rightPadding
|
|
||||||
signal movementEnded
|
|
||||||
signal externalDragStarted
|
|
||||||
|
|
||||||
drag.filterChildren: true
|
|
||||||
|
|
||||||
onClicked: closeAnim.restart()
|
|
||||||
|
|
||||||
//BEGIN functions
|
|
||||||
//Autoscroll related functions
|
|
||||||
function scrollUp() {
|
|
||||||
autoScrollTimer.scrollDown = false;
|
|
||||||
autoScrollTimer.running = true;
|
|
||||||
scrollUpIndicator.opacity = 1;
|
|
||||||
scrollDownIndicator.opacity = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function scrollDown() {
|
|
||||||
autoScrollTimer.scrollDown = true;
|
|
||||||
autoScrollTimer.running = true;
|
|
||||||
scrollUpIndicator.opacity = 0;
|
|
||||||
scrollDownIndicator.opacity = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopScroll() {
|
|
||||||
autoScrollTimer.running = false;
|
|
||||||
scrollUpIndicator.opacity = 0;
|
|
||||||
scrollDownIndicator.opacity = 0;
|
|
||||||
}
|
|
||||||
//END functions
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: autoScrollTimer
|
|
||||||
property bool scrollDown: true
|
|
||||||
repeat: true
|
|
||||||
interval: 1500
|
|
||||||
onTriggered: {
|
|
||||||
//reordering launcher icons
|
|
||||||
if (launcherGrid.reorderingApps) {
|
|
||||||
scrollAnim.to = scrollDown ?
|
|
||||||
//Scroll down
|
|
||||||
Math.min(mainFlickable.contentItem.height - root.height, mainFlickable.contentY + root.height/2) :
|
|
||||||
//Scroll up
|
|
||||||
Math.max(0, mainFlickable.contentY - root.height/2);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
stopScroll();
|
|
||||||
}
|
|
||||||
scrollAnim.running = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NumberAnimation {
|
|
||||||
id: scrollAnim
|
|
||||||
target: mainFlickable
|
|
||||||
property: "contentY"
|
|
||||||
duration: units.longDuration
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.Svg {
|
|
||||||
id: arrowsSvg
|
|
||||||
imagePath: "widgets/arrows"
|
|
||||||
}
|
|
||||||
PlasmaCore.SvgItem {
|
|
||||||
id: scrollUpIndicator
|
|
||||||
anchors {
|
|
||||||
horizontalCenter: parent.horizontalCenter
|
|
||||||
top: parent.top
|
|
||||||
topMargin: 300
|
|
||||||
}
|
|
||||||
z: 2
|
|
||||||
opacity: 0
|
|
||||||
svg: arrowsSvg
|
|
||||||
elementId: "up-arrow"
|
|
||||||
width: units.iconSizes.large
|
|
||||||
height: width
|
|
||||||
Behavior on opacity {
|
|
||||||
OpacityAnimator {
|
|
||||||
duration: 1000
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlasmaCore.SvgItem {
|
|
||||||
id: scrollDownIndicator
|
|
||||||
anchors {
|
|
||||||
horizontalCenter: parent.horizontalCenter
|
|
||||||
bottom: parent.bottom
|
|
||||||
bottomMargin: units.gridUnit * 2
|
|
||||||
}
|
|
||||||
z: 2
|
|
||||||
opacity: 0
|
|
||||||
svg: arrowsSvg
|
|
||||||
elementId: "down-arrow"
|
|
||||||
width: units.iconSizes.large
|
|
||||||
height: width
|
|
||||||
Behavior on opacity {
|
|
||||||
OpacityAnimator {
|
|
||||||
duration: 1000
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Flickable {
|
|
||||||
id: mainFlickable
|
|
||||||
anchors{
|
|
||||||
fill: parent
|
|
||||||
leftMargin: root.leftPadding
|
|
||||||
rightMargin: root.rightPadding
|
|
||||||
}
|
|
||||||
contentWidth: width
|
|
||||||
contentHeight: launcherGrid.height
|
|
||||||
onMovementEnded: root.movementEnded();
|
|
||||||
onFlickEnded: root.movementEnded();
|
|
||||||
LauncherGrid {
|
|
||||||
id: launcherGrid
|
|
||||||
width: parent.width
|
|
||||||
onExternalDragStarted: root.externalDragStarted()
|
|
||||||
onDragPositionChanged: {
|
|
||||||
pos = mapToItem(root, pos.x, pos.y);
|
|
||||||
|
|
||||||
if (pos.y < root.height /3) {
|
|
||||||
scrollUp();
|
|
||||||
} else if (pos.y > root.height / 3 * 2) {
|
|
||||||
scrollDown();
|
|
||||||
} else {
|
|
||||||
stopScroll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents.ScrollBar {
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
right: parent.right
|
|
||||||
bottom: parent.bottom
|
|
||||||
topMargin: Math.max(0, -mainFlickable.contentY) + units.smallSpacing*2
|
|
||||||
rightMargin: root.rightPadding + units.smallSpacing * 2
|
|
||||||
}
|
|
||||||
interactive: false
|
|
||||||
flickableItem: mainFlickable
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -37,11 +37,36 @@ Item {
|
||||||
|
|
||||||
property Item toolBox
|
property Item toolBox
|
||||||
|
|
||||||
DragDrop.DropArea {
|
Text {
|
||||||
|
text:"Edit Mode"
|
||||||
|
color: "white"
|
||||||
|
visible: plasmoid.editMode
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: plasmoid
|
||||||
|
onEditModeChanged: {
|
||||||
|
appletsLayout.editMode = plasmoid.editMode
|
||||||
|
if (plasmoid.editMode) {
|
||||||
|
menuRepeater.freeLayout();
|
||||||
|
} else {
|
||||||
|
menuRepeater.relayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Flickable {
|
||||||
|
id: mainFlickable
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
//TODO type safety?
|
bottomMargin: favoriteStrip.height
|
||||||
property Item appletsArea
|
contentWidth: width
|
||||||
|
contentHeight: appletsLayout.height
|
||||||
|
interactive: !plasmoid.editMode
|
||||||
|
|
||||||
|
DragDrop.DropArea {
|
||||||
|
width: parent.width
|
||||||
|
height: mainFlickable.height + launcher.height
|
||||||
|
|
||||||
onDragEnter: {
|
onDragEnter: {
|
||||||
event.accept(event.proposedAction);
|
event.accept(event.proposedAction);
|
||||||
}
|
}
|
||||||
|
|
@ -67,33 +92,11 @@ Item {
|
||||||
appletsLayout.hidePlaceHolder();
|
appletsLayout.hidePlaceHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
|
||||||
text:"Edit Mode"
|
|
||||||
color: "white"
|
|
||||||
visible: plasmoid.editMode
|
|
||||||
}
|
|
||||||
Connections {
|
|
||||||
target: plasmoid
|
|
||||||
onEditModeChanged: {
|
|
||||||
appletsLayout.editMode = plasmoid.editMode
|
|
||||||
if (plasmoid.editMode) {
|
|
||||||
menuRepeater.freeLayout();
|
|
||||||
} else {
|
|
||||||
menuRepeater.relayout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Flickable {
|
|
||||||
anchors.fill: parent
|
|
||||||
contentWidth: width
|
|
||||||
contentHeight: appletsLayout.height
|
|
||||||
interactive: !plasmoid.editMode
|
|
||||||
|
|
||||||
ContainmentLayoutManager.AppletsLayout {
|
ContainmentLayoutManager.AppletsLayout {
|
||||||
id: appletsLayout
|
id: appletsLayout
|
||||||
width: parent.width
|
|
||||||
height: 500 + launcher.height
|
anchors.fill: parent
|
||||||
|
|
||||||
configKey: width > height ? "ItemGeometries" : "ItemGeometriesVertical"
|
configKey: width > height ? "ItemGeometries" : "ItemGeometriesVertical"
|
||||||
containment: plasmoid
|
containment: plasmoid
|
||||||
editModeCondition: plasmoid.immutable
|
editModeCondition: plasmoid.immutable
|
||||||
|
|
@ -131,6 +134,7 @@ Text {
|
||||||
|
|
||||||
Launcher.LauncherGrid {
|
Launcher.LauncherGrid {
|
||||||
id: launcher
|
id: launcher
|
||||||
|
favoriteStrip: favoriteStrip
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
|
|
@ -139,9 +143,15 @@ Text {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Controls.Button {
|
}
|
||||||
text: "load"
|
Launcher.FavoriteStrip {
|
||||||
onClicked: menuRepeater.model = plasmoid.nativeInterface.applicationListModel
|
id: favoriteStrip
|
||||||
|
launcherGrid: launcher
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue