Changeset View
Changeset View
Standalone View
Standalone View
plugins/extensions/pykrita/plugin/plugins/scripter/uicontroller.py
Show All 16 Lines | 12 | def __init__(self, mainWidget): | |||
---|---|---|---|---|---|
17 | self.actionToolbar.setObjectName('toolBar') | 17 | self.actionToolbar.setObjectName('toolBar') | ||
18 | self.menu_bar.setObjectName('menuBar') | 18 | self.menu_bar.setObjectName('menuBar') | ||
19 | 19 | | |||
20 | self.actions = [] | 20 | self.actions = [] | ||
21 | 21 | | |||
22 | self.mainWidget.setWindowModality(Qt.NonModal) | 22 | self.mainWidget.setWindowModality(Qt.NonModal) | ||
23 | self.editor = pythoneditor.CodeEditor() | 23 | self.editor = pythoneditor.CodeEditor() | ||
24 | self.output = QPlainTextEdit() | 24 | self.output = QPlainTextEdit() | ||
25 | self.statusBar = QLabel('untitled') | ||||
25 | self.highlight = syntax.PythonHighlighter(self.editor.document(), syntaxstyles.DefaultSyntaxStyle()) | 26 | self.highlight = syntax.PythonHighlighter(self.editor.document(), syntaxstyles.DefaultSyntaxStyle()) | ||
26 | 27 | | |||
27 | def initialize(self, scripter): | 28 | def initialize(self, scripter): | ||
28 | self.scripter = scripter | 29 | self.scripter = scripter | ||
29 | 30 | | |||
30 | self.loadMenus() | 31 | self.loadMenus() | ||
31 | self.loadActions() | 32 | self.loadActions() | ||
32 | 33 | | |||
33 | vbox = QVBoxLayout(self.mainWidget) | 34 | vbox = QVBoxLayout(self.mainWidget) | ||
34 | vbox.addWidget(self.menu_bar) | 35 | vbox.addWidget(self.menu_bar) | ||
35 | vbox.addWidget(self.editor) | 36 | vbox.addWidget(self.editor) | ||
36 | vbox.addWidget(self.actionToolbar) | 37 | vbox.addWidget(self.actionToolbar) | ||
37 | vbox.addWidget(self.output) | 38 | vbox.addWidget(self.output) | ||
39 | vbox.addWidget(self.statusBar) | ||||
38 | 40 | | |||
39 | self.mainWidget.resize(400, 500) | 41 | self.mainWidget.resize(400, 500) | ||
40 | self.mainWidget.setWindowTitle("Scripter") | 42 | self.mainWidget.setWindowTitle("Scripter") | ||
41 | self.mainWidget.setSizeGripEnabled(True) | 43 | self.mainWidget.setSizeGripEnabled(True) | ||
42 | self.mainWidget.show() | 44 | self.mainWidget.show() | ||
43 | self.mainWidget.activateWindow() | 45 | self.mainWidget.activateWindow() | ||
44 | 46 | | |||
45 | def loadMenus(self): | 47 | def loadMenus(self): | ||
Show All 29 Lines | 75 | for module in modules: | |||
75 | action_class = getattr(m, module['klass']) | 77 | action_class = getattr(m, module['klass']) | ||
76 | obj = action_class(self.scripter) | 78 | obj = action_class(self.scripter) | ||
77 | parent = self.mainWidget.findChild(QObject, obj.parent) | 79 | parent = self.mainWidget.findChild(QObject, obj.parent) | ||
78 | self.actions.append(dict(action=obj, parent=parent)) | 80 | self.actions.append(dict(action=obj, parent=parent)) | ||
79 | 81 | | |||
80 | for action in self.actions: | 82 | for action in self.actions: | ||
81 | action['parent'].addAction(action['action']) | 83 | action['parent'].addAction(action['action']) | ||
82 | 84 | | |||
85 | def invokeAction(self, actionName): | ||||
86 | for action in self.actions: | ||||
87 | if action['action'].objectName() == actionName: | ||||
88 | method = getattr(action['action'], actionName) | ||||
89 | if method: | ||||
90 | return method() | ||||
91 | | ||||
83 | def setDocumentEditor(self, document): | 92 | def setDocumentEditor(self, document): | ||
84 | self.editor.clear() | 93 | self.editor.clear() | ||
85 | 94 | | |||
86 | for line in document.data(): | 95 | for line in document.data: | ||
87 | self.editor.appendPlainText(line) | 96 | self.editor.appendPlainText(line) | ||
97 | | ||||
98 | def setStatusBar(self, value='untitled'): | ||||
99 | self.statusBar.setText(value) | ||||
100 | | ||||
101 | def clearEditor(self): | ||||
102 | self.editor.clear() |