Example #1
0
/*
  Internal function called from QWidget::setCursor()
   force is true if this function is called from dispatchEnterLeave, it means that the
   mouse is actually directly under this widget.
*/
void qt_symbian_set_cursor(QWidget *w, bool force)
{
    static QPointer<QWidget> lastUnderMouse = 0;
    if (force) {
        lastUnderMouse = w;
    }
    else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse
        && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) {
        w = lastUnderMouse;
    }

    if (!S60->curWin && w && w->internalWinId())
        return;
    QWidget* cW = w && !w->internalWinId() ? w : QWidget::find(S60->curWin);
    if (!cW || cW->window() != w->window() || !cW->isVisible() || !cW->underMouse()
        || QApplication::overrideCursor())
        return;

#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS
    if (S60->brokenPointerCursors)
        qt_symbian_set_pointer_sprite(cW->cursor());
    else
#endif
        qt_symbian_setWindowCursor(cW->cursor(), w->effectiveWinId());
}
ZLQtWaitMessage::ZLQtWaitMessage(const std::string &message) : QWidget(0, Qt::SplashScreen) {
	QWidget *main = qApp->activeWindow();
	if (main != 0) {
		myMainWidget = main;
		myStoredCursor = main->cursor();
		myMainWidget->setCursor(Qt::WaitCursor);
	} else {
		myMainWidget = 0;
	}
	setCursor(Qt::WaitCursor);

	qApp->processEvents();

	QBoxLayout layout(QBoxLayout::LeftToRight, this);
	QLabel *label = new QLabel(::qtString(message), this);
	layout.addWidget(label);

	if (main == 0) {
		main = QApplication::desktop();
	}
	move(
		main->x() + main->width() / 2 - label->width() / 2 - 10,
		main->y() + main->height() / 2 - label->height() / 2 - 10
	);
	show();

	qApp->processEvents();
	usleep(5000);
	qApp->processEvents();
}
Example #3
0
SetWaitCursor::~SetWaitCursor()
{
    if (m_guiApp) {

        RG_DEBUG << "SetWaitCursor::SetWaitCursor() : restoring normal cursor\n";
        QWidget* viewport = 0;
        QCursor currentCompositionViewCursor;

        if ((m_guiApp->getView() &&
                m_guiApp->getView()->getTrackEditor() &&
                m_guiApp->getView()->getTrackEditor()->getCompositionView() &&
                m_guiApp->getView()->getTrackEditor()->getCompositionView()->viewport())) {
            viewport = m_guiApp->getView()->getTrackEditor()->getCompositionView()->viewport();
            currentCompositionViewCursor = viewport->cursor();
        }

        m_guiApp->setCursor(m_saveCursor);

        if (viewport) {
            if (currentCompositionViewCursor.shape() == Qt::WaitCursor) {
                viewport->setCursor(m_saveCompositionViewCursor);
            } else {
                viewport->setCursor(currentCompositionViewCursor); // because m_guiApp->setCursor() has replaced it
            }
        }

        // otherwise, it's been modified elsewhere, so leave it as is

    }

}
Example #4
0
void QwtPanner::showCursor( bool on )
{
    if ( on == d_data->hasCursor )
        return;

    QWidget *w = parentWidget();
    if ( w == NULL || d_data->cursor == NULL )
        return;

    d_data->hasCursor = on;

    if ( on )
    {
        if ( w->testAttribute( Qt::WA_SetCursor ) )
        {
            delete d_data->restoreCursor;
            d_data->restoreCursor = new QCursor( w->cursor() );
        }
        w->setCursor( *d_data->cursor );
    }
    else
    {
        if ( d_data->restoreCursor )
        {
            w->setCursor( *d_data->restoreCursor );
            delete d_data->restoreCursor;
            d_data->restoreCursor = NULL;
        }
        else
            w->unsetCursor();
    }
}
Example #5
0
void QwtPanner::showCursor(bool on)
{
    QWidget *w = parentWidget();
    if ( w == NULL || d_data->cursor == NULL )
        return;

    if ( on )
    {
#if QT_VERSION < 0x040000
        if ( w->testWState(WState_OwnCursor) )
#else
        if ( w->testAttribute(Qt::WA_SetCursor) )
#endif
        {
            delete d_data->restoreCursor;
            d_data->restoreCursor = new QCursor(w->cursor());
        }
        w->setCursor(*d_data->cursor);
    }
    else
    {
        if ( d_data->restoreCursor )
        {
            w->setCursor(*d_data->restoreCursor);
            delete d_data->restoreCursor;
            d_data->restoreCursor = NULL;
        }
        else
            w->unsetCursor();
    }
}
ZLQtWaitMessage::ZLQtWaitMessage(const std::string &message) : QWidget(0, 0, WStyle_Splash), myLabelText(::qtString(message)) {
	QWidget *main = qApp->mainWidget();
	if (main != 0) {
		myCursorIsStored = true;
		myStoredCursor = main->cursor();
		main->setCursor(Qt::waitCursor);
	} else {
		myCursorIsStored = false;
	}
	setCursor(Qt::waitCursor);

	qApp->processEvents();

	if (main == 0) {
		main = QApplication::desktop();
	}
	QPoint position = main->mapToGlobal(main->pos());
	QFontMetrics metrics = fontMetrics();
	const int w = metrics.width(myLabelText) + 20;
	const int h = metrics.height() + 20;
	resize(1, 1);
	show();
	setGeometry(
		position.x() + (main->width() - w) / 2,
		position.y() + (main->height() - h) / 2,
		w, h
	);

	qApp->processEvents();
	for (int i = 0; i < 6; ++i) {
		usleep(5000);
		qApp->processEvents();
	}
}
Example #7
0
bool 
BioWidget::eventFilter( QObject* o, QEvent* e )
{
    QWidget* w = qobject_cast<QWidget*>( o );

    if ( viewport() == w )
    {
        if ( QEvent::MouseMove != e->type() )
            return false;

        QMouseEvent* event = static_cast<QMouseEvent*>(e);
        //respect child widget cursor
        QWidget* w = m_widgetTextObject->widgetAtPoint(event->pos() );

        if ( w != m_currentHoverWidget )
        {
            m_currentHoverWidget = w;

            if( 0 == w )
                viewport()->unsetCursor();
            else
            {
                QWidget* c = w->childAt(event->pos());
                c = c ? c : w;
                viewport()->setCursor( c->cursor());
            }
        }

        return false;
    }
    return false;
}
Example #8
0
void KoCursorPrivateAutoHideEventFilter::hideCursor()
{
    m_autoHideTimer.stop();

    if ( m_isCursorHidden )
        return;

    m_isCursorHidden = true;

    QWidget* w = mouseWidget();

    m_isOwnCursor = w->testAttribute(Qt::WA_SetCursor);
    if ( m_isOwnCursor )
        m_oldCursor = w->cursor();

    w->setCursor( QCursor( Qt::BlankCursor ) );
}
Example #9
0
void KCursorPrivateAutoHideEventFilter::hideCursor()
{
    m_autoHideTimer.stop();

    if ( m_isCursorHidden )
        return;

    m_isCursorHidden = true;

    QWidget* w = actualWidget();

    m_isOwnCursor = w->ownCursor();
    if ( m_isOwnCursor )
        m_oldCursor = w->cursor();

    w->setCursor( KCursor::blankCursor() );
}
Example #10
0
void KoCursorPrivateAutoHideEventFilter::unhideCursor()
{
    m_autoHideTimer.stop();

    if ( !m_isCursorHidden )
        return;

    m_isCursorHidden = false;

    QWidget* w = mouseWidget();

    if ( w->cursor().shape() != Qt::BlankCursor ) // someone messed with the cursor already
	return;

    if ( m_isOwnCursor )
        w->setCursor( m_oldCursor );
    else
        w->unsetCursor();
}
Example #11
0
void OpenGL2Common::setSpherical(bool spherical)
{
    const bool isSphericalView = (spherical && hasVbo);
    if (sphericalView != isSphericalView)
    {
        QWidget *w = widget();
        const bool isBlankCursor = (w->cursor().shape() == Qt::BlankCursor);
        sphericalView = isSphericalView;
        if (sphericalView)
        {
            w->setProperty("customCursor", (int)Qt::OpenHandCursor);
            if (!isBlankCursor)
                w->setCursor(Qt::OpenHandCursor);
            rot = QPointF(90.0, 90.0);
        }
        else
        {
            w->setProperty("customCursor", QVariant());
            if (!isBlankCursor)
                w->setCursor(Qt::ArrowCursor);
            buttonPressed = false;
        }
    }
}
void QTextureViewer::paint(QPainter *painter, QPaintEvent *event)
{
    VOGL_NOTE_UNUSED(event);
    if (m_pKtxTexture == NULL)
    {
        return;
    }

    if (!m_mipmappedTexture.is_valid() || !m_mipmappedTexture.get_num_levels())
    {
        return;
    }

    painter->save();

    const uint border = 25;
    const uint minDimension = 10;
    uint texWidth = m_pKtxTexture->get_width();
    uint texHeight = m_pKtxTexture->get_height();

    uint drawWidth = vogl::math::maximum<uint>(minDimension, texWidth);
    uint drawHeight = vogl::math::maximum<uint>(minDimension, texHeight);

    // offset by 1 so that there is room to draw a border around the biggest mip level
    painter->translate(1, 1);

    // apply zoom factor using scaling
    painter->scale(m_zoomFactor, m_zoomFactor);

    painter->setPen(m_outlinePen);

    uint numMips = m_pKtxTexture->get_num_mips();
    uint maxMip = vogl::math::minimum(numMips, m_maxMipLevel);
    maxMip = vogl::math::minimum(maxMip, m_mipmappedTexture.get_num_levels() - 1);

    uint mipWidth = 0;
    uint mipHeight = 0;

    drawWidth = drawWidth >> m_baseMipLevel;
    drawHeight = drawHeight >> m_baseMipLevel;

    if (m_pKtxTexture->get_num_faces() == 6)
    {
        // adjust draw dimensions
        drawWidth *= 4;
        drawHeight *= 3;
    }

    uint minimumWidth = 0;
    uint minimumHeight = drawHeight + border;

    for (uint mip = m_baseMipLevel; mip <= maxMip; mip++)
    {
        if (m_pixmaps.contains(mip) == false && m_mipmappedTexture.is_valid())
        {
            QWidget* pParent = (QWidget*)this->parent();
            QCursor origCursor = pParent->cursor();
            pParent->setCursor(Qt::WaitCursor);

            vogl::color_quad_u8* pTmpPixels = NULL;
            if (m_mipmappedTexture.is_cubemap())
            {
                vogl::mip_level* mipLevel = m_mipmappedTexture.get_level(m_arrayIndex, 0, mip);
                vogl::image_u8* image = mipLevel->get_image();

                mipWidth = image->get_width();
                mipHeight = image->get_height();

                unsigned char tmp = 0;
                unsigned int pixelsSize = image->get_total_pixels();

                // store face dimensions
                uint faceWidth = mipWidth;
                uint faceHeight = mipHeight;

                uint cubeCrossStride = faceWidth*4;

                // adjust mip dimensions
                mipWidth *= 4;
                mipHeight *= 3;

                pTmpPixels = new vogl::color_quad_u8[pixelsSize * 12];
                memset(pTmpPixels, 0, pixelsSize * 12 * sizeof(vogl::color_quad_u8));

                // order is +X, -X, +Y, -Y, +Z, -Z
                uint faceRowOffset[6] = {faceHeight, faceHeight, 0, 2*faceHeight, faceHeight, faceHeight};
                uint faceColOffset[6] = {0, 2*faceWidth, faceWidth, faceWidth, 3*faceWidth, faceWidth};

                for (uint face = 0; face < m_mipmappedTexture.get_num_faces(); face++)
                {
                    vogl::mip_level* mipLevel2 = m_mipmappedTexture.get_level(m_arrayIndex, face, mip);
                    vogl::image_u8* image2 = mipLevel2->get_image();
                    vogl::color_quad_u8* pPixels = image2->get_pixels();

                    // calculate write location to start of face
                    vogl::color_quad_u8* writeLoc = pTmpPixels + cubeCrossStride*faceRowOffset[face] + faceColOffset[face];

                    for (uint h = 0; h < faceHeight; h++)
                    {
                        // copy row of face into cross
                        memcpy(writeLoc + h*cubeCrossStride, pPixels + h*faceWidth, faceWidth*sizeof(vogl::color_quad_u8));

                        // adjust color of each pixel
                        for (uint w = 0; w < faceWidth; w++)
                        {
                            vogl::color_quad_u8* pPixel = writeLoc + h*cubeCrossStride + w;
                            adjustChannels(m_channelSelection, pPixel->r, pPixel->g, pPixel->b, pPixel->a);
                            tmp = pPixel->r;
                            pPixel->r = pPixel->b;
                            pPixel->b = tmp;
                        }
                    }
                }
            }
            else
            {
                vogl::mip_level* mipLevel = m_mipmappedTexture.get_level(m_arrayIndex, m_sliceIndex, mip);
                vogl::image_u8* image = mipLevel->get_image();
                vogl::color_quad_u8* pPixels = image->get_pixels();

                mipWidth = image->get_width();
                mipHeight = image->get_height();

                unsigned char tmp = 0;
                unsigned int pixelsSize = image->get_total_pixels();

                pTmpPixels = new vogl::color_quad_u8[pixelsSize];
                memcpy(pTmpPixels, pPixels, pixelsSize*sizeof(vogl::color_quad_u8));
                for (uint i = 0; i < pixelsSize; i++)
                {
                    adjustChannels(m_channelSelection, pTmpPixels[i].r, pTmpPixels[i].g, pTmpPixels[i].b, pTmpPixels[i].a);
                    tmp = pTmpPixels[i].r;
                    pTmpPixels[i].r = pTmpPixels[i].b;
                    pTmpPixels[i].b = tmp;
                }
            }

            m_pixmaps.insert(mip, QPixmap::fromImage(QImage((unsigned char*)pTmpPixels, mipWidth, mipHeight, QImage::Format_ARGB32_Premultiplied)));
            m_pixmapData.insert(mip, pTmpPixels);
            pParent->setCursor(origCursor);
        }

        // make sure the rect is 1 pixel around the texture
        painter->drawRect(-1, -1, drawWidth+1, drawHeight+1);

        if (m_pixmaps.contains(mip))
        {
            uint left = 0;
            uint top = 0;
            if (m_bInvert)
            {
                // invert
                painter->scale(1,-1);
                top = -drawHeight;
            }

            painter->drawPixmap(left, top, drawWidth, drawHeight, m_pixmaps[mip]);

            if (m_bInvert)
            {
                // restore inversion
                painter->scale(1,-1);
            }
        }
        painter->translate(drawWidth + border, drawHeight / 2);

        minimumWidth += drawWidth + border;

        drawWidth /= 2;
        drawHeight /= 2;
    }

    this->setMinimumSize(minimumWidth * m_zoomFactor, minimumHeight * m_zoomFactor);

    painter->restore();
}