inline bool HandleStreamEvent(ChannelHandlerContext& ctx, ChannelStateEvent& e) { //ChannelStateEvent& stateEvent = (ChannelStateEvent&) e; switch (e.GetState()) { case CLOSED: { CloseRequested(ctx, e); break; } case BOUND: { BindRequested(ctx, e); break; } case CONNECTED: { ConnectRequested(ctx, e); break; } default: { ctx.SendDownstream(e); break; } } return true; }
void tcGameOutcomePopup::Draw() { //unsigned currentCount = tcTime::Get()->Get30HzCount(); //unsigned age = currentCount - birthCount; if (CloseRequested()) { DestroyWindow(); return; } Update(); StartDraw(); Vec4 color(1, 1, 1, 1); Vec4 titleColor(1, 1, 0.4f, 1); float x = 0.5f * float(mnWidth); float y = 0.5f * float(mnHeight); DrawRectangleR(0, 0, float(mnWidth), float(mnHeight), Vec4(0, 0, 0, 0.5f), FILL_ON); DrawTextR("GAME OVER", x, 15.0, defaultFont.get(), titleColor, fontSize + 6.0f, CENTER_CENTER, float(mnWidth)-10.0f); DrawTextR(messageText.c_str(), 5.0f, y, defaultFont.get(), color, fontSize + 2.0f, LEFT_CENTER, float(mnWidth)-10.0f); FinishDraw(); }
//------------------------------------------------------------------------------- // //------------------------------------------------------------------------------- void tDataSourcesDialog::CreateActions() { /* Create these in order of importance. As many as possible will be added to the softkey bar in this order */ m_pSelectAct = new tAction( tr( "Select" ), this ); Connect( m_pSelectAct, SIGNAL( triggered() ), this, SLOT( Select() ) ); m_ActionList << m_pSelectAct; m_pConfigureAct = new tAction( tr( "Configure device" ), this ); Connect( m_pConfigureAct, SIGNAL( triggered() ), this, SLOT( ConfigureDevice() ) ); m_ActionList << m_pConfigureAct; QString scopeName = tProductSettings::Instance().FullSimnetAllowed() ? tr( "Group", "The extent or effective range of a selection or setting" ) : tr( "Scope", "The extent or effective range of a selection or setting" ); m_pScopeAct = new tListAction( scopeName, QStringList(), 0, Action::AutoShowPopup, this ); SetScopeList( m_pScopeAct, true, true, true ); Connect( m_pScopeAct, SIGNAL( ValueFinalised( int ) ), this, SLOT( OnScopeChanged( int ) ) ); if (tHAL::Instance()->FeaturePresent(tHAL::ePF_NMEA2000) == true) { m_ActionList << m_pScopeAct; } m_pRenameAct = new tAction( tr( "Rename" ), this ); Connect( m_pRenameAct, SIGNAL( triggered() ), this, SLOT( RenameInst() ) ); m_ActionList << m_pRenameAct; m_pNewInstanceAct = new tAction( tr( "New" ), this ); Connect( m_pNewInstanceAct, SIGNAL( triggered() ), this, SLOT( NewInstance() ) ); m_ActionList << m_pNewInstanceAct; m_pRemoveAct = new tAction( tr( "Remove" ), this ); Connect( m_pRemoveAct, SIGNAL( triggered() ), this, SLOT( RemoveInst() ) ); m_ActionList << m_pRemoveAct; QStringList numEnginesList = NumericStringList( 8 ); m_pEngineNumSetAct = new tListAction( tr("Number of Engines"), numEnginesList, 0, Action::AutoShowPopup, this); Connect( m_pEngineNumSetAct, SIGNAL( ValueFinalised( int ) ), this, SLOT( OnUINumEnginesChanged( int ) ) ); m_ActionList << m_pEngineNumSetAct; m_pTransNumSetAct = new tListAction( tr("Number of Transmissions"), numEnginesList, 0, Action::AutoShowPopup, this); Connect( m_pTransNumSetAct, SIGNAL( ValueFinalised( int ) ), this, SLOT( OnUINumTransChanged( int ) ) ); m_ActionList << m_pTransNumSetAct; QStringList numTanksList = NumericStringList( 5 ); m_pTankNumSetAct = new tListAction( tr("Number of Tanks"), numTanksList, 0, Action::AutoShowPopup, this); Connect( m_pTankNumSetAct, SIGNAL( ValueFinalised( int ) ), this, SLOT( OnUINumTanksChanged( int ) ) ); m_ActionList << m_pTankNumSetAct; QStringList numTrimTabsList = NumericStringList( 3 ); m_pTrimTabsNumSetAct = new tListAction( tr("Number of Trim Tabs"), numTrimTabsList, 0, Action::AutoShowPopup, this); Connect( m_pTrimTabsNumSetAct, SIGNAL( ValueFinalised( int ) ), this, SLOT( OnNumTrimTabsChanged( int ) ) ); m_ActionList << m_pTrimTabsNumSetAct; if( tProductSettings::Instance().FullSimnetAllowed() ) { m_pAutoSelectAct = new tAction( tr( "Auto Select" ), this ); Connect( m_pAutoSelectAct, SIGNAL( triggered() ), this, SLOT( OnAutoSelect() ) ); if (tHAL::Instance()->FeaturePresent(tHAL::ePF_NMEA2000) == true) { m_ActionList << m_pAutoSelectAct; } } else { m_pAutoConfigureAct = new tAction( tr( "Auto Configure" ), this ); Connect( m_pAutoConfigureAct, SIGNAL( triggered() ), this, SLOT( AutoConfigure() ) ); if (tHAL::Instance()->FeaturePresent(tHAL::ePF_NMEA2000) == true) { m_ActionList << m_pAutoConfigureAct; } } m_pGlobalResetAct = new tAction( tr( "Reset Global" ), this ); Connect( m_pGlobalResetAct, SIGNAL( triggered() ), this, SLOT( ResetGlobal() ) ); if (tHAL::Instance()->FeaturePresent(tHAL::ePF_NMEA2000) == true) { m_ActionList << m_pGlobalResetAct; } m_pLocalResetAct = new tAction( tr( "Reset Local" ), this ); Connect( m_pLocalResetAct, SIGNAL( triggered() ), this, SLOT( ResetLocal() ) ); if (tHAL::Instance()->FeaturePresent(tHAL::ePF_NMEA2000) == true) { m_ActionList << m_pLocalResetAct; } // Add as many actions as possible to the softkey bar m_KeyList.clear(); for( int i = 0; (i < m_NumKeys - 1) && (i < m_ActionList.size()); i++ ) { m_KeyList << m_ActionList[i]; } if ( HasTitleCloseButton() == false ) { m_pCloseAct = new tAction( tr( "Close", "Text of the exit dialog button." ), this ); Connect( m_pCloseAct, SIGNAL( triggered() ), this, SIGNAL( CloseRequested() ) ); m_KeyList << m_pCloseAct; } // NSW-10765 // Change what actions are displayed for Cougar // This should be done a better way - this will do for now. // // Configure Device // Scope // Rename // New // Remove // Auto Configure // Reset -> Sub menu // Global // Local if( tProductSettings::Instance().GetProductFamily() == tProductSettings::HDSGen2TouchFamily || tProductSettings::Instance().GetProductFamily() == tProductSettings::HDSGen3TouchFamily ) { m_KeyList.clear(); m_KeyList << m_pConfigureAct; m_KeyList << m_pScopeAct; m_KeyList << m_pRenameAct; m_KeyList << m_pNewInstanceAct; m_KeyList << m_pRemoveAct; m_KeyList << m_pAutoConfigureAct; QList<tAction*> resetSubActions; resetSubActions << m_pGlobalResetAct; resetSubActions << m_pLocalResetAct; m_pResetAct = new tAction( tr("Reset") ); m_pResetAct->SetSubActions(resetSubActions); m_ActionList << m_pSelectAct; m_KeyList << m_pResetAct; } }
//-------------------------------------------------------------------------------------- //! Defines the work for constructor //-------------------------------------------------------------------------------------- void tDataSourcesDialog::Init( const QList<tDataFilter*>& filters, tDataType selDataType /* = DATA_TYPE_INVALID*/, int selInstance /* = 0*/, tDataCategory selCategory /* = DATA_CATEGORY_INVALID*/, const QString& title /* = QString()*/ ) { setWindowTitle( title ); // grab the screen size so we can adapt to it QSize screenResolution = tProductSettings::Instance().ScreenResolution(); m_pDataModel = new tDataSourceTreeModel( *m_pSourceSelection->GetSourceSettings(), filters ); m_pTreeView = new tTreeView( this ); m_pTreeView->setModel( m_pDataModel ); m_pTreeView->setHeaderHidden( true ); m_pTreeView->setTextElideMode( Qt::ElideMiddle ); if ( tProductSettings::Instance().ProductSupportsTouch() ) { int largeIconSize = style()->pixelMetric( QStyle::PM_LargeIconSize ); m_pTreeView->setIconSize( QSize(largeIconSize, largeIconSize) ); QHeaderView* pHeaderView = m_pTreeView->header(); if ( m_pDataModel->columnCount() == tDataSourceTreeItem::Columns_Count ) { pHeaderView->setResizeMode( tDataSourceTreeItem::Columns_Icon, QHeaderView::ResizeToContents ); } pHeaderView->setResizeMode( tDataSourceTreeItem::Columns_Name, QHeaderView::Stretch ); pHeaderView->setStretchLastSection( false ); // This is creating the padding about the menu icon. // Remove it if it's too much. pHeaderView->setMinimumSectionSize(largeIconSize); } m_pTreeView->show(); if( tUiSettings::Instance()->ShowTouchToolTips() ) { m_pTreeView->setToolTip( tr("Tap-and-hold for more options.") ); } else { if( tProductSettings::Instance().ProductSupportsMenuKey() == false ) { // Kiwi m_pTreeView->setToolTip( tr("Press and hold pages for more options.") ); } else { m_pTreeView->setToolTip( tr("Press %1 for more options.").arg(BUTTON_HTML(tNOSStyle::FP_ButtonImageMENU, "MENU")) ); } } if( tProductSettings::Instance().ProductSupportsMenuKey() == false ) { // only KIWI at the moment m_pTreeView->setProperty( "RemapLongPressPagesToMenuKey", true ); } m_SelectedSource = tDataId(); // invalid data m_SelectedData = DATA_TYPE_INVALID; m_SelectedInstance = -1; // Status bar m_pValue = new QLabel(""); m_pWidgetLayout = new QGridLayout(); m_pWidgetLayout->addWidget( m_pValue ); m_pDialogLayout = new QVBoxLayout(); m_pDialogLayout->addWidget( m_pTreeView ); if (screenResolution.height() > 240) { //Group box m_pGroupBox1 = new QGroupBox( "" ); m_pGroupBox1->setLayout( m_pWidgetLayout ); m_pDialogLayout->addWidget( m_pGroupBox1 ); } else { m_pDialogLayout->setContentsMargins( 0, 0, 0, 3 ); m_pDialogLayout->addLayout( m_pWidgetLayout ); } setLayout( m_pDialogLayout ); // if we have a SKB keys don't have focus, else hide keys m_NumKeys = 0; SoftKeyBar()->ExplicitHide(); CreateActions(); //todo - check whether we can call this directly instead of signals/slots Connect( this, SIGNAL( CloseRequested() ), this, SLOT( accept() ) ); Connect( this, SIGNAL(ShowSimnetAutoSelectionConfirmation( QWidget* )), m_pDataSourceMonitor, SLOT(ShowSimnetAutoSelectionConfirmation( QWidget* )), Qt::QueuedConnection ); Connect( m_pTreeView, SIGNAL( ItemSelectionChanged( const QModelIndex & ) ), this, SLOT( OnItemSelectionChanged( const QModelIndex & ) ) ); Connect( m_pTreeView, SIGNAL( activated( const QModelIndex& ) ), this, SLOT( OnItemClicked( const QModelIndex& ) ) ); Connect( m_pDataModel, SIGNAL( ModelAboutToBeRefreshed() ), this, SLOT( OnModelAboutToBeRefreshed() ) ); Connect( m_pDataModel, SIGNAL( ModelRefreshed() ), this, SLOT( OnModelRefreshed() ) ); QModelIndex selIndex; if( selDataType != DATA_TYPE_INVALID ) { selIndex = m_pDataModel->FindSelectedData( selDataType, selInstance ); } else if( selCategory != DATA_CATEGORY_INVALID ) { selIndex = m_pDataModel->FindCategory( selCategory ); } else { selIndex = m_pDataModel->index( 0, 0 ); } m_pTreeView->setCurrentIndex( selIndex ); //m_pTreeView->addAction( m_pEngineNumSetAct ); OnItemSelectionChanged( selIndex ); m_TimerId = startTimer( 1000 ); }
//-------------------------------------------------------------------------------------- //! Defines the NDP2k network device page (shows the devices) //-------------------------------------------------------------------------------------- tNDP2kDevicePage::tNDP2kDevicePage(tNDP2k& ndp2k, QWidget* pParent, bool showButtons, const QList<eColumns> customColumnList ) : tDialog(tDialog::Full, pParent) , m_pNDP2k( &ndp2k ) , m_FirstRefresh ( true ) , m_FirstRun( true ) , m_tableRefreshMode( false ) , m_ShowNameColumn( false ) // For debugging purposes , m_ShowButtons( showButtons ) { setWindowTitle( tr( "Device List", "NDP2k device list dialog title" ) ); m_ColumnName[addressColumn] = tr("Address"); m_ColumnName[modelIdColumn] = tr("Model ID"); m_ColumnName[manufacturerColumn] = tr("Manufacturer"); m_ColumnName[productCodeColumn] = tr("Product Code"); m_ColumnName[classFunctionColumn] = tr("Class/Function"); m_ColumnName[nameColumn] = tr("ISO Name"); m_ColumnName[busUsageColumn] = tr("Bus %"); m_ColumnName[deviceInstanceColumn] = tr("Instance"); m_ColumnName[serialNumberColumn] = tr("Serial No."); // keep name last - it is hidden & not in sort list. if( false == customColumnList.isEmpty() ) { m_DisplayColumns = customColumnList; } else { m_DisplayColumns = (QList<eColumns>() << modelIdColumn << serialNumberColumn); } if( tNdp2kSettings::Instance()->GetDebugEnabled() ) { m_DisplayColumns << addressColumn; m_ShowNameColumn = true; } m_DisplayColumns << nameColumn; assert(m_DisplayColumns.contains(nameColumn)); m_NameColumn = m_DisplayColumns.indexOf(nameColumn); m_SortOptionList = QStringList(); m_SortOption = 0; for(int i = 0; i < m_DisplayColumns.count(); i++) { if( m_DisplayColumns[i] != nameColumn || m_ShowNameColumn ) { m_SortOptionList << m_ColumnName[m_DisplayColumns[i]]; } } // if we have a SKB keys don't have focus, else hide keys m_NumKeys = 0; if ( HasSoftKeyBar() ) { m_NumKeys = SoftKeyBar()->numSoftKeys(); SoftKeyBar()->SetSoftKeyFocusPolicy(Qt::NoFocus); } else { SoftKeyBar()->ExplicitHide(); } CreateActions(); Connect( this, SIGNAL( CloseRequested() ), this, SLOT( accept() ) ); m_pTableWidget = new tTableWidget(0, m_DisplayColumns.count(), this); m_pTableWidget->setFocusPolicy(Qt::StrongFocus); m_pTableWidget->setEditTriggers( QAbstractItemView::NoEditTriggers ); m_pTableWidget->verticalHeader()->hide(); m_pTableWidget->setSelectionMode(QAbstractItemView::SingleSelection); m_pTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); m_pTableWidget->SetSoleFocus( true ); m_pTableWidget->SetWrapping( true ); if( tUiSettings::Instance()->ShowTouchToolTips() == true ) { m_pTableWidget->setToolTip( tr("Tap-and-hold for more options.") ); } else { m_pTableWidget->setToolTip( tr("Press %1 for more options.").arg(BUTTON_HTML(tNOSStyle::FP_ButtonImageMENU, "MENU")) ); } Connect( m_pTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( SelectionChanged() ) ); Connect( m_pTableWidget, SIGNAL( itemClicked( QTableWidgetItem* ) ), m_pDetailsAct, SLOT( trigger() ) ); QHeaderView* pHeaderView = m_pTableWidget->horizontalHeader(); // Prevents header bold font pHeaderView->setHighlightSections(false); pHeaderView->setDefaultAlignment(Qt::AlignLeft); Connect( pHeaderView, SIGNAL( sectionClicked( int ) ), this, SLOT( SetSortOption( int ) ) ); SetHeaderFont(); for(int i = 0; i < m_DisplayColumns.count(); i++) { switch(m_DisplayColumns[i]) { case addressColumn: case manufacturerColumn: case productCodeColumn: case busUsageColumn: case deviceInstanceColumn: case serialNumberColumn: default: { pHeaderView->setResizeMode(i, QHeaderView::ResizeToContents); } break; case modelIdColumn: case SwVersionColumn: case classFunctionColumn: { pHeaderView->setResizeMode(i, QHeaderView::Stretch); } break; case nameColumn: { if( m_ShowNameColumn ) { pHeaderView->setResizeMode(i, QHeaderView::Stretch); } else { pHeaderView->setResizeMode(i, QHeaderView::Fixed); pHeaderView->resizeSection(i, 0); // hide it this way. (actual hide breaks sorting.) } } break; } } QStringList headings; for(int i = 0; i < m_DisplayColumns.count(); i++) { headings << m_ColumnName[m_DisplayColumns[i]]; } m_pTableWidget->setHorizontalHeaderLabels(headings); QVBoxLayout* pVLayout = new QVBoxLayout; pVLayout->addWidget(m_pTableWidget); setLayout(pVLayout); tNDP2k* pNDP2k = tGlobal<tNDP2k>::Instance(); Connect(&pNDP2k->DeviceManager(), SIGNAL(DeviceListChanged(const tN2kName&)), this, SLOT(OnDeviceChanged(const tN2kName&))); /* Set the bus status on startup... */ if(pNDP2k->IsBusOff()) { m_IsBusOff = true; } else { m_IsBusOff = false; } m_SelectedName = ""; //NSW-7687 (Work around LGC-4k unreliable response to global request for address claim...) // - No longer required - since we no longer do a global request for address claim. RefreshDeviceList(); // initial row selected in UpdateDeviceList, when we have some content startTimer(1000); //TODO: tNotificationAndStatusMonitor::Instance()->SetVesselShow(false); if ( tProductSettings::Instance().GetProductFamily() == tProductSettings::MedusaFamily ) { Connect( tApOperation::Instance(), SIGNAL( ApModeChanged(tPilotCommandInterface::tPilotMode) ), this, SLOT( OnApModeChanged(tPilotCommandInterface::tPilotMode) ) ); OnApModeChanged( tApOperation::Instance()->GetApMode() ); // Init text } if( tProductSettings::Instance().ScreenPixelWidth() < 480 ) { pVLayout->setMargin(0); } }