FolderViewDialog.qml 2.75 KB
Newer Older
1
2
3
4
5
/*
    SPDX-FileCopyrightText: 2014-2015 Eike Hein <hein@kde.org>

    SPDX-License-Identifier: GPL-2.0-or-later
*/
6
7
8
9
10
11

import QtQuick 2.0
import org.kde.plasma.plasmoid 2.0

import org.kde.plasma.core 2.0 as PlasmaCore

12
import org.kde.private.desktopcontainment.folder 0.1 as Folder
Eike Hein's avatar
Eike Hein committed
13
14

Folder.SubDialog {
15
16
17
18
    id: dialog

    visible: false

19
20
21
22
23
24
25
26
27
28
29
30
    property bool containsDrag: {
        if (folderViewDropArea.containsDrag) {
            return true;
        }

        if (folderView.hoveredItem && folderView.hoveredItem.popupDialog) {
            return folderView.hoveredItem.popupDialog.containsDrag;
        }

        return false;
    }

Bhushan Shah's avatar
Bhushan Shah committed
31
    property QtObject closeTimer: closeTimer
32
33
    property QtObject childDialog: (folderView.hoveredItem != null) ? folderView.hoveredItem.popupDialog : null
    property bool containsMouse: folderView.containsMouse || (childDialog != null && childDialog.containsMouse)
34

35
    property alias url: folderView.url
36
37
38
39
40
41
42
43
44
45
46
47

    location: PlasmaCore.Types.Floating
    hideOnWindowDeactivate: (childDialog == null)

    onContainsMouseChanged: {
        if (containsMouse) {
            closeTimer.stop();
        } else {
            closeTimer.start();
        }
    }

48
49
50
    mainItem: FolderViewDropArea {
        id: folderViewDropArea

51
        width: folderView.cellWidth * 3 + PlasmaCore.Units.gridUnit // FIXME HACK: Use actual scrollbar width.
52
53
54
55
56
57
        height: folderView.cellHeight * 2

        folderView: folderView

        FolderView {
            id: folderView
58

59
            anchors.fill: parent
60

61
            isRootView: false
62
            dialog: dialog
63

64
            locked: true
65

66
            sortMode: ((plasmoid.configuration.sortMode === 0) ? 1 : plasmoid.configuration.sortMode)
67
            filterMode: 0
68

69
70
71
72
            // TODO: Bidi.
            flow:  GridView.FlowLeftToRight
            layoutDirection: Qt.LeftToRight

73
74
            onDragInProgressAnywhereChanged: {
                if (!dragInProgressAnywhere && !dialog.visible) {
75
76
77
78
                    dialog.destroy();
                }
            }
        }
79
80
81
82
83
84
    }

    data: [
        Timer {
            id: closeTimer

85
            interval: PlasmaCore.Units.longDuration * 2
86
87
88

            onTriggered: {
                if (childDialog != null) {
89
90
                    childDialog.closeTimer.stop();
                    childDialog.visible = false;
91
92
                }

93
94
                dialog.visible = false;
                delayedDestroy();
95
96
97
98
            }
        }
    ]

99
    function requestDestroy() {
100
        if (folderView.dragInProgressAnywhere) {
101
102
103
104
105
106
            visible = false;
        } else {
            destroy();
        }
    }

107
    function delayedDestroy() {
108
109
110
        Qt.callLater(function() {
            itemDialog.destroy();
        });
111
112
    }

113
114
115
116
    Component.onDestruction: {
        closeTimer.stop();
    }
}