示例#1
0
GLGaze::GLGaze(Store* st)
{
    // Make our GL Gaze widget self-contained.
    setWindowTitle("GorgonEye - Gaze Control");
    setWindowFlags(Qt::FramelessWindowHint);
    setFrameShape(QFrame::NoFrame);

    // Create new viewport with OpenGL capabilities
    setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    setViewportUpdateMode(QGraphicsView::FullViewportUpdate);

    // Create scene and attempt to use full screen res for training/gaze estimation
    setScene(new GLGazeScene(st, DPI_SCALE, logicalDpiX(), logicalDpiY()));
    setGeometry(QApplication::desktop()->screenGeometry()); // other: availableGeometry
}
示例#2
0
WebView::WebView(KWebKitPart* part, QWidget* parent)
        :KWebView(parent, false),
         m_actionCollection(new KActionCollection(this)),
         m_part(part),
         m_webInspector(0),
         m_autoScrollTimerId(-1),
         m_verticalAutoScrollSpeed(0),
         m_horizontalAutoScrollSpeed(0),
         m_accessKeyActivated(NotActivated)
{
    setAcceptDrops(true);

    // Create the custom page...
    setPage(new WebPage(part, this));

    connect(this, SIGNAL(loadStarted()), this, SLOT(slotStopAutoScroll()));
    connect(this, SIGNAL(loadStarted()), this, SLOT(hideAccessKeys()));
    connect(page(), SIGNAL(scrollRequested(int,int,QRect)), this, SLOT(hideAccessKeys()));
    
    if (WebKitSettings::self()->zoomToDPI())
        setZoomFactor(logicalDpiY() / 96.0f);
}
示例#3
0
/*!
    Maps \a point from viewport co-ordinates to eye co-ordinates.

    The returned vector will have its x and y components set to the
    position of the point on the near plane, and the z component
    set to the inverse of the camera's near plane.

    This function is used for converting a mouse event's position
    into eye co-ordinates within the current camera view.

    \sa QGLCamera::mapPoint()
*/
QVector3D QGLView::mapPoint(const QPoint &point) const
{
    QSize viewportSize(size());
    qreal aspectRatio;

    // Get the size of the underlying paint device.
    int width = viewportSize.width();
    int height = viewportSize.height();

    // Use the device's DPI setting to determine the pixel aspect ratio.
    int dpiX = logicalDpiX();
    int dpiY = logicalDpiY();
    if (dpiX <= 0 || dpiY <= 0)
        dpiX = dpiY = 1;

    // Derive the aspect ratio based on window and pixel size.
    if (width <= 0 || height <= 0)
        aspectRatio = 1.0f;
    else
        aspectRatio = ((qreal)(width * dpiY)) / ((qreal)(height * dpiX));

    // Map the point into eye co-ordinates.
    return d->camera->mapPoint(point, aspectRatio, viewportSize);
}
示例#4
0
SoundSlider::SoundSlider( QWidget *_parent, float _i_step,
                          char *psz_colors, int max )
                        : QAbstractSlider( _parent )
{
    qreal scalingFactorX = static_cast<qreal>(logicalDpiX()) / DPI_REF_VALUE;
    qreal scalingFactorY = static_cast<qreal>(logicalDpiY()) / DPI_REF_VALUE;

    wlength = WLENGTH_BASE * scalingFactorX;
    wheight = WHEIGHT_BASE * scalingFactorY;

    f_step = (float)(_i_step * 10000)
           / (float)((max - SOUNDMIN) * AOUT_VOLUME_DEFAULT);
    setRange( SOUNDMIN, max);
    setMouseTracking( true );
    isSliding = false;
    b_mouseOutside = true;
    b_isMuted = false;

    const QPixmap pixOutsideRaw(Helper::getIconPath("volume-slider-outside.png"));
    const QSize pixOutsideSize(
                static_cast<qreal>(pixOutsideRaw.width()) * scalingFactorX,
                static_cast<qreal>(pixOutsideRaw.height()) * scalingFactorY
            );
    pixOutside = pixOutsideRaw.scaled(pixOutsideSize);

    const QPixmap tempRaw(Helper::getIconPath("volume-slider-inside.png"));
    const QSize tempSize(
                    static_cast<qreal>(tempRaw.width()) * scalingFactorX,
                    static_cast<qreal>(tempRaw.height()) * scalingFactorY
            );
    const QPixmap temp = tempRaw.scaled(tempSize);

    const QBitmap mask( temp.createHeuristicMask() );

    setFixedSize( pixOutside.size() );

    pixGradient = QPixmap( mask.size() );
    pixGradient2 = QPixmap( mask.size() );

    /* Gradient building from the preferences */
    QLinearGradient gradient( paddingL, 2, wlength + paddingL , 2 );
    QLinearGradient gradient2( paddingL, 2, wlength + paddingL , 2 );

    QStringList colorList = qfu( psz_colors ).split( ";" );
    free( psz_colors );

    /* Fill with 255 if the list is too short */
    if( colorList.count() < 12 )
        for( int i = colorList.count(); i < 12; i++)
            colorList.append( "255" );

    background = palette().color( QPalette::Active, QPalette::Window );
    foreground = palette().color( QPalette::Active, QPalette::WindowText );
    foreground.setHsv( foreground.hue(),
                    ( background.saturation() + foreground.saturation() ) / 2,
                    ( background.value() + foreground.value() ) / 2 );

    textfont.setPointSize( 9 );
    textrect.setRect( 0, 0, 34.0*scalingFactorX, 15.0*scalingFactorY );

    /* Regular colors */
#define c(i) colorList.at(i).toInt()
#define add_color(gradient, range, c1, c2, c3) \
    gradient.setColorAt( range, QColor( c(c1), c(c2), c(c3) ) );

    /* Desaturated colors */
#define desaturate(c) c->setHsvF( c->hueF(), 0.2 , 0.5, 1.0 )
#define add_desaturated_color(gradient, range, c1, c2, c3) \
    foo = new QColor( c(c1), c(c2), c(c3) );\
    desaturate( foo ); gradient.setColorAt( range, *foo );\
    delete foo;

    /* combine the two helpers */
#define add_colors( gradient1, gradient2, range, c1, c2, c3 )\
    add_color( gradient1, range, c1, c2, c3 ); \
    add_desaturated_color( gradient2, range, c1, c2, c3 );

    float f_mid_point = ( 100.0 / maximum() );
    QColor * foo;
    add_colors( gradient, gradient2, 0.0, 0, 1, 2 );
    if (f_mid_point + 0.05 <= 1.0) {
        add_colors( gradient, gradient2, f_mid_point - 0.05, 3, 4, 5 );
        add_colors( gradient, gradient2, f_mid_point + 0.05, 6, 7, 8 );
    }
    add_colors( gradient, gradient2, 1.0, 9, 10, 11 );

    painter.begin( &pixGradient );
    painter.setPen( Qt::NoPen );
    painter.setBrush( gradient );
    painter.drawRect( pixGradient.rect() );
    painter.end();

    painter.begin( &pixGradient2 );
    painter.setPen( Qt::NoPen );
    painter.setBrush( gradient2 );
    painter.drawRect( pixGradient2.rect() );
    painter.end();

    pixGradient.setMask( mask );
    pixGradient2.setMask( mask );
}