Esempio n. 1
0
void TabBar::mouseMoveEvent(QMouseEvent* event)
{
    if (mApp->plugins()->processMouseMove(Qz::ON_TabBar, this, event)) {
        return;
    }

    if (!m_dragStartPosition.isNull() && m_tabWidget->buttonAddTab()->isVisible()) {
        int manhattanLength = (event->pos() - m_dragStartPosition).manhattanLength();
        if (manhattanLength > QApplication::startDragDistance()) {
            m_tabWidget->buttonAddTab()->hide();
            hideTabPreview();
        }
    }

    //Tab Preview

    const int tab = tabAt(event->pos());

    if (tab != -1 && tab != m_tabPreview->previewIndex() && event->buttons() == Qt::NoButton && m_dragStartPosition.isNull()) {
        m_tabPreview->setPreviewIndex(tab);
        if (m_tabPreview->isVisible()) {
            showTabPreview();
        }
    }

    QTabBar::mouseMoveEvent(event);
}
Esempio n. 2
0
void TabBar::mouseMoveEvent(QMouseEvent *event)
{
    if (count() == 1)
    {
        return;
    }

    KTabBar::mouseMoveEvent(event);

    if (ReKonfig::hoveringTabOption() == 0)
    {
        //Find the tab under the mouse
        const int tabIndex = tabAt(event->pos());

        // if found and not the current tab then show tab preview
        if (tabIndex != -1
                && tabIndex != currentIndex()
                && m_currentTabPreviewIndex != tabIndex
                && event->buttons() == Qt::NoButton
           )
        {
            m_currentTabPreviewIndex = tabIndex;

            // if first time over tab, apply a small delay. If not, show it now!
            m_isFirstTimeOnTab
            ? QTimer::singleShot(200, this, SLOT(showTabPreview()))
            : showTabPreview();
        }

        // if current tab or not found then hide previous tab preview
        if (tabIndex == currentIndex() || tabIndex == -1)
        {
            if (!m_previewPopup.isNull())
            {
                m_previewPopup.data()->hide();
            }
            m_currentTabPreviewIndex = -1;
        }
    }
}
Esempio n. 3
0
TabBar::TabBar(BrowserWindow* window, TabWidget* tabWidget)
    : ComboTabBar()
    , m_window(window)
    , m_tabWidget(tabWidget)
    , m_tabPreview(new TabPreview(window, window))
    , m_showTabPreviews(false)
    , m_hideTabBarWithOneTab(false)
    , m_showCloseOnInactive(0)
    , m_clickedTab(0)
    , m_normalTabWidth(0)
    , m_activeTabWidth(0)
{
    setObjectName("tabbar");
    setContextMenuPolicy(Qt::CustomContextMenu);
    setElideMode(Qt::ElideRight);
    setFocusPolicy(Qt::NoFocus);
    setTabsClosable(false);
    setMouseTracking(true);
    setDocumentMode(true);
    setAcceptDrops(true);
    setDrawBase(false);
    setMovable(true);

    connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));

    m_tabPreviewShowTimer = new QTimer(this);
    m_tabPreviewShowTimer->setInterval(300);
    m_tabPreviewShowTimer->setSingleShot(true);
    connect(m_tabPreviewShowTimer, SIGNAL(timeout()), this, SLOT(showTabPreview()));

    m_tabPreviewHideTimer = new QTimer(this);
    m_tabPreviewHideTimer->setInterval(300);
    m_tabPreviewHideTimer->setSingleShot(true);
    connect(m_tabPreviewHideTimer, SIGNAL(timeout()), m_tabPreview, SLOT(hideAnimated()));

    // ComboTabBar features
    setUsesScrollButtons(true);
    setCloseButtonsToolTip(BrowserWindow::tr("Close Tab"));
    connect(this, SIGNAL(scrollBarValueChanged(int)), this, SLOT(hideTabPreview()));
    connect(this, SIGNAL(overFlowChanged(bool)), this, SLOT(overflowChanged(bool)));

    if (mApp->isPrivate()) {
        QLabel* privateBrowsing = new QLabel(this);
        privateBrowsing->setObjectName(QSL("private-browsing-icon"));
        privateBrowsing->setPixmap(IconProvider::privateBrowsingIcon().pixmap(16, 16));
        privateBrowsing->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        privateBrowsing->setFixedWidth(30);
        addCornerWidget(privateBrowsing, Qt::TopLeftCorner);
    }
}
Esempio n. 4
0
void TabBar::mouseMoveEvent(QMouseEvent *event)
{
    if (count() == 1)
    {
        return;
    }

    if (event->buttons() & Qt::LeftButton)
    {
        // hide addNewTabButton when moving tabs
        MainView *view = qobject_cast<MainView *>(parent());
        QTimer::singleShot(200, view->addTabButton(), SLOT(hide()));
    }

    KTabBar::mouseMoveEvent(event);

    if (ReKonfig::hoveringTabOption() == 0)
    {
        //Find the tab under the mouse
        const int tabIndex = tabAt(event->pos());

        // if found and not the current tab then show tab preview
        if (tabIndex != -1
                && tabIndex != currentIndex()
                && m_currentTabPreviewIndex != tabIndex
                && event->buttons() == Qt::NoButton
           )
        {
            m_currentTabPreviewIndex = tabIndex;
            QTimer::singleShot(200, this, SLOT( showTabPreview() ) );
        }

        // if current tab or not found then hide previous tab preview
        if (tabIndex == currentIndex() || tabIndex == -1)
        {
            if (!m_previewPopup.isNull())
            {
                m_previewPopup.data()->hide();
            }
            m_currentTabPreviewIndex = -1;
        }
    }
}
Esempio n. 5
0
bool TabBar::event(QEvent* event)
{
    switch (event->type()) {
    case QEvent::Leave:
        hideTabPreview();
        break;

    case QEvent::ToolTip:
        if (m_showTabPreviews) {
            if (!m_tabPreview->isVisible()) {
                showTabPreview();
            }
            return true;
        }
        break;

    default:
        break;
    }

    return QTabBar::event(event);
}