Exemplo n.º 1
0
void
OSDWidget::setVisible( bool visible )
{
    if ( visible )
    {
        if ( !isEnabled() || m_text.isEmpty() )
            return;

        const uint M = fontMetrics().width( 'x' );

        const QRect oldGeometry = QRect( pos(), size() );
        const QRect newGeometry = determineMetrics( M );

        if( newGeometry.width() > 0 && newGeometry.height() > 0 )
        {
            m_m = M;
            m_size = newGeometry.size();
            setGeometry( newGeometry );
            QWidget::setVisible( visible );

            if( m_duration ) //duration 0 -> stay forever
                m_timer->start( m_duration ); //calls hide()
        }
        else
            warning() << "Attempted to make an invalid sized OSD\n";

        update();
    }
    else 
        QWidget::setVisible( visible );
}
void KisFloatingMessage::showMessage()
{
    setGeometry(determineMetrics(fontMetrics().width('x')));
    setWindowOpacity(OSD_WINDOW_OPACITY);

    QWidget::setVisible(true);
    m_timer.start(4500);
}