Ejemplo n.º 1
0
void CanvasQt::wheelEvent(QWheelEvent* e){
    MouseEvent::MouseWheelOrientation orientation;
    if (e->orientation() == Qt::Horizontal) {
        orientation = MouseEvent::MOUSE_WHEEL_HORIZONTAL;
    } else {
        orientation = MouseEvent::MOUSE_WHEEL_VERTICAL;
    }

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
    QPoint numPixels = e->pixelDelta();
    QPoint numDegrees = e->angleDelta() / 8 / 15;
#else
    QPoint numPixels;
    QPoint numDegrees = QPoint(0, e->delta() / 8 / 15);
#endif

    int numSteps = 0;
    if (!numPixels.isNull()) {
        numSteps = (orientation==MouseEvent::MOUSE_WHEEL_HORIZONTAL? numPixels.x() : numPixels.y()) / 5;
    } else if (!numDegrees.isNull()) {
        numSteps = (orientation==MouseEvent::MOUSE_WHEEL_HORIZONTAL? numDegrees.x() : numDegrees.y());
    }
    ivec2 screenPos(e->pos().x(), e->pos().y());
    ivec2 screenPosInvY(screenPos.x, static_cast<int>(getScreenDimensions().y) - 1 - screenPos.y);
    MouseEvent mouseEvent(screenPos, numSteps,
        EventConverterQt::getMouseWheelButton(e), MouseEvent::MOUSE_STATE_WHEEL, orientation,
        EventConverterQt::getModifier(e), getScreenDimensions(),
        getDepthValueAtCoord(screenPosInvY));
    e->accept();
    Canvas::mouseWheelEvent(&mouseEvent);
}
Ejemplo n.º 2
0
void TimeLine::wheelEvent(QWheelEvent* event)
{

    QPoint numPixels = event->pixelDelta();
    QPoint numDegrees = event->angleDelta() / 8;
    int isForward =0;
    if (!numPixels.isNull()) {
        if (numPixels.ry()>0)
          isForward =1;
        else if (numPixels.ry()<0)
          isForward =-1;
    }
    else if (!numDegrees.isNull()) {
        if (numDegrees.ry()>0)
            isForward =1;
        else if (numDegrees.ry()<0)
            isForward =-1;
    }

    if (isForward >0)
        mVScrollbar->triggerAction(QAbstractSlider::SliderSingleStepAdd);
    else if (isForward <0)
        mVScrollbar->triggerAction(QAbstractSlider::SliderSingleStepSub);
    else
    {
      //Do nothing we've had a wheel event where we are neither going forward or backward
      //which should never happen?
    }

    event->accept();
}
Ejemplo n.º 3
0
void MainWin::OnTreeViewContextMenu(const QPoint &point)
{
    if (point.isNull()) 
        return;

    QStandardItem *item = connections->itemFromIndex(
        ui.serversTreeView->indexAt(point)
        );    

    QPoint currentPoint = QCursor::pos(); 

    if (!item || currentPoint.isNull() || treeViewUILocked)
        return;

    int type = item->type();

    if (type == RedisServerItem::TYPE) {

        if (((RedisServerItem*)item)->isLocked()) {
            QMessageBox::warning(ui.serversTreeView, "Warning", "Performing operations. Please Keep patience.");
            return;
        }

        QAction * action = serverMenu->exec(currentPoint);

        if (action == nullptr)
            return;
            
        if (action->text() == "Reload")
            treeViewUILocked = true;
        
    } else if (type == RedisKeyItem::TYPE) {
        keyMenu->exec(currentPoint);
    }
}
Ejemplo n.º 4
0
void MapWidget::wheelEvent(QWheelEvent* event)
{

    QPoint numPixels = event->pixelDelta();
    QPoint numDegrees = event->angleDelta() / 8;
    int steps = 0;

   if (!numPixels.isNull()) {
        steps = numPixels.y()>0 ? numPixels.manhattanLength() : -numPixels.manhattanLength();

    } else if (!numDegrees.isNull()) {
        QPoint numSteps = numDegrees / 15;
        steps = numSteps.y()>0 ? numSteps.manhattanLength() : -numSteps.manhattanLength();
    }

    if(steps==0){
        return;
    }
    if (steps>=0) {
        zoomIn(std::max(1.01,0.2*steps));
    }
    else {
        zoomOut(std::max(1.01,0.2*steps));
    }

    event->accept();
}
Ejemplo n.º 5
0
void QQuickWheelArea::wheelEvent(QWheelEvent *we)
{
    if (we->phase() == Qt::ScrollBegin)
        setActive(true);
    else if (we->phase() == Qt::ScrollEnd)
        setActive(false);

    QPoint numPixels = we->pixelDelta();
    QPoint numDegrees = we->angleDelta() / 8;

    if (!numPixels.isNull()) {
        setHorizontalDelta(numPixels.x() * pixelDeltaAdjustment);
        setVerticalDelta(numPixels.y() * pixelDeltaAdjustment);
    } else if (!numDegrees.isNull()) {
        setHorizontalDelta(numDegrees.x() / 15.0 * m_scrollSpeed);
        setVerticalDelta(numDegrees.y() / 15.0 * m_scrollSpeed);
    }

    // This allows other parent WheelArea's to handle scrolling
    // For example this allows for ScrollView inside of another ScrollView to work correctly
    // Once this scrollbar can't scroll anymore, ie it reaches the limits,
    // it will ignore the scroll event so the parent WheelArea can start scrolling
    if ((numPixels.x() != 0 || numDegrees.x() != 0) &&
        m_horizontalMinimumValue <= m_horizontalMaximumValue &&
        (isAtXBeginning() || isAtXEnd())) {
        we->ignore();
    } else if ((numPixels.y() != 0 || numDegrees.y() != 0) &&
               m_verticalMinimumValue <= m_verticalMaximumValue &&
               (isAtYBeginning() || isAtYEnd())) {
        we->ignore();
    } else {
        we->accept();
    }
}
Ejemplo n.º 6
0
void ExampleView::wheelEvent(QWheelEvent* event)
       {
      QPoint pixelsScrolled = event->pixelDelta();
      QPoint stepsScrolled = event->angleDelta();
      int dx = 0, dy = 0;
      if (!pixelsScrolled.isNull()) {
            dx = pixelsScrolled.x();
            dy = pixelsScrolled.y();
            }
      else if (!stepsScrolled.isNull()) {
            dx = static_cast<qreal>(stepsScrolled.x()) * qMax(2, width() / 10) / 120;
            dy = static_cast<qreal>(stepsScrolled.y()) * qMax(2, height() / 10) / 120;
            }

      if (dx == 0) {
            if (dy == 0)
                  return;
            else
                  dx = dy;
            }

      constraintCanvas(&dx);

      _matrix.setMatrix(_matrix.m11(), _matrix.m12(), _matrix.m13(), _matrix.m21(),
         _matrix.m22(), _matrix.m23(), _matrix.dx()+dx, _matrix.dy(), _matrix.m33());
      imatrix = _matrix.inverted();
      scroll(dx, 0);
      }
