コード例 #1
0
ファイル: TabWidget.cpp プロジェクト: ndeebook/Natron
void TabWidget::moveTab(QWidget* what,TabWidget *where){
    TabWidget* from = dynamic_cast<TabWidget*>(what->parentWidget());
    
    if(!from){
        return;
    }
    if(from == where){
        /*We check that even if it is the same TabWidget, it really exists.*/
        bool found = false;
        for (int i =0; i < from->count(); ++i) {
            if (what == from->tabAt(i)) {
                found = true;
                break;
            }
        }
        if (found) {
            return;
        }
        //it wasn't found somehow
    }
    
    from->removeTab(what);
    assert(where);
    where->appendTab(what);
    what->setParent(where);
    where->getGui()->getApp()->triggerAutoSave();
}
コード例 #2
0
ファイル: SessionManager.cpp プロジェクト: OpenRcon/OpenRcon
void SessionManager::closeSession(GameWidget *gameWidget, int index)
{
    TabWidget *tabWidget = TabWidget::getInstance();
    Client *client = gameWidget->getClient();
    ServerEntry *serverEntry = client->getServerEntry();

    tabWidget->removeTab(index);
    client->getConnection()->hostDisconnect();

    // Remove the ServerEntry from the list.
    if (sessions.remove(serverEntry)) {
        emit (onSessionClosed());
    } else {
        qDebug() << tr("This session does not exist.");
    }

    delete gameWidget;
}
コード例 #3
0
ファイル: Gui05.cpp プロジェクト: JamesLinus/Natron
void
Gui::removeGroupGui(NodeGraph* tab,
                    bool deleteData)
{
    tab->hide();

    if (_imp->_lastFocusedGraph == tab) {
        _imp->_lastFocusedGraph = 0;
    }
    TabWidget* container = dynamic_cast<TabWidget*>( tab->parentWidget() );
    if (container) {
        container->removeTab(tab, true);
    }

    if (deleteData) {
        std::list<NodeGraph*>::iterator it = std::find(_imp->_groups.begin(), _imp->_groups.end(), tab);
        if ( it != _imp->_groups.end() ) {
            _imp->_groups.erase(it);
        }

        unregisterTab(tab);
        tab->deleteLater();
    }
}
コード例 #4
0
ファイル: Gui20.cpp プロジェクト: azerupi/Natron
void
Gui::removeViewerTab(ViewerTab* tab,
                     bool initiatedFromNode,
                     bool deleteData)
{
    assert(tab);
    unregisterTab(tab);

    if (tab == _imp->_activeViewer) {
        _imp->_activeViewer = 0;
    }
    NodeGraph* graph = 0;
    NodeGroupPtr isGrp;
    NodeCollectionPtr collection;
    if ( tab->getInternalNode() && tab->getInternalNode()->getNode() ) {
        NodeCollectionPtr collection = tab->getInternalNode()->getNode()->getGroup();
        isGrp = toNodeGroup(collection);
    }


    if (isGrp) {
        NodeGraphI* graph_i = isGrp->getNodeGraph();
        assert(graph_i);
        graph = dynamic_cast<NodeGraph*>(graph_i);
    } else {
        graph = getNodeGraph();
    }
    assert(graph);
    if (!graph) {
        throw std::logic_error("");
    }

    ViewerTab* lastSelectedViewer = graph->getLastSelectedViewer();

    if (lastSelectedViewer == tab) {
        bool foundOne = false;
        NodesList nodes;
        if (collection) {
            nodes = collection->getNodes();
        }
        for (NodesList::iterator it = nodes.begin(); it != nodes.end(); ++it) {
            ViewerNodePtr isViewer = (*it)->isEffectViewerNode();
            if ( !isViewer || ( isViewer == tab->getInternalNode() ) || !(*it)->isActivated() ) {
                continue;
            }
            OpenGLViewerI* viewerI = isViewer->getUiContext();
            assert(viewerI);
            ViewerGL* glViewer = dynamic_cast<ViewerGL*>(viewerI);
            assert(glViewer);
            if (glViewer) {
                graph->setLastSelectedViewer( glViewer->getViewerTab() );
            }
            foundOne = true;
            break;
        }
        if (!foundOne) {
            graph->setLastSelectedViewer(0);
        }
    }

    ViewerNodePtr viewerNode = tab->getInternalNode();
    ViewerInstancePtr internalViewer;
    if (viewerNode) {
        internalViewer = viewerNode->getInternalViewerNode();
    }
    if (internalViewer) {
        internalViewer->abortAnyEvaluation();
        if (getApp()->getLastViewerUsingTimeline() == internalViewer) {
            getApp()->discardLastViewerUsingTimeline();
        }
    }

    if (!initiatedFromNode) {
        assert(_imp->_nodeGraphArea);
        ///call the deleteNode which will call this function again when the node will be deactivated.
        NodePtr internalNode = tab->getInternalNode()->getNode();
        NodeGuiIPtr guiI = internalNode->getNodeGui();
        NodeGuiPtr gui = boost::dynamic_pointer_cast<NodeGui>(guiI);
        assert(gui);
        NodeGraphI* graph_i = internalNode->getGroup()->getNodeGraph();
        assert(graph_i);
        NodeGraph* graph = dynamic_cast<NodeGraph*>(graph_i);
        assert(graph);
        if (graph) {
            graph->removeNode(gui);
        }
    } else {
        tab->hide();


        TabWidget* container = dynamic_cast<TabWidget*>( tab->parentWidget() );
        if (container) {
            container->removeTab(tab, false);
        }

        if (deleteData) {
            QMutexLocker l(&_imp->_viewerTabsMutex);
            std::list<ViewerTab*>::iterator it = std::find(_imp->_viewerTabs.begin(), _imp->_viewerTabs.end(), tab);
            if ( it != _imp->_viewerTabs.end() ) {
                _imp->_viewerTabs.erase(it);
            }
            tab->notifyGuiClosingPublic();
            tab->deleteLater();
        }
    }
    Q_EMIT viewersChanged();
} // Gui::removeViewerTab
コード例 #5
0
ファイル: Gui05.cpp プロジェクト: ebrayton/Natron
void
Gui::wipeLayout()
{

    std::list<TabWidgetI*> panesCpy = getApp()->getTabWidgetsSerialization();
    getApp()->clearTabWidgets();
    std::list<SerializableWindow*> floatingWidgets = getApp()->getFloatingWindowsSerialization();

    FloatingWidget* projectFW = _imp->_projectGui->getPanel()->getFloatingWindow();
    for (std::list<SerializableWindow*>::const_iterator it = floatingWidgets.begin(); it != floatingWidgets.end(); ++it) {
        if (!projectFW || (*it) != projectFW) {
            FloatingWidget* isFloating = dynamic_cast<FloatingWidget*>(*it);
            if (isFloating) {
                isFloating->deleteLater();
            }
        }
    }
    getApp()->clearFloatingWindows();

    // Re-add the project window
    if (projectFW) {
        getApp()->registerFloatingWindow(projectFW);
    }



    for (std::list<TabWidgetI*>::iterator it = panesCpy.begin(); it != panesCpy.end(); ++it) {
        TabWidget* pane = dynamic_cast<TabWidget*>(*it);
        if (!pane) {
            continue;
        }
        ///Conserve tabs by removing them from the tab widgets. This way they will not be deleted.
        while ( pane->count() > 0 ) {
            pane->removeTab(0, false);
        }
        //(*it)->setParent(NULL);
        pane->deleteLater();
    }

    std::list<SplitterI*> splittersCpy = getApp()->getSplittersSerialization();
    getApp()->clearSplitters();
    for (std::list<SplitterI*>::iterator it = splittersCpy.begin(); it != splittersCpy.end(); ++it) {
        if (_imp->_leftRightSplitter != *it) {
            Splitter* isSplitter = dynamic_cast<Splitter*>(*it);
            if (!isSplitter) {
                continue;
            }
            while ( isSplitter->count() > 0 ) {
                isSplitter->widget(0)->setParent(NULL);
            }
            //(*it)->setParent(NULL);
            isSplitter->deleteLater();
        }
    }


    Splitter *newSplitter = new Splitter(Qt::Horizontal,this, _imp->_centralWidget);
    newSplitter->addWidget(_imp->_toolBox);
    newSplitter->setObjectName_mt_safe( _imp->_leftRightSplitter->objectName_mt_safe() );
    _imp->_mainLayout->removeWidget(_imp->_leftRightSplitter);
    getApp()->unregisterSplitter(_imp->_leftRightSplitter);
    _imp->_leftRightSplitter->deleteLater();
    _imp->_leftRightSplitter = newSplitter;
    _imp->_leftRightSplitter->setChildrenCollapsible(false);
    _imp->_mainLayout->addWidget(newSplitter);

    getApp()->registerSplitter(newSplitter);

    // Re-create new menu actions
    createMenuActions();
 
} // Gui::wipeLayout