ClipContextMenu.qml 2.49 KB
Newer Older
luyikei's avatar
luyikei committed
1 2
import QtQuick 2.0
import QtQuick.Controls 1.4
luyikei's avatar
luyikei committed
3
import QtQuick.Dialogs 1.2
luyikei's avatar
luyikei committed
4 5 6 7 8

Menu {
    id: clipContextMenu
    title: "Edit"

9
    property var clip
10
    property bool grouped
11
    property bool linked
luyikei's avatar
luyikei committed
12 13

    MenuItem {
14
        text: grouped ? "Ungroup" : "Group"
luyikei's avatar
luyikei committed
15

luyikei's avatar
luyikei committed
16 17 18
        onTriggered: {
            if ( selectedClips.length <= 1 )
                return;
luyikei's avatar
luyikei committed
19

20
            if ( grouped === true ) {
21
                removeGroup( clip.uuid );
luyikei's avatar
luyikei committed
22 23 24 25
            }
            else {
                var l = [];
                for ( var i = 0; i < selectedClips.length; ++i ) {
26
                    l.push( "" + selectedClips[i] );
luyikei's avatar
luyikei committed
27 28 29
                }
                addGroup( l );
            }
luyikei's avatar
luyikei committed
30 31
        }
    }
32

33
    MenuItem {
34
        id: linkOrUnlink
35
        text: linked ? "Unlink" : "Link"
36 37

        onTriggered: {
38
            if ( linked === true ) {
39
                for ( var i = 0; i < selectedClips.length; ++i ) {
40
                    for ( var j = i + 1; j < selectedClips.length; ++j ) {
41 42
                        if ( findClipItem( selectedClips[i] ).linkedClips.indexOf( selectedClips[j] ) !== -1 )
                            workflow.unlinkClips( selectedClips[i], selectedClips[j] );
43 44 45 46 47 48
                    }
                }
            }
            else {
                for ( i = 0; i < selectedClips.length; ++i ) {
                    for ( j = i + 1; j < selectedClips.length; ++j ) {
49 50
                        if (findClipItem( selectedClips[i] ).linkedClips.indexOf( selectedClips[j] ) === -1 )
                            workflow.linkClips( selectedClips[i], selectedClips[j] );
51 52 53
                    }
                }
            }
54 55 56
        }
    }

luyikei's avatar
luyikei committed
57 58 59 60 61 62
    MenuSeparator { }

    MenuItem {
        text: "Delete"

        onTriggered: {
63 64 65 66
            if ( selectedClips.length > 0 )
                removeSelectedClipsDialog.visible = true;
            else
                removeClipDialog.visible = true;
luyikei's avatar
luyikei committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80
        }
    }

    MessageDialog {
        id: removeClipDialog
        title: "VLMC"
        text: qsTr( "Do you really want to remove the clip?" )
        icon: StandardIcon.Question
        standardButtons: StandardButton.Yes | StandardButton.No
        onYes: {
            workflow.removeClip( clip.uuid );
        }
    }

81
    onAboutToShow: {
82
        linked = clip.linked();
83
        grouped = findGroup( clip.uuid );
84
        linkOrUnlink.enabled = selectedClips.length > 1
85
    }
86 87 88 89 90 91 92

    MenuSeparator { }

    MenuItem {
        text: "Effects"

        onTriggered: {
93
            workflow.showEffectStack( clip.uuid );
94 95
        }
    }
luyikei's avatar
luyikei committed
96
}