Navigation Menu

Skip to content

Commit

Permalink
status: add "Copy Leading Path to Clipboard"
Browse files Browse the repository at this point in the history
Closes #436
Suggested-by: V字龍 <Vdragon.Taiwan@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Sep 19, 2017
1 parent 647cf5b commit 858951d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cola/widgets/status.py
@@ -1,5 +1,6 @@
from __future__ import division, absolute_import, unicode_literals
import itertools
import os

from qtpy.QtCore import Qt
from qtpy.QtCore import Signal
Expand Down Expand Up @@ -176,6 +177,11 @@ def __init__(self, parent=None):
self.copy_relpath, hotkeys.CUT)
self.copy_relpath_action.setIcon(icons.copy())

self.copy_leading_path_action = qtutils.add_action(
self, N_('Copy Leading Path to Clipboard'),
self.copy_leading_path)
self.copy_leading_path_action.setIcon(icons.copy())

self.view_history_action = qtutils.add_action(
self, N_('View History...'), self.view_history, hotkeys.HISTORY)

Expand Down Expand Up @@ -556,6 +562,8 @@ def _create_staged_context_menu(self, menu, s):
menu.addSeparator()
menu.addAction(self.copy_path_action)
menu.addAction(self.copy_relpath_action)
menu.addAction(self.copy_leading_path_action)
menu.addSeparator()
menu.addAction(self.view_history_action)
menu.addAction(self.view_blame_action)
return menu
Expand All @@ -572,6 +580,8 @@ def _create_staged_submodule_context_menu(self, menu, s):

menu.addAction(self.copy_path_action)
menu.addAction(self.copy_relpath_action)
menu.addAction(self.copy_leading_path_action)
menu.addSeparator()
menu.addAction(self.view_history_action)
return menu

Expand Down Expand Up @@ -624,6 +634,8 @@ def _create_unstaged_context_menu(self, menu, s):
menu.addSeparator()
menu.addAction(self.copy_path_action)
menu.addAction(self.copy_relpath_action)
menu.addAction(self.copy_leading_path_action)
menu.addSeparator()
if not selection.selection_model().is_empty():
menu.addAction(self.view_history_action)
menu.addAction(self.view_blame_action)
Expand All @@ -642,6 +654,8 @@ def _create_modified_submodule_context_menu(self, menu, s):
menu.addSeparator()
menu.addAction(self.copy_path_action)
menu.addAction(self.copy_relpath_action)
menu.addAction(self.copy_leading_path_action)
menu.addSeparator()
menu.addAction(self.view_history_action)
return menu

Expand Down Expand Up @@ -878,6 +892,12 @@ def copy_relpath(self):
"""Copy a selected relative path to the clipboard"""
self.copy_path(absolute=False)

def copy_leading_path(self):
"""Copy the selected leading path to the clipboard"""
filename = selection.selection_model().filename()
dirname = os.path.dirname(filename)
qtutils.copy_path(dirname, absolute=False)

def _item_filter(self, item):
return not item.deleted and core.exists(item.path)

Expand Down
4 changes: 4 additions & 0 deletions share/doc/git-cola/relnotes.rst
Expand Up @@ -77,6 +77,10 @@ Usability, bells and whistles

https://github.com/git-cola/git-cola/issues/530

* The "Status" widget now has a "Copy Leading Path to Clipboard" action.

https://github.com/git-cola/git-cola/issues/436

Fixes
-----
* `git dag` now prevents nodes from overlapping in more situations.
Expand Down

0 comments on commit 858951d

Please sign in to comment.