The main dialog window.
| 94 | |
| 95 | |
| 96 | class Dialog(QtWidgets.QDialog): |
| 97 | """ |
| 98 | The main dialog window. |
| 99 | """ |
| 100 | def __init__(self, entries): |
| 101 | super().__init__() |
| 102 | |
| 103 | self.entries = entries |
| 104 | self.current_entry = -1 |
| 105 | self.current_thumbnail = -1 |
| 106 | |
| 107 | event_filter = EventFilter(self) |
| 108 | self.installEventFilter(event_filter) |
| 109 | |
| 110 | # The list of files on the left-hand side. |
| 111 | self.filelist = QtWidgets.QListWidget() |
| 112 | self.filelist.setMinimumWidth(400) |
| 113 | for entry in entries: |
| 114 | self.filelist.addItem(entry.display) |
| 115 | self.filelist.currentRowChanged.connect(self.set_entry) |
| 116 | |
| 117 | thumbnails_box = QtWidgets.QWidget() |
| 118 | thumbnails_layout = QtWidgets.QVBoxLayout() |
| 119 | self.thumbnails = [] |
| 120 | for i, name in enumerate(('test', 'expected', 'diff')): |
| 121 | thumbnail = Thumbnail(self, i, name) |
| 122 | thumbnails_layout.addWidget(thumbnail) |
| 123 | self.thumbnails.append(thumbnail) |
| 124 | thumbnails_box.setLayout(thumbnails_layout) |
| 125 | |
| 126 | images_layout = QtWidgets.QVBoxLayout() |
| 127 | images_box = QtWidgets.QWidget() |
| 128 | self.image_display = QtWidgets.QLabel() |
| 129 | self.image_display.setAlignment( |
| 130 | QtCore.Qt.AlignmentFlag.AlignHCenter | |
| 131 | QtCore.Qt.AlignmentFlag.AlignVCenter) |
| 132 | self.image_display.setMinimumSize(800, 600) |
| 133 | images_layout.addWidget(self.image_display, 6) |
| 134 | images_box.setLayout(images_layout) |
| 135 | |
| 136 | buttons_box = QtWidgets.QWidget() |
| 137 | buttons_layout = QtWidgets.QHBoxLayout() |
| 138 | accept_button = QtWidgets.QPushButton("Accept (A)") |
| 139 | accept_button.clicked.connect(self.accept_test) |
| 140 | buttons_layout.addWidget(accept_button) |
| 141 | reject_button = QtWidgets.QPushButton("Reject (R)") |
| 142 | reject_button.clicked.connect(self.reject_test) |
| 143 | buttons_layout.addWidget(reject_button) |
| 144 | buttons_box.setLayout(buttons_layout) |
| 145 | images_layout.addWidget(buttons_box) |
| 146 | |
| 147 | main_layout = QtWidgets.QHBoxLayout() |
| 148 | main_layout.addWidget(self.filelist, 1) |
| 149 | main_layout.addWidget(thumbnails_box, 1) |
| 150 | main_layout.addWidget(images_box, 3) |
| 151 | |
| 152 | self.setLayout(main_layout) |
| 153 |