/*! Builds a volume qm parameter area within the quality measure dialog box. This is simply building a QT combo box for the GWS selection. */ void QualVolume::buildParamArea(qmDlgDataT *qmData) { int i; QualVolume *currQM = (QualVolume *)qmData->currQM; #ifdef GRASPITDBG std::cout << "building qualvolume" << std::endl; #endif QBoxLayout *l = new QHBoxLayout(qmData->settingsArea); l->setAutoAdd(true); // create the GWS type menu new QLabel(QString("Limit unit GWS using:"),qmData->settingsArea); QComboBox *gwsComboBox = new QComboBox(qmData->settingsArea,"gwsComboBox"); // count the number of possible gws types for (i=0;GWS::TYPE_LIST[i];i++) { gwsComboBox->insertItem(QString(GWS::TYPE_LIST[i])); if (currQM && !strcmp(currQM->gws->getType(),GWS::TYPE_LIST[i])) gwsComboBox->setCurrentItem(i); } qmData->paramPtr = gwsComboBox; }
UnitsEdit *UnitsEditPage::addEdit( const QString &labelKey, const char **varList, const char **unitsList, int row, bool showDecimals ) { // Find the variable EqVar *varPtr = m_dialog->m_bp->m_eqTree->m_varDict->find( varList[0] ); if ( ! varPtr ) // This code block should never be executed! { QString text(""); translate( text, "UnitsEditDialog:UnknownVar", varList[0] ); bomb( text ); } // Create the QLabel QString text(""); translate( text, labelKey ); QLabel *label = new QLabel( text, m_frame, QString( "%1:Label" ).arg( labelKey ) ); Q_CHECK_PTR( label ); m_grid->addMultiCellWidget( label, row, row, 0, 0, AlignLeft ); // Create the combo box QComboBox *combo = new QComboBox( false, m_frame, QString( "%1:ComboBox" ).arg( labelKey ) ); Q_CHECK_PTR( combo ); // Insert items into the combo box while searching for the current item int n = 0; for ( int id = 0; unitsList[id]; id++ ) { combo->insertItem( unitsList[id] ); if ( appSiUnits()->equivalent( unitsList[id], varPtr->m_displayUnits.latin1() ) ) { n = id; } } combo->setCurrentItem( n ); m_grid->addMultiCellWidget( combo, row, row, 1, 1 ); // Create the spin box QSpinBox *spin = NULL; if ( showDecimals ) { spin = new QSpinBox( 0, 6, 1, m_frame, QString( "%1:SpinBox" ).arg( labelKey ) ); Q_CHECK_PTR( spin ); spin->setValue( varPtr->m_displayDecimals ); m_grid->addMultiCellWidget( spin, row, row, 2, 2 ); } // All rows share the available space equally m_grid->setRowStretch( row, 10 ); // Create the new UnitsEdit UnitsEdit *edit = new UnitsEdit( varList, varPtr, combo, spin ); checkmem( __FILE__, __LINE__, edit, "UnitsEdit edit", 1 ); // Add the UnitsEdit to the UnitEditPage's m_editList m_editList->append( edit ); return( edit ); }
QWidget *DayView::createConfigWidget( QWidget *owner ) { QGroupBox *GroupBox4 = new QGroupBox( owner, "GroupBox4" ); GroupBox4->setTitle( tr( "Day" ) ); GroupBox4->setColumnLayout(0, Qt::Vertical ); GroupBox4->layout()->setSpacing( 0 ); GroupBox4->layout()->setMargin( 0 ); QVBoxLayout *GroupBox4Layout = new QVBoxLayout( GroupBox4->layout() ); GroupBox4Layout->setAlignment( Qt::AlignTop ); GroupBox4Layout->setSpacing( 6 ); GroupBox4Layout->setMargin( 11 ); QCheckBox *chkJumpToCurTime = new QCheckBox( GroupBox4, "chkJumpToCurTime" ); chkJumpToCurTime->setText( tr( "Jump to current time" ) ); GroupBox4Layout->addWidget( chkJumpToCurTime ); QHBoxLayout *Layout5_2 = new QHBoxLayout; Layout5_2->setSpacing( 6 ); Layout5_2->setMargin( 0 ); QLabel *TextLabel1 = new QLabel( GroupBox4, "TextLabel1" ); TextLabel1->setText( tr( "Row style:" ) ); Layout5_2->addWidget( TextLabel1 ); QComboBox *comboRowStyle = new QComboBox( FALSE, GroupBox4, "comboRowStyle" ); comboRowStyle->insertItem( tr( "Default" ) ); comboRowStyle->insertItem( tr( "Medium" ) ); comboRowStyle->insertItem( tr( "Large" ) ); Layout5_2->addWidget( comboRowStyle ); GroupBox4Layout->addLayout( Layout5_2 ); chkJumpToCurTime->setChecked( jumpToCurTime ); comboRowStyle->setCurrentItem( rowStyle ); return GroupBox4; }
// Virtual implemetations. QWidget *qsamplerChannelRoutingComboBox::createEditor (void) const { QComboBox *pComboBox = new QComboBox(QTableItem::table()->viewport()); QObject::connect(pComboBox, SIGNAL(activated(int)), QTableItem::table(), SLOT(doValueChanged())); for (QStringList::ConstIterator iter = m_list.begin(); iter != m_list.end(); iter++) { pComboBox->insertItem(QTableItem::pixmap(), *iter); } pComboBox->setCurrentItem(m_iCurrentItem); return pComboBox; }
GameConfig::GameConfig() : QWidget(0, "game_config_widget"), _magicDialogEnabled(false) { QVBoxLayout *top = new QVBoxLayout(this, KDialog::spacingHint()); QCheckBox *cb = new QCheckBox(i18n("Enable ? mark"), this, "kcfg_UncertainMark"); top->addWidget(cb); cb = new QCheckBox(i18n("Enable keyboard"), this, "kcfg_KeyboardGame"); top->addWidget(cb); cb = new QCheckBox(i18n("Pause if window loses focus"), this, "kcfg_PauseFocus"); top->addWidget(cb); cb = new QCheckBox(i18n("\"Magic\" reveal"), this, "kcfg_MagicReveal"); QWhatsThis::add(cb, i18n("Set flags and reveal squares where they are trivial.")); connect(cb, SIGNAL(toggled(bool)), SLOT(magicModified(bool))); top->addWidget(cb); top->addSpacing(2 * KDialog::spacingHint()); QHBoxLayout *hbox = new QHBoxLayout(top); QVGroupBox *gb = new QVGroupBox(i18n("Mouse Bindings"), this); hbox->addWidget(gb); QGrid *grid = new QGrid(2, gb); grid->setSpacing(KDialog::spacingHint()); for (uint i=0; i< Settings::EnumButton::COUNT; i++) { (void)new QLabel(i18n(MOUSE_BUTTON_LABELS[i]), grid); QComboBox *cb = new QComboBox(false, grid, MOUSE_CONFIG_NAMES[i]); for (uint k=0; k< (Settings::EnumMouseAction::COUNT-1); k++) cb->insertItem(i18n(MOUSE_ACTION_LABELS[k])); cb->setCurrentItem(i); } hbox->addStretch(1); top->addStretch(1); }
Kleo::KeyApprovalDialog::KeyApprovalDialog( const std::vector<Item> & recipients, const std::vector<GpgME::Key> & sender, QWidget * parent, const char * name, bool modal ) : KDialogBase( parent, name, modal, i18n("Encryption Key Approval"), Ok|Cancel, Ok ), d( 0 ) { assert( !recipients.empty() ); d = new Private(); QFrame *page = makeMainWidget(); QVBoxLayout * vlay = new QVBoxLayout( page, 0, spacingHint() ); vlay->addWidget( new QLabel( i18n("The following keys will be used for encryption:"), page ) ); QScrollView * sv = new QScrollView( page ); sv->setResizePolicy( QScrollView::AutoOneFit ); vlay->addWidget( sv ); QWidget * view = new QWidget( sv->viewport() ); QGridLayout * glay = new QGridLayout( view, 3, 2, marginHint(), spacingHint() ); glay->setColStretch( 1, 1 ); sv->addChild( view ); int row = -1; if ( !sender.empty() ) { ++row; glay->addWidget( new QLabel( i18n("Your keys:"), view ), row, 0 ); d->selfRequester = new EncryptionKeyRequester( true, EncryptionKeyRequester::AllProtocols, view ); d->selfRequester->setKeys( sender ); glay->addWidget( d->selfRequester, row, 1 ); ++row; glay->addMultiCellWidget( new KSeparator( Horizontal, view ), row, row, 0, 1 ); } const QStringList prefs = preferencesStrings(); for ( std::vector<Item>::const_iterator it = recipients.begin() ; it != recipients.end() ; ++it ) { ++row; glay->addWidget( new QLabel( i18n("Recipient:"), view ), row, 0 ); glay->addWidget( new QLabel( it->address, view ), row, 1 ); d->addresses.push_back( it->address ); ++row; glay->addWidget( new QLabel( i18n("Encryption keys:"), view ), row, 0 ); KeyRequester * req = new EncryptionKeyRequester( true, EncryptionKeyRequester::AllProtocols, view ); req->setKeys( it->keys ); glay->addWidget( req, row, 1 ); d->requesters.push_back( req ); ++row; glay->addWidget( new QLabel( i18n("Encryption preference:"), view ), row, 0 ); QComboBox * cb = new QComboBox( false, view ); cb->insertStringList( prefs ); glay->addWidget( cb, row, 1 ); cb->setCurrentItem( pref2cb( it->pref ) ); connect( cb, SIGNAL(activated(int)), SLOT(slotPrefsChanged()) ); d->preferences.push_back( cb ); } // calculate the optimal width for the dialog const int dialogWidth = marginHint() + sv->frameWidth() + view->sizeHint().width() + sv->verticalScrollBar()->sizeHint().width() + sv->frameWidth() + marginHint() + 2; // calculate the optimal height for the dialog const int dialogHeight = marginHint() + fontMetrics().height() + spacingHint() + sv->frameWidth() + view->sizeHint().height() + sv->horizontalScrollBar()->sizeHint().height() + sv->frameWidth() + spacingHint() + actionButton( KDialogBase::Cancel )->sizeHint().height() + marginHint() + 2; // don't make the dialog too large const QRect desk = KGlobalSettings::desktopGeometry( this ); setInitialSize( QSize( kMin( dialogWidth, 3 * desk.width() / 4 ), kMin( dialogHeight, 7 * desk.height() / 8 ) ) ); }
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 *)) ); }
QWidget * KviVariantTableItem::createEditor() const { switch(m_property.type()) { case QVariant::String: { QLineEdit * e = new QLineEdit(table()->viewport()); e->setText(m_property.toString()); return e; } break; case QVariant::Int: { QLineEdit * e = new QLineEdit(table()->viewport()); QString sz; sz.setNum(m_property.toInt()); e->setText(sz); e->setValidator(new QIntValidator(e)); return e; } break; case QVariant::UInt: { QLineEdit * e = new QLineEdit(table()->viewport()); QString sz; sz.setNum(m_property.toInt()); e->setText(sz); QIntValidator * i = new QIntValidator(e); i->setBottom(0); e->setValidator(i); return e; } break; case QVariant::Bool: { QComboBox * b = new QComboBox(false,table()->viewport()); b->addAction("FALSE"); b->addAction("TRUE"); b->setCurrentItem(m_property.toBool() ? 1 : 0); return b; } break; case QVariant::Color: { QLineEdit * e = new QLineEdit(table()->viewport()); e->setText(m_property.toColor().name()); return e; } break; case QVariant::Font: { QComboBox * b = new QComboBox(true,table()->viewport()); QString tmp; QString tmpDefault; QFont f = QFont(); f.setStyleHint(QFont::SansSerif); tmpDefault = f.family(); f.setStyleHint(QFont::TypeWriter); tmp.setNum(m_property.toFont().pointSize()); tmp.prepend(", "); tmp.prepend(m_property.toFont().family()); b->addAction(tmp); b->addAction(tmpDefault + ", 8"); b->addAction(tmpDefault + ", 10"); b->addAction(tmpDefault + ", 12"); b->addAction(tmpDefault + ", 14"); b->addAction(tmpDefault + ", 16"); b->addAction(tmpDefault + ", 18"); b->addAction(tmpDefault + ", 20"); b->addAction(tmpDefault + ", 24"); b->addAction(tmpDefault + ", 28"); b->addAction(tmpDefault + ", 32"); b->addAction(tmpDefault + ", 40"); b->addAction(tmpDefault + ", 48"); b->addAction(f.family() + ", 12"); b->setCurrentItem(0); b->setCurrentItem(m_property.toBool() ? 1 : 0); return b; } break; default: break; } return 0; }
void GPConfigDlg::appendWidget(QWidget* parent, CameraWidget* widget) { QWidget* newParent = parent; CameraWidgetType widget_type; const char* widget_name; const char* widget_info; const char* widget_label; float widget_value_float; int widget_value_int; const char* widget_value_string; gp_widget_get_type(widget, &widget_type); gp_widget_get_label(widget, &widget_label); gp_widget_get_info(widget, &widget_info); gp_widget_get_name(widget, &widget_name); // gphoto2 doesn't seem to have any standard for i18n QString whats_this = QString::fromLocal8Bit(widget_info); // Add this widget to parent switch (widget_type) { case GP_WIDGET_WINDOW: { setCaption(widget_label); break; } case GP_WIDGET_SECTION: { if (!d->tabWidget) { d->tabWidget = new QTabWidget(parent); parent->layout()->addWidget(d->tabWidget); } QWidget* tab = new QWidget(d->tabWidget); // widgets are to be aligned vertically in the tab QVBoxLayout* tabLayout = new QVBoxLayout(tab, marginHint(), spacingHint()); d->tabWidget->insertTab(tab, widget_label); KVBox* tabContainer = new KVBox(tab); tabContainer->setSpacing(spacingHint()); tabLayout->addWidget(tabContainer); newParent = tabContainer; tabLayout->addStretch(); break; } case GP_WIDGET_TEXT: { gp_widget_get_value(widget, &widget_value_string); Q3Grid* grid = new Q3Grid(2, Qt::Horizontal, parent); parent->layout()->addWidget(grid); grid->setSpacing(spacingHint()); new QLabel(QString::fromLocal8Bit(widget_label) + ':', grid); QLineEdit* lineEdit = new QLineEdit(widget_value_string, grid); d->wmap.insert(widget, lineEdit); if (!whats_this.isEmpty()) { grid->setWhatsThis(whats_this); } break; } case GP_WIDGET_RANGE: { float widget_low; float widget_high; float widget_increment; gp_widget_get_range(widget, &widget_low, &widget_high, &widget_increment); gp_widget_get_value(widget, &widget_value_float); Q3GroupBox* groupBox = new Q3GroupBox(1, Qt::Horizontal, widget_label, parent); parent->layout()->addWidget(groupBox); QSlider* slider = new QSlider( (int)widget_low, (int)widget_high, (int)widget_increment, (int)widget_value_float, Qt::Horizontal, groupBox); d->wmap.insert(widget, slider); if (!whats_this.isEmpty()) { groupBox->setWhatsThis(whats_this); } break; } case GP_WIDGET_TOGGLE: { gp_widget_get_value(widget, &widget_value_int); QCheckBox* checkBox = new QCheckBox(widget_label, parent); parent->layout()->addWidget(checkBox); checkBox->setChecked(widget_value_int); d->wmap.insert(widget, checkBox); if (!whats_this.isEmpty()) { checkBox->setWhatsThis(whats_this); } break; } case GP_WIDGET_RADIO: { gp_widget_get_value(widget, &widget_value_string); int count = gp_widget_count_choices(widget); // for less than 5 options, align them horizontally Q3ButtonGroup* buttonGroup; if (count > 4) { buttonGroup = new Q3VButtonGroup(widget_label, parent); } else { buttonGroup = new Q3HButtonGroup(widget_label, parent); } parent->layout()->addWidget(buttonGroup); for (int i = 0; i < count; ++i) { const char* widget_choice; gp_widget_get_choice(widget, i, &widget_choice); new QRadioButton(widget_choice, buttonGroup); if (!strcmp(widget_value_string, widget_choice)) { buttonGroup->setButton(i); } } d->wmap.insert(widget, buttonGroup); if (!whats_this.isEmpty()) { buttonGroup->setWhatsThis(whats_this); } break; } case GP_WIDGET_MENU: { gp_widget_get_value(widget, &widget_value_string); QComboBox* comboBox = new KComboBox(parent); parent->layout()->addWidget(comboBox); comboBox->clear(); for (int i = 0; i < gp_widget_count_choices(widget); ++i) { const char* widget_choice; gp_widget_get_choice(widget, i, &widget_choice); comboBox->insertItem(widget_choice); if (!strcmp(widget_value_string, widget_choice)) { comboBox->setCurrentItem(i); } } d->wmap.insert(widget, comboBox); if (!whats_this.isEmpty()) { comboBox->setWhatsThis(whats_this); } break; } case GP_WIDGET_BUTTON: { // TODO // I can't see a way of implementing this. Since there is // no way of telling which button sent you a signal, we // can't map to the appropriate widget->callback QLabel* label = new QLabel(i18n("Button (not supported by KControl)"), parent); parent->layout()->addWidget(label); break; } case GP_WIDGET_DATE: { // TODO QLabel* label = new QLabel(i18n("Date (not supported by KControl)"), parent); parent->layout()->addWidget(label); break; } default: return; } // Append all this widgets children for (int i = 0; i < gp_widget_count_children(widget); ++i) { CameraWidget* widget_child; gp_widget_get_child(widget, i, &widget_child); appendWidget(newParent, widget_child); } // Things that must be done after all children were added /* switch (widget_type) { case GP_WIDGET_SECTION: { tabLayout->addItem( new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); break; } } */ }