Skip to content

Commit

Permalink
Add more clipboard options.
Browse files Browse the repository at this point in the history
  • Loading branch information
KmolYuan committed Oct 13, 2021
1 parent 255f6d5 commit 8f3fc28
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 25 deletions.
10 changes: 10 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Version 21.10

**Features**:

+ Enhance "Copy Curve Data" options.

**Development**:

+ None.

## Version 21.09

**Features**:
Expand Down
10 changes: 7 additions & 3 deletions pyslvs_ui/synthesis/dimensional_synthesis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,13 @@ def clear_path(self, *, ask: bool = True) -> None:
@Slot(name='on_path_copy_clicked')
def __copy_path(self) -> None:
"""Copy the current path coordinates to clipboard."""
QApplication.clipboard().setText('\n'.join(
f"[{x}, {y}]," for x, y in self.current_path()
))
if self.copy_as_csv.isChecked():
text = '\n'.join(f"{x},{y}" for x, y in self.current_path())
elif self.copy_as_array.isChecked():
text = '\n'.join(f"[{x}, {y}]," for x, y in self.current_path())
else:
raise ValueError("invalid option")
QApplication.clipboard().setText(text)

@Slot(name='on_path_paste_clicked')
def __paste_path(self) -> None:
Expand Down
56 changes: 43 additions & 13 deletions pyslvs_ui/synthesis/dimensional_synthesis/dimension_widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>430</width>
<width>457</width>
<height>714</height>
</rect>
</property>
Expand Down Expand Up @@ -256,7 +256,7 @@
<attribute name="title">
<string>Target path</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QSplitter" name="down_splitter">
<property name="orientation">
Expand All @@ -280,6 +280,46 @@
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QGroupBox" name="copy_format_groupbox">
<property name="title">
<string>Copy</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="copy_as_csv">
<property name="text">
<string>Comma-Separated Values</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="copy_as_array">
<property name="text">
<string>Array-like</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="path_copy">
<property name="statusTip">
<string>Copy the path data as a string.</string>
</property>
<property name="text">
<string>Copy Curve Data</string>
</property>
<property name="icon">
<iconset>
<normaloff>icons:copy.png</normaloff>icons:copy.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
Expand Down Expand Up @@ -316,17 +356,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="path_copy">
<property name="statusTip">
<string>Copy the path data as a string.</string>
</property>
<property name="icon">
<iconset>
<normaloff>icons:copy.png</normaloff>icons:copy.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="path_clear">
<property name="statusTip">
Expand Down Expand Up @@ -656,5 +685,6 @@
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
34 changes: 25 additions & 9 deletions pyslvs_ui/synthesis/dimensional_synthesis/dimension_widget_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(430, 714)
Form.resize(457, 714)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("icons:dimensional_synthesis.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
Form.setWindowIcon(icon)
Expand Down Expand Up @@ -144,8 +144,8 @@ def setupUi(self, Form):
self.options_tab.addTab(self.structure, icon8, "")
self.target_path = QtWidgets.QWidget()
self.target_path.setObjectName("target_path")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.target_path)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.target_path)
self.verticalLayout_5.setObjectName("verticalLayout_5")
self.down_splitter = QtWidgets.QSplitter(self.target_path)
self.down_splitter.setOrientation(QtCore.Qt.Horizontal)
self.down_splitter.setObjectName("down_splitter")
Expand All @@ -167,6 +167,22 @@ def setupUi(self, Form):
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.verticalLayout_8 = QtWidgets.QVBoxLayout()
self.verticalLayout_8.setObjectName("verticalLayout_8")
self.copy_format_groupbox = QtWidgets.QGroupBox(self.layoutWidget)
self.copy_format_groupbox.setObjectName("copy_format_groupbox")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.copy_format_groupbox)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.copy_as_csv = QtWidgets.QRadioButton(self.copy_format_groupbox)
self.copy_as_csv.setChecked(True)
self.copy_as_csv.setObjectName("copy_as_csv")
self.verticalLayout_2.addWidget(self.copy_as_csv)
self.copy_as_array = QtWidgets.QRadioButton(self.copy_format_groupbox)
self.copy_as_array.setObjectName("copy_as_array")
self.verticalLayout_2.addWidget(self.copy_as_array)
self.path_copy = QtWidgets.QPushButton(self.copy_format_groupbox)
self.path_copy.setIcon(icon2)
self.path_copy.setObjectName("path_copy")
self.verticalLayout_2.addWidget(self.path_copy)
self.verticalLayout_8.addWidget(self.copy_format_groupbox)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.point_num = QtWidgets.QLabel(self.layoutWidget)
Expand All @@ -181,10 +197,6 @@ def setupUi(self, Form):
self.path_paste.setIcon(icon9)
self.path_paste.setObjectName("path_paste")
self.horizontalLayout_2.addWidget(self.path_paste)
self.path_copy = QtWidgets.QPushButton(self.layoutWidget)
self.path_copy.setIcon(icon2)
self.path_copy.setObjectName("path_copy")
self.horizontalLayout_2.addWidget(self.path_copy)
self.path_clear = QtWidgets.QPushButton(self.layoutWidget)
self.path_clear.setIcon(icon7)
self.path_clear.setAutoDefault(False)
Expand Down Expand Up @@ -276,7 +288,7 @@ def setupUi(self, Form):
spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout_3.addItem(spacerItem3)
self.horizontalLayout_5.addLayout(self.verticalLayout_3)
self.verticalLayout_2.addWidget(self.down_splitter)
self.verticalLayout_5.addWidget(self.down_splitter)
self.options_tab.addTab(self.target_path, icon, "")
self.algorithm = QtWidgets.QWidget()
self.algorithm.setObjectName("algorithm")
Expand Down Expand Up @@ -343,9 +355,13 @@ def retranslateUi(self, Form):
item.setText(_translate("Form", "Range"))
self.options_tab.setTabText(self.options_tab.indexOf(self.structure), _translate("Form", "Structure"))
self.shape_only_option.setText(_translate("Form", "Compare shape only"))
self.copy_format_groupbox.setTitle(_translate("Form", "Copy"))
self.copy_as_csv.setText(_translate("Form", "Comma-Separated Values"))
self.copy_as_array.setText(_translate("Form", "Array-like"))
self.path_copy.setStatusTip(_translate("Form", "Copy the path data as a string."))
self.path_copy.setText(_translate("Form", "Copy Curve Data"))
self.point_num.setText(_translate("Form", "<html><head/><body><p><span style=\" font-size:12pt; color:#00aa00;\">0</span></p></body></html>"))
self.path_paste.setStatusTip(_translate("Form", "Past path data from string format."))
self.path_copy.setStatusTip(_translate("Form", "Copy the path data as a string."))
self.path_clear.setStatusTip(_translate("Form", "Clear all points."))
self.point_up.setStatusTip(_translate("Form", "Move the point up."))
self.point_down.setStatusTip(_translate("Form", "Move the point down."))
Expand Down

0 comments on commit 8f3fc28

Please sign in to comment.