2015-02-25 18:26:04 +00:00
|
|
|
/*
|
2019-09-04 16:39:31 +00:00
|
|
|
* Copyright 2019 Marco Martin <mart@kde.org>
|
2015-02-25 18:26:04 +00:00
|
|
|
*
|
2019-09-04 16:39:31 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2 or
|
|
|
|
|
* (at your option) any later version.
|
2015-02-25 18:26:04 +00:00
|
|
|
*
|
2019-09-04 16:39:31 +00:00
|
|
|
* 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 Library General Public License for more details
|
2015-02-25 18:26:04 +00:00
|
|
|
*
|
2019-09-04 16:39:31 +00:00
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2015-02-25 18:26:04 +00:00
|
|
|
*/
|
|
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
import QtQuick 2.12
|
2015-02-25 18:38:34 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
2019-09-04 16:39:31 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
2015-02-25 18:26:04 +00:00
|
|
|
|
|
|
|
|
import org.kde.plasma.plasmoid 2.0
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2019-09-04 16:39:31 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
|
|
|
|
import org.kde.draganddrop 2.0 as DragDrop
|
2015-02-25 18:26:04 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
import "launcher" as Launcher
|
|
|
|
|
|
|
|
|
|
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
|
|
|
|
|
|
|
|
|
|
import org.kde.phone.homescreen 1.0
|
2015-03-11 10:50:00 +00:00
|
|
|
|
2015-06-19 20:03:02 +00:00
|
|
|
Item {
|
2015-02-25 18:26:04 +00:00
|
|
|
id: root
|
2019-09-04 16:39:31 +00:00
|
|
|
width: 640
|
|
|
|
|
height: 480
|
2015-02-25 18:26:04 +00:00
|
|
|
|
|
|
|
|
property Item toolBox
|
|
|
|
|
|
2015-06-20 23:08:46 +00:00
|
|
|
//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;
|
|
|
|
|
}
|
2015-07-09 11:29:26 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
function recalculateMaxFavoriteCount() {
|
|
|
|
|
if (!componentComplete) {
|
|
|
|
|
return;
|
2015-10-15 13:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
plasmoid.nativeInterface.applicationListModel.maxFavoriteCount = Math.floor(Math.min(width, height) / launcher.cellWidth);
|
2015-06-20 23:08:46 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
//END functions
|
2015-06-20 23:08:46 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
|
|
|
|
|
property bool componentComplete: false
|
|
|
|
|
onWidthChanged: recalculateMaxFavoriteCount()
|
|
|
|
|
onHeightChanged:recalculateMaxFavoriteCount()
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
componentComplete = true;
|
|
|
|
|
recalculateMaxFavoriteCount()
|
2015-03-05 12:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-05 20:12:23 +00:00
|
|
|
Timer {
|
|
|
|
|
id: autoScrollTimer
|
|
|
|
|
property bool scrollDown: true
|
|
|
|
|
repeat: true
|
2015-04-11 09:26:55 +00:00
|
|
|
interval: 1500
|
|
|
|
|
onTriggered: {
|
2019-09-04 16:39:31 +00:00
|
|
|
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);
|
|
|
|
|
|
2015-04-11 09:26:55 +00:00
|
|
|
scrollAnim.running = true;
|
2015-03-05 20:12:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-02-25 18:26:04 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
Connections {
|
|
|
|
|
target: plasmoid
|
|
|
|
|
onEditModeChanged: {
|
|
|
|
|
appletsLayout.editMode = plasmoid.editMode
|
2015-02-25 18:26:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
FeedbackWindow {
|
|
|
|
|
id: feedbackWindow
|
|
|
|
|
}
|
2015-06-10 23:43:10 +00:00
|
|
|
SequentialAnimation {
|
|
|
|
|
id: clickFedbackAnimation
|
|
|
|
|
property Item target
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
target: clickFedbackAnimation.target
|
|
|
|
|
properties: "scale"
|
|
|
|
|
to: 2
|
|
|
|
|
duration: units.longDuration
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
PauseAnimation {
|
|
|
|
|
duration: units.shortDuration
|
|
|
|
|
}
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
target: clickFedbackAnimation.target
|
|
|
|
|
properties: "scale"
|
|
|
|
|
to: 1
|
|
|
|
|
duration: units.longDuration
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
2015-04-10 21:59:52 +00:00
|
|
|
}
|
2015-06-20 23:08:46 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
Launcher.LauncherDragManager {
|
|
|
|
|
id: launcherDragManager
|
2015-02-25 18:26:04 +00:00
|
|
|
anchors.fill: parent
|
2019-09-04 16:39:31 +00:00
|
|
|
z: 2
|
|
|
|
|
appletsLayout: appletsLayout
|
|
|
|
|
launcherGrid: launcher
|
|
|
|
|
favoriteStrip: favoriteStrip
|
|
|
|
|
}
|
2015-07-08 16:30:15 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
Flickable {
|
|
|
|
|
id: mainFlickable
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors {
|
|
|
|
|
fill: parent
|
2020-02-05 19:25:52 +00:00
|
|
|
topMargin: plasmoid.availableScreenRect.y
|
2019-09-04 16:39:31 +00:00
|
|
|
bottomMargin: plasmoid.screenGeometry.height - plasmoid.availableScreenRect.height - plasmoid.availableScreenRect.y
|
2015-03-18 14:45:48 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|
|
|
|
|
bottomMargin: favoriteStrip.height
|
|
|
|
|
contentWidth: width
|
|
|
|
|
contentHeight: flickableContents.height
|
|
|
|
|
interactive: !plasmoid.editMode && !launcherDragManager.active
|
|
|
|
|
|
|
|
|
|
PlasmaComponents.ScrollBar.vertical: PlasmaComponents.ScrollBar {
|
|
|
|
|
id: scrollabr
|
|
|
|
|
opacity: mainFlickable.moving
|
|
|
|
|
interactive: false
|
|
|
|
|
Behavior on opacity {
|
|
|
|
|
OpacityAnimator {
|
|
|
|
|
duration: units.longDuration * 2
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
2015-06-19 20:03:02 +00:00
|
|
|
}
|
2015-04-11 09:26:55 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
NumberAnimation {
|
|
|
|
|
id: scrollAnim
|
|
|
|
|
target: mainFlickable
|
|
|
|
|
properties: "contentY"
|
|
|
|
|
duration: units.longDuration
|
|
|
|
|
easing.type: Easing.InOutQuad
|
2015-04-11 09:26:55 +00:00
|
|
|
}
|
2015-06-19 20:03:02 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
Column {
|
|
|
|
|
id: flickableContents
|
|
|
|
|
width: mainFlickable.width
|
2019-10-11 09:49:18 +00:00
|
|
|
spacing: Math.max(0, favoriteStrip.frame.height + favoriteStrip.anchors.bottomMargin - mainFlickable.contentY)
|
2015-04-11 09:26:55 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
DragDrop.DropArea {
|
|
|
|
|
anchors {
|
|
|
|
|
left: parent.left
|
|
|
|
|
right: parent.right
|
|
|
|
|
}
|
|
|
|
|
height: mainFlickable.height - favoriteStrip.frame.height //TODO: multiple widgets pages
|
2015-06-19 20:03:02 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
onDragEnter: {
|
|
|
|
|
event.accept(event.proposedAction);
|
|
|
|
|
}
|
|
|
|
|
onDragMove: {
|
|
|
|
|
appletsLayout.showPlaceHolderAt(
|
|
|
|
|
Qt.rect(event.x - appletsLayout.defaultItemWidth / 2,
|
|
|
|
|
event.y - appletsLayout.defaultItemHeight / 2,
|
|
|
|
|
appletsLayout.defaultItemWidth,
|
|
|
|
|
appletsLayout.defaultItemHeight)
|
|
|
|
|
);
|
|
|
|
|
}
|
2015-04-10 21:59:52 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
onDragLeave: {
|
|
|
|
|
appletsLayout.hidePlaceHolder();
|
2015-06-19 20:03:02 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|
|
|
|
|
preventStealing: true
|
|
|
|
|
|
|
|
|
|
onDrop: {
|
|
|
|
|
plasmoid.processMimeData(event.mimeData,
|
|
|
|
|
event.x - appletsLayout.placeHolder.width / 2, event.y - appletsLayout.placeHolder.height / 2);
|
|
|
|
|
event.accept(event.proposedAction);
|
|
|
|
|
appletsLayout.hidePlaceHolder();
|
2015-06-19 20:03:02 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|
|
|
|
|
PlasmaCore.Svg {
|
|
|
|
|
id: arrowsSvg
|
|
|
|
|
imagePath: "widgets/arrows"
|
|
|
|
|
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
2015-06-19 20:03:02 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
PlasmaCore.IconItem {
|
|
|
|
|
z: 9
|
|
|
|
|
anchors {
|
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
|
bottom: parent.bottom
|
2015-04-11 10:40:54 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
source: "arrow-up"
|
|
|
|
|
width: units.iconSizes.medium
|
|
|
|
|
height: width
|
|
|
|
|
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
2015-06-19 20:03:02 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
MouseArea {
|
|
|
|
|
anchors {
|
|
|
|
|
fill: parent
|
|
|
|
|
margins: -units.smallSpacing
|
2015-06-19 20:03:02 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
onClicked: mainFlickable.flick(0, -mainFlickable.height)
|
2015-06-19 20:03:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-02-25 18:38:34 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
ContainmentLayoutManager.AppletsLayout {
|
|
|
|
|
id: appletsLayout
|
2015-03-05 20:12:23 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
anchors.fill: parent
|
2015-03-05 15:53:58 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
cellWidth: Math.floor(width / launcher.columns)
|
|
|
|
|
cellHeight: launcher.cellHeight
|
2015-03-11 12:10:43 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
configKey: width > height ? "ItemGeometriesHorizontal" : "ItemGeometriesVertical"
|
|
|
|
|
containment: plasmoid
|
|
|
|
|
editModeCondition: plasmoid.immutable
|
|
|
|
|
? ContainmentLayoutManager.AppletsLayout.Manual
|
|
|
|
|
: ContainmentLayoutManager.AppletsLayout.AfterPressAndHold
|
|
|
|
|
|
|
|
|
|
// Sets the containment in edit mode when we go in edit mode as well
|
|
|
|
|
onEditModeChanged: plasmoid.editMode = editMode
|
|
|
|
|
|
|
|
|
|
minimumItemWidth: units.gridUnit * 3
|
|
|
|
|
minimumItemHeight: minimumItemWidth
|
|
|
|
|
|
|
|
|
|
defaultItemWidth: units.gridUnit * 6
|
|
|
|
|
defaultItemHeight: defaultItemWidth
|
|
|
|
|
|
|
|
|
|
//cellWidth: units.iconSizes.small
|
|
|
|
|
//cellHeight: cellWidth
|
|
|
|
|
|
|
|
|
|
acceptsAppletCallback: function(applet, x, y) {
|
|
|
|
|
print("Applet: "+applet+" "+x+" "+y)
|
|
|
|
|
return true;
|
2015-06-19 20:03:02 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|
|
|
|
|
appletContainerComponent: ContainmentLayoutManager.BasicAppletContainer {
|
|
|
|
|
id: appletContainer
|
|
|
|
|
configOverlayComponent: ConfigOverlay {}
|
|
|
|
|
|
|
|
|
|
onEditModeChanged: {
|
|
|
|
|
launcherDragManager.active = dragActive || editMode;
|
|
|
|
|
}
|
|
|
|
|
onDragActiveChanged: {
|
|
|
|
|
launcherDragManager.active = dragActive || editMode;
|
|
|
|
|
}
|
2015-04-11 10:59:52 +00:00
|
|
|
}
|
2015-02-25 18:26:04 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
placeHolder: ContainmentLayoutManager.PlaceHolder {}
|
2015-06-19 20:03:02 +00:00
|
|
|
}
|
2015-02-25 18:26:04 +00:00
|
|
|
}
|
2015-03-13 13:58:18 +00:00
|
|
|
|
2019-09-04 16:39:31 +00:00
|
|
|
Launcher.LauncherGrid {
|
|
|
|
|
id: launcher
|
2015-06-19 20:03:02 +00:00
|
|
|
anchors {
|
2019-09-04 16:39:31 +00:00
|
|
|
left: parent.left
|
2016-01-25 12:47:07 +00:00
|
|
|
right: parent.right
|
2015-03-05 16:28:24 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|
|
|
|
|
favoriteStrip: favoriteStrip
|
|
|
|
|
appletsLayout: appletsLayout
|
2015-03-05 16:28:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-02-25 18:26:04 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|
|
|
|
|
ScrollIndicator {
|
|
|
|
|
id: scrollUpIndicator
|
|
|
|
|
anchors {
|
|
|
|
|
top: parent.top
|
|
|
|
|
topMargin: units.gridUnit * 2
|
|
|
|
|
}
|
|
|
|
|
elementId: "up-arrow"
|
|
|
|
|
}
|
|
|
|
|
ScrollIndicator {
|
|
|
|
|
id: scrollDownIndicator
|
|
|
|
|
anchors {
|
|
|
|
|
bottom: favoriteStrip.top
|
|
|
|
|
bottomMargin: units.gridUnit
|
|
|
|
|
}
|
|
|
|
|
elementId: "down-arrow"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Launcher.FavoriteStrip {
|
|
|
|
|
id: favoriteStrip
|
|
|
|
|
anchors {
|
|
|
|
|
left: parent.left
|
|
|
|
|
right: parent.right
|
|
|
|
|
bottom: parent.bottom
|
|
|
|
|
bottomMargin: plasmoid.screenGeometry.height - plasmoid.availableScreenRect.height - plasmoid.availableScreenRect.y
|
|
|
|
|
}
|
|
|
|
|
appletsLayout: appletsLayout
|
|
|
|
|
launcherGrid: launcher
|
|
|
|
|
//y: Math.max(krunner.inputHeight, root.height - height - mainFlickable.contentY)
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-05 19:25:52 +00:00
|
|
|
// KRunner {
|
|
|
|
|
// id: krunner
|
|
|
|
|
// z: 998
|
|
|
|
|
// height: plasmoid.availableScreenRect.height
|
|
|
|
|
// topPadding: plasmoid.availableScreenRect.y
|
|
|
|
|
// anchors {
|
|
|
|
|
// top: parent.top
|
|
|
|
|
// left: parent.left
|
|
|
|
|
// right: parent.right
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2015-06-20 21:45:19 +00:00
|
|
|
}
|
2019-09-04 16:39:31 +00:00
|
|
|
|