[kde-doc-english] [amarok] /: Offer move operation only if Shift is pressed.

Bart Cerneels bart.cerneels at kde.org
Mon May 21 11:58:33 UTC 2012


Git commit 7e4a8823537b94b131f7509e4089c7c79412f1a2 by Bart Cerneels.
Committed on 17/05/2012 at 22:00.
Pushed by shanachie into branch 'master'.

Offer move operation only if Shift is pressed.

Reasons:
- Limit number of context menu actions to keep it usuable.
- Copy is probably used 9 times out of 10.
- Move is destructive operation.

If discoverability is an issue we can add "(+Shift to move)" tooltip to the QAction.

GUI: Needs to be mentioned in the manual.

M  +1    -0    ChangeLog
M  +20   -11   src/browsers/CollectionTreeView.cpp

http://commits.kde.org/amarok/7e4a8823537b94b131f7509e4089c7c79412f1a2

diff --git a/ChangeLog b/ChangeLog
index e1fb213..6412f41 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,6 +48,7 @@ VERSION 2.6-Beta 1
       vice versa. (BR 142579)
 
   CHANGES:
+    * Only offer move action when Ctrl key is pressed in Collection context menu.
     * Remove context view video applet. Unmaintained and broken. (BR 242793)
     * Album cover images are written in background to prevent freezes. (BR 298332)
     * Make keyboard & mouse behaviour of saved playlists browser same as of the
diff --git a/src/browsers/CollectionTreeView.cpp b/src/browsers/CollectionTreeView.cpp
index cbc2ee5..ee6d890 100644
--- a/src/browsers/CollectionTreeView.cpp
+++ b/src/browsers/CollectionTreeView.cpp
@@ -276,20 +276,29 @@ CollectionTreeView::contextMenuEvent( QContextMenuEvent *event )
     m_currentMoveDestination = getMoveActions( indices );
     m_currentRemoveDestination = getRemoveActions( indices );
 
-    KMenu copyMenu( i18n( "Copy to Collection" ) );
-    if( !m_currentCopyDestination.empty() )
+    //offer move operation only if Shift is pressed. Rational: Move is destructive operation
+    if( event->modifiers().testFlag( Qt::ShiftModifier ) )
     {
-        copyMenu.setIcon( KIcon( "edit-copy" ) );
-        copyMenu.addActions( m_currentCopyDestination.keys() );
-        menu.addMenu( &copyMenu );
+        //TODO: subclass KMenu in order to show tooltip and respond to Shift key press
+        // during exec()
+        KMenu *moveMenu = new KMenu( i18n( "Move to Collection" ), &menu );
+        moveMenu->setToolTip( i18n("Press Shift key for move") );
+        if( !m_currentMoveDestination.empty() )
+        {
+            moveMenu->setIcon( KIcon( "go-jump" ) );
+            moveMenu->addActions( m_currentMoveDestination.keys() );
+            menu.addMenu( moveMenu );
+        }
     }
-
-    KMenu moveMenu( i18n( "Move to Collection" ) );
-    if( !m_currentMoveDestination.empty() )
+    else
     {
-        moveMenu.setIcon( KIcon( "go-jump" ) );
-        moveMenu.addActions( m_currentMoveDestination.keys() );
-        menu.addMenu( &moveMenu );
+        KMenu *copyMenu = new KMenu( i18n( "Copy to Collection" ), &menu );
+        if( !m_currentCopyDestination.empty() )
+        {
+            copyMenu->setIcon( KIcon( "edit-copy" ) );
+            copyMenu->addActions( m_currentCopyDestination.keys() );
+            menu.addMenu( copyMenu );
+        }
     }
 
     if( !m_currentRemoveDestination.empty() )



More information about the kde-doc-english mailing list