Skip to content

Commit

Permalink
Merge pull request #3512 from magister990/style_edit_width_and_height
Browse files Browse the repository at this point in the history
Add the ability to edit width and hight in the style edit dialog.
  • Loading branch information
grossmj authored Oct 24, 2023
2 parents a989026 + 3d89d6e commit 9087ba8
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build and run Docker image
run: |
docker build -t gns3-gui-test .
Expand Down
14 changes: 14 additions & 0 deletions gns3/dialogs/style_editor_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,20 @@ def __init__(self, parent, items):
if not corner_radius:
corner_radius = first_item.verticalCornerRadius()
self.uiCornerRadiusSpinBox.setValue(corner_radius)
else:
self.uiCornerRadiusLabel.hide()
self.uiCornerRadiusSpinBox.hide()
self.uiRotationSpinBox.setValue(int(first_item.rotation()))
self.uiBorderWidthSpinBox.setValue(pen.width())
if isinstance(first_item, ShapeItem):
rect = first_item.rect()
self.uiWidthSpinBox.setValue(int(rect.width()))
self.uiHeightSpinBox.setValue(int(rect.height()))
else:
self.uiWidthSpinBox.hide()
self.uiWidthLabel.hide()
self.uiHeightSpinBox.hide()
self.uiHeightLabel.hide()
index = self.uiBorderStyleComboBox.findData(pen.style())
if index != -1:
self.uiBorderStyleComboBox.setCurrentIndex(index)
Expand Down Expand Up @@ -134,6 +146,8 @@ def _applyPreferencesSlot(self):
# maybe we support setting them separately in the future
item.setHorizontalCornerRadius(corner_radius)
item.setVerticalCornerRadius(corner_radius)
if isinstance(item, ShapeItem):
item.setWidthAndHeight(self.uiWidthSpinBox.value(), self.uiHeightSpinBox.value())
item.setRotation(self.uiRotationSpinBox.value())

def done(self, result):
Expand Down
3 changes: 3 additions & 0 deletions gns3/items/shape_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ def hoverLeaveEvent(self, event):
if not self.locked():
self._graphics_view.setCursor(QtCore.Qt.ArrowCursor)

def setWidthAndHeight(self, width, height):
self.setRect(0, 0, width, height)

