Exemple #1
0
void KTabBar::mouseMoveEvent( QMouseEvent *event )
{
  if ( event->buttons() == Qt::LeftButton && !isMovable() ) {
    int tab = selectTab( event->pos() );
    if ( d->mDragSwitchTab && tab != d->mDragSwitchTab ) {
      d->mActivateDragSwitchTabTimer->stop();
      d->mDragSwitchTab = 0;
    }

    int delay = KGlobalSettings::dndEventDelay();
    QPoint newPos = event->pos();
    if ( newPos.x() > d->mDragStart.x() + delay || newPos.x() < d->mDragStart.x() - delay ||
         newPos.y() > d->mDragStart.y() + delay || newPos.y() < d->mDragStart.y() - delay ) {
      if ( tab != -1 ) {
        emit initiateDrag( tab );
        return;
      }
    }
  } else if ( event->buttons() == Qt::MidButton && !isMovable() ) {
    if ( d->mReorderStartTab == -1 ) {
      int delay = KGlobalSettings::dndEventDelay();
      QPoint newPos = event->pos();

      if ( newPos.x() > d->mDragStart.x() + delay || newPos.x() < d->mDragStart.x() - delay ||
           newPos.y() > d->mDragStart.y() + delay || newPos.y() < d->mDragStart.y() - delay ) {
        int tab = selectTab( event->pos() );
        if ( tab != -1 && d->mTabReorderingEnabled ) {
          d->mReorderStartTab = tab;
          grabMouse( Qt::SizeAllCursor );
          return;
        }
      }
    } else {
      int tab = selectTab( event->pos() );
      if ( tab != -1 ) {
        int reorderStopTab = tab;
        if ( d->mReorderStartTab != reorderStopTab && d->mReorderPreviousTab != reorderStopTab ) {
          emit moveTab( d->mReorderStartTab, reorderStopTab );

          d->mReorderPreviousTab = d->mReorderStartTab;
          d->mReorderStartTab = reorderStopTab;

          return;
        }
      }
    }
  } else if ( event->button() == Qt::NoButton && event->buttons() == Qt::MidButton && isMovable() ) {
    // compatibility feature for old middle mouse tab moving
    d->mMiddleMouseTabMoveInProgress = true;
    event->accept();
    QMouseEvent fakedMouseEvent(event->type(), event->pos(), event->button(), Qt::LeftButton, event->modifiers());
    QCoreApplication::sendEvent(this, &fakedMouseEvent);
    return;
  }

  QTabBar::mouseMoveEvent( event );
}
Exemple #2
0
void QDockTabBar::mouseReleaseEvent(QMouseEvent *e)
{
	isLButtonDown_ = false;
	QTabBar::mouseReleaseEvent(e);
	if (insertPos_ >= 0)
	{
		moveTab(currentIndex(), insertPos_);
	}

	insertPos_ = -1;
	repaint();
}
	void SeparateTabBar::dropEvent (QDropEvent *event)
	{
		auto data = event->mimeData ();

		const int to = tabAt (event->pos ());
		auto widget = TabWidget_->Widget (to);
		if (data->data ("x-leechcraft/tab-drag-action") == "reordering")
		{
			const int from = tabAt (DragStartPos_);

			if (from == to || (IsLastTab_ && to == count () - 1))
				return;

			moveTab (from, to);
			emit releasedMouseAfterMove (to);
			event->acceptProposedAction ();
		}
		else if (auto idt = qobject_cast<IDNDTab*> (widget))
			idt->HandleDrop (event);
	}