Ejemplo n.º 7
0
void XMainWindow::showEvent(QShowEvent *event)
{
  if(!_private->_shown)
  {
    _private->_shown = true;
//qDebug("isModal() %s", isModal()?"true":"false");

    QRect availableGeometry = QApplication::desktop()->availableGeometry();
    if(!omfgThis->showTopLevel() && !isModal())
      availableGeometry = omfgThis->workspace()->geometry();

    QString objName = objectName();
    QPoint pos = xtsettingsValue(objName + "/geometry/pos").toPoint();
    QSize lsize = xtsettingsValue(objName + "/geometry/size").toSize();

    if(lsize.isValid() && xtsettingsValue(objName + "/geometry/rememberSize", true).toBool() && (metaObject()->className() != QString("xTupleDesigner")))
      resize(lsize);

    setAttribute(Qt::WA_DeleteOnClose);
    if(omfgThis->showTopLevel() || isModal())
    {
      omfgThis->_windowList.append(this);
      statusBar()->show();
      QRect r(pos, size());
      if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool())
        move(pos);
    }
    else
    {
      QWidget * fw = focusWidget();
      omfgThis->workspace()->addWindow(this);
      QRect r(pos, size());
      if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool())
        move(pos);
      // This originally had to be after the show? Will it work here?
      if(fw)
        fw->setFocus();
    }

    _private->loadScriptEngine();

    QList<XCheckBox*> allxcb = findChildren<XCheckBox*>();
    for (int i = 0; i < allxcb.size(); ++i)
      allxcb.at(i)->init();

    shortcuts::setStandardKeys(this);
  }

  bool blocked = _private->_action->blockSignals(true);
  _private->_action->setChecked(true);
  _private->_action->blockSignals(blocked);

  _private->callShowEvent(event);

  QMainWindow::showEvent(event);
}
void DisplayBoard::wheelEvent(QWheelEvent *event) {
    QPoint numPixels = event->pixelDelta();
    QPoint numDegrees = event->angleDelta() / 8;
    if (!numDegrees.isNull()) {
        zoom *= pow(2, numDegrees.y() / 90.0);
    }
    else if (!numPixels.isNull()) {
        zoom *= pow(2, numPixels.y() / 100.0);
    }
    update();
    event->accept();
}
Ejemplo n.º 9
0
void LinkDialogGraphicsView::wheelEvent(QWheelEvent* e) {
    QPoint numPixels = e->pixelDelta();
    QPoint numDegrees = e->angleDelta() / 8 / 15;

    if (!numPixels.isNull()) {
        scene_->wheelAction(static_cast<float>(numPixels.y()) / 50.f);
    } else if (!numDegrees.isNull()) {
        scene_->wheelAction(static_cast<float>(numDegrees.y()) / 10.f);
    }

    e->accept();
}
Ejemplo n.º 10
0
void XWidget::showEvent(QShowEvent *event)
{
  if(!_private->_shown)
  {
    _private->_shown = true;
    if (windowFlags() & (Qt::Window | Qt::Dialog))
    {
      QRect availableGeometry = QApplication::desktop()->availableGeometry();
      if(!omfgThis->showTopLevel() && !isModal())
        availableGeometry = QRect(QPoint(0, 0), omfgThis->workspace()->size());

      QString objName = objectName();
      QPoint pos = xtsettingsValue(objName + "/geometry/pos").toPoint();
      QSize lsize = xtsettingsValue(objName + "/geometry/size").toSize();

      if(lsize.isValid() && xtsettingsValue(objName + "/geometry/rememberSize", true).toBool())
        resize(lsize);

      setAttribute(Qt::WA_DeleteOnClose);
      if(omfgThis->showTopLevel() || isModal())
      {
        omfgThis->_windowList.append(this);
        QRect r(pos, size());
        if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool())
          move(pos);
      }
      else
      {
        QWidget * fw = focusWidget();
        omfgThis->workspace()->addWindow(this);
        QRect r(pos, size());
        if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool() && parentWidget())
          parentWidget()->move(pos);
        // This originally had to be after the show? Will it work here?
        if(fw)
          fw->setFocus();
      }
    }

    _private->loadScriptEngine();

    QList<XCheckBox*> allxcb = findChildren<XCheckBox*>();
    for (int i = 0; i < allxcb.size(); ++i)
      allxcb.at(i)->init();

    shortcuts::setStandardKeys(this);
  }

  _private->callShowEvent(event);

  QWidget::showEvent(event);
}
Ejemplo n.º 11
0
bool PopupItem::eventFilter( QObject *object, QEvent *e )
{
    MarbleWidget *widget = dynamic_cast<MarbleWidget*> ( object );
    if ( !widget ) {
        return BillboardGraphicsItem::eventFilter( object, e );
    }

    if ( e->type() == QEvent::MouseButtonDblClick
            || e->type() == QEvent::MouseMove
            || e->type() == QEvent::MouseButtonPress
            || e->type() == QEvent::MouseButtonRelease )
    {
        // Mouse events are forwarded to the underlying widget
        QMouseEvent *event = static_cast<QMouseEvent*> ( e );
        QPoint const shiftedPos = transform( event->pos() );
        bool const forcedMouseRelease = m_needMouseRelease && e->type() == QEvent::MouseButtonRelease;
        if ( !shiftedPos.isNull() || forcedMouseRelease ) {
            if ( !m_needMouseRelease && e->type() == QEvent::MouseButtonPress ) {
                m_needMouseRelease = true;
            } else if ( forcedMouseRelease ) {
                m_needMouseRelease = false;
            }
            widget->setCursor( Qt::ArrowCursor );
            // transform to children's coordinates
            QMouseEvent shiftedEvent = QMouseEvent( e->type(), shiftedPos,
                                                    event->globalPos(), event->button(), event->buttons(),
                                                    event->modifiers() );
            if ( QApplication::sendEvent( m_webView, &shiftedEvent ) ) {
                widget->setCursor( m_webView->cursor() );
                emit dirty();
                return true;
            }
        }
    } else if ( e->type() == QEvent::Wheel ) {
        // Wheel events are forwarded to the underlying widget
        QWheelEvent *event = static_cast<QWheelEvent*> ( e );
        QPoint const shiftedPos = transform( event->pos() );
        if ( !shiftedPos.isNull() ) {
            widget->setCursor( Qt::ArrowCursor );
            QWheelEvent shiftedEvent = QWheelEvent( shiftedPos,
                                                    event->globalPos(), event->delta(), event->buttons(),
                                                    event->modifiers() );
            if ( QApplication::sendEvent( m_webView, &shiftedEvent ) ) {
                widget->setCursor( m_webView->cursor() );
                emit dirty();
                return true;
            }
        }
    }

    return BillboardGraphicsItem::eventFilter( object, e );
}
Ejemplo n.º 12
0
/**
 * Override to support zooming in and out using the mouse wheel.
 */
