[vlmc-devel] Implement MarkerContextMenu

Yikai Lu git at videolan.org
Sat Jul 23 17:12:28 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sun Jul 24 00:06:32 2016 +0900| [d54a0fef65b791f6b07c37260ed004ba18fdad9e] | committer: Yikai Lu

Implement MarkerContextMenu

> https://code.videolan.org/videolan/vlmc/commit/d54a0fef65b791f6b07c37260ed004ba18fdad9e
---

 src/Gui/timeline/Marker.qml             | 12 ++++++++++++
 src/Gui/timeline/MarkerContextMenu.qml  | 29 +++++++++++++++++++++++++++++
 src/Gui/timeline/main.qml               | 18 ++++++++++++++++++
 src/Gui/timeline/resources-timeline.qrc |  1 +
 4 files changed, 60 insertions(+)

diff --git a/src/Gui/timeline/Marker.qml b/src/Gui/timeline/Marker.qml
index 443c0ce..a0a9947 100644
--- a/src/Gui/timeline/Marker.qml
+++ b/src/Gui/timeline/Marker.qml
@@ -34,6 +34,18 @@ Rectangle {
             drag.target: marker
             drag.axis: Drag.XAxis
             drag.minimumX: 0
+            acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+            onClicked: {
+                if ( mouse.button & Qt.RightButton ) {
+                    markerContextMenu.popup();
+                }
+            }
+        }
+
+        MarkerContextMenu {
+            id: markerContextMenu
+            marker: marker
         }
     }
 }
diff --git a/src/Gui/timeline/MarkerContextMenu.qml b/src/Gui/timeline/MarkerContextMenu.qml
new file mode 100644
index 0000000..2d013ce
--- /dev/null
+++ b/src/Gui/timeline/MarkerContextMenu.qml
@@ -0,0 +1,29 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.4
+import QtQuick.Dialogs 1.2
+
+Menu {
+    id: markerContextMenu
+    title: "Edit"
+
+    property var marker
+
+    MenuItem {
+        text: "Delete"
+
+        onTriggered: {
+            removeMarkerDialog.visible = true;
+        }
+    }
+
+    MessageDialog {
+        id: removeMarkerDialog
+        title: "VLMC"
+        text: qsTr( "Do you really want to remove the marker?" )
+        icon: StandardIcon.Question
+        standardButtons: StandardButton.Yes | StandardButton.No
+        onYes: {
+            removeMarker( marker.position );
+        }
+    }
+}
diff --git a/src/Gui/timeline/main.qml b/src/Gui/timeline/main.qml
index 9f7ac9f..d3e03a4 100644
--- a/src/Gui/timeline/main.qml
+++ b/src/Gui/timeline/main.qml
@@ -203,6 +203,24 @@ Rectangle {
                        } );
     }
 
+    function findMarker( pos ) {
+        for ( var i = 0; i < markers.count; ++i ) {
+            if ( markers.get( i )["position"] === pos ) {
+                return markers.get( i );
+            }
+        }
+        return null;
+    }
+
+    function removeMarker( pos ) {
+        for ( var i = 0; i < markers.count; ++i ) {
+            if ( markers.get( i )["position"] === pos ) {
+                markers.remove( i );
+                return;
+            }
+        }
+    }
+
     function addGroup( clips ) {
         groups.push( clips );
     }
diff --git a/src/Gui/timeline/resources-timeline.qrc b/src/Gui/timeline/resources-timeline.qrc
index 6cfaf4f..4caecdf 100644
--- a/src/Gui/timeline/resources-timeline.qrc
+++ b/src/Gui/timeline/resources-timeline.qrc
@@ -9,5 +9,6 @@
         <file>Clip.qml</file>
         <file>ClipContextMenu.qml</file>
         <file>PropertyButton.qml</file>
+        <file>MarkerContextMenu.qml</file>
     </qresource>
 </RCC>



More information about the Vlmc-devel mailing list