示例#1
0
void MainWindow::installTool(Tool* controllingWidget)
{
    QAction* action = controllingWidget->action();

    action->setCheckable(true);

    tools_list.push_back(controllingWidget);

    sidebarContents->addWidget(controllingWidget);
    modeActions->addAction(action);

    connect(action, SIGNAL(triggered(bool)),
            this, SLOT(actionTriggered()));

    connect(controllingWidget, SIGNAL(activateMe()),
            this, SLOT(activateTool()));

    connect(controllingWidget, SIGNAL(showEvent(Event_model*)),
            this, SLOT(showEvent(Event_model*)));

    connect(controllingWidget, SIGNAL(showState(State_model*)),
            this, SLOT(showState(State_model*)));


    connect(controllingWidget, SIGNAL(browse()),
            this, SLOT(browse()));

    action->setWhatsThis(controllingWidget->whatsThis());
}
示例#2
0
int TabWidget::addTab(Tab *widget, const QString &name, quint32 tabId)
{
    if(!widget->isHometab())
        emit closeHomeTab();

    int idx = QTabWidget::addTab(widget, name);

    installEventFilterToChildren(widget);

    std::vector<quint32>::iterator itr = m_tab_ids.begin() + idx;
    m_tab_ids.insert(itr, tabId);

    setCurrentIndex(idx);
    changeMenu(idx);

    if(count() >= 2)
        m_tab_bar->enableSplit(true);

    if(widget->isWorkTab())
    {
        connect(widget, SIGNAL(statusBarMsg(QString,int)),     SIGNAL(statusBarMsg(QString,int)));
        connect(widget, SIGNAL(setConnId(QString,bool)),       SLOT(setConnString(QString,bool)));
    }
    else if(widget->isChild())
        connect((ChildTab*)widget, SIGNAL(tabText(QString)), SLOT(setTabNameAndTooltip(QString)));
    connect(widget, SIGNAL(activateMe()), SLOT(activateTab()));
    connect(widget, SIGNAL(destroyed()), SLOT(checkEmpty()), Qt::QueuedConnection);

    setTabNameAndTooltip(idx, name);
    setTabsClosable(true);
    return idx;
}