Created
April 24, 2018 06:22
-
-
Save MurphyMc/5784a91b5304263dd33193612327aafc to your computer and use it in GitHub Desktop.
Patch git-cola so that clicking icon toggles staged/unstaged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/orig.status.py b/usr/share/git-cola/lib/cola/widgets/status.py | |
| index 4761228..852c057 100644 | |
| --- a/orig.status.py | |
| +++ b/usr/share/git-cola/lib/cola/widgets/status.py | |
| @@ -786,6 +786,23 @@ class StatusTreeWidget(QtWidgets.QTreeWidget): | |
| """Called when an item is double-clicked in the repo status tree.""" | |
| cmds.do(cmds.StageOrUnstage) | |
| + def mousePressEvent(self, event): | |
| + """Handle clicks on icon""" | |
| + item = self.itemAt(event.pos()) | |
| + is_dir = item.text(0).endswith("/") # Must be better way | |
| + item_rect = self.visualItemRect(item) | |
| + rect = QtCore.QRect() | |
| + rect.setTopLeft(item_rect.topLeft()) | |
| + # Assume icon area is the entire height and width==height | |
| + rect.setHeight(item_rect.height()) | |
| + rect.setWidth(rect.height()) | |
| + if rect.contains(event.pos()) and not is_dir: | |
| + # Clicked icon -- simulate double-click | |
| + self.setCurrentItem(item) | |
| + self.double_clicked(item, 0) | |
| + else: | |
| + return super().mousePressEvent(event) | |
| + | |
| def show_selection(self): | |
| """Show the selected item.""" | |
| # Sync the selection model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment