-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdiff_ui.py
executable file
·152 lines (132 loc) · 8.56 KB
/
diff_ui.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
# Form implementation generated from reading ui file 'diff.ui'
#
# Created by: PyQt6 UI code generator 6.4.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
import platform
from PyQt6 import QtWidgets, QtCore, QtGui
class DroppableTextEdit(QtWidgets.QTextEdit):
file_dropped_sig = QtCore.pyqtSignal(list)
def __init__(self, parent=None, text_edit_for_file1or2=None):
super().__init__(parent)
self.text_edit_for_file = text_edit_for_file1or2
self.setAcceptDrops(True)
def dragEnterEvent(self, event):
if event.mimeData().hasUrls():
event.acceptProposedAction()
def dragMoveEvent(self, event):
if event.mimeData().hasUrls():
event.acceptProposedAction()
def dropEvent(self, event):
for url in event.mimeData().urls():
if url.isLocalFile():
file_path = url.toLocalFile()
self.clear()
self.setText(file_path)
self.file_dropped_sig.emit([self.text_edit_for_file, file_path])
class Ui_DiffDialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(363, 163)
self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.textEdit = DroppableTextEdit(parent=Dialog, text_edit_for_file1or2="file1")
self.textEdit.setReadOnly(True)
self.textEdit.setObjectName("textEdit")
self.gridLayout.addWidget(self.textEdit, 0, 0, 1, 1)
self.textEdit_2 = DroppableTextEdit(parent=Dialog, text_edit_for_file1or2="file2")
self.textEdit_2.setReadOnly(True)
self.textEdit_2.setObjectName("textEdit_2")
self.gridLayout.addWidget(self.textEdit_2, 0, 1, 1, 1)
self.file1Btn = QtWidgets.QPushButton(Dialog)
self.file1Btn.setObjectName("file1Btn")
self.file1Btn.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus)
self.gridLayout.addWidget(self.file1Btn, 1, 0, 1, 1)
self.file2Btn = QtWidgets.QPushButton(Dialog)
self.file2Btn.setObjectName("file2Btn")
self.file2Btn.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus)
self.gridLayout.addWidget(self.file2Btn, 1, 1, 1, 1)
self.doDiffBtn = QtWidgets.QPushButton(Dialog)
self.doDiffBtn.setObjectName("doDiffBtn")
self.doDiffBtn.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus)
self.gridLayout.addWidget(self.doDiffBtn, 2, 0, 1, 2)
self.checkboxGridLayout = QtWidgets.QGridLayout()
self.gridLayout.addLayout(self.checkboxGridLayout, 4, 0, 1, 2)
self.checkboxes = []
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Binary Diff"))
font_family = ".AppleSystemUIFont" if platform.system() == "Darwin" else "Courier New"
font_size = "13pt" if platform.system() == "Darwin" else "9pt"
self.textEdit.setHtml(_translate("Dialog",
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"hr { height: 1px; border-width: 0; }\n"
"li.unchecked::marker { content: \"\\2610\"; }\n"
"li.checked::marker { content: \"\\2612\"; }\n"
f"</style></head><body style=\" font-family:{font_family}; font-size:{font_size}; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">File1 </p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">(Drag & Drop)</p></body></html>"))
self.textEdit_2.setHtml(_translate("Dialog",
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"hr { height: 1px; border-width: 0; }\n"
"li.unchecked::marker { content: \"\\2610\"; }\n"
"li.checked::marker { content: \"\\2612\"; }\n"
f"</style></head><body style=\" font-family:{font_family}; font-size:{font_size}; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">File2</p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">(Drag & Drop)</p></body></html>"))
self.file1Btn.setText(_translate("Dialog", "File1"))
self.file2Btn.setText(_translate("Dialog", "File2"))
self.doDiffBtn.setText(_translate("Dialog", "Diff"))
class CompareFilesWindow(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(924, 424)
Form.setMinimumSize(QtCore.QSize(980, 0))
font = QtGui.QFont()
font.setFamily("Courier New")
Form.setFont(font)
self.gridLayout = QtWidgets.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setContentsMargins(-1, 0, -1, -1)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.stopDiffBtn = QtWidgets.QPushButton(Form)
self.stopDiffBtn.setMaximumSize(QtCore.QSize(50, 16777215))
self.stopDiffBtn.setObjectName("stopDiffBtn")
self.gridLayout.addWidget(self.stopDiffBtn, 0, 0, 1, 1)
self.file1TextEdit = QtWidgets.QTextEdit(Form)
self.file1TextEdit.setMaximumSize(QtCore.QSize(16777215, 50))
self.file1TextEdit.setReadOnly(True)
self.file1TextEdit.setObjectName("file1TextEdit")
self.horizontalLayout.addWidget(self.file1TextEdit)
self.file2TextEdit = QtWidgets.QTextEdit(Form)
self.file2TextEdit.setMaximumSize(QtCore.QSize(16777215, 50))
self.file2TextEdit.setReadOnly(True)
self.file2TextEdit.setObjectName("file2TextEdit")
self.horizontalLayout.addWidget(self.file2TextEdit)
self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 2, 1)
self.addressTextEdit = QtWidgets.QTextEdit(Form)
self.addressTextEdit.setMaximumSize(QtCore.QSize(16777215, 26))
self.addressTextEdit.setReadOnly(True)
self.addressTextEdit.setObjectName("addressTextEdit")
self.gridLayout.addWidget(self.addressTextEdit, 3, 0, 1, 1)
self.binaryDiffResultView = QtWidgets.QTextEdit(Form)
self.binaryDiffResultView.setReadOnly(True)
self.binaryDiffResultView.setObjectName("binaryDiffResultView")
self.gridLayout.addWidget(self.binaryDiffResultView, 4, 0, 1, 1)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Binary Diff Result"))
self.stopDiffBtn.setText(_translate("Form", "Stop"))