提交 bc7de19d 编写于 作者: K Kentaro Wada

Minor fix saveWithImageData

上级 e2894d37
......@@ -243,17 +243,13 @@ class MainWindow(QtWidgets.QMainWindow):
)
saveAuto.setChecked(self._config['auto_save'])
def onSaveWithImageDataClick(x):
self._config['store_data'] = x
self.actions.saveWithImageData.setChecked(x)
saveWithImageData = action(
text='Save With Image Data',
slot=onSaveWithImageDataClick,
slot=self.enableSaveImageWithData,
tip='Save image data in label file',
checkable=True,
checked=self._config['store_data'],
)
saveWithImageData.setChecked(self._config['store_data'])
close = action('&Close', self.closeFile, shortcuts['close'], 'close',
'Close current file')
......@@ -1344,6 +1340,10 @@ class MainWindow(QtWidgets.QMainWindow):
w = self.centralWidget().width() - 2.0
return w / self.canvas.pixmap.width()
def enableSaveImageWithData(self, enabled):
self._config['store_data'] = enabled
self.actions.saveWithImageData.setChecked(enabled)
def closeEvent(self, event):
if not self.mayContinue():
event.ignore()
......
......@@ -26,7 +26,7 @@ def newButton(text, icon=None, slot=None):
def newAction(parent, text, slot=None, shortcut=None, icon=None,
tip=None, checkable=False, enabled=True):
tip=None, checkable=False, enabled=True, checked=False):
"""Create a new action and assign callbacks, shortcuts, etc."""
a = QtWidgets.QAction(text, parent)
if icon is not None:
......@@ -45,6 +45,7 @@ def newAction(parent, text, slot=None, shortcut=None, icon=None,
if checkable:
a.setCheckable(True)
a.setEnabled(enabled)
a.setChecked(checked)
return a
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册