def cut(self, path, imagelock=None): pathrectf = path.boundingRect() pathrect = pathrectf.toAlignedRect() if not imagelock: imagelock = qtcore.QWriteLocker(self.imagelock) oldareaimage = self.getImageCopy(imagelock, pathrect) win = BeeApp().master.getWindowById(self.windowid) if win.ownedByMe(self.owner): self.copy(path, imagelock) # erase from image painter = qtgui.QPainter() painter.begin(self.image) painter.setClipPath(path) painter.setCompositionMode(qtgui.QPainter.CompositionMode_Clear) painter.drawImage(self.image.rect(), self.image) painter.end() imagelock.unlock() win.view.updateView(pathrectf) BeeApp().master.refreshLayerThumb(self.windowid, self.key) command = CutCommand(self.key, oldareaimage, path) win = BeeApp().master.getWindowById(self.windowid) win.addCommandToHistory(command, self.owner)
def updateValuesFromLayer(self, winlock=None, proplock=None, layerslock=None): win = BeeApp().master.getWindowById(self.windowid, winlock) if not win: return layer = win.getLayerForKey(self.layerkey, layerslock) if not layer: print_debug("WARNING: updateValueFromLayer could not find layer with key %s" % self.layerkey) return if not proplock: proplock = qtcore.QReadLocker(layer.propertieslock) # update visibility box self.ui.visibility_box.setChecked(layer.isVisible()) # update opacity slider # self.ui.opacity_box.setValue(layer.opacity()) self.ui.opacity_slider.setValue(int(layer.opacity() * 100)) # update name displayname = layer.name if layer.type == LayerTypes.animation: displayname += " (Animation)" elif layer.type == LayerTypes.network: displayname += " (Network)" self.ui.layer_name_label.setText(displayname) # update blend mode box self.ui.blend_mode_box.setCurrentIndex( self.ui.blend_mode_box.findText(BlendTranslations.modeToName(layer.compmode)) ) netbuttonstate = False netbuttontext = "" # only need text on the button if it's a network or floating layer if win.type == WindowTypes.networkclient: if win.ownedByNobody(layer.getOwner(proplock)): netbuttontext = "Claim Ownership" netbuttonstate = True elif win.ownedByMe(layer.getOwner(proplock)): netbuttontext = "Give Up Ownership" netbuttonstate = True if layer.type == LayerTypes.floating: netbuttontext = "Anchor On Layer" netbuttonstate = True # disable controls if client shouldn't be able to control them if win.type == WindowTypes.networkclient: if win.ownedByMe(layer.getOwner(proplock)) or layer.type == LayerTypes.floating: self.ui.opacity_slider.setEnabled(True) self.ui.blend_mode_box.setEnabled(True) else: self.ui.opacity_slider.setDisabled(True) self.ui.blend_mode_box.setDisabled(True) self.ui.network_control_button.setText(netbuttontext) self.ui.network_control_button.setEnabled(netbuttonstate)