Ejemplo n.º 1
0
bool MapEditorTool::containsDrawingButtons(Qt::MouseButtons buttons) const
{
	if (buttons.testFlag(Qt::LeftButton)) 
		return true;
	
	return (draw_on_right_click && buttons.testFlag(Qt::RightButton) && editingInProgress());
}
Ejemplo n.º 2
0
void tst_QFlags::testFlag() const
{
    Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton;

    QVERIFY(btn.testFlag(Qt::LeftButton));
    QVERIFY(!btn.testFlag(Qt::MidButton));

    btn = 0;
    QVERIFY(!btn.testFlag(Qt::LeftButton));
}
Ejemplo n.º 3
0
void PreviewClient::requestToggleMaximization(Qt::MouseButtons buttons)
{
    if (buttons.testFlag(Qt::LeftButton)) {
        const bool set = !isMaximized();
        setMaximizedHorizontally(set);
        setMaximizedVertically(set);
    } else if (buttons.testFlag(Qt::RightButton)) {
        setMaximizedHorizontally(!isMaximizedHorizontally());
    } else if (buttons.testFlag(Qt::MiddleButton)) {
        setMaximizedVertically(!isMaximizedVertically());
    }
}
Ejemplo n.º 4
0
unsigned int EditorSceneWidget::getMouseButton(Qt::MouseButtons buttons,Qt::MouseButton button)
{
	unsigned int flags = 0;
	buttons |= button;

	if(buttons.testFlag(Qt::LeftButton))
		flags |= MOUSEB_LEFT;
	if(buttons.testFlag(Qt::RightButton))
		flags |= MOUSEB_RIGHT;
	if(buttons.testFlag(Qt::MidButton))
		flags |= MOUSEB_MIDDLE;

	return flags;
}
Ejemplo n.º 5
0
MouseButton UsageLogger::mapButtons(Qt::MouseButtons b){
	MouseButton button;
	if(b.testFlag(Qt::LeftButton)){
		button = LEFT;
	}
	else if(b.testFlag(Qt::RightButton)){
		button = RIGHT;
	}
	else if(b.testFlag(Qt::MidButton)){
		button = MIDDLE;
	}
	else{
		button = NO;
	}
	return button;
}
Ejemplo n.º 6
0
QString TabletWidget::buttonsToString(Qt::MouseButtons bs)
{
    QStringList ret;
    for (int i = 0; (uint)(1 << i) <= Qt::MaxMouseButton; ++i) {
        Qt::MouseButton b = static_cast<Qt::MouseButton>(1 << i);
        if (bs.testFlag(b))
            ret << buttonToString(b);
    }
    return ret.join("|");
}
Ejemplo n.º 7
0
void QValueFilterEditor::sensitivityLabelClicked(Qt::MouseButtons buttons)
{
    if (buttons.testFlag(Qt::LeftButton)){
        if (m_sensitivity == Qt::CaseInsensitive){
            setCaseSensitivity(Qt::CaseSensitive);
        } else {
            setCaseSensitivity(Qt::CaseInsensitive);
        }
    }
}
Ejemplo n.º 8
0
void tst_QFlags::testFlagZeroFlag() const
{
    {
        Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton;
        /* Qt::NoButton has the value 0. */

        QVERIFY(!btn.testFlag(Qt::NoButton));
    }

    {
        /* A zero enum set should test true with zero. */
        QVERIFY(Qt::MouseButtons().testFlag(Qt::NoButton));
    }

    {
        Qt::MouseButtons btn = Qt::NoButton;
        QVERIFY(btn.testFlag(Qt::NoButton));
    }
}
Ejemplo n.º 9
0
void tst_QFlags::initializerLists()
{
#if defined(Q_COMPILER_INITIALIZER_LISTS)
    Qt::MouseButtons bts = { Qt::LeftButton, Qt::RightButton };
    QVERIFY(bts.testFlag(Qt::LeftButton));
    QVERIFY(bts.testFlag(Qt::RightButton));
    QVERIFY(!bts.testFlag(Qt::MiddleButton));

#if defined(Q_COMPILER_CLASS_ENUM)
    MyStrictNoOpFlags flags = { MyStrictNoOpEnum::StrictOne, MyStrictNoOpEnum::StrictFour };
    QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictOne));
    QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictFour));
    QVERIFY(!flags.testFlag(MyStrictNoOpEnum::StrictTwo));
#endif // Q_COMPILER_CLASS_ENUM

#else
    QSKIP("This test requires C++11 initializer_list support.");
