Beispiel #1
0
void TabBar::mousePressEvent(QMouseEvent* event)
{
    hideTabPreview(false);

    if (mApp->plugins()->processMousePress(Qz::ON_TabBar, this, event)) {
        return;
    }

    if (event->buttons() & Qt::LeftButton && tabAt(event->pos()) != -1) {
        m_dragStartPosition = mapFromGlobal(event->globalPos());
    }
    else {
        m_dragStartPosition = QPoint();
    }

    QTabBar::mousePressEvent(event);
}
Beispiel #2
0
void OpenGLWindow::mouseMoveEvent(QMouseEvent *e)
{
    if(trackMouse){
        QPoint mousePosition = mapFromGlobal(QCursor::pos());
        int dX = width()/2 - mousePosition.x();
        int dY = height()/2 - mousePosition.y();
        camera->mouseMoveEvent(dX, dY);
        mousePosition = QPoint(width()/2, height()/2);
        QCursor::setPos(mapToGlobal(mousePosition));
    } else {
        /*
        QToolTip::showText(e->globalPos(),
                               QString::number( e->pos().x() ) + ", " +
                               QString::number( e->pos().y() ) );
                               */
    }
}
void ZoomableAssemblyOverview::drawZoomToRegion(QPainter & p) {
    if(!zoomToRegionSelector.scribbling) {
        assert(false);
        return;
    }
    QPoint topLeft;
    QPoint bottomRight;
    int curX = mapFromGlobal(QCursor::pos()).x();
    if(zoomToRegionSelector.startPos.x() <= curX) {
        topLeft = QPoint(zoomToRegionSelector.startPos.x(), 0);
        bottomRight = QPoint(curX, height());
    } else {
        topLeft = QPoint(curX, 0);
        bottomRight = QPoint(zoomToRegionSelector.startPos.x(), height());
    }
    p.fillRect(QRect(topLeft, bottomRight), QColor(128, 0, 0, 100));
}
PromotionDialog::PromotionDialog(QWidget *parent, Color color) :
    QDialog(parent),
    ui(new Ui::PromotionDialog),
    m_index(-1)
{
    BoardView view;
    view.configure();
    ui->setupUi(this);

    QPoint pos = mapFromGlobal(QCursor::pos());
    move(pos);

    int offset = color==White ? 0 : (BlackKing-WhiteKing);
    ui->btQueen->setIcon(view.theme().piece(Piece(WhiteQueen+offset)));
    ui->btRook->setIcon(view.theme().piece(Piece(WhiteRook+offset)));
    ui->btBishop->setIcon(view.theme().piece(Piece(WhiteBishop+offset)));
    ui->btKnight->setIcon(view.theme().piece(Piece(WhiteKnight+offset)));
}
void SourceViewerWebWidget::showContextMenu(const QPoint &position)
{
	updateHitTestResult(position);
	updateEditActions();

	emit actionsStateChanged(ActionsManager::ActionDefinition::EditingCategory);

	QWidget *child(childAt(position.isNull() ? mapFromGlobal(QCursor::pos()) : position));
	QMenu menu;

	if (child && child->metaObject()->className() == QLatin1String("Otter::MarginWidget"))
	{
		QAction *showLineNumbersAction(menu.addAction(tr("Show Line Numbers")));
		showLineNumbersAction->setCheckable(true);
		showLineNumbersAction->setChecked(SettingsManager::getOption(SettingsManager::SourceViewer_ShowLineNumbersOption).toBool());

		connect(showLineNumbersAction, SIGNAL(triggered(bool)), this, SLOT(setShowLineNumbers(bool)));
	}
Beispiel #6
0
    void TextEditEx::selectByPos(const QPoint& p)
    {
        QTextCursor c = cursorForPosition(mapFromGlobal(p));
        int pos = c.position();
        QTextCursor cur = textCursor();

        if (!cur.hasSelection() && prev_pos_ == -1)
        {
            cur.setPosition(pos);
            cur.setPosition(pos > prev_pos_ ? pos + 1  : pos -1, QTextCursor::KeepAnchor);
        }
        else
        {
            cur.setPosition(pos, QTextCursor::KeepAnchor);
        }
        prev_pos_ = pos;
        setTextCursor(cur);
    }
Beispiel #7
0
void QmitkRenderWindow::keyPressEvent(QKeyEvent *ke)
{
  mitk::InteractionEvent::ModifierKeys modifiers = GetModifiers(ke);
  std::string key = GetKeyLetter(ke);

  mitk::InteractionKeyEvent::Pointer keyEvent = mitk::InteractionKeyEvent::New(m_Renderer, key, modifiers);
  if (!this->HandleEvent(keyEvent.GetPointer()))
  { // TODO: INTERACTION_LEGACY
    QPoint cp = mapFromGlobal(QCursor::pos());
    mitk::KeyEvent mke(QmitkEventAdapter::AdaptKeyEvent(m_Renderer, ke, cp));
    this->keyPressMitkEvent(&mke);
    ke->accept();
    QVTKWidget::keyPressEvent(ke);
  }

  if (m_ResendQtEvents)
    ke->ignore();
}
bool KDockSplitter::eventFilter(QObject *o, QEvent *e)
{
  QMouseEvent *mev;
  bool handled = false;
  int factor = (mHighResolution)? 10000:100;

  switch (e->type()) {
    case QEvent::MouseMove:
      mev= (QMouseEvent*)e;
      child0->setUpdatesEnabled(mOpaqueResize);
      child1->setUpdatesEnabled(mOpaqueResize);
      if (orientation == Horizontal) {
        if (!mOpaqueResize) {
          int position = checkValue( mapFromGlobal(mev->globalPos()).y() );
          divider->move( 0, position );
        } else {
          xpos = factor * checkValue( mapFromGlobal(mev->globalPos()).y() ) / height();
          resizeEvent(0);
          divider->repaint(true);
        }
      } else {
        if (!mOpaqueResize) {
          int position = checkValue( mapFromGlobal(QCursor::pos()).x() );
          divider->move( position, 0 );
        } else {
          xpos = factor * checkValue( mapFromGlobal( mev->globalPos()).x() ) / width();
          resizeEvent(0);
          divider->repaint(true);
        }
      }
      handled= true;
      break;
    case QEvent::MouseButtonRelease:
      child0->setUpdatesEnabled(true);
      child1->setUpdatesEnabled(true);
      mev= (QMouseEvent*)e;
      if (orientation == Horizontal){
        xpos = factor* checkValue( mapFromGlobal(mev->globalPos()).y() ) / height();
        resizeEvent(0);
        divider->repaint(true);
      } else {
        xpos = factor* checkValue( mapFromGlobal(mev->globalPos()).x() ) / width();
        resizeEvent(0);
        divider->repaint(true);
      }
      handled= true;
      break;
    default:
      break;
  }
  return (handled) ? true : QWidget::eventFilter( o, e );
}
Beispiel #9
0
bool MediaView::event(QEvent *e) {
	if (e->type() == QEvent::TouchBegin || e->type() == QEvent::TouchUpdate || e->type() == QEvent::TouchEnd || e->type() == QEvent::TouchCancel) {
		QTouchEvent *ev = static_cast<QTouchEvent*>(e);
		if (ev->device()->type() == QTouchDevice::TouchScreen) {
			if (!ev->touchPoints().isEmpty()) {
				QPoint p(mapFromGlobal(ev->touchPoints().cbegin()->screenPos().toPoint()));
				if ((!_close.isHidden() && _close.geometry().contains(p)) ||
				    (!_save.isHidden() && _save.geometry().contains(p)) ||
				    (!_forward.isHidden() && _forward.geometry().contains(p)) ||
					(!_delete.isHidden() && _delete.geometry().contains(p))) {
					return QWidget::event(e);
				}
			}
			touchEvent(ev);
			return true;
		}
	}
	return QWidget::event(e);
}
Beispiel #10
0
void WidgetArea::wheelEvent(QWheelEvent *ev)
{
    // Move area only if the mouse is not in some of the widgets
    QPoint pos = mapFromGlobal(QCursor::pos());
    for(w_map::iterator itr = m_widgets.begin(); itr != m_widgets.end(); ++itr)
        if((*itr)->geometry().contains(pos))
            return;

    int move = qApp->wheelScrollLines()*10*(float(ev->delta())/120);
    switch(ev->orientation())
    {
        case Qt::Vertical:
            moveWidgets(QPoint(0, move));
            break;
        case Qt::Horizontal:
            moveWidgets(QPoint(move, 0));
            break;
    }
}
Beispiel #11
0
void MembersBox::Inner::updateSelection() {
	if (!_mouseSelection) return;

	QPoint p(mapFromGlobal(_lastMousePos));
	p.setY(p.y() - st::membersMarginTop);
	bool in = parentWidget()->rect().contains(parentWidget()->mapFromGlobal(_lastMousePos));
	auto selected = (in && p.y() >= 0 && p.y() < _rows.size() * _rowHeight) ? (p.y() / _rowHeight) : -1;
	auto kickSelected = selected;
	if (selected >= 0 && (!data(selected)->canKick || !QRect(width() - _kickWidth - st::contactsPadding.right() - st::contactsCheckPosition.x(), selected * _rowHeight + st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, _kickWidth, st::normalFont->height).contains(p))) {
		kickSelected = -1;
	}
	if (_selected != selected || _kickSelected != kickSelected) {
		updateSelectedRow();
		_selected = selected;
		_kickSelected = kickSelected;
		updateSelectedRow();
		setCursor(_kickSelected >= 0 ? style::cur_pointer : style::cur_default);
	}
}
void SeExprEdSlider::paintEvent(QPaintEvent* e)
{
    Q_UNUSED(e);
    QPainter p(this);
    
    float v = value();
    float r = maximum()-minimum();
    int linepos = (int)((v-minimum())/r*(width()-5)+2);
    
    QColor qcol = palette().color(QPalette::Dark);
    QColor bcol = palette().color(QPalette::Midlight);
    QColor dcol = bcol.lighter(140);
    QColor bgcol = palette().color(QPalette::Base);
    
    if (underMouse())
    {
        bcol = bcol.lighter(110);
        bgcol = bgcol.lighter(110);
        int mx = mapFromGlobal(QCursor::pos()).x();
        if (abs(linepos-mx)<4) dcol = dcol.lighter(200);
    }
    
    p.fillRect(1,1,width()-1,height()-2,bgcol);
    p.fillRect(1,1,linepos-1,height()-2,bcol);
    
    QPen pen = p.pen();
    
    pen.setColor(dcol);
    p.setPen(pen);
    pen.setWidth(3);
    p.setPen(pen);
    p.drawLine(linepos,2,linepos,height()-2);
    pen.setWidth(1);
    pen.setColor(qcol);
    p.setPen(pen);
    p.drawLine(linepos-2,1,linepos-2,height()-1);
    p.drawLine(linepos+2,1,linepos+2,height()-1);
    
    pen.setWidth(1);
    pen.setColor(qcol);
    p.setPen(pen);
    p.drawRect(0,0,width()-1,height()-1);
}
Beispiel #13
0
void AttachmentView::indicateHover()
{
    if (m_menu->isVisible() || rect().contains(mapFromGlobal(QCursor::pos()))) { // WA_UnderMouse is wrong
        if (!autoFillBackground()) {
            setAutoFillBackground(true);
            QPalette pal(palette());
            QLinearGradient grad(0,0,0,height());
            grad.setColorAt(0, pal.color(backgroundRole()));
            grad.setColorAt(0.15, pal.color(backgroundRole()).lighter(110));
            grad.setColorAt(0.8, pal.color(backgroundRole()).darker(110));
            grad.setColorAt(1, pal.color(backgroundRole()));
            pal.setBrush(backgroundRole(), grad);
            setPalette(pal);
        }
    } else {
        setAutoFillBackground(false);
        setPalette(QPalette());
    }
}
Beispiel #14
0
void Screen::checkMousePos() {
    //qDebug("Screen::checkMousePos");

    if (!autohide_cursor) {
        setCursor(QCursor(Qt::ArrowCursor));
        return;
    }

    QPoint pos = mapFromGlobal(QCursor::pos());

    //qDebug("Screen::checkMousePos: x: %d, y: %d", pos.x(), pos.y());

    if (mouse_last_position != pos) {
        setCursor(QCursor(Qt::ArrowCursor));
    } else {
        setCursor(QCursor(Qt::BlankCursor));
    }
    mouse_last_position = pos;
}
Beispiel #15
0
QPolygon Popup::arrow_polygon() const
{
	QPolygon poly;

	const QPoint p = mapFromGlobal(_point);
	const int l = ArrowLength + ArrowOverlap; 

	switch (_pos)
        {
	case Right:
		poly << QPoint(p.x() + l, p.y() - l);
		break;

	case Bottom:
		poly << QPoint(p.x() - l, p.y() + l);
		break;

        case Left:
	case Top:
		poly << QPoint(p.x() - l, p.y() - l);
		break;
	}

	poly << p;

	switch (_pos)
        {
	case Right:
	case Bottom:
		poly << QPoint(p.x() + l, p.y() + l);
		break;

        case Left:
		poly << QPoint(p.x() - l, p.y() + l);
		break;
		
	case Top:
		poly << QPoint(p.x() + l, p.y() - l);
		break;
	}

	return poly;
}
void Menu::itemPressed(TriggeredSource source) {
	if (source == TriggeredSource::Mouse && !_mouseSelection) {
		return;
	}
	if (_selected >= 0 && _selected < _actions.size() && _actions[_selected]->isEnabled()) {
		setPressed(_selected);
		if (source == TriggeredSource::Mouse) {
			if (!_actionsData[_pressed].ripple) {
				auto mask = RippleAnimation::rectMask(QSize(width(), _itemHeight));
				_actionsData[_pressed].ripple = std::make_unique<RippleAnimation>(_st.ripple, std::move(mask), [this, selected = _pressed] {
					updateItem(selected);
				});
			}
			_actionsData[_pressed].ripple->add(mapFromGlobal(QCursor::pos()) - QPoint(0, itemTop(_pressed)));
		} else {
			itemReleased(source);
		}
	}
}
Beispiel #17
0
void EditSpell::misspelling (const QString& original, const QStringList&, unsigned int)
{
    if (!find(original, true, true, true, &nPara, &nIndex)){
        string oldWord;
        oldWord = original.local8Bit();
        log(L_DEBUG, "%s not found", oldWord.c_str());
        return;
    }
    setCursorPosition(nPara, nIndex);
    for (unsigned i = 0; i < original.length(); i++)
        moveCursor(MoveForward, true);
    ensureCursorVisible();
    QRect rc = paragraphRect(nPara);
    QPoint p1 = QPoint(rc.left(), rc.top());
    QPoint p2 = QPoint(rc.right(), rc.bottom());
    p1 = viewport()->mapToParent(p1);
    p2 = viewport()->mapToParent(p2);
    p1.setX(QMAX(p1.x(), 0));
    p1.setY(QMAX(p1.y(), 0));
    p2.setX(QMIN(p2.x(), width()));
    p2.setY(QMIN(p2.y(), height()));
    p1 = mapToGlobal(p1);
    p2 = mapToGlobal(p2);

    int yPos = p1.y();
    if (p1.y() >= pSpell->heightDlg() - 10){
        yPos -= pSpell->heightDlg() + 25;
    }else{
        yPos = p2.y() + 10;
    }
    p1.setY(yPos);
    p1 = mapFromGlobal(p1);
    pSpell->moveDlg(p1.x(), p1.y());
#else
void EditSpell::misspelling (const QString&, const QStringList&, unsigned int)
{
#endif
}

void EditSpell::corrected_old(QString original, QString newword, unsigned pos)
{
    corrected((const QString&)original, (const QString&)newword, (unsigned int)pos);
}
Beispiel #18
0
void ContactsInner::updateSel() {
	if (!_mouseSel) return;

	int32 rh = st::profileListPhotoSize + st::profileListPadding.height() * 2;
	QPoint p(mapFromGlobal(_lastMousePos));
	if (_filter.isEmpty()) {
		DialogRow *newSel = rect().contains(p) ? _contacts->list.rowAtY(p.y(), rh) : 0;
		if (newSel != _sel) {
			_sel = newSel;
			parentWidget()->update();
		}		
	} else {
		int32 newFilteredSel = (p.y() >= 0 && rect().contains(p)) ? (p.y() / rh) : -1;
		if (newFilteredSel != _filteredSel) {
			_filteredSel = newFilteredSel;
			parentWidget()->update();
		}
	}
}
Beispiel #19
0
void CheckableHeader::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
{
    const QStyle *style = QApplication::style();
    painter->save();
    QHeaderView::paintSection(painter, rect, logicalIndex);
    painter->restore();

    if (logicalIndex == 0 && m_visible) {
        QStyleOptionButton option;
        option.state = QStyle::State_None;
        option.rect = rect;
        if (QApplication::isRightToLeft()) {
            option.rect.setRight(rect.right() - UNIVERSAL_PADDING);
        } else {
            option.rect.setLeft(rect.left() + UNIVERSAL_PADDING);
        }
        option.rect.setLeft(rect.left() + UNIVERSAL_PADDING);
        switch (m_state) {
        case Qt::Unchecked :
            option.state |= QStyle::State_Off;
            break;
        case Qt::PartiallyChecked :
            option.state |= QStyle::State_NoChange;
            break;
        case Qt::Checked :
            option.state |= QStyle::State_On;
            break;
        }

        // Get the cursor position to check if it has focus
        QPoint pos = mapFromGlobal(QCursor::pos());
        QRect rect = style->subElementRect(QStyle::SE_CheckBoxIndicator, &option);

        if (insideCheckBox(rect, pos)) {
            option.state |= QStyle::State_HasFocus;
        }

        // draw item data as CheckBox
        painter->save();
        style->drawControl(QStyle::CE_CheckBox, &option, painter);
        painter->restore();
    }
}
Beispiel #20
0
void KoView::slotAutoScroll(  )
{
    QPoint scrollDistance;
    bool actuallyDoScroll = false;
    QPoint pos( mapFromGlobal( QCursor::pos() ) );

    //Provide progressive scrolling depending on the mouse position
    if ( pos.y() < topBorder() )
    {
        scrollDistance.setY ((int) - autoScrollAcceleration( - pos.y() + topBorder() ));
        actuallyDoScroll = true;
    }
    else if ( pos.y() > height() - bottomBorder() )
    {
        scrollDistance.setY ((int) autoScrollAcceleration(pos.y() - height() + bottomBorder() ));
        actuallyDoScroll = true;
    }

    if ( pos.x() < leftBorder() )
    {
        scrollDistance.setX ((int) - autoScrollAcceleration( - pos.x() + leftBorder() ));
        actuallyDoScroll = true;
    }
    else if ( pos.x() > width() - rightBorder() )
    {
        scrollDistance.setX ((int) autoScrollAcceleration( pos.x() - width() + rightBorder() ));
        actuallyDoScroll = true;
    }

    if ( actuallyDoScroll )
    {
        int state=0;
#if KDE_IS_VERSION(3,4,0)
        state = kapp->keyboardMouseState();
#endif

        pos = canvas()->mapFrom(this, pos);
        QMouseEvent * event = new QMouseEvent(QEvent::MouseMove, pos, 0, state);

        QApplication::postEvent( canvas(), event );
        emit autoScroll( scrollDistance );
    }
}
Beispiel #21
0
void GisMapWidget::zoomInSlot()
{
	long int h, w;
	this->GetMapHW( &h, &w);
	QSize size = this->size();
	QPoint mousePos = mapFromGlobal( QCursor::pos());
	DOUBLEPOINT coordinate = this->pictureToGeo( mousePos.x(), mousePos.y());

	if( h >= size.height() || w >= size.width())
		this->SetViewScale( this->GetViewScale() * ScaleFactor_);
	else
		return;

//	if( sender() != zoomInAction_)
//	{
		DOUBLEPOINT dPoint = this->geoToPicture( coordinate);
		this->SetMapLeftTop( dPoint.x - mousePos.x(), dPoint.y - mousePos.y());
//	}
}
Beispiel #22
0
void KCRowHeader::slotAutoScroll(const QPoint& scrollDistance)
{
    // NOTE Stefan: This slot is triggered by the same signal as
    //              KCCanvas::slotAutoScroll and KCColumnHeader::slotAutoScroll.
    //              Therefore, nothing has to be done except the scrolling was
    //              initiated in this header.
    if (!m_bMousePressed)
        return;
    if (scrollDistance.y() == 0)
        return;
    const QPoint offset = m_pCanvas->viewConverter()->documentToView(m_pCanvas->offset()).toPoint();
    if (offset.y() + scrollDistance.y() < 0)
        return;
    m_pCanvas->setDocumentOffset(offset + QPoint(0, scrollDistance.y()));
    QMouseEvent event(QEvent::MouseMove, mapFromGlobal(QCursor::pos()),
                      Qt::NoButton, Qt::NoButton, QApplication::keyboardModifiers());
    QApplication::sendEvent(this, &event);
    m_pCanvas->update();
}
Beispiel #23
0
void GameView::mouseMoveEvent(QMouseEvent *event)
{
  event->accept();
  QPoint delta = event->pos() - my_last_mouse_pos;

  if (my_state == GameViewState::LOOKING) {
    if (delta == my_ignore_mouse_move) {
      return;
    }

    my_camera.set_yaw(my_camera.get_yaw() - delta.x() / 400.0f);
    my_camera.set_pitch(my_camera.get_pitch() - delta.y() / 400.0f);

    my_ignore_mouse_move = event->pos() - mapFromGlobal(my_cursor_pos);
    QCursor::setPos(my_cursor_pos);

    find_triangle_in_center();
  }
}
Beispiel #24
0
void Q3TitleBar::paintEvent(QPaintEvent *)
{
    Q_D(Q3TitleBar);
    QStyleOptionTitleBar opt = d->getStyleOption();
    opt.subControls = QStyle::SC_TitleBarLabel;
    opt.activeSubControls = d->buttonDown;
    if (d->flags & Qt::WindowSystemMenuHint) {
        opt.subControls |= QStyle::SC_TitleBarSysMenu | QStyle::SC_TitleBarCloseButton;
        if (d->window && (d->flags & Qt::WindowShadeButtonHint)) {
            if (d->window->isMinimized())
                opt.subControls |= QStyle::SC_TitleBarUnshadeButton;
            else
                opt.subControls |= QStyle::SC_TitleBarShadeButton;
        }
        if (d->window && (d->flags & Qt::WindowMinMaxButtonsHint)) {
            if(d->window && d->window->isMinimized())
                opt.subControls |= QStyle::SC_TitleBarNormalButton;
            else
                opt.subControls |= QStyle::SC_TitleBarMinButton;
        }
        if (d->window && (d->flags & Qt::WindowMaximizeButtonHint) && !d->window->isMaximized())
            opt.subControls |= QStyle::SC_TitleBarMaxButton;
    }
    QStyle::SubControl under_mouse = QStyle::SC_None;
    
    if (underMouse()) {
        under_mouse = style()->hitTestComplexControl(QStyle::CC_TitleBar, &opt,
                                                     mapFromGlobal(QCursor::pos()), this);
        opt.activeSubControls |= under_mouse;
        if (d->pressed)
            opt.state |= QStyle::State_Sunken;
        else if(autoRaise())
            opt.state |= QStyle::State_MouseOver;
    }
    
    opt.palette.setCurrentColorGroup(usesActiveColor() ? QPalette::Active : QPalette::Inactive);

    QPainter p(this);
    if (!windowTitle().isEmpty())
        opt.titleBarFlags |= Qt::WindowTitleHint;
    style()->drawComplexControl(QStyle::CC_TitleBar, &opt, &p, this);
}
void cTextField::onMouseDown(QMouseEvent *e) {
	cControl::onMouseDown(e);

	QPoint local = mapFromGlobal(e->pos());
	int index = getOffset(local.x());
	selection_ = 0;

	// XXXXXX TODO: Normal windows selection rules with mouse

	// Selection?
	if ((e->state() & Key_Shift) != 0) {
		// In which direction do we select?
		int diff = caret_ - index;

		// The offset would be the new selection value
		selection_ = diff;
	}

	setCaret(index);
}
Beispiel #26
0
void
BrowserBar::mouseMovedOverSplitter( QMouseEvent *e )
{
    const uint oldPos   = m_pos;
    const uint newPos   = mapFromGlobal( e->globalPos() ).x();
    const uint minWidth = m_tabBar->width() + m_browserBox->minimumWidth();
    const uint maxWidth = maxBrowserWidth();

    if( newPos < minWidth )
        m_pos = minWidth;

    else if( newPos > maxWidth )
        m_pos = maxWidth;

    else
        m_pos = newPos;

    if( m_pos != oldPos )
        adjustWidgetSizes();
}
void KstViewWidget::keyReleaseEvent(QKeyEvent *e) {
  if (_view->viewMode() == KstTopLevelView::DisplayMode) {
    KstViewObjectPtr vo;
    // Note: should mouse grabbers get keyboard input?
    if (_view->mouseGrabbed()) {
      vo = _view->mouseGrabber();
    } else {
      vo = findChildFor(mapFromGlobal(QCursor::pos()));
    }
    if (vo) {
      vo->keyReleaseEvent(this, e);
    }
    return;
  } else if (e->key() == Qt::Key_Control && _view->viewMode() == KstTopLevelView::LayoutMode) {
    _view->setViewMode(_lastViewMode);
    _lastViewMode = KstTopLevelView::LayoutMode;
  }

  QWidget::keyReleaseEvent(e);
}
Beispiel #28
0
void TabBarWidget::removeTab(int index)
{
	if (underMouse())
	{
		const bool isHorizontal = (shape() == QTabBar::RoundedNorth || shape() == QTabBar::RoundedSouth);
		const QSize size = tabSizeHint(count() - 1);

		m_tabSize = (isHorizontal ? size.width() : size.height());
	}

	QTabBar::removeTab(index);

	if (underMouse() && tabAt(mapFromGlobal(QCursor::pos())) < 0)
	{
		m_tabSize = 0;

		updateGeometry();
		adjustSize();
	}
}
Beispiel #29
0
void UBMagnifier::slot_refresh()
{
    if(!(updPointGrab.isNull())) 
        grabPoint(updPointGrab);

    if(isCusrsorAlreadyStored)
    {
        QPoint globalCursorPos = QCursor::pos();
        QPoint cursorPos = mapFromGlobal(globalCursorPos);
        if (cursorPos.x() < size().width() - mResizeItem->width() - 20 || 
            cursorPos.x() > size().width() - 20 ||
            cursorPos.y() < size().height() - mResizeItem->height() - 20 ||
            cursorPos.y() > size().height() - - 20
            )
        {
            isCusrsorAlreadyStored = false;
            setCursor(mOldCursor);
        }
    }
}
Beispiel #30
0
void IconsWidget::mouseMoveEvent(QMouseEvent *event)
{
    if (crashed)
        return;

    QCursor cursor;
    QPoint  cursorPos = mapFromGlobal(cursor.pos());

    if (rect().contains(cursorPos)) {
        int border = 5;
        QPoint point  = mapToGlobal(event->pos());
        QPoint point2 = mapToGlobal(QPoint(0, 0));
        if (point2.y() - mainPix.height() - 6 > 0) {
            toolTip->setGeometry(point.x() - mainPix.width()/2, point2.y() - mainPix.height()-6,
                                 mainPix.width(), mainPix.height());
        } else {
            toolTip->setGeometry(point.x() - mainPix.width()/2, point2.y() + height() + border,
                                 mainPix.width(), mainPix.height());
        }
    }
}