Skip to content

Commit

Permalink
Merge branch 'comet0-snap_to_grid' into 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-duponchelle committed Jun 20, 2016
2 parents b59d318 + fbbe8af commit 88bf51c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ it on https://github.com/GNS3/gns3-gui we will take care of the triage.

For bugs specific to the GNS3 VM, please report on https://github.com/GNS3/gns3-vm

## Security issues

For security issues please keep it private and send an email to [email protected]

## Asking for new features

The best is to start a discussion on the community website in order to get feedback
Expand Down
5 changes: 5 additions & 0 deletions gns3/items/node_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ def itemChange(self, change, value):
:param value: value of the change
"""

# 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)))

# dynamically change the renderer when this node item is selected/unselected.
if change == QtWidgets.QGraphicsItem.ItemSelectedChange:
if value:
Expand Down
12 changes: 12 additions & 0 deletions gns3/ui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ background-none;
<addaction name="uiFitInViewAction"/>
<addaction name="separator"/>
<addaction name="uiShowLayersAction"/>
<addaction name="uiSnapToGridAction"/>
<addaction name="uiResetPortLabelsAction"/>
<addaction name="uiShowPortNamesAction"/>
<addaction name="separator"/>
Expand Down Expand Up @@ -904,6 +905,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">
Expand Down
21 changes: 13 additions & 8 deletions gns3/ui/main_window_ui.py
Original file line number Diff line number Diff line change
@@ -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 '/Users/noplay/code/gns3/gns3-gui/gns3/ui/main_window.ui'
#
# Created: Tue May 10 10:08:21 2016
# by: PyQt5 UI code generator 5.2.1
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!

Expand Down Expand Up @@ -87,8 +86,8 @@ def setupUi(self, MainWindow):
self.uiNodesDockWidgetContents = QtWidgets.QWidget()
self.uiNodesDockWidgetContents.setObjectName("uiNodesDockWidgetContents")
self.vboxlayout = QtWidgets.QVBoxLayout(self.uiNodesDockWidgetContents)
self.vboxlayout.setSpacing(0)
self.vboxlayout.setContentsMargins(0, 0, 0, 0)
self.vboxlayout.setSpacing(0)
self.vboxlayout.setObjectName("vboxlayout")
self.uiNodesView = NodesView(self.uiNodesDockWidgetContents)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
Expand Down Expand Up @@ -129,8 +128,8 @@ def setupUi(self, MainWindow):
self.uiConsoleDockWidgetContents = QtWidgets.QWidget()
self.uiConsoleDockWidgetContents.setObjectName("uiConsoleDockWidgetContents")
self.vboxlayout1 = QtWidgets.QVBoxLayout(self.uiConsoleDockWidgetContents)
self.vboxlayout1.setSpacing(0)
self.vboxlayout1.setContentsMargins(0, 0, 0, 0)
self.vboxlayout1.setSpacing(0)
self.vboxlayout1.setObjectName("vboxlayout1")
self.uiConsoleTextEdit = ConsoleView(self.uiConsoleDockWidgetContents)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
Expand Down Expand Up @@ -324,6 +323,9 @@ def setupUi(self, MainWindow):
self.uiShowLayersAction = QtWidgets.QAction(MainWindow)
self.uiShowLayersAction.setCheckable(True)
self.uiShowLayersAction.setObjectName("uiShowLayersAction")
self.uiSnapToGridAction = QtWidgets.QAction(MainWindow)
self.uiSnapToGridAction.setCheckable(True)
self.uiSnapToGridAction.setObjectName("uiSnapToGridAction")
self.uiSaveProjectAsAction = QtWidgets.QAction(MainWindow)
icon21 = QtGui.QIcon()
icon21.addPixmap(QtGui.QPixmap(":/icons/save-as-project.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
Expand Down Expand Up @@ -385,9 +387,9 @@ def setupUi(self, MainWindow):
self.uiAddLinkAction.setCheckable(True)
icon29 = QtGui.QIcon()
icon29.addPixmap(QtGui.QPixmap(":/icons/cancel-connection.svg"), QtGui.QIcon.Active, QtGui.QIcon.On)
icon29.addPixmap(QtGui.QPixmap(":/icons/cancel-connection.svg"), QtGui.QIcon.Normal, QtGui.QIcon.On)
icon29.addPixmap(QtGui.QPixmap(":/icons/connection-new-hover.svg"), QtGui.QIcon.Active, QtGui.QIcon.Off)
icon29.addPixmap(QtGui.QPixmap(":/icons/connection-new.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon29.addPixmap(QtGui.QPixmap(":/icons/cancel-connection.svg"), QtGui.QIcon.Normal, QtGui.QIcon.On)
self.uiAddLinkAction.setIcon(icon29)
self.uiAddLinkAction.setObjectName("uiAddLinkAction")
self.uiGettingStartedAction = QtWidgets.QAction(MainWindow)
Expand Down Expand Up @@ -475,6 +477,7 @@ def setupUi(self, MainWindow):
self.uiViewMenu.addAction(self.uiFitInViewAction)
self.uiViewMenu.addSeparator()
self.uiViewMenu.addAction(self.uiShowLayersAction)
self.uiViewMenu.addAction(self.uiSnapToGridAction)
self.uiViewMenu.addAction(self.uiResetPortLabelsAction)
self.uiViewMenu.addAction(self.uiShowPortNamesAction)
self.uiViewMenu.addSeparator()
Expand Down Expand Up @@ -642,6 +645,8 @@ def retranslateUi(self, MainWindow):
self.uiSnapshotAction.setStatusTip(_translate("MainWindow", "Manage snapshots"))
self.uiShowLayersAction.setText(_translate("MainWindow", "Show layers"))
self.uiShowLayersAction.setStatusTip(_translate("MainWindow", "Show layers"))
self.uiSnapToGridAction.setText(_translate("MainWindow", "Snap To Grid"))
self.uiSnapToGridAction.setStatusTip(_translate("MainWindow", "Snap To Grid"))
self.uiSaveProjectAsAction.setText(_translate("MainWindow", "&Save project as..."))
self.uiSaveProjectAsAction.setToolTip(_translate("MainWindow", "Save project as..."))
self.uiSaveProjectAsAction.setStatusTip(_translate("MainWindow", "Save project as..."))
Expand Down Expand Up @@ -702,9 +707,9 @@ def retranslateUi(self, MainWindow):
self.uiEditReadmeAction.setText(_translate("MainWindow", "Edit readme"))
self.uiAcademyAction.setText(_translate("MainWindow", "GNS3 &Academy"))

from ..graphics_view import GraphicsView
from ..console_view import ConsoleView
from ..graphics_view import GraphicsView
from ..nodes_view import NodesView
from ..topology_summary_view import TopologySummaryView
from ..server_summary_view import ServerSummaryView
from ..topology_summary_view import TopologySummaryView
from . import resources_rc

0 comments on commit 88bf51c

Please sign in to comment.