void MapView::wheelEvent(QWheelEvent *event)
{
    auto *hBar = static_cast<FlexibleScrollBar*>(horizontalScrollBar());
    auto *vBar = static_cast<FlexibleScrollBar*>(verticalScrollBar());

    if (event->modifiers() & Qt::ControlModifier
        && event->orientation() == Qt::Vertical)
    {
        // No automatic anchoring since we'll do it manually
        setTransformationAnchor(QGraphicsView::NoAnchor);

        // This works around problems with automatic alignment of scenes that
        // are smaller than the view, which seems to be impossible to disable.
        hBar->allowNextRangeChange();
        vBar->allowNextRangeChange();

        mZoomable->handleWheelDelta(event->delta());

        adjustCenterFromMousePosition(mLastMousePos);

        // Restore the centering anchor
        setTransformationAnchor(QGraphicsView::AnchorViewCenter);
        return;
    }

    // By default, the scroll area forwards the wheel events to the scroll
    // bars, which apply their bounds. This custom wheel handling is here to
    // override the bounds checking.
    //
    // This also disables QGraphicsSceneWheelEvent, but Tiled does not rely
    // on that event.

    QPoint pixels = event->pixelDelta();

    if (pixels.isNull()) {
        QPointF steps = event->angleDelta() / 8.0 / 15.0;
        int lines = QApplication::wheelScrollLines();
        pixels.setX(int(steps.x() * lines * hBar->singleStep()));
        pixels.setY(int(steps.y() * lines * vBar->singleStep()));
    }

    if (!pixels.isNull()) {
        int horizontalValue = hBar->value() + (isRightToLeft() ? pixels.x() : -pixels.x());
        int verticalValue = vBar->value() - pixels.y();
        hBar->forceSetValue(horizontalValue);
        vBar->forceSetValue(verticalValue);

        // When scrolling the mouse does not move, but the view below it does.
        // This affects the mouse scene position, which needs to be updated.
        mLastMouseScenePos = mapToScene(viewport()->mapFromGlobal(mLastMousePos));
    }
}
Ejemplo n.º 13
0
void CMindMapDtLineTool::onLineColor()
{
    QPoint					p;
	QColor					c;
	QPen					pen;
	QList<CDiagramItem*>	items;

    if (!m_d || !m_p)
		return;

	items = m_d->getItemsHasFocus();
	if (items.length() == 0)
		return;

	foreach (CDiagramItem *item, items)
	{
		if (dynamic_cast<CMindMapNode*>(item))
		{
			pen = item->pen();
			break;
		}
	}
	c = pen.color();
	m_lineColors->setMode( CUiColorPanel::SolidFill );
	m_lineColors->setSelectedColor(c);

    p = Utils::getPopupPoint(m_d, m_p, ui->m_btnLineColor, m_lineColors);
    if (!p.isNull())
    {
        m_lineColors->raise();
        m_lineColors->show();
        m_lineColors->move( p );
    }
}
Ejemplo n.º 14
0
/*
 A dialog for getting/setting general info about a Make Controller
*/
Inspector::Inspector(MainWindow *mainWindow) : QDialog( 0 )
{
  this->mainWindow = mainWindow;
  setupUi(this);
  connect(this, SIGNAL(finished(int)), this, SLOT(onFinished()));
  connect(&infoTimer, SIGNAL(timeout()), this, SLOT(getBoardInfo()));
  connect(applyButton, SIGNAL(clicked()), this, SLOT(onApply()));
  connect(revertButton, SIGNAL(clicked()), this, SLOT(onRevert()));

  connect(nameEdit, SIGNAL(textEdited(QString)), this, SLOT(onAnyValueEdited()));
  connect(serialEdit, SIGNAL(textEdited(QString)), this, SLOT(onAnyValueEdited()));
  connect(versionEdit, SIGNAL(textEdited(QString)), this, SLOT(onAnyValueEdited()));
  connect(freememEdit, SIGNAL(textEdited(QString)), this, SLOT(onAnyValueEdited()));
  connect(ipEdit, SIGNAL(textEdited(QString)), this, SLOT(onAnyValueEdited()));
  connect(netmaskEdit, SIGNAL(textEdited(QString)), this, SLOT(onAnyValueEdited()));
  connect(gatewayEdit, SIGNAL(textEdited(QString)), this, SLOT(onAnyValueEdited()));
  connect(listenPortEdit, SIGNAL(textEdited(QString)), this, SLOT(onAnyValueEdited()));
  connect(sendPortEdit, SIGNAL(textEdited(QString)), this, SLOT(onAnyValueEdited()));
  connect(dhcpBox, SIGNAL(clicked(bool)), this, SLOT(onAnyValueEdited()));

  QSettings settings("MakingThings", "mchelper");
  QPoint inspectorPos = settings.value("inspector_pos").toPoint();
  if(!inspectorPos.isNull())
    move(inspectorPos);

  resize(gridLayout->sizeHint());
}
bool EnlargeShrink::setOption(const QString &option, const QVariant &value)
{
    bool ok = false;

    if (option == QuillImageFilter::Radius) {
        double radius = value.toDouble(&ok);
        if (ok) {
            m_Radius = radius;
        }

    } else if (option == QuillImageFilter::Center) {
        QPoint center = value.toPoint();
        if (!center.isNull()) {
            m_Center = center;
            ok = true;
        }

    } else if (option == FORCE_OPTION) {
        double force = value.toDouble(&ok);
        ok = ok && force <= 1.0 && force >= -1.0;
        if (ok) {
            // Divide by the FORCE_FACTOR to get appropiated values for
            // the Amplitude used by the "distort" function
            m_Force = force/FORCE_FACTOR;
        }
    }

    return ok;
}
Ejemplo n.º 16
0
void LinkDialogGraphicsView::wheelEvent(QWheelEvent* e) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
    QPoint numPixels = e->pixelDelta();
    QPoint numDegrees = e->angleDelta() / 8 / 15;
