Add Snap to Grid to Qt ui file

This commit is contained in:
Cometo
2016-06-20 10:27:45 +01:00
parent 4f3d20a7c4
commit fbbe8aff54
3 changed files with 16 additions and 4 deletions

View File

@@ -377,7 +377,8 @@ class NodeItem():
:param value: value of the change
"""
if change == 9 and self._main_window.uiSnapToGridAction.isChecked(): # Unsure but change seems to alternate between 0/9 while dragging
# was causing infinite recursion loops when placed within the below if statements
if change == QtWidgets.QGraphicsItem.ItemPositionHasChanged and self._main_window.uiSnapToGridAction.isChecked():
GRID_SIZE = 75
self.setPos(float(GRID_SIZE * round(self.x() / GRID_SIZE)), float(GRID_SIZE * round(self.y() / GRID_SIZE)))

View File

@@ -126,6 +126,7 @@ background-none;
<addaction name="uiFitInViewAction"/>
<addaction name="separator"/>
<addaction name="uiShowLayersAction"/>
<addaction name="uiSnapToGridAction"/>
<addaction name="uiResetPortLabelsAction"/>
<addaction name="uiShowPortNamesAction"/>
<addaction name="separator"/>
@@ -889,6 +890,17 @@ background-none;
<string>Show layers</string>
</property>
</action>
<action name="uiSnapToGridAction">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Snap To Grid</string>
</property>
<property name="statusTip">
<string>Snap To Grid</string>
</property>
</action>
<action name="uiSaveProjectAsAction">
<property name="icon">
<iconset resource="../../resources/resources.qrc">

View File

@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/grossmj/PycharmProjects/gns3-gui/gns3/ui/main_window.ui'
# Form implementation generated from reading ui file '/home/cometo/dev/gns3-gui/gns3/ui/main_window.ui'
#
# Created: Tue Apr 26 11:38:43 2016
# by: PyQt5 UI code generator 5.2.1
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!