mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 05:19:08 +08:00
Limit draggable component to the main window.
This commit is contained in:
parent
28a14c0a3b
commit
37fddaee5c
@ -1782,3 +1782,13 @@ class CuraApplication(QtApplication):
|
|||||||
# Only show the what's new dialog if there's no machine and we have just upgraded
|
# 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
|
show_whatsnew_only = has_active_machine and has_app_just_upgraded
|
||||||
return show_whatsnew_only
|
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:
|
onPositionChanged:
|
||||||
{
|
{
|
||||||
var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y);
|
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;
|
var minPt = base.mapFromItem(null, 0, 0);
|
||||||
contentContainer.y += delta.y;
|
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…
x
Reference in New Issue
Block a user