LineEditWithButtons::LineEditWithButtons(const QString &text, QWidget *parent): QWidget(parent) { layout_ = new QHBoxLayout(this); layout_->setContentsMargins(0,0,0,0); layout_->setSpacing(0); lineEditor_ = new QLineEdit(this); lineEditor_->setText(text); layout_->addWidget(lineEditor_); setFocusProxy(lineEditor_); connect(lineEditor_, SIGNAL(editingFinished()), this, SIGNAL(EditingFinished())); }
QWidget *LineEditPropertyFactory::createEditor(QtStringPropertyManager *manager, QtProperty *property, QWidget *parent) { LineEditWithButtons *editor = new LineEditWithButtons(manager->value(property), parent); buttonFactory = new EditorButtonFactory(parent); editor->layout()->addWidget(buttonFactory); for(uint i = 0; i < (uint)buttons_.size(); ++i) { QPushButton *button = buttonFactory->AddButton(buttons_[i].objectName, buttons_[i].text); connect(button, SIGNAL(clicked(bool)), SLOT(OnButtonClicked())); } propertyToWidget_[property] = editor; widgetToProperty_[editor] = property; connect(editor, SIGNAL(EditingFinished()), SLOT(OnEditingFinished())); connect(editor, SIGNAL(destroyed(QObject*)), SLOT(OnEditorDestroyed(QObject*))); emit EditorCreated(property, this); return editor; }
//------------------------------------------------------------------------------------------------- void tInstrumentDeviceConfigurePage::Init( tNDP2kDevice* pDevice ) { // Title text m_DeviceName = pDevice->ModelId(); QString title = m_DeviceName + " - " + tr("Device configuration"); setWindowTitle(title); QFont f = font(); f.setPixelSize( style()->pixelMetric( NPM( tNOSStyle::NPM_FontSizeSmall ) ) ); setFont( f ); // Widgets m_pConfigMainGroupBox = new QGroupBox(tr("Configuration"), this); m_pAdvancedMainGroupBox = new QGroupBox(tr("Advanced Options"), this); m_pDeviceName = new QLabel( m_DeviceName + " " + pDevice->Nickname(), this ); m_pDeviceLabel = new QLabel( tr( "Device " ), this ); m_pUpdateTimer = new QTimer(this); m_pUpdateTimer->setSingleShot( true ); m_LastInstanceValue = pDevice->Instance(); m_pInstanceEdit = new tInstrumentIntEdit(m_LastInstanceValue, 0, 255, this); m_pInstanceLabel = new QLabel(tr("Instance"), this); // Use queued connection to make the textEdit popup edit smoother. Confirmation dialog seems to stop the new value showing. Connect( m_pInstanceEdit, SIGNAL( EditingFinished() ), this, SLOT( OnInstanceChange() ), Qt::QueuedConnection ); bool serNoOk; QString serNoStr = pDevice->SerialNo(); if( pDevice->N2kName().ManCode() == SIMRAD_ID ) { // device->SerialNo ends in # serNoStr.remove( '#' ); } long long serNo = serNoStr.toLongLong(&serNoOk); m_pSerialNumberEdit = new tInstrumentDoubleEdit((double)serNo, 0, 9999999999LL, 0, this); m_pSerialNumberEdit->SetTitle( tr( "Serial Number" ) ); m_pSerialNumberLabel = new QLabel(tr("Serial #"), this); m_pSendSerialPushButton = new tPushButton( tr("Send Serial"), this); m_pDefaultsPushButton = new tPushButton( tr("Unconfigure"), this); Connect( m_pDefaultsPushButton, SIGNAL( clicked() ), this, SLOT( ResetDefaults() ) ); m_pUpdatingLabel = new QLabel(tr("Configuring..."), this); m_pUpdatingLabel->hide(); m_pSerialNumberLabel->hide(); m_pSerialNumberEdit->hide(); m_pSendSerialPushButton->hide(); m_SequenceActive = false; unsigned short manCode = m_pDevice->N2kName().ManCode(); m_SerialEditable = serNoOk && ( (manCode == LOWRANCE_ID && !m_pDevice->IsInternalDevice() && !m_pDevice->HasNosProductCode() ) || (manCode == SIMRAD_ID && m_pDevice->IsInternalDevice() ) ); m_pNDP2k = tGlobal<tNDP2k>::Instance(); Connect(&m_pNDP2k->DeviceManager(), SIGNAL(DeviceListChanged(const tN2kName&)), this, SLOT(UpdateDeviceInstance(const tN2kName&))); Connect(m_pSendSerialPushButton, SIGNAL(clicked()), this, SLOT(ChangeSerialNumber())); ///////// m_pConfigLayout = new QGridLayout(); m_pConfigLayout->setMargin( 2 ); m_pConfigLayout->addWidget( m_pDeviceLabel, 0, 0, 1, 2 ); m_pConfigLayout->addWidget( m_pDeviceName, 0, 1, 2, 2 ); m_pConfigMainGroupBox->setLayout( m_pConfigLayout ); ///////// ///////// m_pAdvancedLayout = new QGridLayout(); m_pAdvancedLayout->setMargin( 2 ); int row = 0; m_pAdvancedLayout->addWidget(m_pInstanceLabel, row, 0); m_pAdvancedLayout->addWidget(m_pInstanceEdit, row, 1, Qt::AlignLeft); m_pAdvancedLayout->addWidget(m_pDefaultsPushButton, row, 2); ++row; if (m_pDigitalDataSettings->IsPossibleGenerator( pDevice->N2kName() )) { QStringList genOptions; genOptions << tr("Auto") << tr("Yes") << tr("No"); tDigitalDataSettings::eGeneratorStatus genStatus = m_pDigitalDataSettings->GeneratorStatus( pDevice->N2kName() ); int index; switch (genStatus) { case tDigitalDataSettings::eGenStatus_AutoNot: case tDigitalDataSettings::eGenStatus_ManualNot: index = 2; break; case tDigitalDataSettings::eGenStatus_ManualIs: case tDigitalDataSettings::eGenStatus_AutoIs: index = 1; break; default: index = 0; break; } m_pGeneratorLabel = new QLabel( tr("Is Generator"), this ); m_pGeneratorList = new tComboBox( genOptions, index, this ); Connect( m_pGeneratorList, SIGNAL(currentIndexChanged(int)), this, SLOT(OnIsGeneratorChanged(int)) ); m_pAdvancedLayout->addWidget(m_pGeneratorLabel, row, 0); m_pAdvancedLayout->addWidget(m_pGeneratorList, row, 1, Qt::AlignLeft); //m_pAdvancedLayout->addWidget(m_pDefaultsPushButton, row, 2); ++row; }
tLaylinesDialogTarget::tLaylinesDialogTarget( tSailingSettings& sailingSettings, QWidget* pParent ) : tSaveCancelDialog( tDialog::Partial, pParent ) , m_pTrueWindAngleCombo( 0 ) , m_pUpwindAngleLabel( 0 ) , m_pUpwindAngleEdit( 0 ) , m_pDownwindAngleLabel( 0 ) , m_pDownwindAngleEdit( 0 ) , m_pUpwindSpeedLabel( 0 ) , m_pUpwindSpeedEdit( 0 ) , m_pDownwindSpeedLabel( 0 ) , m_pDownwindSpeedEdit( 0 ) , m_SailingSettings( sailingSettings ) { setWindowTitle( tr("Targets") ); // True Wind Angle QLabel* pTwaLabel = new QLabel( tr("True wind angle"), this ); int initialIndex = static_cast<int>( m_SailingSettings.LaylineTargetAngleOption() ); m_pTrueWindAngleCombo = new tComboBox( m_SailingSettings.LaylineTargetAngleOptionList(), initialIndex, this ); Connect( m_pTrueWindAngleCombo, SIGNAL( currentIndexChanged(int) ), this, SLOT( OnEdit() ) ); m_pUpwindAngleLabel = new QLabel( tr( "Upwind true wind angle (°)" ), this ); m_pUpwindAngleEdit = new tIntEdit( m_SailingSettings.LaylineUpwindAngle(), 5, 85, this ); Connect( m_pUpwindAngleEdit, SIGNAL( EditingFinished(int) ), this, SLOT( OnEdit() ) ); m_pDownwindAngleLabel = new QLabel( tr( "Downwind true wind angle (°)" ), this ); m_pDownwindAngleEdit = new tIntEdit( m_SailingSettings.LaylineDownwindAngle(), 95, 175, this ); Connect( m_pDownwindAngleEdit, SIGNAL( EditingFinished(int) ), this, SLOT( OnEdit() ) ); tConvert* pConvert = tConvert::Instance(); const float cMaxTargetSpeedUserUnits = pConvert->BaseToUser( UNITS_BOAT_SPEED, cMaxTargetSpeed ); const QString speedUnitsString = pConvert->GetUnitsString( UNITS_BOAT_SPEED ); float currentValueInBaseUnits = m_SailingSettings.TargetUpwindSpeed(); float currentValueInUserUnits = pConvert->BaseToUser( UNITS_BOAT_SPEED, currentValueInBaseUnits ); m_pUpwindSpeedLabel = new QLabel( QString( tr( "Upwind speed (%1)" ) ).arg( speedUnitsString ), this ); m_pUpwindSpeedEdit = new tDoubleEdit( currentValueInUserUnits, 0.0, cMaxTargetSpeedUserUnits, 1, this ); Connect( m_pUpwindSpeedEdit, SIGNAL( EditingFinished() ), this, SLOT( OnEdit() ) ); currentValueInBaseUnits = m_SailingSettings.TargetDownwindSpeed(); currentValueInUserUnits = pConvert->BaseToUser( UNITS_BOAT_SPEED, currentValueInBaseUnits ); m_pDownwindSpeedLabel = new QLabel( QString( tr( "Downwind speed (%1)" ) ).arg( speedUnitsString ), this ); m_pDownwindSpeedEdit = new tDoubleEdit( currentValueInUserUnits, 0.0, cMaxTargetSpeedUserUnits, 1, this ); Connect( m_pDownwindSpeedEdit, SIGNAL( EditingFinished() ), this, SLOT( OnEdit() ) ); // Main layout QGridLayout* pMainLayout = new QGridLayout( this ); int row = 0; pMainLayout->addWidget( pTwaLabel, row, 0 ); pMainLayout->addWidget( m_pTrueWindAngleCombo, row++, 1 ); pMainLayout->addWidget( m_pUpwindAngleLabel, row, 0 ); pMainLayout->addWidget( m_pUpwindAngleEdit, row++, 1 ); pMainLayout->addWidget( m_pDownwindAngleLabel, row, 0 ); pMainLayout->addWidget( m_pDownwindAngleEdit, row++, 1 ); pMainLayout->addWidget( m_pUpwindSpeedLabel, row, 0 ); pMainLayout->addWidget( m_pUpwindSpeedEdit, row++, 1 ); pMainLayout->addWidget( m_pDownwindSpeedLabel, row, 0 ); pMainLayout->addWidget( m_pDownwindSpeedEdit, row++, 1 ); setLayout( pMainLayout ); Connect( m_pTrueWindAngleCombo, SIGNAL( currentIndexChanged(int) ), this, SLOT( UpdateEnabled() ) ); UpdateEnabled(); }
//----------------------------------------------------------------------------- //! Constructor for a dialog //----------------------------------------------------------------------------- tAutopilotAdvancedDialog::tAutopilotAdvancedDialog( tPilotController& pilotDevice, QWidget* pParent ) : tSaveCancelDialog( tDialog::Full, pParent ) , m_PilotDevice(pilotDevice) { setWindowTitle( tr( "Advanced" ) ); tPilotH5000AdvancedInterface::tH5000AdvancedParameters h5000AdvancedParameters; m_PilotDevice.GetH5000AdvancedInterface()->GetH5000AdvancedParameters( &h5000AdvancedParameters ); // Gust response tLabel* pGustResponseLbl = new tLabel( QString( tr( "Gust response" ) ), this ); // Gust response - enable tLabel* pGustResponseEnableLbl = new tLabel( QString( tr( "Enable" ) ), this ); m_pGustResponseCheck = new tCheckBox( false, this ); m_pGustResponseCheck->setChecked( h5000AdvancedParameters.gustResponse ); Connect( m_pGustResponseCheck, SIGNAL( toggled( bool ) ), this, SLOT( OnGustResponseEnableChanged( bool ) ) ); // Gust response - Gust MIN tLabel* pGustMinLbl = new tLabel( QString( tr( "Gust MIN" ) ), this ); m_pGustMinEdit = new tIntEdit( h5000AdvancedParameters.gustMin, 1, 10, this ); m_pGustMinEdit->setFixedWidth( 100 ); m_pGustMinEdit->setEnabled( m_pGustResponseCheck->isChecked() ); Connect( m_pGustMinEdit, SIGNAL( EditingFinished( int ) ), this, SLOT( OnEdit() ) ); // Gust response - Response rate tLabel* pGuestResponseRateLbl = new tLabel( QString( tr( "Response rate" ) ), this ); m_pGustResponseRateEdit = new tIntEdit( h5000AdvancedParameters.gustResponseRate, 1, 10, this ); m_pGustResponseRateEdit->setFixedWidth( 100 ); m_pGustResponseRateEdit->setEnabled( m_pGustResponseCheck->isChecked() ); Connect( m_pGustResponseRateEdit, SIGNAL( EditingFinished( int ) ), this, SLOT( OnEdit() ) ); // Gust response - TWA response tLabel* pTWAResponseLbl = new tLabel( QString( tr( "TWA response" ) ), this ); m_pTWAReponseEdit = new tDoubleEdit( h5000AdvancedParameters.TWAResponse, 1.0F, 5.0F, 1, this ); m_pTWAReponseEdit->setFixedWidth( 100 ); m_pTWAReponseEdit->setEnabled( m_pGustResponseCheck->isChecked() ); Connect( m_pTWAReponseEdit, SIGNAL( EditingFinished() ), this, SLOT( OnEdit() ) ); // TWS response tLabel* pTWSResponseLbl = new tLabel( QString( tr( "TWS response" ) ), this ); // TWS response - enable tLabel* pTWSResponseEnableLbl = new tLabel( QString( tr( "Enable" ) ), this ); m_pTWSCheck = new tCheckBox( false, this ); m_pTWSCheck->setChecked( h5000AdvancedParameters.TWSResponse ); Connect( m_pTWSCheck, SIGNAL( toggled( bool ) ), this, SLOT( OnTWSResponseEnableChanged( bool ) ) ); // TWS response - Response rate tLabel* pTWSResponseRateLbl = new tLabel( QString( tr( "Response rate" ) ), this ); m_pTWSResponseRateEdit = new tIntEdit( h5000AdvancedParameters.TWSResponseRate, 1, 10, this ); m_pTWSResponseRateEdit->setFixedWidth( 100 ); m_pTWSResponseRateEdit->setEnabled( m_pTWSCheck->isChecked() ); Connect( m_pTWSResponseRateEdit, SIGNAL( EditingFinished( int ) ), this, SLOT( OnEdit() ) ); // Heel compensation tLabel* pHeelCompensationLbl = new tLabel( QString( tr( "Heel compensation" ) ), this ); // Heel compensation - enable tLabel* pHeelCompensationEnableLbl = new tLabel( QString( tr( "Enable" ) ), this ); m_pHeelCompensationCheck = new tCheckBox( false, this ); m_pHeelCompensationCheck->setChecked( h5000AdvancedParameters.heelCompensation ); Connect( m_pHeelCompensationCheck, SIGNAL( toggled( bool ) ), this, SLOT( OnHeelCompensationEnableChanged( bool ) ) ); // Heel compensation - Response rate tLabel* pHeelCompensationResponseRateLbl = new tLabel( QString( tr( "Response rate" ) ), this ); m_pHeelCompensationResponseRateEdit = new tIntEdit( h5000AdvancedParameters.heelCompensationRate, 1, 10, this ); m_pHeelCompensationResponseRateEdit->setFixedWidth( 100 ); m_pHeelCompensationResponseRateEdit->setEnabled( m_pHeelCompensationCheck->isChecked() ); Connect( m_pHeelCompensationResponseRateEdit, SIGNAL( EditingFinished( int ) ), this, SLOT( OnEdit() ) ); int row( 0 ); QGridLayout* pGridLayout = new QGridLayout( this ); // Gust response pGridLayout->addWidget( pGustResponseLbl, row++, 0 ); pGridLayout->addWidget( pGustResponseEnableLbl, row, 0, Qt::AlignRight ); pGridLayout->addWidget( m_pGustResponseCheck, row++, 1 ); pGridLayout->addWidget( pGustMinLbl, row, 0, Qt::AlignRight ); pGridLayout->addWidget( m_pGustMinEdit, row++, 1 ); pGridLayout->addWidget( pGuestResponseRateLbl, row, 0, Qt::AlignRight ); pGridLayout->addWidget( m_pGustResponseRateEdit, row++, 1 ); pGridLayout->addWidget( pTWAResponseLbl, row, 0, Qt::AlignRight ); pGridLayout->addWidget( m_pTWAReponseEdit, row++, 1 ); // TWS response pGridLayout->addWidget( pTWSResponseLbl, row++, 0 ); pGridLayout->addWidget( pTWSResponseEnableLbl, row, 0, Qt::AlignRight ); pGridLayout->addWidget( m_pTWSCheck, row++, 1 ); pGridLayout->addWidget( pTWSResponseRateLbl, row, 0, Qt::AlignRight ); pGridLayout->addWidget( m_pTWSResponseRateEdit, row++, 1 ); // Heel compensation pGridLayout->addWidget( pHeelCompensationLbl, row++, 0 ); pGridLayout->addWidget( pHeelCompensationEnableLbl, row, 0, Qt::AlignRight ); pGridLayout->addWidget( m_pHeelCompensationCheck, row++, 1 ); pGridLayout->addWidget( pHeelCompensationResponseRateLbl, row, 0, Qt::AlignRight ); pGridLayout->addWidget( m_pHeelCompensationResponseRateEdit, row++, 1 ); setLayout( pGridLayout ); m_pGustResponseCheck->setFocus(); Connect ( m_PilotDevice.GetH5000AdvancedInterface(), SIGNAL( H5000AdvancedParametersChanged( tPilotH5000AdvancedInterface::tH5000AdvancedParameters ) ), this, SLOT( OnH5000AdvancedParametersChanged( tPilotH5000AdvancedInterface::tH5000AdvancedParameters ) ) ); }