FlightController::FlightController(QWidget *parent) : QMainWindow(parent), ui(new Ui::FlightController), mm(NULL) { ui->setupUi(this); ui->mainPanel->setCurrentIndex(0); connect(ui->ClearButton, SIGNAL(clicked()), ui->LogViewport, SLOT(clearButtonClick())); connect(ui->CopyAllButton, SIGNAL(clicked()), ui->LogViewport, SLOT(copyAllButtonClick())); connect(ui->RedButton, SIGNAL(toggled(bool)), this, SLOT(redButtonToggle(bool))); connect(ui->BootloaderButton, SIGNAL(clicked()), this, SLOT(bootloaderButtonClick())); connect(ui->MatrixMonitorButton, SIGNAL(clicked()), this, SLOT(matrixMonitorButtonClick())); connect(ui->statusRequestButton, SIGNAL(clicked()), this, SLOT(statusRequestButtonClick())); DeviceInterface &di = Singleton<DeviceInterface>::instance(); di.setLogger(ui->LogViewport); di.start(); connect(this, SIGNAL(sendCommand(uint8_t,uint8_t)), &di, SLOT(sendCommand(uint8_t, uint8_t))); ui->ColumnMapping->setLayout(new QHBoxLayout()); for (uint8_t i = 0; i<16; i++) { QComboBox *b = new QComboBox(); b->addItem(0, "Skip"); b->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); b->sizeHint().setWidth(0); ui->ColumnMapping->layout()->addWidget(b); columns[i] = b; } ui->RowMapping->setLayout(new QGridLayout()); }
CProperties::CProperties( QWidget* parent, const char* name, HODBCINSTPROPERTY hTheFirstProperty ) : QMainWindow( parent, name, 0 ) { HODBCINSTPROPERTY hProperty; int nProperty; pMainWidget = new QWidget( this ); setCentralWidget( pMainWidget ); pTopLayout = new QVBoxLayout( pMainWidget ); // SETUP TOOLBAR toolbarMain = new QToolBar( this ); addToolBar( toolbarMain, tr( "ToolBar" ), Top, FALSE ); new QToolButton( QPixmap( checkOk_xpm ), QString(tr("Save and Exit")), QString(""), this, SLOT(pbOk_Clicked()), toolbarMain ); new QToolButton( QPixmap( checkCancel_xpm ), QString(tr("Cancel any changes and Exit")), QString(""), this, SLOT(pbCancel_Clicked()), toolbarMain ); QWhatsThis::whatsThisButton ( toolbarMain ); /* PROPERTIES */ hFirstProperty = hTheFirstProperty; for ( nProperties = 0, hProperty = hFirstProperty; hProperty != NULL; hProperty = hProperty->pNext ) { nProperties++; } pGridLayout = new QGridLayout( nProperties, 2, 2 ); pTopLayout->addLayout( pGridLayout ); pGridLayout->setColStretch ( 0, 0 ); pGridLayout->setColStretch ( 1, 1 ); for ( nProperty = 0, hProperty = hFirstProperty; hProperty != NULL; nProperty++, hProperty = hProperty->pNext ) { QLabel *pLabel = new QLabel( pMainWidget ); // 1ST COLUMN IS ALWAYS A LABEL CONTAINING THE PROPERTY NAME if ( hProperty->nPromptType != ODBCINST_PROMPTTYPE_HIDDEN ) { if ( hProperty->pszHelp ) QWhatsThis::add( pLabel, hProperty->pszHelp ); pLabel->setLineWidth( 1 ); pLabel->setText( hProperty->szName ); pLabel->setMinimumSize( pLabel->sizeHint() ); pLabel->setFixedHeight( pLabel->sizeHint().height() ); pGridLayout->addWidget( pLabel, nProperty, 0 ); } // 2ND COLUMN IS WHERE THE USER ENTERS DATA SO CREATE A WIDGET THAT IS MEANINGFULL switch ( hProperty->nPromptType ) { case ODBCINST_PROMPTTYPE_LABEL: { QLabel *pLabel2 = new QLabel( pMainWidget ); if ( hProperty->pszHelp ) QWhatsThis::add( pLabel2, hProperty->pszHelp ); pLabel2->setFrameStyle( QFrame::Box | QFrame::Sunken ); pLabel2->setLineWidth( 1 ); pLabel2->setText( hProperty->szValue ); pLabel2->setMinimumSize( pLabel2->sizeHint() ); pLabel2->setFixedHeight( pLabel2->sizeHint().height() ); pGridLayout->addWidget( pLabel2, nProperty, 1 ); hProperty->pWidget = pLabel2; if ( hProperty->pszHelp ) QToolTip::add( pLabel2, hProperty->pszHelp ); } break; case ODBCINST_PROMPTTYPE_LISTBOX: { QComboBox *pComboBox = new QComboBox( pMainWidget ); if ( hProperty->pszHelp ) QWhatsThis::add( pComboBox, hProperty->pszHelp ); pComboBox->insertStrList( (const char **)hProperty->aPromptData ); pComboBox->setMinimumSize( pComboBox->sizeHint() ); pComboBox->setFixedHeight( pComboBox->sizeHint().height() ); pGridLayout->addWidget( pComboBox, nProperty, 1 ); hProperty->pWidget = pComboBox; if ( hProperty->pszHelp ) QToolTip::add( pComboBox, hProperty->pszHelp ); setCurrentItem( pComboBox, hProperty->szValue ); } break; case ODBCINST_PROMPTTYPE_COMBOBOX: { QComboBox *pComboBox = new QComboBox( true, pMainWidget ); if ( hProperty->pszHelp ) QWhatsThis::add( pComboBox, hProperty->pszHelp ); pComboBox->insertStrList( (const char **)hProperty->aPromptData ); pComboBox->setEditText( hProperty->szValue ); pComboBox->setMinimumSize( pComboBox->sizeHint() ); pComboBox->setFixedHeight( pComboBox->sizeHint().height() ); pGridLayout->addWidget( pComboBox, nProperty, 1 ); hProperty->pWidget = pComboBox; if ( hProperty->pszHelp ) QToolTip::add( pComboBox, hProperty->pszHelp ); } break; case ODBCINST_PROMPTTYPE_FILENAME: { CFileSelector *pFileSelector = new CFileSelector( pMainWidget ); if ( hProperty->pszHelp ) QWhatsThis::add( pFileSelector, hProperty->pszHelp ); pFileSelector->pLineEdit->setText( hProperty->szValue ); pGridLayout->addWidget( pFileSelector, nProperty, 1 ); hProperty->pWidget = pFileSelector; if ( hProperty->pszHelp ) QToolTip::add( pFileSelector, hProperty->pszHelp ); } break; case ODBCINST_PROMPTTYPE_HIDDEN: delete pLabel; break; default: // PROMPTTYPE_TEXTEDIT and PROMPTTYPE_TEXTEDIT_PASSWORD { QLineEdit *pLineEdit = new QLineEdit( pMainWidget ); if ( hProperty->pszHelp ) QWhatsThis::add( pLineEdit, hProperty->pszHelp ); pLineEdit->setText( hProperty->szValue ); pLineEdit->setMinimumHeight( pLineEdit->sizeHint().height() ); pLineEdit->setFixedHeight( pLineEdit->sizeHint().height() ); if (hProperty->nPromptType == ODBCINST_PROMPTTYPE_TEXTEDIT_PASSWORD) pLineEdit->setEchoMode( QLineEdit::Password ) ; pGridLayout->addWidget( pLineEdit, nProperty, 1 ); pLabel->setBuddy( pLineEdit ); hProperty->pWidget = pLineEdit; if ( hProperty->pszHelp ) QToolTip::add( pLineEdit, hProperty->pszHelp ); } } } /* SPACER */ QLabel *pSpacer = new QLabel( pMainWidget ); pTopLayout->addWidget( pSpacer, 11 ); pTopLayout->activate(); pMainWidget->show(); }
void fixComboBoxViewWidth(QComboBox &comboBox) { comboBox.setSizeAdjustPolicy(QComboBox::AdjustToContents); comboBox.view()->setMinimumWidth(comboBox.sizeHint().width()); }
VW::VW( QWidget * parent, const char * name ) : QWidget( parent, name ) { QHBoxLayout * hb; hb = new QHBoxLayout( this, 10 ); QGroupBox * box; box = new QGroupBox( this, "input box" ); hb->addWidget( box, 0, AlignTop ); QVBoxLayout * b; // set up the input box b = new QVBoxLayout( box, 12 ); QLabel * l = new QLabel( "Enter Vehicle Details", box, "header" ); l->setMinimumSize( l->sizeHint() ); b->addWidget( l ); QFrame * f = new QFrame( box, "horizontal divider" ); f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); f->setMinimumHeight( 12 ); b->addWidget( f ); QGridLayout *grid = new QGridLayout( 3, 2 ); b->addLayout( grid ); // here we start on the input grid, with labels and other widget // neatly arranged. the variable names are reused all over the // place. QComboBox * model = new QComboBox( FALSE, box, "model selection" ); model->insertItem( "Type 1 Beetle" ); model->insertItem( "Camper" ); model->insertItem( "Van" ); model->insertItem( "Fastback" ); model->insertItem( "Squareback" ); model->insertItem( "Notchback" ); model->insertItem( "411" ); model->setCurrentItem( model->count() - 1 ); // I like the 411 currentModel = "411"; model->insertItem( "412" ); model->insertItem( "Karmann Ghia" ); model->insertItem( "Thing" ); model->insertItem( "Safari" ); model->insertItem( "Kubelwagen" ); model->insertItem( "Trekker" ); model->insertItem( "Baja" ); model->setMinimumSize( model->sizeHint() ); model->setMaximumHeight( model->minimumSize().height() ); grid->addWidget( model, 0, 1 ); l = new QLabel( model, "Model:", box, "model label" ); l->setMinimumSize( l->sizeHint() ); grid->addWidget( l, 0, 0 ); QSpinBox * motor = new QSpinBox( 1000, 1600, 100, box, "motor size selection" ); motor->setValue( 1000 ); currentMotorSize = 1000; motor->setMinimumSize( motor->sizeHint() ); motor->setMaximumHeight( motor->minimumSize().height() ); grid->addWidget( motor, 1, 1 ); l = new QLabel( motor, "Motor size (cc):", box, "motor size label" ); l->setMinimumSize( l->sizeHint() ); grid->addWidget( l, 1, 0 ); QSpinBox * year = new QSpinBox( box, "model year" ); year->setRange( 1949, 1981 ); year->setValue( 1949 ); currentYear = 1949; year->setMinimumSize( year->sizeHint() ); year->setMaximumHeight( year->minimumSize().height() ); grid->addWidget( year, 2, 1 ); l = new QLabel( year, "Model:", box, "model year label" ); l->setMinimumSize( l->sizeHint() ); grid->addWidget( l, 2, 0 ); b->addStretch( 1 ); b->activate(); // output box box = new QGroupBox( this, "output box" ); hb->addWidget( box, 0, AlignTop ); b = new QVBoxLayout( box, 12 ); l = new QLabel( "Resulting Limousine:", box, "header" ); l->setMinimumSize( l->sizeHint() ); b->addWidget( l ); f = new QFrame( box, "horizontal divider" ); f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); f->setMinimumHeight( 12 ); b->addWidget( f ); l = new QLabel( box, "output label" ); l->setAlignment( AlignTop | AlignLeft | WordBreak ); l->setText( "No VW selected yet." ); b->addWidget( l, 1 ); b->addStretch( 1 ); b->activate(); hb->activate(); // set up connections connect( model, SIGNAL(activated(const char *)), this, SLOT(modelSelected(const char *)) ); connect( motor, SIGNAL(valueChanged(int)), this, SLOT(motorSelected(int)) ); connect( year, SIGNAL(valueChanged(int)), this, SLOT(yearSelected(int)) ); connect( this, SIGNAL(validSelectionMade(const char *)), l, SLOT(setText(const char *)) ); }