Пример #1
0
    def postLoad(self):
        self.initActions()
        self.initMenus()
        self.initMenuBar()
        self.initLayout()

        from candy_editor.qt.controls.EditorCommon.IEditor import getIEditor, EEditorNotifyEvent
        getIEditor().notify(EEditorNotifyEvent.Notify_OnMainFrameInitialized)
Пример #2
0
    def createPaneContents(self, tool: QTabPane):
        """ Create QTabPane Contents

			Args:
				tool (QTabPane)

			Returns:
				CEditor
	    """
        tool.viewCreated = True

        from qt.controls.EditorCommon.IEditor import getIEditor
        classDesc = getIEditor().getClassFactory().findClass(tool.class_)
        if classDesc == None or classDesc.systemClassID(
        ) != ESystemClassID.ESYSTEM_CLASS_VIEWPANE:
            qWarning(
                "QToolTabManager.createPaneContents ClassDesc not found %s" %
                tool.class_)
            return None

        pane = classDesc.createPane()

        if pane != None:
            contentWidget = pane.getWidget()
            tool.layout().addWidget(contentWidget)
            tool.pane = pane

            print(
                "[QToolTabManager] createPaneContents tool: %s tool.pane: %s contentWidget: %s"
                % (tool, tool.pane, contentWidget))

            contentWidget.windowTitleChanged.connect(tool.setWindowTitle)
            contentWidget.windowIconChanged.connect(tool.setWindowIcon)

        else:
            # TODO: QWinHostPane platform native window
            hostWidget = QPlatformHostPane()
            qWarning(
                'QToolTabManager.createPaneContents native host window not impl.'
            )
            pass

        return pane
