list.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. # -*- coding: utf-8 -*-
  2. from PyQt6.QtCore import *
  3. from PyQt6.QtWidgets import *
  4. from PyQt6.QtGui import *
  5. from qfluentwidgets import *
  6. from .common.config import cfg, FEEDBACK_URL, HELP_URL, EXAMPLE_URL
  7. from .common.icon import Icon
  8. from .common.style_sheet import StyleSheet
  9. from .common.signal_bus import signalBus
  10. from demeter.core import *
  11. # https://doc.qt.io/qt-6/qt.html
  12. from qfluentwidgets.components.dialog_box.mask_dialog_base import MaskDialogBase
  13. import gc
  14. class List(ScrollArea):
  15. def __init__(self, title: str, subtitle: str, model : str, parent=None, button=None, addButton=True):
  16. super().__init__(parent = parent)
  17. self.box = 350
  18. self.base = QWidget(self)
  19. self.model = model;
  20. self.title = title;
  21. self.toolBar = ToolBar(title, subtitle, self, button, addButton)
  22. self.vBoxLayout = QVBoxLayout(self.base)
  23. self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
  24. self.setViewportMargins(0, self.toolBar.height(), 0, 0)
  25. self.setWidget(self.base)
  26. self.setWidgetResizable(True)
  27. self.vBoxLayout.setSpacing(30)
  28. self.vBoxLayout.setAlignment(Qt.AlignmentFlag.AlignTop)
  29. self.vBoxLayout.setContentsMargins(36, 20, 36, 36)
  30. self.base.setObjectName('view')
  31. StyleSheet.LIST.apply(self)
  32. self.pageWidgets = []
  33. def addCard(self, title, widget, sourcePath: str, stretch = 0):
  34. self.widget = widget
  35. self.card = Card(title, widget, sourcePath, stretch, self.base)
  36. self.vBoxLayout.addWidget(self.card, 0, Qt.AlignmentFlag.AlignTop)
  37. return self.card
  38. def scrollToCard(self, index: int):
  39. """ scroll to example card """
  40. w = self.vBoxLayout.itemAt(index).widget()
  41. self.verticalScrollBar().setValue(w.y())
  42. def resizeEvent(self, e):
  43. super().resizeEvent(e)
  44. self.toolBar.resize(self.width(), self.toolBar.height())
  45. def initPage(self):
  46. show_page = 10
  47. total_page = Demeter.config['page']['total']
  48. current_page = Demeter.config['page']['current']
  49. start_page = max(1, current_page - show_page // 2)
  50. end_page = min(total_page, current_page + show_page // 2)
  51. if end_page - start_page < show_page:
  52. if start_page == 1:
  53. end_page = min(total_page, show_page)
  54. else:
  55. start_page = max(1, end_page - show_page + 1)
  56. prev_page = max(1, current_page - 1)
  57. next_page = min(total_page, current_page + 1)
  58. layout = QHBoxLayout()
  59. widgets = []
  60. widgets.append(self.createPageLabel('<', prev_page))
  61. if start_page > 1:
  62. widgets.append(self.createPageLabel(1, 1))
  63. widgets.append(self.createPageLabel('...', 2))
  64. for v in range(start_page, end_page+1, 1):
  65. widgets.append(self.createPageLabel(v, v, current_page))
  66. if end_page < total_page:
  67. widgets.append(self.createPageLabel('...', v+1))
  68. widgets.append(self.createPageLabel(total_page, total_page))
  69. widgets.append(self.createPageLabel('>', next_page))
  70. page_info = QLabel(f"共 {Demeter.config['page']['totalNum']} 条")
  71. page_info.setObjectName('pageCurrent')
  72. widgets.append(page_info)
  73. for key, value in enumerate(self.pageWidgets):
  74. self.vBoxLayout.removeWidget(value)
  75. for key, value in enumerate(widgets):
  76. layout.addWidget(value)
  77. layout.setAlignment(Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignCenter)
  78. #layout.setContentsMargins(0, 0, 0, 0)
  79. layout.setSpacing(10)
  80. self.vBoxLayout.addLayout(layout)
  81. self.pageWidgets = widgets
  82. def createPageLabel(self, label, page, current_page = 0):
  83. label = QPushButton(str(label))
  84. if page:
  85. label.mousePressEvent = lambda event: self.initData(page)
  86. if current_page and current_page == page:
  87. label.setObjectName('pageCurrent')
  88. else:
  89. label.setObjectName('page')
  90. return label
  91. def initButton(self, config):
  92. if config:
  93. button = QWidget()
  94. layout = QHBoxLayout()
  95. for key, value in config.items():
  96. click = PushButton(key)
  97. click.setObjectName('operButton')
  98. layout.addWidget(click)
  99. click.clicked.connect(config[key])
  100. button.setLayout(layout)
  101. return button
  102. return False
  103. def getInfo(self, id):
  104. return Demeter.service('common').one(self.model, id=id)
  105. def update(self):
  106. id = self.widget.getItem()
  107. self.showUpdate('编辑', id)
  108. def delete(self):
  109. if hasattr(self, 'deleteCheck'):
  110. state = self.deleteCheck()
  111. if state:
  112. InfoBar.error(
  113. title='错误提示',
  114. content=state,
  115. orient=Qt.Orientation.Horizontal,
  116. isClosable=True,
  117. position=InfoBarPosition.TOP,
  118. duration=2000,
  119. parent=self.window()
  120. )
  121. return
  122. id = self.widget.getItem()
  123. self.showOper('删除', id, {'state' : 2})
  124. def showUpdate(self, title='', id=0):
  125. self.id = id
  126. box = MessageBoxBase(self.window())
  127. title = SubtitleLabel(title + self.title)
  128. box.viewLayout.addWidget(title)
  129. self.showUpdateItem(id)
  130. for key, value in self.updateItem.items():
  131. box.viewLayout.addWidget(value)
  132. # 设置对话框的最小宽度
  133. box.widget.setMinimumWidth(self.box)
  134. box.yesButton.setText("保存")
  135. box.cancelButton.setText("取消")
  136. if box.exec():
  137. self.save(box)
  138. def showOper(self, title = '', id = 0, data = {}):
  139. self.id = id
  140. box = MessageBoxBase(self.window())
  141. label = BodyLabel('确定要' + title + '吗?')
  142. title = SubtitleLabel(title + self.title)
  143. box.viewLayout.addWidget(title)
  144. box.viewLayout.addWidget(label)
  145. # 设置对话框的最小宽度
  146. box.widget.setMinimumWidth(350)
  147. box.yesButton.setText("确定")
  148. box.cancelButton.setText("取消")
  149. if box.exec():
  150. self.up(data)
  151. def save(self, box):
  152. up = True
  153. data = {}
  154. for key, value in self.updateItem.items():
  155. if 'text' not in key:
  156. if 'check' in key:
  157. key = key.replace('_check', '')
  158. data[key] = value.isChecked()
  159. else:
  160. data[key] = value.text()
  161. if hasattr(self, 'updateFunc') and key in self.updateFunc:
  162. data[key] = self.updateFunc[key](data[key])
  163. if hasattr(self, 'updateDefault'):
  164. for key, value in self.updateDefault.items():
  165. data[key] = value
  166. if 'name' in data:
  167. if not data['name']:
  168. InfoBar.error(
  169. title='错误提示',
  170. content="名称不能为空",
  171. orient=Qt.Orientation.Horizontal,
  172. isClosable=True,
  173. position=InfoBarPosition.TOP,
  174. duration=2000,
  175. parent=self.window()
  176. )
  177. up = False
  178. if box.exec():
  179. return self.save(box)
  180. else:
  181. model = Demeter.model(self.model)
  182. model.name = data['name']
  183. if hasattr(self, 'updateDefault'):
  184. for key, value in self.updateDefault.items():
  185. setattr(model, key, value)
  186. model.id.nq(self.id)
  187. info = model.select(type='fetchone')
  188. if info:
  189. up = False
  190. InfoBar.error(
  191. title='错误提示',
  192. content="名称已存在",
  193. orient=Qt.Orientation.Horizontal,
  194. isClosable=True,
  195. position=InfoBarPosition.TOP,
  196. duration=2000,
  197. parent=self.window()
  198. )
  199. if box.exec():
  200. return self.save(box)
  201. if up:
  202. self.up(data)
  203. def up(self, data = {}):
  204. Demeter.service('common').update(self.model, id=self.id, data=data)
  205. InfoBar.success(
  206. title='系统提示',
  207. content="操作已成功",
  208. orient=Qt.Orientation.Horizontal,
  209. isClosable=True,
  210. position=InfoBarPosition.TOP,
  211. duration=2000,
  212. parent=self.window()
  213. )
  214. if hasattr(self, 'upFunc'):
  215. for key, value in data.items():
  216. if key in self.upFunc:
  217. self.upFunc[key](data[key])
  218. self.initData()
  219. def showTip(self, title, cur, data, click):
  220. position = TeachingTipTailPosition.LEFT
  221. view = TeachingTipView(
  222. icon=None,
  223. title=title,
  224. content="",
  225. isClosable=True,
  226. tailPosition=position,
  227. )
  228. self.listWidget = ListWidget()
  229. index = 0
  230. stands = []
  231. for key, value in enumerate(data):
  232. if (cur['id'] == value['id']):
  233. index = key
  234. stands.append(value['name'])
  235. # 添加列表项
  236. for stand in stands:
  237. item = QListWidgetItem(stand)
  238. #item.setIcon(QIcon(':/qfluentwidgets/images/logo.png'))
  239. self.listWidget.addItem(item)
  240. self.listWidget.setCurrentRow(index)
  241. self.listWidget.itemClicked.connect(click)
  242. view.addWidget(self.listWidget)
  243. # 添加组件
  244. '''
  245. button = PushButton('确认选择')
  246. button.setFixedWidth(120)
  247. view.addWidget(button, align=Qt.AlignCenter)
  248. '''
  249. self.tip = PopupTeachingTip.make(
  250. target=self.toolBar.button[0],
  251. view=view,
  252. duration=-1, # 关闭自动消失
  253. tailPosition=position,
  254. parent=self
  255. )
  256. view.closed.connect(self.tip.close)
  257. class TableBase(TableWidget):
  258. def __init__(self, parent=None):
  259. super().__init__(parent)
  260. self.parent = parent
  261. # 设置不可编辑
  262. #self.setEditTriggers(QAbstractItemView.NoEditTriggers)
  263. self.verticalHeader().hide()
  264. self.setBorderRadius(8)
  265. self.setBorderVisible(True)
  266. self.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
  267. self.verticalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
  268. width = parent.window().width()
  269. height = parent.window().height()
  270. self.setFixedSize(width-170, height-380)
  271. #self.resize(800, 300)
  272. self.resizeColumnsToContents()
  273. self.resizeRowsToContents()
  274. self.init()
  275. def initData(self, page=1, param={}):
  276. column = len(self.head)
  277. self.setColumnCount(column)
  278. body = Demeter.model(self.parent.model).getList(page, param)
  279. self.setRowCount(len(body))
  280. for i, info in enumerate(body):
  281. id = info[0]
  282. for j in range(column):
  283. info[j] = QTableWidgetItem(info[j])
  284. info[j].setTextAlignment(Qt.AlignmentFlag.AlignCenter)
  285. self.setItem(i, j, info[j])
  286. self.setCellWidget(i, column-1, self.parent.initButton(self.button))
  287. self.setHorizontalHeaderLabels(self.head)
  288. if Demeter.config['page']['total'] > 0:
  289. self.parent.initPage()
  290. def getItem(self, index = 0):
  291. item = ''
  292. pos = self.getPos()
  293. if pos:
  294. row = pos.row()
  295. column = pos.column()
  296. item = self.item(row, index).text()
  297. return item
  298. def getPos(self):
  299. button = self.sender()
  300. if button:
  301. pos = self.indexAt(button.parent().pos())
  302. return pos
  303. return False
  304. class SeparatorWidget(QWidget):
  305. """ Seperator widget """
  306. def __init__(self, parent=None):
  307. super().__init__(parent=parent)
  308. self.setFixedSize(6, 16)
  309. def paintEvent(self, e):
  310. painter = QPainter(self)
  311. pen = QPen(1)
  312. pen.setCosmetic(True)
  313. c = QColor(255, 255, 255, 21) if isDarkTheme() else QColor(0, 0, 0, 15)
  314. pen.setColor(c)
  315. painter.setPen(pen)
  316. x = self.width() // 2
  317. painter.drawLine(x, 0, x, self.height())
  318. class ToolBar(QWidget):
  319. """ Tool bar """
  320. def __init__(self, title, subtitle, parent=None, button=None, addButton=True):
  321. super().__init__(parent=parent)
  322. self.parent = parent
  323. self.button = button
  324. self.titleLabel = TitleLabel(title, self)
  325. self.subtitleLabel = CaptionLabel(subtitle, self)
  326. self.addButton = addButton
  327. if self.addButton:
  328. self.createButton = PushButton(
  329. '添加', self, FluentIcon.ADD)
  330. self.helpButton = ToolButton(FluentIcon.FEEDBACK, self)
  331. self.separator = SeparatorWidget(self)
  332. self.themeButton = ToolButton(FluentIcon.CONSTRACT, self)
  333. self.vBoxLayout = QVBoxLayout(self)
  334. self.buttonLayout = QHBoxLayout()
  335. self.__initWidget()
  336. def __initWidget(self):
  337. self.setFixedHeight(138)
  338. self.vBoxLayout.setSpacing(0)
  339. self.vBoxLayout.setContentsMargins(36, 22, 36, 12)
  340. self.vBoxLayout.addWidget(self.titleLabel)
  341. self.vBoxLayout.addSpacing(4)
  342. self.vBoxLayout.addWidget(self.subtitleLabel)
  343. self.vBoxLayout.addSpacing(4)
  344. self.vBoxLayout.addLayout(self.buttonLayout, 1)
  345. self.vBoxLayout.setAlignment(Qt.AlignmentFlag.AlignTop)
  346. self.buttonLayout.setSpacing(4)
  347. self.buttonLayout.setContentsMargins(0, 0, 0, 0)
  348. if self.addButton:
  349. self.buttonLayout.addWidget(self.createButton, 0, Qt.AlignmentFlag.AlignLeft)
  350. if self.button:
  351. for key, value in enumerate(self.button):
  352. self.button[key] = PushButton(value['name'], self, value['icon'])
  353. self.button[key].clicked.connect(value['click'])
  354. self.buttonLayout.addWidget(self.button[key], 0, Qt.AlignmentFlag.AlignLeft)
  355. self.buttonLayout.addStretch(1)
  356. self.buttonLayout.addWidget(self.helpButton, 0, Qt.AlignmentFlag.AlignRight)
  357. self.buttonLayout.addWidget(self.separator, 0, Qt.AlignmentFlag.AlignRight)
  358. self.buttonLayout.addWidget(self.themeButton, 0, Qt.AlignmentFlag.AlignRight)
  359. self.buttonLayout.setAlignment(Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignLeft)
  360. self.themeButton.installEventFilter(ToolTipFilter(self.themeButton))
  361. self.helpButton.installEventFilter(ToolTipFilter(self.helpButton))
  362. self.themeButton.setToolTip(self.tr('Toggle theme'))
  363. self.helpButton.setToolTip('在线教程')
  364. self.themeButton.clicked.connect(lambda: toggleTheme(True))
  365. if self.addButton:
  366. self.createButton.clicked.connect(self.add)
  367. self.helpButton.clicked.connect(
  368. lambda: QDesktopServices.openUrl(QUrl(HELP_URL)))
  369. self.subtitleLabel.setTextColor(QColor(96, 96, 96), QColor(216, 216, 216))
  370. def add(self):
  371. self.parent.showUpdate('添加')
  372. class Card(QWidget):
  373. """ card """
  374. def __init__(self, title, widget: QWidget, sourcePath, stretch=0, parent=None):
  375. super().__init__(parent=parent)
  376. self.widget = widget
  377. self.stretch = stretch
  378. self.titleLabel = StrongBodyLabel(title, self)
  379. self.card = QFrame(self)
  380. self.sourceWidget = QFrame(self.card)
  381. self.sourcePath = sourcePath
  382. self.sourcePathLabel = BodyLabel(
  383. self.tr('Source code'), self.sourceWidget)
  384. self.linkIcon = IconWidget(FluentIcon.LINK, self.sourceWidget)
  385. self.vBoxLayout = QVBoxLayout(self)
  386. self.cardLayout = QVBoxLayout(self.card)
  387. self.topLayout = QHBoxLayout()
  388. #self.bottomLayout = QHBoxLayout(self.sourceWidget)
  389. self.__initWidget()
  390. def __initWidget(self):
  391. self.linkIcon.setFixedSize(16, 16)
  392. self.__initLayout()
  393. self.sourceWidget.setCursor(Qt.CursorShape.PointingHandCursor)
  394. self.sourceWidget.installEventFilter(self)
  395. self.card.setObjectName('card')
  396. self.sourceWidget.setObjectName('sourceWidget')
  397. def __initLayout(self):
  398. '''
  399. setSizeConstraint 方法用于设置布局的大小约束,它可以接受以下参数:
  400. QLayout.SizeConstraint.SetDefaultConstraint:默认约束,布局将根据其内容自动调整大小。
  401. QLayout.SizeConstraint.SetFixedSize:固定大小约束,布局的大小将保持不变。
  402. QLayout.SizeConstraint.SetMinimumSize:最小尺寸约束,布局的大小将不小于指定的最小尺寸。
  403. QLayout.SizeConstraint.SetMaximumSize:最大尺寸约束,布局的大小将不大于指定的最大尺寸。
  404. '''
  405. self.vBoxLayout.setSizeConstraint(QLayout.SizeConstraint.SetMinimumSize)
  406. self.cardLayout.setSizeConstraint(QLayout.SizeConstraint.SetMinimumSize)
  407. self.topLayout.setSizeConstraint(QLayout.SizeConstraint.SetMinimumSize)
  408. self.vBoxLayout.setSpacing(12)
  409. self.vBoxLayout.setContentsMargins(0, 0, 0, 0)
  410. self.topLayout.setContentsMargins(12, 12, 12, 12)
  411. #self.bottomLayout.setContentsMargins(18, 18, 18, 18)
  412. self.cardLayout.setContentsMargins(0, 0, 0, 0)
  413. self.vBoxLayout.addWidget(self.titleLabel, 0, Qt.AlignmentFlag.AlignTop)
  414. self.vBoxLayout.addWidget(self.card, 0, Qt.AlignmentFlag.AlignTop)
  415. self.vBoxLayout.setAlignment(Qt.AlignmentFlag.AlignTop)
  416. self.cardLayout.setSpacing(0)
  417. self.cardLayout.setAlignment(Qt.AlignmentFlag.AlignTop)
  418. self.cardLayout.addLayout(self.topLayout, 0)
  419. self.cardLayout.addWidget(self.sourceWidget, 0, Qt.AlignmentFlag.AlignBottom)
  420. self.widget.setParent(self.card)
  421. self.topLayout.addWidget(self.widget)
  422. if self.stretch == 0:
  423. self.topLayout.addStretch(1)
  424. self.widget.show()
  425. #self.bottomLayout.addWidget(self.sourcePathLabel, 0, Qt.AlignmentFlag.AlignLeft)
  426. #self.bottomLayout.addStretch(1)
  427. #self.bottomLayout.addWidget(self.linkIcon, 0, Qt.AlignmentFlag.AlignRight)
  428. #self.bottomLayout.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
  429. def eventFilter(self, obj, e):
  430. if obj is self.sourceWidget:
  431. if e.type() == QEvent.Type.MouseButtonRelease:
  432. QDesktopServices.openUrl(QUrl(self.sourcePath))
  433. return super().eventFilter(obj, e)
  434. class WorkerSignals(QObject):
  435. finished = pyqtSignal()
  436. error = pyqtSignal(tuple)
  437. result = pyqtSignal(object)
  438. progress = pyqtSignal(int) # Add progress signal
  439. class Worker(QThread):
  440. def __init__(self, fn, *args, **kwargs):
  441. super().__init__()
  442. self.fn = fn
  443. self.args = args
  444. self.kwargs = kwargs
  445. self.signals = WorkerSignals()
  446. self._is_running = True
  447. @pyqtSlot()
  448. def run(self):
  449. try:
  450. # Call the function and pass a callback to report progress
  451. result = self.fn(self.report_progress, *self.args, **self.kwargs)
  452. if self._is_running: # 检查标志,如果未停止则发出结果信号
  453. self.signals.result.emit(result)
  454. except Exception as e:
  455. self.signals.error.emit((e.__class__, e, e.__traceback__))
  456. finally:
  457. self.signals.finished.emit()
  458. def report_progress(self, progress):
  459. if self._is_running: # 检查标志,如果未停止则发出进度信号
  460. self.signals.progress.emit(progress)
  461. def stop(self):
  462. self._is_running = False # 设置标志为 False 以停止线程的运行
  463. def terminate(self):
  464. self._is_running = False # 确保标志位设置为 False
  465. super().terminate() # 强制终止线程
  466. self.clean_up() # 执行清理
  467. def clean_up(self):
  468. # 执行任何必要的清理
  469. del self.fn
  470. del self.args
  471. del self.kwargs
  472. gc.collect() # 强制垃圾回收
  473. class Progress(MaskDialogBase):
  474. cancelSignal = pyqtSignal()
  475. def __init__(self, title, parent=None):
  476. super().__init__(parent=parent)
  477. self.work = False
  478. self.title = BodyLabel(title)
  479. #self.widget.setFixedSize(500, 150)
  480. self.vBoxLayout = QVBoxLayout(self.widget)
  481. self.viewLayout = QVBoxLayout()
  482. self.__initWidget()
  483. def __initWidget(self):
  484. self.__setQss()
  485. self.__initLayout()
  486. self.setShadowEffect(60, (0, 10), QColor(0, 0, 0, 50))
  487. self.setMaskColor(QColor(0, 0, 0, 76))
  488. def __initLayout(self):
  489. self._hBoxLayout.removeWidget(self.widget)
  490. self._hBoxLayout.addWidget(self.widget, 1, Qt.AlignmentFlag.AlignCenter)
  491. self.vBoxLayout.setSpacing(0)
  492. self.vBoxLayout.setContentsMargins(0, 0, 0, 0)
  493. self.vBoxLayout.addLayout(self.viewLayout, 1)
  494. self.viewLayout.setSpacing(12)
  495. self.viewLayout.setContentsMargins(24, 24, 24, 24)
  496. self.progressBar = ProgressBar()
  497. #ProgressBar ProgressRing IndeterminateProgressRing
  498. self.progressBar.setRange(0, 100)
  499. self.progressBar.setValue(0)
  500. self.viewLayout.addWidget(self.title)
  501. self.viewLayout.addWidget(self.progressBar)
  502. self.show()
  503. def __setQss(self):
  504. FluentStyleSheet.DIALOG.apply(self)
  505. def setValue(self, value):
  506. self.progressBar.setValue(value)
  507. def __onCancelButtonClicked(self):
  508. self.cancelSignal.emit()
  509. self.reject()
  510. '''
  511. if self.work:
  512. self.work.close()
  513. '''
  514. def bind(self, work):
  515. self.work = work