Allow brush shapes to have no icon.
This commit is contained in:
parent
49e55338e4
commit
251c999742
@ -25,11 +25,14 @@ class ShapeWidget(QtGui.QWidget):
|
|||||||
iconBase = resourcePath("mcedit2/assets/mcedit2/icons")
|
iconBase = resourcePath("mcedit2/assets/mcedit2/icons")
|
||||||
actions = {}
|
actions = {}
|
||||||
for shape in getShapes():
|
for shape in getShapes():
|
||||||
filename = os.path.join(iconBase, shape.icon)
|
if shape.icon is not None:
|
||||||
assert os.path.exists(filename), "%r does not exist" % filename
|
filename = os.path.join(iconBase, shape.icon)
|
||||||
icon = QtGui.QIcon(filename)
|
assert os.path.exists(filename), "%r does not exist" % filename
|
||||||
if icon is None:
|
icon = QtGui.QIcon(filename)
|
||||||
raise ValueError("Failed to read shape icon file %s" % filename)
|
if icon is None:
|
||||||
|
log.warn("Failed to read shape icon file %s" % filename)
|
||||||
|
else:
|
||||||
|
icon = None
|
||||||
|
|
||||||
def _handler(shape):
|
def _handler(shape):
|
||||||
def handler():
|
def handler():
|
||||||
@ -37,7 +40,10 @@ class ShapeWidget(QtGui.QWidget):
|
|||||||
BrushShapeSetting.setValue(shape.ID)
|
BrushShapeSetting.setValue(shape.ID)
|
||||||
self.shapeChanged.emit()
|
self.shapeChanged.emit()
|
||||||
return handler
|
return handler
|
||||||
action = QtGui.QAction(icon, shape.ID, self, triggered=_handler(shape))
|
if icon is None:
|
||||||
|
action = QtGui.QAction(shape.ID, self, triggered=_handler(shape))
|
||||||
|
else:
|
||||||
|
action = QtGui.QAction(icon, shape.ID, self, triggered=_handler(shape))
|
||||||
button = QtGui.QToolButton()
|
button = QtGui.QToolButton()
|
||||||
action.setCheckable(True)
|
action.setCheckable(True)
|
||||||
button.setDefaultAction(action)
|
button.setDefaultAction(action)
|
||||||
|
Reference in New Issue
Block a user