You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
5.4 KiB
QML
174 lines
5.4 KiB
QML
8 years ago
|
/*
|
||
|
* Copyright 2013 by Sebastian Kügler <sebas@kde.org>
|
||
|
* Copyright 2014 by Martin Gräßlin <mgraesslin@kde.org>
|
||
|
* Copyright 2016 by Kai Uwe Broulik <kde@privat.broulik.de>
|
||
|
* Copyright 2017 by Roman Gilg <subdiff@gmail.com>
|
||
|
*
|
||
|
* 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.
|
||
|
*
|
||
|
* 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
|
||
|
*
|
||
|
* 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 2.010-1301, USA.
|
||
|
*/
|
||
|
|
||
|
import QtQuick 2.6
|
||
|
import QtQuick.Layouts 1.1
|
||
|
import QtGraphicalEffects 1.0
|
||
|
import QtQml.Models 2.2
|
||
|
|
||
8 years ago
|
import org.kde.draganddrop 2.0
|
||
|
|
||
8 years ago
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
||
|
import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons
|
||
|
|
||
|
import org.kde.taskmanager 0.1 as TaskManager
|
||
|
|
||
|
|
||
|
PlasmaExtras.ScrollArea {
|
||
8 years ago
|
id: mainToolTip
|
||
8 years ago
|
property Item parentTask
|
||
7 years ago
|
property var rootIndex
|
||
8 years ago
|
|
||
|
property string appName
|
||
|
property int pidParent
|
||
|
property bool isGroup
|
||
8 years ago
|
property bool hideCloseButtons
|
||
8 years ago
|
|
||
|
property var windows
|
||
|
readonly property bool isWin: windows !== undefined
|
||
|
|
||
|
property variant icon
|
||
|
property url launcherUrl
|
||
|
property bool isLauncher
|
||
|
property bool isMinimizedParent
|
||
|
|
||
|
// Needed for generateSubtext()
|
||
|
property string displayParent
|
||
|
property string genericName
|
||
6 years ago
|
property var virtualDesktopParent
|
||
8 years ago
|
property bool isOnAllVirtualDesktopsParent
|
||
|
property var activitiesParent
|
||
|
//
|
||
7 years ago
|
readonly property bool isVerticalPanel: plasmoid.formFactor === PlasmaCore.Types.Vertical
|
||
8 years ago
|
|
||
|
Layout.minimumWidth: contentItem.width
|
||
|
Layout.maximumWidth: Layout.minimumWidth
|
||
|
|
||
|
Layout.minimumHeight: contentItem.height
|
||
|
Layout.maximumHeight: Layout.minimumHeight
|
||
|
|
||
|
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
|
||
|
LayoutMirroring.childrenInherit: true
|
||
|
|
||
|
property int textWidth: theme.mSize(theme.defaultFont).width * 20
|
||
|
|
||
|
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
|
||
|
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
|
||
|
|
||
|
Component.onCompleted: {
|
||
|
flickableItem.interactive = Qt.binding(function() {
|
||
|
return isVerticalPanel ? contentItem.height > viewport.height : contentItem.width > viewport.width
|
||
|
});
|
||
|
}
|
||
7 years ago
|
|
||
8 years ago
|
Item{
|
||
8 years ago
|
width: contentItem.width
|
||
|
height: contentItem.height
|
||
8 years ago
|
|
||
7 years ago
|
//! DropArea
|
||
8 years ago
|
DropArea {
|
||
|
id: dropMainArea
|
||
7 years ago
|
anchors.fill: parent
|
||
8 years ago
|
enabled: isGroup
|
||
|
preventStealing: true
|
||
|
|
||
|
property QtObject currentWindow
|
||
|
|
||
|
onDragLeave: {
|
||
|
windowsPreviewDlg.hide();
|
||
|
}
|
||
|
|
||
|
onDragMove: {
|
||
7 years ago
|
var current = mainToolTip.instanceAtPos(event.x, event.y);
|
||
8 years ago
|
|
||
|
if (current && currentWindow !== current && current.submodelIndex) {
|
||
|
currentWindow = current;
|
||
|
tasksModel.requestActivate(current.submodelIndex);
|
||
|
}
|
||
|
}
|
||
7 years ago
|
} //! DropArea
|
||
8 years ago
|
|
||
7 years ago
|
Loader {
|
||
|
id: contentItem
|
||
|
active: mainToolTip.rootIndex !== undefined
|
||
|
asynchronous: true
|
||
|
sourceComponent: isGroup ? groupToolTip : singleTooltip
|
||
8 years ago
|
|
||
7 years ago
|
Component {
|
||
|
id: singleTooltip
|
||
8 years ago
|
|
||
7 years ago
|
ToolTipInstance {
|
||
|
submodelIndex: mainToolTip.rootIndex
|
||
|
}
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
7 years ago
|
Component {
|
||
|
id: groupToolTip
|
||
8 years ago
|
|
||
7 years ago
|
Grid {
|
||
|
rows: !isVerticalPanel
|
||
|
columns: isVerticalPanel
|
||
|
flow: isVerticalPanel ? Grid.TopToBottom : Grid.LeftToRight
|
||
|
spacing: units.largeSpacing
|
||
8 years ago
|
|
||
7 years ago
|
Repeater {
|
||
8 years ago
|
id: groupRepeater
|
||
|
model: DelegateModel {
|
||
7 years ago
|
model: mainToolTip.rootIndex ? tasksModel : null
|
||
|
rootIndex: mainToolTip.rootIndex
|
||
8 years ago
|
|
||
7 years ago
|
delegate: ToolTipInstance {
|
||
|
submodelIndex: tasksModel.makeModelIndex(mainToolTip.rootIndex.row, index)
|
||
|
}
|
||
8 years ago
|
}
|
||
8 years ago
|
}
|
||
|
}
|
||
7 years ago
|
}
|
||
|
} //! Loader
|
||
|
} //! Item
|
||
8 years ago
|
|
||
7 years ago
|
function instanceAtPos(x, y){
|
||
|
var previewInstances = isGroup ? contentItem.children[0].children : contentItem.children;
|
||
|
var instancesLength = previewInstances.length;
|
||
8 years ago
|
|
||
7 years ago
|
for(var i=0; i<instancesLength; ++i){
|
||
|
var instance = previewInstances[i];
|
||
|
var choords = contentItem.mapFromItem(instance,0, 0);
|
||
8 years ago
|
|
||
7 years ago
|
if(choords.y < 0)
|
||
|
choords.y = 0;
|
||
|
if(choords.x < 0)
|
||
|
choords.x = 0;
|
||
|
|
||
|
if( (x>=choords.x) && (x<=choords.x+instance.width)
|
||
|
&& (y>=choords.y) && (y<=choords.y+instance.height)){
|
||
|
return instance;
|
||
8 years ago
|
}
|
||
8 years ago
|
}
|
||
7 years ago
|
return null;
|
||
8 years ago
|
}
|
||
|
}
|
||
7 years ago
|
|
||
|
|