/*! \brief Internal helper method to start the state timeout timer * * Internal helper method to start the state timeout timer */ void AliveState::StartStateTimer() { auto self(shared_from_this()); m_StateTimer.expires_from_now(boost::posix_time::seconds(15)); m_StateTimer.async_wait([this, self](const boost::system::error_code& ec) { if (!ec) { // A state timeout occured OnStateTimeout(); StartStateTimer(); // start again } // if }); }
//----------------------------------------------------------------------------- //! 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 ); }