#else
    QPoint numPixels;
    QPoint numDegrees = QPoint(0, e->delta() / 8 / 15);
#endif
    if (!numPixels.isNull()) {
        scene_->wheelAction(static_cast<float>(numPixels.y()) / 50.0);
    } else if (!numDegrees.isNull()) {
        scene_->wheelAction(static_cast<float>(numDegrees.y()) / 10.0);
    }

    e->accept();
}
Ejemplo n.º 17
0
/*
  Restore the app to its state before it was shut down.
*/
void MainWindow::readSettings()
{
	QSettings settings("MakingThings", "mcbuilder");
	settings.beginGroup("MainWindow");
	
	QSize size = settings.value( "size" ).toSize( );
	if( size.isValid( ) )
		resize( size );
	
	QList<QVariant> splitterSettings = settings.value( "splitterSizes" ).toList( );
	QList<int> splitterSizes;
	if( !splitterSettings.isEmpty( ) )
	{
		for( int i = 0; i < splitterSettings.count( ); i++ )
			splitterSizes.append( splitterSettings.at(i).toInt( ) );
		splitter->setSizes( splitterSizes );
	}
  
  if(settings.value("checkForUpdates", true).toBool())
    updater->checkForUpdates(APPUPDATE_BACKGROUND);
  
  QString lastProject = settings.value("lastOpenProject").toString();
  if(!lastProject.isEmpty())
    openProject(lastProject);
	settings.endGroup();
  QPoint mainWinPos = settings.value("mainwindow_pos").toPoint();
  if(!mainWinPos.isNull())
    move(mainWinPos);
}
Ejemplo n.º 18
0
void BrowserView::jump_to_media(MEDIA::MediaPtr media)
{
    VIEW::Id mode;

    if(!media)
      return;
    
    if(media->type() == TYPE_ARTIST)
      mode = VIEW::ViewArtist;
    else if(media->type() == TYPE_ALBUM)
      mode = VIEW::ViewAlbum;
    else if(media->type() == TYPE_TRACK)
      mode = VIEW::ViewTrack;
    else return;  
      
    CentralToolBar::instance()->setExplorerFilterText("");
    m_scenes[VIEW::ViewArtist]->setFilter("");
    m_scenes[VIEW::ViewTuneIn]->setFilter("");
    m_scenes[VIEW::ViewFileSystem]->setFilter("");
      
    active_view(mode,"", QVariant());

    /* localise item */
    QPoint p = static_cast<LocalScene*>(m_scenes[mode])->get_item_position(media);

    if(!p.isNull()) 
      this->verticalScrollBar()->setSliderPosition( p.y() - 40 );
}
Ejemplo n.º 19
0
void ZoomableAssemblyOverview::sl_zoomOut(const QPoint & pos) {
    if(!zoomable) return;

    // 1. count new length of the visible region
    qint64 newLen = visibleRange.length * ZOOM_MULT + 0.5;
    U2OpStatusImpl os;
    if(newLen > model->getModelLength(os)) {
        newLen = model->getModelLength(os);
    }

    // 2. count new start of the visible region
    qint64 newStart = 0;
    if(!pos.isNull()) {
        //Black magic. Zooms overview so that region under mouse pointer remains
        //under pointer after zoom
        newStart = calcXAssemblyCoord(pos.x()) - double(newLen)/width()*pos.x();
    } else {
        //simply zoom to center
        newStart = visibleRange.startPos + (visibleRange.length-newLen)/2;
    }

    //3. if nothing changed -> do nothing
    if(newLen == visibleRange.length && newStart == visibleRange.startPos) {
        return;
    }

    //4. set new values and update widget
    checkedSetVisibleRange(newStart, newLen);
    sl_redraw();
}
Ejemplo n.º 20
0
	void SeparateTabWidget::handleContextMenuRequested (const QPoint& point)
	{
		if (point.isNull ())
			return;

		QMenu *menu = new QMenu ("", MainTabBar_);
		int index = MainTabBar_->tabAt (point);

		if (index == -1)
			for (auto act : TabBarActions_)
			{
				if (!act)
				{
					qWarning () << Q_FUNC_INFO
							<< "detected null pointer";
					continue;
				}
				menu->addAction (act);
			}
		else if (index == MainTabBar_->count () - 1)
			menu->addActions (AddTabButtonContextMenu_->actions ());
		else
		{
			LastContextMenuTab_ = index;
			delete menu;
			menu = GetTabMenu (index);
		}
		menu->exec (MainTabBar_->mapToGlobal (point));
		delete menu;
	}