Exemple #4
0
void TabBar::dropEvent(QDropEvent *event)
{
    event->acceptProposedAction();

    QStringList lst = QString::fromLatin1(event->mimeData()->data("data/tabinfo")).split(' ');
    int tabId = lst[1].toInt();

    if(event->source() != this)
    {
        MainWindow *window = sWorkTabMgr.getWindow(lst[2].toUInt());
        if(!window)
            return;
        TabWidget *source = window->getTabView()->getWidget(lst[0].toUInt());
        emit pullTab(tabId, source, m_drag_idx);
    }
    else
        moveTab(tabId, tabId < m_drag_idx ? m_drag_idx -1 : m_drag_idx);

    if(m_drag_insert)
        m_drag_insert->hide();
}
Exemple #5
0
void TabView::readViewConfig(KConfig* c,
			     QString prefix, QString postfix,
			     bool withOptions)
{
    if (0) qDebug("%s::readConfig(%s%s)", name(),
		  prefix.ascii(), postfix.ascii());

    KConfigGroup* g = configGroup(c, prefix, postfix);

    _mainSplitter->setSizes(g->readIntListEntry("MainSizes"));
    _leftSplitter->setSizes(g->readIntListEntry("LeftSizes"));
    _bottomSplitter->setSizes(g->readIntListEntry("BottomSizes"));

    QString activeT = g->readEntry("ActiveTop", "CallerView");
    QString activeB = g->readEntry("ActiveBottom", "CalleeView");
    QString activeL = g->readEntry("ActiveLeft", "");
    QString activeR = g->readEntry("ActiveRight", "");

    QStringList topTabs    = g->readListEntry("TopTabs");
    QStringList bottomTabs = g->readListEntry("BottomTabs");
    QStringList leftTabs   = g->readListEntry("LeftTabs");
    QStringList rightTabs  = g->readListEntry("RightTabs");

    if (topTabs.isEmpty() && bottomTabs.isEmpty() &&
        rightTabs.isEmpty() && leftTabs.isEmpty()) {
      // no tabs visible ?! Reset to default
      topTabs << "CostTypeView" << "CallerView" << "AllCallerView"
              << "CalleeMapView" << "SourceView";
      bottomTabs << "PartView" << "CalleeView" << "CallGraphView"
                 << "AllCalleeView" << "CallerMapView" << "InstrView";
    }

    TraceItemView *activeTop = 0, *activeBottom = 0;
    TraceItemView *activeLeft = 0, *activeRight = 0;

    moveTab(0, TraceItemView::Top, true);
    TraceItemView *v;
    QPtrListIterator<TraceItemView> it( _tabs );
    while ( (v=it.current()) != 0) {
      ++it;

      QString n = QString(v->widget()->name());
      if (topTabs.contains(n)) {
        moveTab(v->widget(), TraceItemView::Top);
        if (n == activeT) activeTop = v;
      }
      else if (bottomTabs.contains(n)) {
        moveTab(v->widget(), TraceItemView::Bottom);
        if (n == activeB) activeBottom = v;
      }
      else if (leftTabs.contains(n)) {
        moveTab(v->widget(), TraceItemView::Left);
        if (n == activeL) activeLeft = v;
      }
      else if (rightTabs.contains(n)) {
        moveTab(v->widget(), TraceItemView::Right);
        if (n == activeR) activeRight = v;
      }
      else moveTab(v->widget(), Hidden);

      if (withOptions)
	v->readViewConfig(c, QString("%1-%2")
			  .arg(prefix).arg(v->widget()->name()),
			  postfix, true);
    }
    if (activeTop)   _topTW->showPage(activeTop->widget());
    if (activeBottom)_bottomTW->showPage(activeBottom->widget());
    if (activeLeft)  _leftTW->showPage(activeLeft->widget());
    if (activeRight) _rightTW->showPage(activeRight->widget());

    QString activeType = g->readEntry("ActiveItemType", "");
    QString activeName = g->readEntry("ActiveItemName", "");
    QString selectedType = g->readEntry("SelectedItemType", "");
    QString selectedName = g->readEntry("SelectedItemName", "");
    delete g;
    
    if (!_data) return;
    
    if (withOptions) {  
      // restore active item
      TraceItem::CostType t = TraceItem::costType(activeType);
      if (t==TraceItem::NoCostType) t = TraceItem::Function;
      TraceCost* activeItem = _data->search(t, activeName, _costType);
      if (!activeItem) return;
      activate(activeItem);
      
      // restore selected item
      t = TraceItem::costType(selectedType);
      if (t==TraceItem::NoCostType) t = TraceItem::Function;
      TraceCost* selectedItem = _data->search(t, selectedName,
					      _costType, activeItem);
      if (selectedItem) select(selectedItem);
    }

    updateView();
}
void EditorMenuManager::goatskinTabPressed(Ref* sender)
{
    CCLOG("Goatskin clicked");
    moveTab(GOATSKIN_MENU);
}
void EditorMenuManager::noteTabPressed(Ref* sender)
{
    CCLOG("Note clicked");
    moveTab(NOTE_MENU);
}
void EditorMenuManager::sheepTabPressed(Ref* sender)
{
    CCLOG("Sheep clicked");
    moveTab(SHEEP_MENU);
}
void EditorMenuManager::inputTabPressed(Ref* sender)
{
    CCLOG("Pan clicked");
    moveTab(INPUT_MENU);
}
void KTabBar::mouseMoveEvent( QMouseEvent *e )
{
    if ( e->state() == LeftButton ) {
        QTab *tab = selectTab( e->pos() );
        if ( mDragSwitchTab && tab != mDragSwitchTab ) {
          mActivateDragSwitchTabTimer->stop();
          mDragSwitchTab = 0;
        }

        int delay = KGlobalSettings::dndEventDelay();
        QPoint newPos = e->pos();
        if( newPos.x() > mDragStart.x()+delay || newPos.x() < mDragStart.x()-delay ||
            newPos.y() > mDragStart.y()+delay || newPos.y() < mDragStart.y()-delay )
         {
            if( tab!= 0L ) {
                emit( initiateDrag( indexOf( tab->identifier() ) ) );
                return;
           }
       }
    }
    else if ( e->state() == MidButton ) {
        if (mReorderStartTab==-1) {
            int delay = KGlobalSettings::dndEventDelay();
            QPoint newPos = e->pos();
            if( newPos.x() > mDragStart.x()+delay || newPos.x() < mDragStart.x()-delay ||
                newPos.y() > mDragStart.y()+delay || newPos.y() < mDragStart.y()-delay )
            {
                QTab *tab = selectTab( e->pos() );
                if( tab!= 0L && mTabReorderingEnabled ) {
                    mReorderStartTab = indexOf( tab->identifier() );
                    grabMouse( sizeAllCursor );
                    return;
                }
            }
        }
        else {
            QTab *tab = selectTab( e->pos() );
            if( tab!= 0L ) {
                int reorderStopTab = indexOf( tab->identifier() );
                if ( mReorderStartTab!=reorderStopTab && mReorderPreviousTab!=reorderStopTab ) {
                    emit( moveTab( mReorderStartTab, reorderStopTab ) );
                    mReorderPreviousTab=mReorderStartTab;
                    mReorderStartTab=reorderStopTab;
                    return;
                }
            }
        }
    }

    if ( mHoverCloseButtonEnabled && mReorderStartTab==-1) {
        QTab *t = selectTab( e->pos() );

        //BEGIN Workaround
        //Qt3.2.0 (and 3.2.1) emit wrong local coordinates
        //for MouseMove events when the pointer leaves a widget. Discard those
        //to avoid enabling the wrong hover button
#ifdef __GNUC__
#warning "Workaround for Qt 3.2.0, 3.2.1 bug"
#endif
        if ( e->globalPos() != mapToGlobal( e->pos() ) )
            return;
        //END Workaround

        if( t && t->iconSet() && t->isEnabled() ) {
            QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal );
            QRect rect( 0, 0, pixmap.width() + 4, pixmap.height() +4);

            int xoff = 0, yoff = 0;
            // The additional offsets were found by try and error, TODO: find the rational behind them
            if ( t == tab( currentTab() ) ) {
#if QT_VERSION >= 0x030200
                xoff = style().pixelMetric( QStyle::PM_TabBarTabShiftHorizontal, this ) + 3;
                yoff = style().pixelMetric( QStyle::PM_TabBarTabShiftVertical, this ) - 4;
#else
                xoff = 3;
                yoff = -4;
#endif
            }
            else {
                xoff = 7;
                yoff = 0;
            }
            rect.moveLeft( t->rect().left() + 2 + xoff );
            rect.moveTop( t->rect().center().y()-pixmap.height()/2 + yoff );
            if ( rect.contains( e->pos() ) ) {
                if ( mHoverCloseButton ) {
                    if ( mHoverCloseButtonTab == t )
                        return;
                    mEnableCloseButtonTimer->stop();
                    delete mHoverCloseButton;
                }

                mHoverCloseButton = new QPushButton( this );
                mHoverCloseButton->setIconSet( KGlobal::iconLoader()->loadIcon("fileclose", KIcon::Toolbar, KIcon::SizeSmall, KIcon::ActiveState) );
                mHoverCloseButton->setGeometry( rect );
                QToolTip::add(mHoverCloseButton,i18n("Close this tab"));
                mHoverCloseButton->setFlat(true);
                mHoverCloseButton->show();
                if ( mHoverCloseButtonDelayed ) {
                  mHoverCloseButton->setEnabled(false);
                  mEnableCloseButtonTimer->start( QApplication::doubleClickInterval(), true );
                }
                mHoverCloseButtonTab = t;
                connect( mHoverCloseButton, SIGNAL( clicked() ), SLOT( closeButtonClicked() ) );
                return;
            }
        }
        if ( mHoverCloseButton ) {
            mEnableCloseButtonTimer->stop();
            delete mHoverCloseButton;
            mHoverCloseButton = 0;
        }
    }

    QTabBar::mouseMoveEvent( e );
}