mirror of
https://github.com/GNS3/gns3-gui.git
synced 2026-05-17 00:46:01 +03:00
Snapback feature for port labels. Fixes #1182.
This commit is contained in:
@@ -857,6 +857,13 @@ class GraphicsView(QtWidgets.QGraphicsView):
|
||||
show_in_file_manager_action.triggered.connect(self.getCommandLineSlot)
|
||||
menu.addAction(show_in_file_manager_action)
|
||||
|
||||
if True in list(map(lambda item: isinstance(item, NoteItem), items)) and False in list(map(lambda item: item.parentItem() is None, items)):
|
||||
# action only for port labels
|
||||
reset_label_position_action = QtWidgets.QAction("Reset position", menu)
|
||||
reset_label_position_action.setIcon(QtGui.QIcon(':/icons/reset.svg'))
|
||||
reset_label_position_action.triggered.connect(self.resetLabelPositionActionSlot)
|
||||
menu.addAction(reset_label_position_action)
|
||||
|
||||
# item must have no parent
|
||||
if True in list(map(lambda item: item.parentItem() is None, items)):
|
||||
|
||||
@@ -1396,6 +1403,24 @@ class GraphicsView(QtWidgets.QGraphicsView):
|
||||
text_edit_dialog.show()
|
||||
text_edit_dialog.exec_()
|
||||
|
||||
def resetLabelPositionActionSlot(self):
|
||||
"""
|
||||
Slot to receive events from the reset label position action in the
|
||||
contextual menu.
|
||||
"""
|
||||
|
||||
for item in self.scene().selectedItems():
|
||||
if isinstance(item, NoteItem) and item.parentItem():
|
||||
links = item.parentItem().links()
|
||||
for port in item.parentItem().node().ports():
|
||||
# find the correct port associated with the label
|
||||
if port.label() == item:
|
||||
port.deleteLabel()
|
||||
break
|
||||
# adjust all node links to force to re-display the label
|
||||
for link in links:
|
||||
link.adjust()
|
||||
|
||||
def horizontalAlignmentSlot(self):
|
||||
"""
|
||||
Slot to receive events from the horizontal align action in the
|
||||
|
||||
@@ -201,14 +201,8 @@ class LinkItem(QtWidgets.QGraphicsPathItem):
|
||||
Resets the port label positions.
|
||||
"""
|
||||
|
||||
source_port_label = self._source_port.label()
|
||||
destination_port_label = self._destination_port.label()
|
||||
if source_port_label is not None:
|
||||
source_port_label.delete()
|
||||
self._source_port.setLabel(None)
|
||||
if destination_port_label is not None:
|
||||
destination_port_label.delete()
|
||||
self._destination_port.setLabel(None)
|
||||
self._source_port.deleteLabel()
|
||||
self._destination_port.deleteLabel()
|
||||
|
||||
def populateLinkContextualMenu(self, menu):
|
||||
"""
|
||||
|
||||
@@ -424,6 +424,15 @@ class Port:
|
||||
|
||||
self._port_label = label
|
||||
|
||||
def deleteLabel(self):
|
||||
"""
|
||||
Deletes a port label.
|
||||
"""
|
||||
|
||||
if self._port_label is not None:
|
||||
self._port_label.delete()
|
||||
self._port_label = None
|
||||
|
||||
@classmethod
|
||||
def loadPacketCaptureSettings(cls):
|
||||
"""
|
||||
|
||||
224003
gns3/ui/resources_rc.py
224003
gns3/ui/resources_rc.py
File diff suppressed because it is too large
Load Diff
273
resources/icons/reset.svg
Normal file
273
resources/icons/reset.svg
Normal file
@@ -0,0 +1,273 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="48"
|
||||
height="48"
|
||||
id="svg4198"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="reset.svg">
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="985"
|
||||
inkscape:window-height="480"
|
||||
id="namedview46"
|
||||
showgrid="false"
|
||||
inkscape:zoom="4.9166667"
|
||||
inkscape:cx="24"
|
||||
inkscape:cy="24"
|
||||
inkscape:window-x="218"
|
||||
inkscape:window-y="154"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="layer1" />
|
||||
<defs
|
||||
id="defs4200">
|
||||
<linearGradient
|
||||
id="linearGradient3558">
|
||||
<stop
|
||||
id="stop3560"
|
||||
style="stop-color:#000000;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop3562"
|
||||
style="stop-color:#000000;stop-opacity:0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
cx="22.571428"
|
||||
cy="30.857143"
|
||||
r="15.571428"
|
||||
fx="22.571428"
|
||||
fy="30.857143"
|
||||
id="radialGradient3564"
|
||||
xlink:href="#linearGradient3558"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1,0,0,0.651376,0,10.75754)" />
|
||||
<linearGradient
|
||||
id="linearGradient15218">
|
||||
<stop
|
||||
id="stop15220"
|
||||
style="stop-color:#f8f8f7;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop2269"
|
||||
style="stop-color:#e8e8e8;stop-opacity:1"
|
||||
offset="0.59928656" />
|
||||
<stop
|
||||
id="stop15222"
|
||||
style="stop-color:#e2e2de;stop-opacity:1"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="22.308331"
|
||||
y1="18.99214"
|
||||
x2="35.785294"
|
||||
y2="39.498238"
|
||||
id="linearGradient15224"
|
||||
xlink:href="#linearGradient15218"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.060837,0,0,0.987595,4.641161,4.108291)" />
|
||||
<linearGradient
|
||||
id="linearGradient2259">
|
||||
<stop
|
||||
id="stop2261"
|
||||
style="stop-color:#ffffff;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop2263"
|
||||
style="stop-color:#ffffff;stop-opacity:0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="26.076092"
|
||||
y1="26.696676"
|
||||
x2="30.811172"
|
||||
y2="42.007351"
|
||||
id="linearGradient2265"
|
||||
xlink:href="#linearGradient2259"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.993566,0,0,1,6.219859,4.033411)" />
|
||||
<linearGradient
|
||||
id="linearGradient2216">
|
||||
<stop
|
||||
id="stop2218"
|
||||
style="stop-color:#000000;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop2220"
|
||||
style="stop-color:#000000;stop-opacity:0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="36.8125"
|
||||
y1="39.15625"
|
||||
x2="39.0625"
|
||||
y2="42.0625"
|
||||
id="linearGradient2222"
|
||||
xlink:href="#linearGradient2216"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(6.161836,4.033411)" />
|
||||
<linearGradient
|
||||
id="linearGradient2224">
|
||||
<stop
|
||||
id="stop2226"
|
||||
style="stop-color:#7c7c7c;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop2228"
|
||||
style="stop-color:#b8b8b8;stop-opacity:1"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="20.794008"
|
||||
y1="18.378813"
|
||||
x2="35.596001"
|
||||
y2="39.60046"
|
||||
id="linearGradient2240"
|
||||
xlink:href="#linearGradient15218"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.342704,0,0,1.235378,-8.219611,-6.577189)" />
|
||||
<linearGradient
|
||||
x1="26.5"
|
||||
y1="34.25"
|
||||
x2="26.25"
|
||||
y2="43.571831"
|
||||
id="linearGradient2314"
|
||||
xlink:href="#linearGradient2308"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
id="linearGradient2308">
|
||||
<stop
|
||||
id="stop2310"
|
||||
style="stop-color:#edd400;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop2312"
|
||||
style="stop-color:#edd400;stop-opacity:0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="26.5"
|
||||
y1="34.25"
|
||||
x2="26.25"
|
||||
y2="43.571831"
|
||||
id="linearGradient2322"
|
||||
xlink:href="#linearGradient2316"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
id="linearGradient2316">
|
||||
<stop
|
||||
id="stop2318"
|
||||
style="stop-color:#c4a000;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop2320"
|
||||
style="stop-color:#c4a000;stop-opacity:0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="26.5"
|
||||
y1="34.25"
|
||||
x2="26.25"
|
||||
y2="43.571831"
|
||||
id="linearGradient3048"
|
||||
xlink:href="#linearGradient2308"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.0630341,0,0,0.97284054,-5.2806841,0.40829463)" />
|
||||
<linearGradient
|
||||
x1="26.5"
|
||||
y1="34.25"
|
||||
x2="26.25"
|
||||
y2="43.571831"
|
||||
id="linearGradient3050"
|
||||
xlink:href="#linearGradient2316"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.0630341,0,0,0.97284054,-5.2806841,0.40829463)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient2308"
|
||||
id="linearGradient3022"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.3947237,0,0,1.0793483,-7.1041004,-1.6497535)"
|
||||
x1="26.5"
|
||||
y1="34.25"
|
||||
x2="26.25"
|
||||
y2="43.571831" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient2216"
|
||||
id="linearGradient3024"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.3947237,0,0,1.0793483,-7.1041004,-1.6497535)"
|
||||
x1="26.5"
|
||||
y1="34.25"
|
||||
x2="26.25"
|
||||
y2="43.571831" />
|
||||
</defs>
|
||||
<metadata
|
||||
id="metadata4203">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
<dc:date>2005-10-29</dc:date>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Andreas Nilsson</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
<dc:subject>
|
||||
<rdf:Bag>
|
||||
<rdf:li>justify</rdf:li>
|
||||
<rdf:li>center</rdf:li>
|
||||
<rdf:li>format</rdf:li>
|
||||
</rdf:Bag>
|
||||
</dc:subject>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
|
||||
</cc:Work>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
|
||||
<cc:permits
|
||||
rdf:resource="http://web.resource.org/cc/Reproduction" />
|
||||
<cc:permits
|
||||
rdf:resource="http://web.resource.org/cc/Distribution" />
|
||||
<cc:requires
|
||||
rdf:resource="http://web.resource.org/cc/Notice" />
|
||||
<cc:requires
|
||||
rdf:resource="http://web.resource.org/cc/Attribution" />
|
||||
<cc:permits
|
||||
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
|
||||
<cc:requires
|
||||
rdf:resource="http://web.resource.org/cc/ShareAlike" />
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1">
|
||||
<path
|
||||
d="M 6.2607584,46.958017 C 62.085702,48.383989 53.262894,11.619271 24.224756,11.839564 l 0,-10.1193329 L 1.004725,17.46423 24.224756,33.975594 c 0,0 0,-10.43555 0,-10.43555 19.614151,-0.632465 25.352631,23.133219 -17.9639976,23.417973 z"
|
||||
id="path1432"
|
||||
style="color:#000000;fill:url(#linearGradient3022);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient3024);stroke-width:1.2269448;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:block;overflow:visible"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.4 KiB |
@@ -96,6 +96,7 @@
|
||||
<file>icons/snapshot.svg</file>
|
||||
<file>icons/plus.svg</file>
|
||||
<file>icons/minus.svg</file>
|
||||
<file>icons/reset.svg</file>
|
||||
<file>icons/horizontally.svg</file>
|
||||
<file>icons/vertically.svg</file>
|
||||
<file>icons/export_config.svg</file>
|
||||
|
||||
Reference in New Issue
Block a user