Пример #3
0
    def createTabPane(self,
                      paneClassName,
                      title=None,
                      nOverrideDockDirection=-1,
                      bLoadLayoutPersonalization=False):
        pane = None
        isToolAlreadyCreated = False

        from candy_editor.qt.controls.EditorCommon.IEditor import getIEditor
        classDesc = getIEditor().getClassFactory().findClass(paneClassName)
        if classDesc is None or classDesc.systemClassID(
        ) != ESystemClassID.ESYSTEM_CLASS_VIEWPANE:
            qWarning(
                "CTabPaneManager::createTabPane return None %s pane class not found."
                % paneClassName)
            return None

        viewPaneClass = classDesc

        if viewPaneClass.singlePane():
            for i in range(0, len(self.panes)):
                pane = self.panes[i]
                if pane.class_ == paneClassName and pane.viewCreated:
                    isToolAlreadyCreated = True
                    break

        if not isToolAlreadyCreated:
            # print ( "CTabPaneManager.createTabPane create QTabPane for", paneClassName )
            pane = QTabPane()
            pane.setParent(self.parent)
            pane.class_ = paneClassName
            self.panes.append(pane)

        dockDir = EDockingDirection.DOCK_FLOAT

        contentWidget = None

        if not isToolAlreadyCreated:
            contentWidget = self.createPaneContents(pane)
            if contentWidget != None:
                if title == None:
                    title = contentWidget.getPaneTitle()
                dockDir = contentWidget.getDockingDirection()
            elif title == None:
                title = viewPaneClass.getPaneTitle()

            pane.title = title
            pane.setObjectName(self.createObjectName(title))
            pane.setWindowTitle(title)
            pane.category = viewPaneClass.category()

            if contentWidget:
                contentWidget.initialize()
                if bLoadLayoutPersonalization:
                    contentWidget.loadLayoutPersonalization()
        else:
            contentWidget = pane.pane
            if contentWidget != None:
                dockDir = contentWidget.getDockingDirection()

        bDockDirection = False

        from qt.controls.QToolWindowManager import QToolWindowAreaReference, QToolWindowAreaTarget
        toolAreaTarget = QToolWindowAreaTarget(
            QToolWindowAreaReference.Floating)

        if nOverrideDockDirection != -1:
            dockDir = nOverrideDockDirection

        if dockDir == EDockingDirection.DOCK_DEFAULT:
            toolAreaTarget = QToolWindowAreaTarget(
                QToolWindowAreaReference.Floating)
        elif dockDir == EDockingDirection.DOCK_TOP:
            toolAreaTarget = QToolWindowAreaTarget(
                QToolWindowAreaReference.HSplitTop)
            bDockDirection = True
        elif dockDir == EDockingDirection.DOCK_BOTTOM:
            toolAreaTarget = QToolWindowAreaTarget(
                QToolWindowAreaReference.HSplitBottom)
            bDockDirection = True
        elif dockDir == EDockingDirection.DOCK_LEFT:
            toolAreaTarget = QToolWindowAreaTarget(
                QToolWindowAreaReference.VSplitLeft)
            bDockDirection = True
        elif dockDir == EDockingDirection.DOCK_RIGHT:
            toolAreaTarget = QToolWindowAreaTarget(
                QToolWindowAreaReference.VSplitRight)
            bDockDirection = True
        elif dockDir == EDockingDirection.DOCK_FLOAT:
            toolAreaTarget = QToolWindowAreaTarget(
                QToolWindowAreaReference.Floating)

        if bDockDirection:
            referencePane = self.findTabPaneByTitle(
                "Perspective")  # FIXME: No Perspective Pane
            if referencePane != None:
                toolArea = self.getToolManager().areaOf(referencePane)
                if toolArea != None:
                    toolAreaTarget = QToolWindowAreaTarget.createByArea(
                        toolArea, toolAreaTarget.reference)
                else:
                    toolAreaTarget = QToolWindowAreaTarget(
                        QToolWindowAreaReference.Floating)

        paneRect = QRect(0, 0, 800, 600)
        if contentWidget != None:
            paneRect = contentWidget.getPaneRect()
        if pane.title in self.panesHistory:
            paneHistory = self.panesHistory[pane.title]
            paneRect = paneHistory.rect

        maxRc = qApp.desktop().screenGeometry()

        minimumSize = QSize()
        if contentWidget != None:
            minimumSize = contentWidget.getMinSize()

        paneRect = paneRect.intersected(maxRc)

        if paneRect.width() < 10:
            paneRect.setRight(paneRect.left() + 10)
        if paneRect.height() < 10:
            paneRect.setBottom(paneRect.top() + 10)

        pane.defaultSize = QSize(paneRect.width(), paneRect.height())
        pane.minimumSize = minimumSize

        toolPath = {}
        spawnLocationMap = {
        }  # GetIEditor()->GetPersonalizationManager()->GetState("SpawnLocation")

        if not self.bLayoutLoaded:
            toolAreaTarget = QToolWindowAreaTarget(
                QToolWindowAreaReference.Hidden)
        else:
            if spawnLocationMap.setdefault(paneClassName, False):
                toolPath = spawnLocationMap[paneClassName]
                if not toolPath.setdefault("geometry", False):
                    t = self.getToolManager().targetFromPath(toolPath["path"])
                    if t.reference != QToolWindowAreaReference.Floating:
                        toolAreaTarget = t

        self.getToolManager().addToolWindowTarget(pane, toolAreaTarget)

        if toolAreaTarget.reference == QToolWindowAreaReference.Floating:
            alreadyPlaced = False
            if toolPath.setdefault("geometry", False):
                alreadyPlaced = pane.window().restoreGeometry(
                    toolPath["geometry"])
            if not alreadyPlaced:
                w = pane
                while not w.isWindow():
                    w = w.parentWidget()
                i = 0
                w.move(QPoint(32, 32) * (i + 1))
                i = (i + 1) % 10
            self.onTabPaneMoved(pane, True)

        self.toolsDirty = True

        if pane.pane != None:
            # from qt.controls.QToolWindowManager.QtViewPane import IPane
            pane.pane.signalPaneCreated.emit(pane.pane)

        return pane