Example #1
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
tNASVirtualHead::~tNASVirtualHead()
{
    // Don't need the timers anymore, and don't want any surprise timeouts!
    m_StateTimer->stop();
    m_CloseOnUserInactivityTimer->stop();

    // Delete the accumulated items in m_WidgetItemList.
    // Don't worry about m_pListWidget, it will automatically delete the items it has.
    qDeleteAll(m_WidgetItemList);
    m_WidgetItemList.clear();

    // before sending the close command, disconnect the signal, we know we are closing it.
    disconnect( &m_pFusionClientAgent, SIGNAL(MenuAction(quint8,quint32,tFusionClient::eMenuStatus)),
            this, SLOT(OnMenuAction(quint8,quint32,tFusionClient::eMenuStatus)) );

    // just send MenuActionClose instead of Exit, therefore we can open the menu to the last place it was.
    m_pFusionClientAgent.SetMenuAction( m_SourceId, 0, tFusionClient::eMA_Close );
}
bool Screen_Base::BasicMenuTouchFunc(int action, int id, float x, float y, float pressure, float size)
{
    // flip y to make it start at bottom left.
    y = g_pGame->m_GameHeight - y;

    switch( action )
    {
    case GCBA_Down: // new finger down
        {
            g_Fingers[id].set( x, y, id );

            for( int i=m_MenuItemsNeeded-1; i>=0; i-- )
            {
                if( GetMenuItem(i) )
                {
                    if( GetMenuItem(i)->HoldOnCollision( id, x, y, true ) )
                        return true;
                }
            }
        }
        break;

    case GCBA_Held: // any finger might have moved
        {
            int fingerindex = -1;

            for( int i=0; i<10; i++ )
            {
                if( g_Fingers[i].id == id )
                    fingerindex = i;
            }

            if( fingerindex != -1 )
            {
                g_Fingers[fingerindex].set( x, y, id );

                BasicMenuHandleHeldFunc( fingerindex, x, y );
            }
        }
        break;

    case GCBA_Up: // any finger up
        {
            g_Fingers[id].reset();

            for( int i=m_MenuItemsNeeded-1; i>=0; i-- )
            {
                if( GetMenuItem(i) )
                {
                    int action = GetMenuItem(i)->TriggerOnCollision( id, x, y, true );

                    if( action != -1 && OnMenuAction( action ) )
                        return true;
                }
            }
        }
        break;
    }

    return false;
}
Example #3
0
//-----------------------------------------------------------------------------
//! Constructor for a dialog
//-----------------------------------------------------------------------------
tNASVirtualHead::tNASVirtualHead( const QString& rootName, tFusionClientAgent& fusionClientAgent, bool showButtons, QWidget* pParent )
    : tDialog( tDialog::Full, pParent ), 
    m_pFusionClientAgent( fusionClientAgent ),
    m_SourceId( fusionClientAgent.GetCurrentSourceId() ),
    m_ShowButtons( showButtons ),
    m_State( eIdle ),
    m_StateTimer( 0 ),
    m_CloseOnUserInactivityTimer( 0 ),
    m_IsRoot( true ),
    m_MenuItemCount( 0 ),
    m_ItemIndex( 0 ),
    m_FirstIndexInList( 0 ),
    m_LastIndexInList( 0 ),
    m_NextIndex( 0 ),
    m_FillingDown( true ),
    m_WidgetItemList(),
    m_pListWidget( 0 ),
    m_pPathLabel( 0 ),
    m_pStatus( 0 ),
    m_pRootAct( 0 ),
    m_pBackAct( 0 ),
    m_pCloseAct( 0 ),
    m_CheckHeight( true ),
    m_NumItemsNew( 20 ),
    m_NewItemsNext( 5 )
{
    // if we have a SKB keys don't have focus, else hide keys 
    // show the softkey bar if there is a touch screen so you don't have to use the menu
    if ( HasSoftKeyBar() || tUiConfig::Instance()->CanSupportTouch() )
    {
        SoftKeyBar()->SetSoftKeyFocusPolicy( Qt::NoFocus );
    }
    else
    {
        SoftKeyBar()->ExplicitHide();
    }
    m_pListWidget = new tListWidget( this );
    m_pListWidget->setWordWrap( true );
    m_pListWidget->SetSoleFocus( true );
    m_pListWidget->SetWrapping( false );
    m_pListWidget->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
    m_pListWidget->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    m_pListWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    Connect( m_pListWidget, SIGNAL( itemClicked( QListWidgetItem* ) ), 
            this, SLOT( HandleItemActivated( QListWidgetItem* ) ) );
    Connect( m_pListWidget, SIGNAL( currentRowChanged( int ) ),
            this, SLOT( OnCurrentRowChanged( int ) ) );

    QFont f = m_pListWidget->font();
    int fontSize = style()->pixelMetric( NPM( tNOSStyle::NPM_FontSizeNormal ), 0, m_pListWidget );
    f.setPixelSize( fontSize );
    m_pListWidget->setFont( f );

    QGridLayout* pMainLayout = new QGridLayout;

    m_pPathLabel = new QLabel;
    m_pPathLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    m_pPathLabel->setText( rootName );

    m_pStatus = new QLabel;

    pMainLayout->addWidget( m_pPathLabel, 0, 0 );
    pMainLayout->addWidget( m_pStatus, 0, 1 );
    pMainLayout->addWidget( m_pListWidget, 1, 0, 1, 3 );

    setLayout( pMainLayout );

    // Connections to the NAS
    Connect( &m_pFusionClientAgent, SIGNAL(MenuAction(quint8, quint32, tFusionClient::eMenuStatus)),
        this, SLOT(OnMenuAction(quint8,quint32,tFusionClient::eMenuStatus)), Qt::QueuedConnection );

    Connect( &m_pFusionClientAgent, SIGNAL(MenuItemCount(quint8,quint32)),
            this, SLOT(OnMenuItemCount(quint8,quint32)), Qt::QueuedConnection );

    Connect( &m_pFusionClientAgent, SIGNAL(MenuItem(quint8,quint32,quint8,QString)),
            this, SLOT(OnMenuItem(quint8,quint32,quint8,QString)), Qt::QueuedConnection );

    Connect( &m_pFusionClientAgent, SIGNAL( LibraryResetReceived() ),
            this, SLOT( GoBackToRoot() ), Qt::QueuedConnection );

    CreateActions();

    m_StateTimer = new QTimer(this);
    Connect( m_StateTimer, SIGNAL(timeout()), this, SLOT(OnStateTimeout()) );

    m_CloseOnUserInactivityTimer = new QTimer(this);
    m_CloseOnUserInactivityTimer->setInterval( cUserInactivityInterval );
    Connect( m_CloseOnUserInactivityTimer, SIGNAL(timeout()), this, SLOT(reject()) );

    // open previous menu that was up
    SendSetMenuAction( tFusionClient::eMA_Open, 0 );
}