Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#: A signal emitted when the pin button is toggled. This
#: signal is proxied from the current dock item title bar.
pinButtonToggled = Signal(bool)
#: A signal emitted when the title is edited by the user. This
#: signal is proxied from the current dock item title bar.
titleEdited = Signal(str)
#: A signal emitted when the empty area is left double clicked.
#: This signal is proxied from the current dock item title bar.
titleBarLeftDoubleClicked = Signal(QPoint)
#: A signal emitted when the empty area is right clicked. This
#: signal is proxied from the current dock item title bar.
titleBarRightClicked = Signal(QPoint)
#: A signal emitted when the item is alerted. The payload is the
#: new alert level. An empty string indicates no alert.
alerted = Signal(str)
def __init__(self, parent=None):
""" Initialize a QDockItem.
Parameters
----------
parent : QWidget, optional
The parent of the dock item.
"""
super(QDockItem, self).__init__(parent)
layout = QDockItemLayout()
x = pos.x()
y = pos.y()
width = rect.width()
height = rect.height()
margins = self.resizeMargins()
extra = self.ResizeCornerExtra
if x < margins.left():
if y < margins.top() + extra:
mode = self.NorthWestBorder
offset = QPoint(x, y)
elif y > height - (margins.bottom() + extra):
mode = self.SouthWestBorder
offset = QPoint(x, height - y)
else:
mode = self.WestBorder
offset = QPoint(x, 0)
elif y < margins.top():
if x < margins.left() + extra:
mode = self.NorthWestBorder
offset = QPoint(x, y)
elif x > width - (margins.right() + extra):
mode = self.NorthEastBorder
offset = QPoint(width - x, y)
else:
mode = self.NorthBorder
offset = QPoint(0, y)
elif x > width - margins.right():
if y < margins.top() + extra:
mode = self.NorthEastBorder
offset = QPoint(width - x, y)
elif y > height - (margins.bottom() + extra):
mode = self.SouthEastBorder
if y < margins.top() + extra:
mode = self.NorthEastBorder
offset = QPoint(width - x, y)
elif y > height - (margins.bottom() + extra):
mode = self.SouthEastBorder
offset = QPoint(width - x, height - y)
else:
mode = self.EastBorder
offset = QPoint(width - x, 0)
elif y > height - margins.bottom():
if x < margins.left() + extra:
mode = self.SouthWestBorder
offset = QPoint(x, height - y)
elif x > width - (margins.right() + extra):
mode = self.SouthEastBorder
offset = QPoint(width - x, height - y)
else:
mode = self.SouthBorder
offset = QPoint(0, height - y)
else:
mode = self.NoBorder
offset = QPoint()
return mode, offset
""" A QDockFrame which holds a QDockItem instance.
A QDockContainer has a dynamic boolean property 'floating' which
can be used to apply custom stylesheet styling when the container
is a floating top level window versus docked in a dock area.
"""
#: A signal emitted when the container changes its toplevel state.
topLevelChanged = Signal(bool)
class FrameState(QDockFrame.FrameState):
""" A private class for managing container drag state.
"""
#: The original title bar press position.
press_pos = Typed(QPoint)
#: Whether or not the dock item is being dragged.
dragging = Bool(False)
#: Whether the dock item is maximized in the dock area.
item_is_maximized = Bool(False)
#: Whether or not the container is stored in a dock bar. This
#: value is manipulated directly by the QDockBarManager.
in_dock_bar = Bool(False)
def __init__(self, manager, parent=None):
""" Initialize a QDockContainer.
Parameters
----------
delta = QSize(0, delta.y())
elif p == QDockBar.East:
delta = QSize(-delta.x(), 0)
elif p == QDockBar.South:
delta = QSize(0, -delta.y())
else:
delta = QSize(delta.x(), 0)
user_size = self.size() + delta
user_size = user_size.expandedTo(self.minimumSize())
parent = self.parent()
if parent is not None:
user_size = user_size.boundedTo(parent.size())
self._user_size = user_size
if p == QDockBar.East or p == QDockBar.South:
d = user_size - self.size()
p = self.pos() - QPoint(d.width(), d.height())
self.setGeometry(QRect(p, user_size))
else:
self.resize(user_size)
Parameters
----------
window : QDockWindow
The dock window to close.
event : QCloseEvent
The close event passed to the event handler.
"""
area = window.dockArea()
if area is not None:
containers = list(iter_containers(area))
geometries = {}
for container in containers:
pos = container.mapToGlobal(QPoint(0, 0))
size = container.size()
geometries[container] = QRect(pos, size)
for container, ignored in area.dockBarContainers():
containers.append(container)
size = container.sizeHint()
geometries[container] = QRect(window.pos(), size)
for container in containers:
if not container.close():
container.unplug()
container.float()
container.setGeometry(geometries[container])
container.show()
self._free_window(window)
mode = self.NorthBorder
offset = QPoint(0, y)
elif x > width - margins.right():
if y < margins.top() + extra:
mode = self.NorthEastBorder
offset = QPoint(width - x, y)
elif y > height - (margins.bottom() + extra):
mode = self.SouthEastBorder
offset = QPoint(width - x, height - y)
else:
mode = self.EastBorder
offset = QPoint(width - x, 0)
elif y > height - margins.bottom():
if x < margins.left() + extra:
mode = self.SouthWestBorder
offset = QPoint(x, height - y)
elif x > width - (margins.right() + extra):
mode = self.SouthEastBorder
offset = QPoint(width - x, height - y)
else:
mode = self.SouthBorder
offset = QPoint(0, height - y)
else:
mode = self.NoBorder
offset = QPoint()
return mode, offset
The global coordinates of the target parent anchor.
"""
state = self._state
if state.anchor_mode == AnchorMode.Cursor:
origin = QCursor.pos()
size = QSize()
else:
parent = self.parent()
if parent is None:
desktop = QApplication.desktop()
geo = desktop.availableGeometry()
origin = geo.topLeft()
size = geo.size()
else:
origin = parent.mapToGlobal(QPoint(0, 0))
size = parent.size()
anchor = state.parent_anchor
px = int(anchor.x() * size.width())
py = int(anchor.y() * size.height())
return origin + QPoint(px, py)
hint = item.sizeHint().boundedTo(pane.size())
position = item.position()
if position == QDockBar.North:
start_pos = QPoint(0, -hint.height())
end_pos = QPoint(0, 0)
size = QSize(pane.width(), hint.height())
elif position == QDockBar.East:
start_pos = QPoint(pane.width(), 0)
end_pos = QPoint(pane.width() - hint.width(), 0)
size = QSize(hint.width(), pane.height())
elif position == QDockBar.South:
start_pos = QPoint(0, pane.height())
end_pos = QPoint(0, pane.height() - hint.height())
size = QSize(pane.width(), hint.height())
else:
start_pos = QPoint(-hint.width(), 0)
end_pos = QPoint(0, 0)
size = QSize(hint.width(), pane.height())
start_geo = QRect(start_pos, size)
end_geo = QRect(end_pos, size)
return start_geo, end_geo
if x < margins.left() + extra:
mode = self.NorthWestBorder
offset = QPoint(x, y)
elif x > width - (margins.right() + extra):
mode = self.NorthEastBorder
offset = QPoint(width - x, y)
else:
mode = self.NorthBorder
offset = QPoint(0, y)
elif x > width - margins.right():
if y < margins.top() + extra:
mode = self.NorthEastBorder
offset = QPoint(width - x, y)
elif y > height - (margins.bottom() + extra):
mode = self.SouthEastBorder
offset = QPoint(width - x, height - y)
else:
mode = self.EastBorder
offset = QPoint(width - x, 0)
elif y > height - margins.bottom():
if x < margins.left() + extra:
mode = self.SouthWestBorder
offset = QPoint(x, height - y)
elif x > width - (margins.right() + extra):
mode = self.SouthEastBorder
offset = QPoint(width - x, height - y)
else:
mode = self.SouthBorder
offset = QPoint(0, height - y)
else:
mode = self.NoBorder
offset = QPoint()