Skip to content

Commit

Permalink
hook up the title bar right click event
Browse files Browse the repository at this point in the history
  • Loading branch information
sccolbert committed Jun 17, 2013
1 parent 75f00a8 commit 812e97a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion enaml/qt/qt_dock_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def init_layout(self):
# Use a queued connection so the dock manager can finish
# closing the dock item before the signal handler runs.
widget.titleEdited.connect(self.on_title_edited)
widget.titleBarRightClicked.connect(self.on_title_bar_right_clicked)
widget.closed.connect(self.on_closed, Qt.QueuedConnection)

#--------------------------------------------------------------------------
Expand Down Expand Up @@ -113,6 +114,14 @@ def on_title_edited(self, text):
finally:
self._guard &= ~TITLE_GUARD

def on_title_bar_right_clicked(self, pos):
""" Handle the 'titleBarRightClicked' signal on the dock item.
"""
d = self.declaration
if d is not None:
d.title_bar_right_clicked()

def on_closed(self):
""" Handle the closed signal from the dock item.
Expand Down Expand Up @@ -164,7 +173,7 @@ def set_title_bar_visible(self, visible):
""" Set the visibility of the widget's title bar.
"""
self.widget.titleBarWidget().setForceHidden(not visible)
self.widget.setTitleBarForceHidden(not visible)

def set_icon(self, icon):
""" Set the icon on the underlying widget.
Expand Down
3 changes: 3 additions & 0 deletions enaml/widgets/dock_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class DockItem(Widget):
#: Whether or not the dock item is closable via a close button.
closable = d_(Bool(True))

#: An event emitted when the title bar is right clicked.
title_bar_right_clicked = d_(Event(), writable=False)

#: An event emitted when the dock item is closed. The item will be
#: destroyed after this event has completed.
closed = d_(Event(), writable=False)
Expand Down

0 comments on commit 812e97a

Please sign in to comment.