def fromSvg(self, svg):
"""
Import element information from SVG
Expand Down
5 changes: 5 additions & 0 deletions gns3/schemas/appliance.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
"format": "uri",
"title": "Website of the vendor"
},
"vendor_logo_url": {
"type": "string",
"format": "uri",
"title": "Link to the vendor logo (used by the GNS3 marketplace)"
},
"documentation_url": {
"type": "string",
"format": "uri",
Expand Down
5 changes: 5 additions & 0 deletions gns3/schemas/appliance_v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@
"format": "uri",
"title": "Website of the vendor"
},
"vendor_logo_url": {
"type": "string",
"format": "uri",
"title": "Link to the vendor logo (used by the GNS3 marketplace)"
},
"documentation_url": {
"type": "string",
"format": "uri",
Expand Down
52 changes: 46 additions & 6 deletions gns3/ui/style_editor_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>270</width>
<height>294</height>
<width>288</width>
<height>358</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -84,14 +84,14 @@
<item row="3" column="1">
<widget class="QComboBox" name="uiBorderStyleComboBox"/>
</item>
<item row="5" column="0">
<item row="7" column="0">
<widget class="QLabel" name="uiRotationLabel">
<property name="text">
<string>Rotation:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="7" column="1">
<widget class="QSpinBox" name="uiRotationSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
Expand All @@ -114,14 +114,14 @@ editing (notes only) with ALT and '+' (or P) / ALT and '-' (or M)</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="6" column="0">
<widget class="QLabel" name="uiCornerRadiusLabel">
<property name="text">
<string>Corner radius:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="6" column="1">
<widget class="QSpinBox" name="uiCornerRadiusSpinBox">
<property name="suffix">
<string>°</string>
Expand All @@ -131,6 +131,46 @@ editing (notes only) with ALT and '+' (or P) / ALT and '-' (or M)</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="uiWidthLabel">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="uiWidthSpinBox">
<property name="suffix">
<string> px</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="uiHeightLabel">
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="uiHeightSpinBox">
<property name="suffix">
<string> px</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
32 changes: 26 additions & 6 deletions gns3/ui/style_editor_dialog_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file '/home/grossmj/PycharmProjects/gns3-gui/gns3/ui/style_editor_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
# Created by: PyQt5 UI code generator 5.15.6
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
Expand All @@ -14,7 +14,7 @@
class Ui_StyleEditorDialog(object):
def setupUi(self, StyleEditorDialog):
StyleEditorDialog.setObjectName("StyleEditorDialog")
StyleEditorDialog.resize(270, 294)
StyleEditorDialog.resize(288, 358)
StyleEditorDialog.setModal(True)
self.verticalLayout = QtWidgets.QVBoxLayout(StyleEditorDialog)
self.verticalLayout.setObjectName("verticalLayout")
Expand Down Expand Up @@ -53,7 +53,7 @@ def setupUi(self, StyleEditorDialog):
self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.uiBorderStyleComboBox)
self.uiRotationLabel = QtWidgets.QLabel(self.uiStyleSettingsGroupBox)
self.uiRotationLabel.setObjectName("uiRotationLabel")
self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.uiRotationLabel)
self.formLayout.setWidget(7, QtWidgets.QFormLayout.LabelRole, self.uiRotationLabel)
self.uiRotationSpinBox = QtWidgets.QSpinBox(self.uiStyleSettingsGroupBox)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
Expand All @@ -63,14 +63,30 @@ def setupUi(self, StyleEditorDialog):
self.uiRotationSpinBox.setMinimum(-360)
self.uiRotationSpinBox.setMaximum(360)
self.uiRotationSpinBox.setObjectName("uiRotationSpinBox")
self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.uiRotationSpinBox)
self.formLayout.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.uiRotationSpinBox)
self.uiCornerRadiusLabel = QtWidgets.QLabel(self.uiStyleSettingsGroupBox)
self.uiCornerRadiusLabel.setObjectName("uiCornerRadiusLabel")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.uiCornerRadiusLabel)
self.formLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.uiCornerRadiusLabel)
self.uiCornerRadiusSpinBox = QtWidgets.QSpinBox(self.uiStyleSettingsGroupBox)
self.uiCornerRadiusSpinBox.setMaximum(100)
self.uiCornerRadiusSpinBox.setObjectName("uiCornerRadiusSpinBox")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.uiCornerRadiusSpinBox)
self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.uiCornerRadiusSpinBox)
self.uiWidthLabel = QtWidgets.QLabel(self.uiStyleSettingsGroupBox)
self.uiWidthLabel.setObjectName("uiWidthLabel")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.uiWidthLabel)
self.uiWidthSpinBox = QtWidgets.QSpinBox(self.uiStyleSettingsGroupBox)
self.uiWidthSpinBox.setMinimum(10)
self.uiWidthSpinBox.setMaximum(1000)
self.uiWidthSpinBox.setObjectName("uiWidthSpinBox")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.uiWidthSpinBox)
self.uiHeightLabel = QtWidgets.QLabel(self.uiStyleSettingsGroupBox)
self.uiHeightLabel.setObjectName("uiHeightLabel")
self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.uiHeightLabel)
self.uiHeightSpinBox = QtWidgets.QSpinBox(self.uiStyleSettingsGroupBox)
self.uiHeightSpinBox.setMinimum(10)
self.uiHeightSpinBox.setMaximum(1000)
self.uiHeightSpinBox.setObjectName("uiHeightSpinBox")
self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.uiHeightSpinBox)
self.verticalLayout.addWidget(self.uiStyleSettingsGroupBox)
self.uiButtonBox = QtWidgets.QDialogButtonBox(StyleEditorDialog)
self.uiButtonBox.setOrientation(QtCore.Qt.Horizontal)
Expand Down Expand Up @@ -100,4 +116,8 @@ def retranslateUi(self, StyleEditorDialog):
self.uiRotationSpinBox.setSuffix(_translate("StyleEditorDialog", "°"))
self.uiCornerRadiusLabel.setText(_translate("StyleEditorDialog", "Corner radius:"))
self.uiCornerRadiusSpinBox.setSuffix(_translate("StyleEditorDialog", "°"))
self.uiWidthLabel.setText(_translate("StyleEditorDialog", "Width:"))
self.uiWidthSpinBox.setSuffix(_translate("StyleEditorDialog", " px"))
self.uiHeightLabel.setText(_translate("StyleEditorDialog", "Height:"))
self.uiHeightSpinBox.setSuffix(_translate("StyleEditorDialog", " px"))
from . import resources_rc
4 changes: 2 additions & 2 deletions gns3/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
# or negative for a release candidate or beta (after the base version
# number has been incremented)

__version__ = "2.2.43"
__version__ = "2.2.44.dev1"

__version_info__ = (2, 2, 43, 0)
__version_info__ = (2, 2, 44, 99)

if "dev" in __version__:
try:
Expand Down
2 changes: 2 additions & 0 deletions mac-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-rrequirements.txt

PyQt5-Qt5==5.15.2
PyQt5-sip==12.12.2
PyQt5==5.15.9
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
jsonschema>=4.17.3,<4.18; python_version >= '3.7' # v4.17.3 is the last version to support Python 3.7
jsonschema==3.2.0; python_version < '3.7' # v3.2.0 is the last version to support Python 3.6
sentry-sdk==1.31.0,<1.32
psutil==5.9.5
sentry-sdk==1.32.0,<1.33
psutil==5.9.6
distro>=1.8.0
truststore>=0.8.0; python_version >= '3.10'
importlib-resources>=1.3; python_version <= '3.9'
importlib-resources>=1.3; python_version < '3.9'
setuptools>=60.8.1; python_version >= '3.7'
setuptools==59.6.0; python_version < '3.7' # v59.6.0 is the last version to support Python 3.6
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def run_tests(self):
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
],
)
2 changes: 1 addition & 1 deletion win-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-rrequirements.txt

PyQt5==5.15.9 # pyup: ignore
PyQt5==5.15.10 # pyup: ignore
pywin32==306 # pyup: ignore

0 comments on commit 9087ba8

Please sign in to comment.