mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-08 06:23:59 -06:00
Limit draggable component to the main window.
This commit is contained in:
parent
28a14c0a3b
commit
37fddaee5c
2 changed files with 19 additions and 3 deletions
|
@ -1782,3 +1782,13 @@ class CuraApplication(QtApplication):
|
|||
# Only show the what's new dialog if there's no machine and we have just upgraded
|
||||
show_whatsnew_only = has_active_machine and has_app_just_upgraded
|
||||
return show_whatsnew_only
|
||||
|
||||
@pyqtSlot(result = int)
|
||||
def appWidth(self) -> int:
|
||||
main_window = cast(UM.Qt.Bindings.MainWindow, QtApplication.getInstance().getMainWindow())
|
||||
return main_window.width()
|
||||
|
||||
@pyqtSlot(result = int)
|
||||
def appHeight(self) -> int:
|
||||
main_window = cast(UM.Qt.Bindings.MainWindow, QtApplication.getInstance().getMainWindow())
|
||||
return main_window.height()
|
||||
|
|
|
@ -245,10 +245,16 @@ Item
|
|||
onPositionChanged:
|
||||
{
|
||||
var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y);
|
||||
if (delta.x != 0 || delta.y != 0)
|
||||
if (delta.x !== 0 || delta.y !== 0)
|
||||
{
|
||||
contentContainer.x += delta.x;
|
||||
contentContainer.y += delta.y;
|
||||
var minPt = base.mapFromItem(null, 0, 0);
|
||||
var maxPt = base.mapFromItem(null,
|
||||
CuraApplication.appWidth() - contentContainer.width,
|
||||
CuraApplication.appHeight() - contentContainer.height);
|
||||
var initialY = background.height + base.shadowOffset + base.contentSpacingY;
|
||||
|
||||
contentContainer.x = Math.min(maxPt.x, Math.max(minPt.x, contentContainer.x + delta.x));
|
||||
contentContainer.y = Math.min(maxPt.y, Math.max(initialY, contentContainer.y + delta.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue