コード例 #1
0
ファイル: CodeBoxFieldEditor.py プロジェクト: tommo/gii
class CodeBoxEditorWidget( QtGui.QWidget ):
	def __init__( self, *args ):
		super( CodeBoxEditorWidget, self ).__init__( *args )
		self.setWindowFlags( Qt.Popup | Qt.Window )
		self.ui = CodeBoxForm()
		self.ui.setupUi( self )
		
		self.editor = None
		self.originalText = ''

		self.ui.buttonOK.clicked.connect( self.apply )
		self.ui.buttonCancel.clicked.connect( self.cancel )
		self.codeBox = CodeEditor( self.ui.containerContent )
		layout = QtGui.QVBoxLayout( self.ui.containerContent )
		layout.addWidget( self.codeBox )
		layout.setSpacing( 0 )
		layout.setMargin( 0 )
		
		self.setFocusProxy( self.codeBox )

		self.installEventFilter( self )
		self.codeBox.installEventFilter( self )

	def eventFilter( self, obj, ev ):
		e = ev.type()
		if obj == self:
			if e == QEvent.WindowDeactivate:
				obj.hide()
		elif obj == self.codeBox:
			if e == QEvent.KeyPress:
				if ( ev.key(), ev.modifiers() ) == ( Qt.Key_Return, Qt.ControlModifier ):
					self.apply()
					return True
		return QWidget.eventFilter( self, obj, ev )
	
	def getText( self ):
		return self.codeBox.toPlainText()

	def startEdit( self, editor, text ):
		self.originalText = text or ''
		self.editor = editor
		self.codeBox.setPlainText( text, 'text/x-lua' )

	def hideEvent( self, ev ):
		self.apply( True )
		return super( CodeBoxEditorWidget, self ).hideEvent( ev )

	def apply( self, noHide = False ):
		if self.editor:
			self.editor.changeText( self.getText() )
			self.editor = None
		if not noHide:
			self.hide()

	def cancel( self, noHide = False ):
		if self.editor:
			self.editor.changeText( self.originalText )
			self.editor = None
		if not noHide:
			self.hide()
コード例 #2
0
 def __init__(self, path, container):
     CodeEditor.__init__(self, container)
     self.path = path
     self.mimeType = 'text/x-lua'
     self.container = container
     self.fileTime = 0
     self.setReadOnly(True)
     self.refreshCode()
コード例 #3
0
class SQNodeScriptLuaEditor(SQNodeEditor):
    def __init__(self):
        super(SQNodeScriptLuaEditor, self).__init__()
        layout = QtWidgets.QVBoxLayout(self)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        self.codeBox = CodeEditor(self)
        self.codeBox.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                   QtWidgets.QSizePolicy.Expanding)
        layout.addWidget(self.codeBox)
        self.codeBox.textChanged.connect(self.onTextChanged)
        self.firstTouched = False

    def onTextChanged(self):
        self.targetNode.text = self.codeBox.toPlainText()
        self.notifyChanged()

    def onRefresh(self, node):
        self.codeBox.setPlainText(node.script or '', 'text/x-lua')

    def onLoad(self, node):
        self.firstTouched = False

    def setFocus(self):
        self.codeBox.setFocus()
        if self.firstTouched: return
        self.firstTouched = True
        self.codeBox.selectAll()
コード例 #4
0
ファイル: CommonSQNodeEditor.py プロジェクト: tommo/gii
class SQNodeScriptLuaEditor( SQNodeEditor ):
	def __init__(self):
		super(SQNodeScriptLuaEditor, self).__init__()
		layout = QtGui.QVBoxLayout( self )
		layout.setSpacing( 0 )
		layout.setMargin( 0 )
		self.codeBox = CodeEditor( self )
		self.codeBox.setSizePolicy(
			QtGui.QSizePolicy.Expanding,
			QtGui.QSizePolicy.Expanding
			)
		layout.addWidget( self.codeBox )
		self.codeBox.textChanged.connect( self.onTextChanged )
		self.firstTouched = False

	def onTextChanged( self ):
		self.targetNode.text = self.codeBox.toPlainText()
		self.notifyChanged()

	def onRefresh( self, node ):
		self.codeBox.setPlainText( node.script or '', 'text/x-lua' )

	def onLoad( self, node ):
		self.firstTouched = False

	def setFocus( self ):
		self.codeBox.setFocus()
		if self.firstTouched: return
		self.firstTouched = True
		self.codeBox.selectAll()
コード例 #5
0
 def __init__(self):
     super(SQNodeScriptLuaEditor, self).__init__()
     layout = QtWidgets.QVBoxLayout(self)
     layout.setSpacing(0)
     layout.setContentsMargins(0, 0, 0, 0)
     self.codeBox = CodeEditor(self)
     self.codeBox.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                QtWidgets.QSizePolicy.Expanding)
     layout.addWidget(self.codeBox)
     self.codeBox.textChanged.connect(self.onTextChanged)
     self.firstTouched = False
コード例 #6
0
ファイル: CodeBoxFieldEditor.py プロジェクト: pixpil/gii
	def __init__( self, *args ):
		super( CodeBoxEditorWidget, self ).__init__( *args )
		self.setWindowFlags( Qt.Popup | Qt.Window )
		self.ui = CodeBoxForm()
		self.ui.setupUi( self )
		self.installEventFilter( WindowAutoHideEventFilter( self ) )

		self.editor = None
		self.originalText = ''

		self.ui.buttonOK.clicked.connect( self.apply )
		self.ui.buttonCancel.clicked.connect( self.cancel )
		self.codeBox = CodeEditor( self.ui.containerContent )
		layout = QtGui.QVBoxLayout( self.ui.containerContent )
		layout.addWidget( self.codeBox )
		layout.setSpacing( 0 )
		layout.setMargin( 0 )

		# settingData = jsonHelper.tryLoadJSON(
		# 		app.findDataFile( 'script_settings.json' )
		# 	)
		# if settingData:
		# 	self.codeBox.applySetting( settingData )
		
		self.setFocusProxy( self.codeBox )
コード例 #7
0
    def __init__(self, *args):
        super(CodeBoxEditorWidget, self).__init__(*args)
        self.setWindowFlags(Qt.Popup | Qt.Window)
        self.ui = CodeBoxForm()
        self.ui.setupUi(self)

        self.editor = None
        self.originalText = ''

        self.ui.buttonOK.clicked.connect(self.apply)
        self.ui.buttonCancel.clicked.connect(self.cancel)
        self.codeBox = CodeEditor(self.ui.containerContent)
        layout = QtGui.QVBoxLayout(self.ui.containerContent)
        layout.addWidget(self.codeBox)
        layout.setSpacing(0)
        layout.setMargin(0)

        self.setFocusProxy(self.codeBox)

        self.installEventFilter(self)
        self.codeBox.installEventFilter(self)
コード例 #8
0
ファイル: CommonSQNodeEditor.py プロジェクト: tommo/gii
	def __init__(self):
		super(SQNodeScriptLuaEditor, self).__init__()
		layout = QtGui.QVBoxLayout( self )
		layout.setSpacing( 0 )
		layout.setMargin( 0 )
		self.codeBox = CodeEditor( self )
		self.codeBox.setSizePolicy(
			QtGui.QSizePolicy.Expanding,
			QtGui.QSizePolicy.Expanding
			)
		layout.addWidget( self.codeBox )
		self.codeBox.textChanged.connect( self.onTextChanged )
		self.firstTouched = False
コード例 #9
0
ファイル: CodeBoxFieldEditor.py プロジェクト: pixpil/gii
    def __init__(self, *args):
        super(CodeBoxEditorWidget, self).__init__(*args)
        self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)
        self.setWindowModality(Qt.WindowModal)
        self.setWindowTitle('Code Edit')
        self.ui = CodeBoxForm()
        self.ui.setupUi(self)

        self.editor = None
        self.originalText = ''

        self.ui.buttonOK.clicked.connect(self.apply)
        self.ui.buttonCancel.clicked.connect(self.cancel)
        self.codeBox = CodeEditor(self.ui.containerContent)
        layout = QtWidgets.QVBoxLayout(self.ui.containerContent)
        layout.addWidget(self.codeBox)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)

        self.setFocusProxy(self.codeBox)

        self.installEventFilter(self)
        self.codeBox.installEventFilter(self)
コード例 #10
0
ファイル: CodeBoxFieldEditor.py プロジェクト: tommo/gii
	def __init__( self, *args ):
		super( CodeBoxEditorWidget, self ).__init__( *args )
		self.setWindowFlags( Qt.Popup | Qt.Window )
		self.ui = CodeBoxForm()
		self.ui.setupUi( self )
		
		self.editor = None
		self.originalText = ''

		self.ui.buttonOK.clicked.connect( self.apply )
		self.ui.buttonCancel.clicked.connect( self.cancel )
		self.codeBox = CodeEditor( self.ui.containerContent )
		layout = QtGui.QVBoxLayout( self.ui.containerContent )
		layout.addWidget( self.codeBox )
		layout.setSpacing( 0 )
		layout.setMargin( 0 )
		
		self.setFocusProxy( self.codeBox )

		self.installEventFilter( self )
		self.codeBox.installEventFilter( self )
コード例 #11
0
    def onLoad(self):
        self.windowTitle = 'Effect System Editor'
        self.container = self.requestDocumentWindow(
            'MockEffectEditor',
            title='Effect Editor',
            size=(500, 300),
            minSize=(500, 300),
            # allowDock = False
        )

        self.tool = self.addToolBar('effect_editor',
                                    self.container.addToolBar())
        self.addTool('effect_editor/save', label='Save', icon='save')
        self.addTool('effect_editor/----')
        self.addTool('effect_editor/remove_node', icon='remove')
        self.addTool('effect_editor/clone_node', icon='clone')
        self.addTool('effect_editor/add_system', label='+System')
        self.addTool('effect_editor/add_child', label='+Child')
        self.addTool('effect_editor/----')
        self.addTool('effect_editor/add_move', label='+Move')
        self.addTool('effect_editor/----')
        self.addTool('effect_editor/move_up', icon='arrow-up')
        self.addTool('effect_editor/move_down', icon='arrow-down')
        self.addTool('effect_editor/----')
        self.addTool('effect_editor/toggle_preview', icon='play', type='check')

        self.window = window = self.container.addWidgetFromFile(
            _getModulePath('EffectEditor.ui'))
        self.canvas = addWidgetWithLayout(
            MOAIEditCanvas(window.containerPreview))
        window.setFocusProxy(self.canvas)
        self.tree = addWidgetWithLayout(
            EffectNodeTreeWidget(window.containerTree))
        self.tree.module = self

        propLayout = QtGui.QVBoxLayout()
        window.containerEditor.setLayout(propLayout)
        propLayout.setSpacing(2)
        propLayout.setMargin(0)

        self.nodePropEditor = PropertyEditor(window.containerEditor)
        self.paramPropEditor = PropertyEditor(window.containerEditor)

        propLayout.addWidget(self.nodePropEditor)
        propLayout.addWidget(self.paramPropEditor)
        self.paramPropEditor.setVisible(False)
        window.containerScript.setVisible(False)

        self.codebox = codebox = addWidgetWithLayout(
            CodeEditor(window.containerScript))

        settingData = jsonHelper.tryLoadJSON(
            self.getApp().findDataFile('script_settings.json'))
        # if settingData:
        # 	codebox.applySetting( settingData )

        self.editingTarget = None

        #ShortCuts
        self.addShortcut(self.container, '+', self.addSystem)
        self.addShortcut(self.container, '=', self.promptAddChild)
        self.addShortcut(self.container, '-', self.removeNode)
        # self.addShortcut( self.container, ']',  self.moveNodeUp )
        # self.addShortcut( self.container, '[',  self.moveNodeDown )
        self.addShortcut(self.container, 'ctrl+D', self.cloneNode)
        self.addShortcut(self.container, 'f5', self.togglePreview)
        self.addShortcut(self.container, 'f4', self.restartPreview)

        #Signals
        self.nodePropEditor.propertyChanged.connect(self.onNodePropertyChanged)
        self.paramPropEditor.propertyChanged.connect(
            self.onParamPropertyChanged)
        self.codebox.textChanged.connect(self.onScriptChanged)
コード例 #12
0
ファイル: CodeBoxFieldEditor.py プロジェクト: pixpil/gii
class CodeBoxEditorWidget(QtWidgets.QWidget):
    def __init__(self, *args):
        super(CodeBoxEditorWidget, self).__init__(*args)
        self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)
        self.setWindowModality(Qt.WindowModal)
        self.setWindowTitle('Code Edit')
        self.ui = CodeBoxForm()
        self.ui.setupUi(self)

        self.editor = None
        self.originalText = ''

        self.ui.buttonOK.clicked.connect(self.apply)
        self.ui.buttonCancel.clicked.connect(self.cancel)
        self.codeBox = CodeEditor(self.ui.containerContent)
        layout = QtWidgets.QVBoxLayout(self.ui.containerContent)
        layout.addWidget(self.codeBox)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)

        self.setFocusProxy(self.codeBox)

        self.installEventFilter(self)
        self.codeBox.installEventFilter(self)

    def eventFilter(self, obj, ev):
        e = ev.type()
        if obj == self:
            if e == QEvent.WindowDeactivate:
                obj.hide()
        elif obj == self.codeBox:
            if e == QEvent.KeyPress:
                if (ev.key(), ev.modifiers()) == (Qt.Key_Return,
                                                  Qt.ControlModifier):
                    self.apply()
                    return True
        return QWidget.eventFilter(self, obj, ev)

    def getText(self):
        return self.codeBox.toPlainText()

    def startEdit(self, editor, text):
        self.originalText = text or ''
        self.editor = editor
        self.codeBox.setPlainText(text, 'text/x-lua')

    def hideEvent(self, ev):
        self.apply(True)
        return super(CodeBoxEditorWidget, self).hideEvent(ev)

    def apply(self, noHide=False):
        if self.editor:
            self.editor.changeText(self.getText())
            self.editor = None
        if not noHide:
            self.hide()

    def cancel(self, noHide=False):
        if self.editor:
            self.editor.changeText(self.originalText)
            self.editor = None
        if not noHide:
            self.hide()
コード例 #13
0
ファイル: CodeBoxFieldEditor.py プロジェクト: pixpil/gii
class CodeBoxEditorWidget( QtGui.QWidget ):
	def __init__( self, *args ):
		super( CodeBoxEditorWidget, self ).__init__( *args )
		self.setWindowFlags( Qt.Popup | Qt.Window )
		self.ui = CodeBoxForm()
		self.ui.setupUi( self )
		self.installEventFilter( WindowAutoHideEventFilter( self ) )

		self.editor = None
		self.originalText = ''

		self.ui.buttonOK.clicked.connect( self.apply )
		self.ui.buttonCancel.clicked.connect( self.cancel )
		self.codeBox = CodeEditor( self.ui.containerContent )
		layout = QtGui.QVBoxLayout( self.ui.containerContent )
		layout.addWidget( self.codeBox )
		layout.setSpacing( 0 )
		layout.setMargin( 0 )

		# settingData = jsonHelper.tryLoadJSON(
		# 		app.findDataFile( 'script_settings.json' )
		# 	)
		# if settingData:
		# 	self.codeBox.applySetting( settingData )
		
		self.setFocusProxy( self.codeBox )
	
	def getText( self ):
		return self.codeBox.toPlainText()

	def startEdit( self, editor, text ):
		self.originalText = text or ''
		self.editor = editor
		self.codeBox.setPlainText( text, 'text/x-lua' )

	def hideEvent( self, ev ):
		self.apply( True )
		return super( CodeBoxEditorWidget, self ).hideEvent( ev )

	def apply( self, noHide = False ):
		if self.editor:
			self.editor.changeText( self.getText() )
			self.editor = None
		if not noHide:
			self.hide()

	def cancel( self, noHide = False ):
		if self.editor:
			self.editor.changeText( self.originalText )
			self.editor = None
		if not noHide:
			self.hide()

	def keyPressEvent( self, ev ):
		key = ev.key()
		if ( key, ev.modifiers() ) == ( Qt.Key_Return, Qt.ControlModifier ):
			print("????" )
			self.apply()
			return
		# if key == Qt.Key_Escape:
		# 	self.cancel()
		# 	return
		return super( CodeBoxEditorWidget, self ).keyPressEvent( ev )