Пример #1
0
bool PlaylistTabBar::event(QEvent* e) {
  switch (e->type()) {
    case QEvent::ToolTip: {
      QHelpEvent* he = static_cast<QHelpEvent*>(e);

      QRect displayed_tab;
      QSize real_tab;
      bool is_elided = false;

      real_tab = tabSizeHint(tabAt(he->pos()));
      displayed_tab = tabRect(tabAt(he->pos()));
      // Check whether the tab is elided or not
      is_elided = displayed_tab.width() < real_tab.width();
      if (!is_elided) {
        // If it's not elided, don't show the tooltip
        QToolTip::hideText();
      } else {
        QToolTip::showText(he->globalPos(), tabToolTip(tabAt(he->pos())));
      }
      return true;
    }
    default:
      return QTabBar::event(e);
  }
}
Пример #2
0
bool ComboTabBar::event(QEvent *event)
{
    switch (event->type()) {
    case QEvent::ToolTip:
        if (!isDragInProgress() && !isScrollInProgress()) {
            int index = tabAt(mapFromGlobal(QCursor::pos()));
            if (index >= 0)
                QToolTip::showText(QCursor::pos(), tabToolTip(index));
        }
        break;

    case QEvent::Resize:
        ensureVisible();
        break;

    case QEvent::Show:
        if (!event->spontaneous())
            QTimer::singleShot(0, this, &ComboTabBar::setUpLayout);
        break;

    case QEvent::Enter:
    case QEvent::Leave:
        // Make sure tabs are painted with correct mouseover state
        QTimer::singleShot(100, this, &ComboTabBar::updateTabBars);
        break;

    default:
        break;
    }

    return QWidget::event(event);
}
Пример #3
0
bool TabBar::event(QEvent* event)
{
    switch (event->type()) {
    case QEvent::ToolTip:
        if (!m_showTabPreviews && !isDragInProgress()) {
            QHelpEvent* ev = static_cast<QHelpEvent*>(event);
            int index = tabAt(ev->pos());

            if (index >= 0) {
                QToolTip::showText(mapToGlobal(ev->pos()), tabToolTip(index));
            }
        }
        break;

    case QEvent::Leave:
        if (!rect().contains(mapFromGlobal(QCursor::pos()))) {
            hideTabPreview();
        }
        break;

    case QEvent::Wheel:
        hideTabPreview(false);
        break;

    default:
        break;
    }

    return ComboTabBar::event(event);
}
Пример #4
0
void TabBar::renameTab()
{
    QString name = tabToolTip(m_cur_menu_tab);
    QString conStr;
    if(name.contains(" - "))
    {
        conStr = name.mid(name.lastIndexOf(" - "));
        name = name.left(name.lastIndexOf(" - "));
    }

    QString newName = QInputDialog::getText(this, tr("Rename tab"), tr("New name:"),
                                         QLineEdit::Normal, name);
    if(!newName.isEmpty())
    {
        newName.replace('-', '_');
        newName += conStr;

        setTabToolTip(m_cur_menu_tab, newName);

        if(newName.size() > 25)
        {
            newName.resize(25);
            newName += "...";
        }
        setTabText(m_cur_menu_tab, newName);
    }
}
Пример #5
0
void TabWidget::saveData(DataFileParser *file)
{
    file->writeVal(m_id);

    if(m_tab_ids.empty())
    {
        file->writeVal((quint32)0);
        return;
    }

    file->writeVal(count());
    for(int i = 0; i < count(); ++i)
    {
        Tab *tab = (Tab*)widget(i);
        if(tab->isWorkTab())
        {
            file->writeBlockIdentifier("tabWidgetTab");

            QString name = tabToolTip(i);
            int idx = name.lastIndexOf(" - ");
            if(idx != -1)
                name = name.left(idx);
            file->writeString(name);

            ((WorkTab*)tab)->saveData(file);
        }
    }

    file->writeBlockIdentifier("tabWidgetIdx");
    file->writeVal(currentIndex());
}
Пример #6
0
void TabBar::mouseMoveEvent (QMouseEvent *event)
{
    QTabBar::mouseMoveEvent (event);
    int index = tabAt (event->pos());
    if (index != -1)
        QToolTip::showText (event->globalPos(), tabToolTip (index));
}
Пример #7
0
void TabBar::mouseMoveEvent (QMouseEvent *event)
{
    if (!dragStartPosition_.isNull()
        && (event->pos() - dragStartPosition_).manhattanLength() >= QApplication::startDragDistance())
    {
      dragStarted_ = true;
    }

    /* since Wayland has a serious issue related to QDrag that interferes with
       dropping tabs outside all windows, we don't enable tab DND without X11 */
    if (!noTabDND_
        && (event->buttons() & Qt::LeftButton)
        && dragStarted_
        && !window()->geometry().contains (event->globalPos()))
    {
        int index = currentIndex();
        if (index == -1)
        {
            event->accept();
            return;
        }

        QPointer<QDrag> drag = new QDrag (this);
        QMimeData *mimeData = new QMimeData;
        QByteArray array;
        array.append (QString ("%1+%2").arg (window()->winId()).arg (index));
        mimeData->setData ("application/featherpad-tab", array);
        drag->setMimeData (mimeData);
        QPixmap px = QIcon (":icons/tab.svg").pixmap (22, 22);
        drag->setPixmap (px);
        drag->setHotSpot (QPoint (px.width()/2, px.height()));
        Qt::DropAction dragged = drag->exec (Qt::MoveAction);
        if (dragged != Qt::MoveAction)
        {
            /* A tab is dropped outside all windows. WARNING: Under Enlightenment,
               this may be Qt::CopyAction, not IgnoreAction (an E bug). */
            if (count() > 1)
                emit tabDetached();
            else
                finishMouseMoveEvent();
            event->accept();
        }
        else // a tab is dropped into another window
            event->accept();
        drag->deleteLater();
    }
    else
    {
        QTabBar::mouseMoveEvent(event);
        int index = tabAt (event->pos());
        if (index > -1)
            QToolTip::showText (event->globalPos(), tabToolTip (index));
        else
            QToolTip::hideText();
    }
}
Пример #8
0
bool FancyTabBar::event(QEvent *event)
{
    if (event->type() == QEvent::ToolTip) {
        if (validIndex(m_hoverIndex)) {
            QString tt = tabToolTip(m_hoverIndex);
            if (!tt.isEmpty()) {
                QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), tt, this);
                return true;
            }
        }
    }
    return QWidget::event(event);
}
Пример #9
0
void TabWidget::currentIndexChanged(int idx)
{
    changeMenu(idx);

    if(idx == -1)
        return;

    emit changeWindowTitle(tabToolTip(idx));

    if((size_t)idx < m_tab_ids.size())
    {
        m_tabHistory.removeOne(m_tab_ids[idx]);
        m_tabHistory.push_back(m_tab_ids[idx]);
    }
}
Пример #10
0
void pTabBar::dropEvent( QDropEvent* event )
{
    if ( !event->mimeData()->hasUrls() )
    {
        // get drop tab
        int ni = tabAt( event->pos() );
        
        // if get it
        if ( ni != -1 )
        {
            // get original tab infos
            int oi = event->mimeData()->data( "x-tabindex" ).toInt();
            QVariant otd = tabData( oi );
            QIcon oti = tabIcon( oi );
            QString ott = tabText( oi );
            QColor ottc = tabTextColor( oi );
            QString ottt = tabToolTip( oi );
            QString otwt = tabWhatsThis( oi );
            
            // remove original tab
            removeTab( oi );
            
            // insert new one with correct infos
            int i = insertTab( ni, oti, ott );
            setTabData( i, otd );
            setTabTextColor( i, ottc );
            setTabToolTip( i, ottt );
            setTabWhatsThis( i, otwt );
            
            //accept
            event->acceptProposedAction();
            
            // emit signal
            emit tabDropped( oi, i );
            
            // set new current index
            setCurrentIndex( i );
        }
    }
    else
        emit urlsDropped( event->mimeData()->urls () );
    
    // default event
    QTabBar::dropEvent( event );
}
Пример #11
0
void TabWidget::setConnString(const QString &str, bool hadConn)
{
    Q_ASSERT(sender());
    if(!sender())
        return;

    int idx = indexOf((QWidget*)sender());
    if(idx == -1)
        return;

    QString text = tabToolTip(idx);
    if(!hadConn)
        text += " - " + str;
    else
    {
        text = text.left(text.lastIndexOf(" - "));
        if(!str.isEmpty())
            text += " - " + str;
    }

    setTabNameAndTooltip(idx, text);
}
Пример #12
0
void AdvancedTabBar::tabLayoutChange()
{
    d->list->setIconSize(iconSize());

    while (count() < d->list->count()) {
        delete d->list->takeItem(0);
    }
    if (count() == -1) return;

    while (count() > d->list->count()) {
        d->list->addItem(QString());
    }

    for (int i = 0; i < count(); i++) {
        QListWidgetItem * item = d->list->item(i);
        item->setText(tabText(i));
        item->setIcon(tabIcon(i));
        item->setToolTip(tabToolTip(i));
        item->setWhatsThis(tabWhatsThis(i));
    }

    d->list->setCurrentRow(currentIndex());
}