예제 #1
0
void TabWidget::createTabTree()
{
    m_tabTree = new TabTree(this);
    m_toolBarTree->addWidget(m_tabTree);

    m_tabTree->setObjectName("tab_tree");

    connect( m_tabTree, SIGNAL(tabMenuRequested(QPoint,QString)),
             this, SIGNAL(tabMenuRequested(QPoint,QString)) );
    connect( m_tabTree, SIGNAL(tabMoved(QString,QString,QString)),
             this, SIGNAL(tabMoved(QString,QString,QString)) );
    connect( m_tabTree, SIGNAL(dropItems(QString,QMimeData)),
             this, SIGNAL(dropItems(QString,QMimeData)) );
    connect( m_tabTree, SIGNAL(currentTabChanged(int)),
             this, SLOT(setCurrentIndex(int)) );

    updateToolBar();

    // Override left and right keys of tab tree.
    addTabAction(m_tabTree, Qt::Key_Left, this, SLOT(previousTab()), Qt::WidgetShortcut);
    addTabAction(m_tabTree, Qt::Key_Right, this, SLOT(nextTab()), Qt::WidgetShortcut);
}
예제 #2
0
void TabBar::mouseReleaseEvent(QMouseEvent *AEvent)
{
    int index = tabAt(AEvent->pos());
    if (index == FPressedIndex)
    {
        if (AEvent->button() == Qt::LeftButton)
        {
            setCurrentIndex(index);
        }
        else if (AEvent->button() == Qt::MidButton)
        {
            emit tabCloseRequested(index);
        }
        else if (AEvent->button() == Qt::RightButton)
        {
            emit tabMenuRequested(index);
        }
    }
    FPressedIndex = -1;
    //QWidget::mouseReleaseEvent(AEvent);
}