#include "optionsform.h" #include "const.h" #include #include #include #include #include #include #include #include OptionsForm::OptionsForm( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "OptionsForm" ); QWidget* privateLayoutWidget = new QWidget( this, "optionsFormLayout" ); privateLayoutWidget->setGeometry( QRect( 10, 10, 252, 282 ) ); optionsFormLayout = new QVBoxLayout( privateLayoutWidget, 11, 6, "optionsFormLayout"); stapelLayout = new QHBoxLayout( 0, 0, 6, "stapelLayout"); stapelsLabel = new QLabel( privateLayoutWidget, "stapelsLabel" ); stapelLayout->addWidget( stapelsLabel ); stapelsSlider = new QSlider( privateLayoutWidget, "stapelsSlider" ); stapelsSlider->setMinValue( MIN_STAPELS ); stapelsSlider->setMaxValue( MAX_STAPELS ); stapelsSlider->setValue( START_STAPELS ); stapelsSlider->setOrientation( QSlider::Horizontal ); stapelLayout->addWidget( stapelsSlider ); stapelsLCDNumber = new QLCDNumber( privateLayoutWidget, "stapelsLCDNumber" ); stapelsLCDNumber->setNumDigits( 2 ); stapelsLCDNumber->setProperty( "intValue", START_STAPELS ); stapelLayout->addWidget( stapelsLCDNumber ); optionsFormLayout->addLayout( stapelLayout ); stapels2stokjesSpacer = new QSpacerItem( 20, 30, QSizePolicy::Minimum, QSizePolicy::Expanding ); optionsFormLayout->addItem( stapels2stokjesSpacer ); stokjesLayout = new QHBoxLayout( 0, 0, 6, "stokjesLayout"); stokjesLabel = new QLabel( privateLayoutWidget, "stokjesLabel" ); stokjesLayout->addWidget( stokjesLabel ); stokjesSlider = new QSlider( privateLayoutWidget, "stokjesSlider" ); stokjesSlider->setMinValue( MIN_STOKJES ); stokjesSlider->setMaxValue( MAX_STOKJES ); stokjesSlider->setValue ( START_STOKJES ); stokjesSlider->setOrientation( QSlider::Horizontal ); stokjesLayout->addWidget( stokjesSlider ); stokjesLCDNumber = new QLCDNumber( privateLayoutWidget, "stokjesLCDNumber" ); stokjesLCDNumber->setNumDigits( 2 ); stokjesLCDNumber->setProperty( "intValue", START_STOKJES ); stokjesLayout->addWidget( stokjesLCDNumber ); optionsFormLayout->addLayout( stokjesLayout ); stokjes2niveauSpacer = new QSpacerItem( 20, 30, QSizePolicy::Minimum, QSizePolicy::Expanding ); optionsFormLayout->addItem( stokjes2niveauSpacer ); niveauButtonGroup = new QButtonGroup( privateLayoutWidget, "niveauButtonGroup" ); niveau1RadioButton = new QRadioButton( niveauButtonGroup, "niveau1RadioButton" ); niveau1RadioButton->setGeometry( QRect( 11, 20, 99, 19 ) ); niveau2RadioButton = new QRadioButton( niveauButtonGroup, "niveau2RadioButton" ); niveau2RadioButton->setGeometry( QRect( 11, 45, 99, 19 ) ); niveauButtonGroup->setButton(START_NIVEAU - 1); optionsFormLayout->addWidget( niveauButtonGroup ); niveau2buttonSpacer = new QSpacerItem( 20, 21, QSizePolicy::Minimum, QSizePolicy::Expanding ); optionsFormLayout->addItem( niveau2buttonSpacer ); buttonLayout = new QHBoxLayout( 0, 0, 6, "buttonLayout"); cancelPushButton = new QPushButton( privateLayoutWidget, "cancelPushButton" ); buttonLayout->addWidget( cancelPushButton ); cancel2ok = new QSpacerItem( 100, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); buttonLayout->addItem( cancel2ok ); okPushButton = new QPushButton( privateLayoutWidget, "okPushButton" ); buttonLayout->addWidget( okPushButton ); optionsFormLayout->addLayout( buttonLayout ); languageChange(); resize( QSize(273, 305).expandedTo(minimumSizeHint()) ); // signals and slots connections connect( stapelsSlider, SIGNAL( valueChanged(int) ), stapelsLCDNumber, SLOT( display(int) ) ); connect( stokjesSlider, SIGNAL( valueChanged(int) ), stokjesLCDNumber, SLOT( display(int) ) ); connect( okPushButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( cancelPushButton, SIGNAL( clicked() ), this, SLOT( reject() ) ); } OptionsForm::~OptionsForm() { } void OptionsForm::languageChange() { setCaption( tr( "Nim --- Opties" ) ); stapelsLabel->setText( tr( "Stapels" ) ); stokjesLabel->setText( tr( "Stokjes" ) ); niveauButtonGroup->setTitle( tr( "Computer Niveau" ) ); niveau1RadioButton->setText( tr( "&Random" ) ); niveau1RadioButton->setAccel( QKeySequence( tr( "Alt+R" ) ) ); niveau2RadioButton->setText( tr( "&Winnend" ) ); niveau2RadioButton->setAccel( QKeySequence( tr( "Alt+W" ) ) ); cancelPushButton->setText( tr( "&Cancel" ) ); cancelPushButton->setAccel( QKeySequence( tr( "Alt+C" ) ) ); okPushButton->setText( tr( "&OK" ) ); okPushButton->setAccel( QKeySequence( tr( "Alt+O" ) ) ); }