-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.py
327 lines (320 loc) · 18.7 KB
/
mainwindow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created by: PyQt5 UI code generator 5.14.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1000, 800)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout.setContentsMargins(2, 2, 2, 2)
self.verticalLayout.setSpacing(2)
self.verticalLayout.setObjectName("verticalLayout")
self.graphicsView = GraphicsView(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.graphicsView.sizePolicy().hasHeightForWidth())
self.graphicsView.setSizePolicy(sizePolicy)
self.graphicsView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.graphicsView.setAcceptDrops(False)
brush = QtGui.QBrush(QtGui.QColor(150, 150, 150))
brush.setStyle(QtCore.Qt.SolidPattern)
self.graphicsView.setBackgroundBrush(brush)
self.graphicsView.setRenderHints(QtGui.QPainter.Antialiasing|QtGui.QPainter.SmoothPixmapTransform|QtGui.QPainter.TextAntialiasing)
self.graphicsView.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag)
self.graphicsView.setObjectName("graphicsView")
self.verticalLayout.addWidget(self.graphicsView)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1000, 21))
self.menubar.setAcceptDrops(False)
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setAcceptDrops(False)
self.menuFile.setObjectName("menuFile")
self.menuEdit = QtWidgets.QMenu(self.menubar)
self.menuEdit.setObjectName("menuEdit")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.toolBar = QtWidgets.QToolBar(MainWindow)
self.toolBar.setIconSize(QtCore.QSize(30, 30))
self.toolBar.setObjectName("toolBar")
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
self.dockWidgetFile = QtWidgets.QDockWidget(MainWindow)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.dockWidgetFile.sizePolicy().hasHeightForWidth())
self.dockWidgetFile.setSizePolicy(sizePolicy)
self.dockWidgetFile.setMinimumSize(QtCore.QSize(160, 97))
self.dockWidgetFile.setObjectName("dockWidgetFile")
self.dockWidgetContents = QtWidgets.QWidget()
self.dockWidgetContents.setObjectName("dockWidgetContents")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.dockWidgetContents)
self.verticalLayout_2.setContentsMargins(2, 2, 2, 2)
self.verticalLayout_2.setSpacing(2)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.tableViewFile = QtWidgets.QTableView(self.dockWidgetContents)
self.tableViewFile.setMinimumSize(QtCore.QSize(150, 0))
self.tableViewFile.setAcceptDrops(True)
self.tableViewFile.setDragDropOverwriteMode(False)
self.tableViewFile.setObjectName("tableViewFile")
self.verticalLayout_2.addWidget(self.tableViewFile)
self.dockWidgetFile.setWidget(self.dockWidgetContents)
MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockWidgetFile)
self.dockWidgetStanp = QtWidgets.QDockWidget(MainWindow)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.dockWidgetStanp.sizePolicy().hasHeightForWidth())
self.dockWidgetStanp.setSizePolicy(sizePolicy)
self.dockWidgetStanp.setMinimumSize(QtCore.QSize(300, 200))
self.dockWidgetStanp.setObjectName("dockWidgetStanp")
self.dockWidgetContents_2 = QtWidgets.QWidget()
self.dockWidgetContents_2.setObjectName("dockWidgetContents_2")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.dockWidgetContents_2)
self.verticalLayout_3.setContentsMargins(2, 2, 2, 2)
self.verticalLayout_3.setSpacing(2)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.tableViewStamp = QtWidgets.QTableView(self.dockWidgetContents_2)
self.tableViewStamp.setAlternatingRowColors(True)
self.tableViewStamp.setObjectName("tableViewStamp")
self.tableViewStamp.verticalHeader().setDefaultSectionSize(50)
self.tableViewStamp.verticalHeader().setMinimumSectionSize(50)
self.verticalLayout_3.addWidget(self.tableViewStamp)
self.dockWidgetStanp.setWidget(self.dockWidgetContents_2)
MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockWidgetStanp)
self.dockWidget = QtWidgets.QDockWidget(MainWindow)
self.dockWidget.setObjectName("dockWidget")
self.dockWidgetContents_3 = QtWidgets.QWidget()
self.dockWidgetContents_3.setObjectName("dockWidgetContents_3")
self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.dockWidgetContents_3)
self.verticalLayout_6.setContentsMargins(2, 2, 2, 2)
self.verticalLayout_6.setSpacing(2)
self.verticalLayout_6.setObjectName("verticalLayout_6")
self.tabWidget = QtWidgets.QTabWidget(self.dockWidgetContents_3)
self.tabWidget.setObjectName("tabWidget")
self.tab_circle_stamp = QtWidgets.QWidget()
self.tab_circle_stamp.setObjectName("tab_circle_stamp")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.tab_circle_stamp)
self.verticalLayout_4.setContentsMargins(2, 2, 2, 2)
self.verticalLayout_4.setSpacing(2)
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setSpacing(2)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label = QtWidgets.QLabel(self.tab_circle_stamp)
font = QtGui.QFont()
font.setPointSize(10)
self.label.setFont(font)
self.label.setObjectName("label")
self.horizontalLayout_2.addWidget(self.label)
self.doubleSpinBox_height = QtWidgets.QDoubleSpinBox(self.tab_circle_stamp)
self.doubleSpinBox_height.setMinimumSize(QtCore.QSize(0, 24))
font = QtGui.QFont()
font.setPointSize(10)
self.doubleSpinBox_height.setFont(font)
self.doubleSpinBox_height.setDecimals(1)
self.doubleSpinBox_height.setMaximum(99999.0)
self.doubleSpinBox_height.setProperty("value", 30.0)
self.doubleSpinBox_height.setObjectName("doubleSpinBox_height")
self.horizontalLayout_2.addWidget(self.doubleSpinBox_height)
self.label_2 = QtWidgets.QLabel(self.tab_circle_stamp)
font = QtGui.QFont()
font.setPointSize(10)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.horizontalLayout_2.addWidget(self.label_2)
self.doubleSpinBox_width = QtWidgets.QDoubleSpinBox(self.tab_circle_stamp)
self.doubleSpinBox_width.setMinimumSize(QtCore.QSize(0, 24))
font = QtGui.QFont()
font.setPointSize(10)
self.doubleSpinBox_width.setFont(font)
self.doubleSpinBox_width.setDecimals(1)
self.doubleSpinBox_width.setMaximum(99999.0)
self.doubleSpinBox_width.setProperty("value", 30.0)
self.doubleSpinBox_width.setObjectName("doubleSpinBox_width")
self.horizontalLayout_2.addWidget(self.doubleSpinBox_width)
self.verticalLayout_4.addLayout(self.horizontalLayout_2)
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setSpacing(2)
self.gridLayout.setObjectName("gridLayout")
self.lineEdit_3 = QtWidgets.QLineEdit(self.tab_circle_stamp)
self.lineEdit_3.setMinimumSize(QtCore.QSize(0, 24))
font = QtGui.QFont()
font.setPointSize(10)
self.lineEdit_3.setFont(font)
self.lineEdit_3.setObjectName("lineEdit_3")
self.gridLayout.addWidget(self.lineEdit_3, 2, 0, 1, 1)
self.lineEdit = QtWidgets.QLineEdit(self.tab_circle_stamp)
self.lineEdit.setMinimumSize(QtCore.QSize(0, 24))
font = QtGui.QFont()
font.setPointSize(10)
self.lineEdit.setFont(font)
self.lineEdit.setObjectName("lineEdit")
self.gridLayout.addWidget(self.lineEdit, 0, 0, 1, 1)
self.lineEdit_2 = QtWidgets.QLineEdit(self.tab_circle_stamp)
self.lineEdit_2.setMinimumSize(QtCore.QSize(0, 24))
font = QtGui.QFont()
font.setPointSize(10)
self.lineEdit_2.setFont(font)
self.lineEdit_2.setObjectName("lineEdit_2")
self.gridLayout.addWidget(self.lineEdit_2, 1, 0, 1, 1)
self.doubleSpinBox = QtWidgets.QDoubleSpinBox(self.tab_circle_stamp)
self.doubleSpinBox.setMinimumSize(QtCore.QSize(0, 24))
font = QtGui.QFont()
font.setPointSize(10)
self.doubleSpinBox.setFont(font)
self.doubleSpinBox.setDecimals(1)
self.doubleSpinBox.setMaximum(9999.0)
self.doubleSpinBox.setProperty("value", 6.5)
self.doubleSpinBox.setObjectName("doubleSpinBox")
self.gridLayout.addWidget(self.doubleSpinBox, 0, 1, 1, 1)
self.doubleSpinBox_2 = QtWidgets.QDoubleSpinBox(self.tab_circle_stamp)
self.doubleSpinBox_2.setMinimumSize(QtCore.QSize(0, 24))
font = QtGui.QFont()
font.setPointSize(10)
self.doubleSpinBox_2.setFont(font)
self.doubleSpinBox_2.setDecimals(1)
self.doubleSpinBox_2.setProperty("value", 5.0)
self.doubleSpinBox_2.setObjectName("doubleSpinBox_2")
self.gridLayout.addWidget(self.doubleSpinBox_2, 1, 1, 1, 1)
self.doubleSpinBox_3 = QtWidgets.QDoubleSpinBox(self.tab_circle_stamp)
self.doubleSpinBox_3.setMinimumSize(QtCore.QSize(0, 24))
font = QtGui.QFont()
font.setPointSize(10)
self.doubleSpinBox_3.setFont(font)
self.doubleSpinBox_3.setDecimals(1)
self.doubleSpinBox_3.setProperty("value", 6.5)
self.doubleSpinBox_3.setObjectName("doubleSpinBox_3")
self.gridLayout.addWidget(self.doubleSpinBox_3, 2, 1, 1, 1)
self.verticalLayout_4.addLayout(self.gridLayout)
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setSpacing(2)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.toolButton_2 = QtWidgets.QToolButton(self.tab_circle_stamp)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/remixicon/file-transfer-line.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.toolButton_2.setIcon(icon)
self.toolButton_2.setIconSize(QtCore.QSize(30, 30))
self.toolButton_2.setAutoRaise(True)
self.toolButton_2.setObjectName("toolButton_2")
self.horizontalLayout_3.addWidget(self.toolButton_2)
self.toolButton = QtWidgets.QToolButton(self.tab_circle_stamp)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/remixicon/refresh-line.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.toolButton.setIcon(icon1)
self.toolButton.setIconSize(QtCore.QSize(30, 30))
self.toolButton.setAutoRaise(True)
self.toolButton.setObjectName("toolButton")
self.horizontalLayout_3.addWidget(self.toolButton)
self.toolButton_3 = QtWidgets.QToolButton(self.tab_circle_stamp)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/remixicon/crop-line.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.toolButton_3.setIcon(icon2)
self.toolButton_3.setIconSize(QtCore.QSize(30, 30))
self.toolButton_3.setAutoRaise(True)
self.toolButton_3.setObjectName("toolButton_3")
self.horizontalLayout_3.addWidget(self.toolButton_3)
self.toolButton_4 = QtWidgets.QToolButton(self.tab_circle_stamp)
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(":/remixicon/drag-move-2-fill.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.toolButton_4.setIcon(icon3)
self.toolButton_4.setIconSize(QtCore.QSize(30, 30))
self.toolButton_4.setAutoRaise(True)
self.toolButton_4.setObjectName("toolButton_4")
self.horizontalLayout_3.addWidget(self.toolButton_4)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem)
self.verticalLayout_4.addLayout(self.horizontalLayout_3)
self.graphicsView_circle_stamp = GraphicsView(self.tab_circle_stamp)
self.graphicsView_circle_stamp.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag)
self.graphicsView_circle_stamp.setObjectName("graphicsView_circle_stamp")
self.verticalLayout_4.addWidget(self.graphicsView_circle_stamp)
self.tabWidget.addTab(self.tab_circle_stamp, "")
self.tab_sqare_stamp = QtWidgets.QWidget()
self.tab_sqare_stamp.setObjectName("tab_sqare_stamp")
self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.tab_sqare_stamp)
self.verticalLayout_5.setContentsMargins(2, 2, 2, 2)
self.verticalLayout_5.setSpacing(2)
self.verticalLayout_5.setObjectName("verticalLayout_5")
self.graphicsView_sqare_stamp = GraphicsView(self.tab_sqare_stamp)
self.graphicsView_sqare_stamp.setObjectName("graphicsView_sqare_stamp")
self.verticalLayout_5.addWidget(self.graphicsView_sqare_stamp)
self.tabWidget.addTab(self.tab_sqare_stamp, "")
self.verticalLayout_6.addWidget(self.tabWidget)
self.dockWidget.setWidget(self.dockWidgetContents_3)
MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockWidget)
self.actionOpen = QtWidgets.QAction(MainWindow)
icon4 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap(":/remixicon/file-line.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionOpen.setIcon(icon4)
self.actionOpen.setObjectName("actionOpen")
self.actionSave = QtWidgets.QAction(MainWindow)
icon5 = QtGui.QIcon()
icon5.addPixmap(QtGui.QPixmap(":/remixicon/save-3-line.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionSave.setIcon(icon5)
self.actionSave.setObjectName("actionSave")
self.action_select_range = QtWidgets.QAction(MainWindow)
self.action_select_range.setIcon(icon2)
self.action_select_range.setObjectName("action_select_range")
self.action_drag_item = QtWidgets.QAction(MainWindow)
self.action_drag_item.setIcon(icon3)
self.action_drag_item.setObjectName("action_drag_item")
self.menuFile.addAction(self.actionOpen)
self.menuFile.addAction(self.actionSave)
self.menuEdit.addAction(self.action_select_range)
self.menuEdit.addAction(self.action_drag_item)
self.menubar.addAction(self.menuFile.menuAction())
self.menubar.addAction(self.menuEdit.menuAction())
self.toolBar.addAction(self.actionOpen)
self.toolBar.addAction(self.actionSave)
self.toolBar.addSeparator()
self.toolBar.addAction(self.action_select_range)
self.toolBar.addAction(self.action_drag_item)
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0)
self.tableViewFile.clicked['QModelIndex'].connect(MainWindow.preview_pdf)
self.graphicsView.customContextMenuRequested['QPoint'].connect(self.graphicsView.exec_context_menu)
self.toolButton.clicked.connect(MainWindow.preview_circle_stamp)
self.toolButton_2.clicked.connect(MainWindow.set_stamp)
self.actionSave.triggered.connect(MainWindow.save_files)
self.actionOpen.triggered.connect(MainWindow.open_files)
self.action_drag_item.triggered.connect(self.graphicsView.setScrollHandDragMode)
self.action_select_range.triggered.connect(self.graphicsView.setRubberBandDragMode)
self.toolButton_3.clicked.connect(self.graphicsView_circle_stamp.setRubberBandDragMode)
self.toolButton_4.clicked.connect(self.graphicsView_circle_stamp.setScrollHandDragMode)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "PDF Stamp"))
self.menuFile.setTitle(_translate("MainWindow", "File"))
self.menuEdit.setTitle(_translate("MainWindow", "Edit"))
self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar"))
self.dockWidgetFile.setWindowTitle(_translate("MainWindow", "File list"))
self.dockWidgetStanp.setWindowTitle(_translate("MainWindow", "Stamp settings"))
self.dockWidget.setWindowTitle(_translate("MainWindow", "Stamp editor"))
self.label.setText(_translate("MainWindow", "Height"))
self.label_2.setText(_translate("MainWindow", "Width"))
self.lineEdit_3.setText(_translate("MainWindow", "text2"))
self.lineEdit.setText(_translate("MainWindow", "text1"))
self.toolButton_2.setText(_translate("MainWindow", "Set stamp"))
self.toolButton.setText(_translate("MainWindow", "Preview"))
self.toolButton_3.setText(_translate("MainWindow", "Select range"))
self.toolButton_4.setText(_translate("MainWindow", "Drag item"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_circle_stamp), _translate("MainWindow", "Circle stamp"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_sqare_stamp), _translate("MainWindow", "Square Stamp"))
self.actionOpen.setText(_translate("MainWindow", "Open"))
self.actionSave.setText(_translate("MainWindow", "Save"))
self.action_select_range.setText(_translate("MainWindow", "Select range"))
self.action_drag_item.setText(_translate("MainWindow", "Drag item"))
from graphics_view import GraphicsView
import resource_rc