コード例 #1
0
ファイル: main_window.py プロジェクト: JPLeBreton/dreamer
class MainWindow(QtGui.QMainWindow):
    def __init__(self, *args):
        QtGui.QMainWindow.__init__(self)
        loadUi(ui.UI_RESOURCE_PATH + ui_file_name, self)
        
        self._layer_widget = LayerWidget(self)
        self.layer_dock.setWidget(self._layer_widget)
    
    @QtCore.Slot()
    def _on_action_new_layer(self):
        self._layer_widget.new_layer()
コード例 #2
0
ファイル: main_window.py プロジェクト: Dingobloo/dreamer
class MainWindow(QtGui.QMainWindow):
    def __init__(self, *args):
        QtGui.QMainWindow.__init__(self)

        loadUi(ui.UI_RESOURCE_PATH + ui_file_name, self)

        self._pages_widget = PageWidget(self)
        self.pages_dock.setWidget(self._pages_widget)

        self._layer_widget = LayerWidget(self)
        self.layer_dock.setWidget(self._layer_widget)

        layer_list = [Layer('duh'), Layer('bluh'), Layer('meh')]
        layer_model = LayerListModel(layer_list)
        self._layer_widget.set_model(layer_model)

        #Web View Initialisation
        self._web_view = DreamWebView(self)
        self._web_view.setUrl(":ui/resources/startup.html")
        #self._web_view.setUrl("")
        self.setCentralWidget(self._web_view)

        self._web_view.loadFinished.connect(self.webLoadFinished)

        #self.propertiesTable.setModel(self)
        properties_model = PropertiesItemModel(self)
        self.propertiesTable.setModel(properties_model)

        myList = [QStandardItem("Test"), QStandardItem(2)]
        properties_model.insertRow(0,myList)

        myList = [QStandardItem("Test"), QStandardItem("Testing")]
        properties_model.insertRow(1,myList)

        self.current_tool = TranslateTool(self._web_view)
        #print(dir(item))

        self.buttonNoTool.pressed.connect(self.buttonNonePressed)
        self.buttonMoveTool.pressed.connect(self.buttonMovePressed)

    def buttonNonePressed(self):
        self.current_tool = None

    def buttonMovePressed(self):
        self.current_tool = TranslateTool(self._web_view)

    def webLoadFinished(self, loaded):
        print("We loaded a web page")

        infile = QFile(self)
        infile.setFileName("ui/resources/jquery-1.9.1.js")

        if not infile.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text):
            print("Error opening file: " + infile.errorString())

        stream = QtCore.QTextStream(infile)
        self.jQuery = stream.readAll()
        infile.close()

        print("We loaded jQuery")

        self._web_view.page().mainFrame().evaluateJavaScript(self.jQuery)

        print("We evaluated jQuery")

        self._web_view.page().mainFrame().evaluateJavaScript("$( 'div.header' ).css( '-webkit-transition', '-webkit-transform 2s'); $( 'div.header' ).css('-webkit-transform', 'rotate(360deg)')")

        print("Ran some simple jQuery")

    @QtCore.Slot()
    def _on_action_new_layer(self):
        self._layer_widget.new_layer()
        print("A new layer was added")

    @QtCore.Slot()
    def _on_action_save_document(self):
        print("Saving Document...")
        writer = DreamerWriter()
        writer.write()

    @QtCore.Slot()
    def _on_action_open_document(self):
        print("Loading Document...")
        reader = DreamerReader()
        document = reader.read()
        print("We got a story named: " + document.StoryName)