#endif // Q_COMPILER_INITIALIZER_LISTS
}
Ejemplo n.º 10
0
// TODO consider using QWidget::mouseDoubleClickEvent() for double-click
void WzMainWindow::mousePressEvent(QMouseEvent *event)
{
	mouseXPos = event->x();
	mouseYPos = event->y();

	Qt::MouseButtons presses = event->buttons();	// full state info for all buttons
	MOUSE_KEY_CODE idx = buttonToIdx(event->button());			// index of button that caused event

	if (idx == MOUSE_BAD)
	{
		debug(LOG_ERROR, "bad mouse idx");	// FIXME remove
		return; // not recognized mouse button
	}

	MousePress mousePress;
	mousePress.action = MousePress::Press;
	mousePress.key = idx;
	mousePress.pos = Vector2i(mouseXPos, mouseYPos);
	mousePresses.push_back(mousePress);

	aMouseState[idx].pressPos.x = mouseXPos;
	aMouseState[idx].pressPos.y = mouseYPos;

	if (aMouseState[idx].state == KEY_UP
		|| aMouseState[idx].state == KEY_RELEASED
		|| aMouseState[idx].state == KEY_PRESSRELEASE)
	{
		if (!presses.testFlag(Qt::MidButton)) //skip doubleclick check for wheel
		{
			// whether double click or not
			if (realTime - aMouseState[idx].lastdown < DOUBLE_CLICK_INTERVAL)
			{
				aMouseState[idx].state = KEY_DOUBLECLICK;
				aMouseState[idx].lastdown = 0;
			}
			else
			{
				aMouseState[idx].state = KEY_PRESSED;
				aMouseState[idx].lastdown = realTime;
			}
		}
		else	//mouse wheel up/down was used, so notify. FIXME.
		{
			aMouseState[idx].state = KEY_PRESSED;
			aMouseState[idx].lastdown = 0;
		}

		if (idx == MOUSE_LMB || idx == MOUSE_RMB || idx == MOUSE_MMB)
		{
			dragKey = idx;
			dragX = mouseX();
			dragY = mouseY();
		}
	}
}
Ejemplo n.º 11
0
void QValueFilterEditor::matchFlagsLabelClicked(Qt::MouseButtons buttons)
{
    if (buttons.testFlag(Qt::LeftButton)){
        if (m_matchFlag == Qt::MatchStartsWith){
            setMatchFlag(Qt::MatchEndsWith);
        } else if (m_matchFlag == Qt::MatchEndsWith){
            setMatchFlag(Qt::MatchContains);
        } else if (m_matchFlag == Qt::MatchContains){
            setMatchFlag(Qt::MatchStartsWith);
        }
    }
}
Ejemplo n.º 12
0
//====================
//         PROTECTED
//====================
void DirWidget::mouseReleaseEvent(QMouseEvent *ev){
  static Qt::MouseButtons backmap = Qt::BackButton | Qt::ExtraButton5;
  //qDebug() << "Mouse Click:" << ev->button();
  if(backmap.testFlag(ev->button())){
    ev->accept();
    on_actionBack_triggered();
  //}else if(ev->button()==Qt::ForwardButton()){
    //ev->accept();
  }else{
    ev->ignore(); //not handled here
  }
}
void QInputGeneratorGeneric::mouseDClick(const QPoint& pos, Qt::MouseButtons state)
{
    QTT_TRACE_FUNCTION();
    const Qt::MouseButton buttons[] = {Qt::LeftButton, Qt::RightButton, Qt::MidButton, Qt::XButton1, Qt::XButton2};
    QWidget *widget=QApplication::widgetAt(pos);
    if (pos != currentPos) {
        mouseEvent(MouseMove, widget, Qt::NoButton, currentButtons, 0, widget->mapFromGlobal(pos));
        currentPos = pos;
    }
    for (unsigned int i=0; i<sizeof(buttons)/sizeof(Qt::MouseButton); i++) {
        if (state.testFlag(buttons[i])) {
            qttDebug() << "mouseClick" << pos << buttons[i];
            mouseEvent(MouseDClick, widget, buttons[i], state, 0, widget->mapFromGlobal(pos));
        }
    }
}
Ejemplo n.º 14
0
void EditMarkerGroupDialog::sl_onItemEntered(const QModelIndex &idx) {
    Qt::MouseButtons bs = QApplication::mouseButtons();
    if (bs.testFlag(Qt::LeftButton)) {
        sl_onItemSelected(idx);
    }
}