Ejemplo n.º 21
0
void KisColorSelectorTriangle::updatePixelCache()
{
    int width = triangleWidth() + 1;
    int height = triangleHeight();

    QPoint pixelCacheOffset;

    Acs::PixelCacheRenderer::render(this,
                                    m_parent->converter(),
                                    QRect(0, 0, width, height),
                                    m_realPixelCache,
                                    m_renderedPixelCache,
                                    pixelCacheOffset);

    if (!pixelCacheOffset.isNull()) {
        qWarning() << "WARNING: offset of the triangle selector is not null!";
    }

    // antialiased border
    QPainter gc(&m_renderedPixelCache);
    gc.setRenderHint(QPainter::Antialiasing);
    gc.setPen(QPen(QColor(0,0,0,128), 2.5));
    gc.setCompositionMode(QPainter::CompositionMode_Clear);
    gc.drawLine(QPointF(0, triangleHeight()), QPointF((triangleWidth()) / 2.0, 0));
    gc.drawLine(QPointF(triangleWidth() / 2.0 + 1.0, 0), QPointF(triangleWidth() + 1, triangleHeight()));
}
Ejemplo n.º 22
0
void TileLayer::offsetTiles(const QPoint &offset,
                            const QRect &bounds,
                            bool wrapX, bool wrapY)
{
    if (offset.isNull())
        return;

    const std::unique_ptr<TileLayer> newLayer(clone());

    for (int y = bounds.top(); y <= bounds.bottom(); ++y) {
        for (int x = bounds.left(); x <= bounds.right(); ++x) {
            // Get position to pull tile value from
            int oldX = x - offset.x();
            int oldY = y - offset.y();

            // Wrap x value that will be pulled from
            if (wrapX)
                oldX = clampWrap(oldX, bounds.left(), bounds.right() + 1);

            // Wrap y value that will be pulled from
            if (wrapY)
                oldY = clampWrap(oldY, bounds.top(), bounds.bottom() + 1);

            // Set the new tile
            if (bounds.contains(oldX, oldY))
                newLayer->setCell(x, y, cellAt(oldX, oldY));
            else
                newLayer->setCell(x, y, Cell::empty);
        }
    }

    mChunks = newLayer->mChunks;
    mBounds = newLayer->mBounds;
}
Ejemplo n.º 23
0
/** Restores the last size and location of the window. */
void
VidaliaWindow::restoreWindowState()
{
#if QT_VERSION >= 0x040200
  QByteArray geometry = getSetting("Geometry", QByteArray()).toByteArray();
  if (geometry.isEmpty())
    adjustSize();
  else
    restoreGeometry(geometry);
#else
  QRect screen = QDesktopWidget().availableGeometry();

  /* Restore the window size. */
  QSize size = getSetting("Size", QSize()).toSize();
  if (!size.isEmpty()) {
    size = size.boundedTo(screen.size());
    resize(size);
  }

  /* Restore the window position. */
  QPoint pos = getSetting("Position", QPoint()).toPoint();
  if (!pos.isNull() && screen.contains(pos)) {
    move(pos);
  }
#endif
}
Ejemplo n.º 24
0
wxPoint wxQtConvertPoint( const QPoint &point )
{
    if (point.isNull())
        return wxDefaultPosition;

    return wxPoint( point.x(), point.y() );
}
Ejemplo n.º 25
0
void  EditorWindow::loadSettings()
{

    QSettings settings;

    /* Main Window location */
    settings.beginGroup("EditorWindow");
    QSize size = settings.value("size").toSize();
    QPoint pos = settings.value("position").toPoint();
    QByteArray state = settings.value("state").toByteArray();

    /* Recent docs/projects */
    recentDocs = settings.value("recentDocs", QStringList()).toStringList();
    recentProjects = settings.value("recentProjects",
                                    QStringList()).toStringList();

    settings.endGroup();

    if(!(size.isNull() || pos.isNull() || state.isNull()))
    {
        resize(size);
        move(pos);
        restoreState(state);
    }

}
Ejemplo n.º 26
0
bool BaseViewer::zoomOnWheelEvent(QEvent * e)
{
    if (e->type() == QEvent::Wheel)
    {
        QWheelEvent * event = static_cast<QWheelEvent*>(e);
        // mouse has X units that covers 360 degrees. Zoom when 15 degrees is provided
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
        QPoint numDegrees = event->angleDelta() / 8;
#else
        QPoint numDegrees(0,event->delta() / 8);
#endif
        if (!numDegrees.isNull())
        {
            if (numDegrees.y() >= 15)
            { // Zoom in
                if (_zoomLevel+1<=_zoomMaxLevel)
                    centerOnAtZoom(_zoomLevel+1);
            }
            else if (numDegrees.y() <= -15)
            { // Zoom out
                if (_zoomLevel-1>=_zoomMinLevel)
                    centerOnAtZoom(_zoomLevel-1);
            }
            event->accept();
            return true;
        }
        return true;
    }
    return false;
}
Ejemplo n.º 27
0
void QX11WindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
{
    if (d_ptr->device.isNull())
        return;

    QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
    QRegion wrgn(rgn);
    QRect br = rgn.boundingRect();
    if (!wOffset.isNull())
        wrgn.translate(-wOffset);
    QRect wbr = wrgn.boundingRect();

    int num;
    XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
    if (num <= 0)
        return;
//         qDebug() << "XSetClipRectangles";
//         for  (int i = 0; i < num; ++i)
//             qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height;
    if (num != 1)
        XSetClipRectangles(X11->display, gc, 0, 0, rects, num, YXBanded);
    XCopyArea(X11->display, d_ptr->device.handle(), widget->handle(), gc,
              br.x() + offset.x(), br.y() + offset.y(), br.width(), br.height(), wbr.x(), wbr.y());
    if (num != 1)
        XSetClipMask(X11->display, gc, XNone);
}
Ejemplo n.º 28
0
void SignatureItem::showMenu(const QPoint &pos) {
    if (pos.isNull()) {
        // not used
    }
    //QMenu* menu = new QMenu(treeWidget());
    //menu->addAction("Test Signature");
    //menu->popup(treeWidget()->viewport()->mapToGlobal(pos));
}
Ejemplo n.º 29
0
void ToolTip::showText(const QPoint &pos, const QString &text, QWidget *widget)
{
    if (pos.isNull() or text.isEmpty()) {
        instance()->hide();
        return;
    }
    instance()->show(pos, text, widget);
}
Ejemplo n.º 30
0
QIcon CountryField::icon(const QString &code, const QPixmap &layout)
{
  QPoint point = pos(code);
  if (point.isNull())
    return QIcon();

  return QIcon(layout.copy(point.x(), point.y(), 16, 11));
}