source: liacs/pm/qt-nim2/optionsform.cpp@ 9

Last change on this file since 9 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

  • Property svn:executable set to *
File size: 4.7 KB
Line 
1#include "optionsform.h"
2#include "const.h"
3
4#include <qvariant.h>
5#include <qpushbutton.h>
6#include <qlabel.h>
7#include <qslider.h>
8#include <qlcdnumber.h>
9#include <qbuttongroup.h>
10#include <qradiobutton.h>
11#include <qlayout.h>
12
13OptionsForm::OptionsForm( QWidget* parent, const char* name, bool modal, WFlags fl )
14 : QDialog( parent, name, modal, fl )
15{
16 if ( !name )
17 setName( "OptionsForm" );
18
19 QWidget* privateLayoutWidget = new QWidget( this, "optionsFormLayout" );
20 privateLayoutWidget->setGeometry( QRect( 10, 10, 252, 282 ) );
21 optionsFormLayout = new QVBoxLayout( privateLayoutWidget, 11, 6, "optionsFormLayout");
22
23 stapelLayout = new QHBoxLayout( 0, 0, 6, "stapelLayout");
24
25 stapelsLabel = new QLabel( privateLayoutWidget, "stapelsLabel" );
26 stapelLayout->addWidget( stapelsLabel );
27
28 stapelsSlider = new QSlider( privateLayoutWidget, "stapelsSlider" );
29 stapelsSlider->setMinValue( MIN_STAPELS );
30 stapelsSlider->setMaxValue( MAX_STAPELS );
31 stapelsSlider->setValue( START_STAPELS );
32 stapelsSlider->setOrientation( QSlider::Horizontal );
33 stapelLayout->addWidget( stapelsSlider );
34
35 stapelsLCDNumber = new QLCDNumber( privateLayoutWidget, "stapelsLCDNumber" );
36 stapelsLCDNumber->setNumDigits( 2 );
37 stapelsLCDNumber->setProperty( "intValue", START_STAPELS );
38 stapelLayout->addWidget( stapelsLCDNumber );
39 optionsFormLayout->addLayout( stapelLayout );
40 stapels2stokjesSpacer = new QSpacerItem( 20, 30, QSizePolicy::Minimum, QSizePolicy::Expanding );
41 optionsFormLayout->addItem( stapels2stokjesSpacer );
42
43 stokjesLayout = new QHBoxLayout( 0, 0, 6, "stokjesLayout");
44
45 stokjesLabel = new QLabel( privateLayoutWidget, "stokjesLabel" );
46 stokjesLayout->addWidget( stokjesLabel );
47
48 stokjesSlider = new QSlider( privateLayoutWidget, "stokjesSlider" );
49 stokjesSlider->setMinValue( MIN_STOKJES );
50 stokjesSlider->setMaxValue( MAX_STOKJES );
51 stokjesSlider->setValue ( START_STOKJES );
52 stokjesSlider->setOrientation( QSlider::Horizontal );
53 stokjesLayout->addWidget( stokjesSlider );
54
55 stokjesLCDNumber = new QLCDNumber( privateLayoutWidget, "stokjesLCDNumber" );
56 stokjesLCDNumber->setNumDigits( 2 );
57 stokjesLCDNumber->setProperty( "intValue", START_STOKJES );
58 stokjesLayout->addWidget( stokjesLCDNumber );
59 optionsFormLayout->addLayout( stokjesLayout );
60 stokjes2niveauSpacer = new QSpacerItem( 20, 30, QSizePolicy::Minimum, QSizePolicy::Expanding );
61 optionsFormLayout->addItem( stokjes2niveauSpacer );
62
63 niveauButtonGroup = new QButtonGroup( privateLayoutWidget, "niveauButtonGroup" );
64
65 niveau1RadioButton = new QRadioButton( niveauButtonGroup, "niveau1RadioButton" );
66 niveau1RadioButton->setGeometry( QRect( 11, 20, 99, 19 ) );
67
68 niveau2RadioButton = new QRadioButton( niveauButtonGroup, "niveau2RadioButton" );
69 niveau2RadioButton->setGeometry( QRect( 11, 45, 99, 19 ) );
70
71 niveauButtonGroup->setButton(START_NIVEAU - 1);
72
73 optionsFormLayout->addWidget( niveauButtonGroup );
74 niveau2buttonSpacer = new QSpacerItem( 20, 21, QSizePolicy::Minimum, QSizePolicy::Expanding );
75 optionsFormLayout->addItem( niveau2buttonSpacer );
76
77 buttonLayout = new QHBoxLayout( 0, 0, 6, "buttonLayout");
78
79 cancelPushButton = new QPushButton( privateLayoutWidget, "cancelPushButton" );
80 buttonLayout->addWidget( cancelPushButton );
81 cancel2ok = new QSpacerItem( 100, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
82 buttonLayout->addItem( cancel2ok );
83
84 okPushButton = new QPushButton( privateLayoutWidget, "okPushButton" );
85 buttonLayout->addWidget( okPushButton );
86 optionsFormLayout->addLayout( buttonLayout );
87 languageChange();
88 resize( QSize(273, 305).expandedTo(minimumSizeHint()) );
89
90 // signals and slots connections
91 connect( stapelsSlider, SIGNAL( valueChanged(int) ), stapelsLCDNumber, SLOT( display(int) ) );
92 connect( stokjesSlider, SIGNAL( valueChanged(int) ), stokjesLCDNumber, SLOT( display(int) ) );
93 connect( okPushButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
94 connect( cancelPushButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
95}
96
97OptionsForm::~OptionsForm()
98{
99
100}
101
102void OptionsForm::languageChange()
103{
104 setCaption( tr( "Nim --- Opties" ) );
105 stapelsLabel->setText( tr( "Stapels" ) );
106 stokjesLabel->setText( tr( "Stokjes" ) );
107 niveauButtonGroup->setTitle( tr( "Computer Niveau" ) );
108 niveau1RadioButton->setText( tr( "&Random" ) );
109 niveau1RadioButton->setAccel( QKeySequence( tr( "Alt+R" ) ) );
110 niveau2RadioButton->setText( tr( "&Winnend" ) );
111 niveau2RadioButton->setAccel( QKeySequence( tr( "Alt+W" ) ) );
112 cancelPushButton->setText( tr( "&Cancel" ) );
113 cancelPushButton->setAccel( QKeySequence( tr( "Alt+C" ) ) );
114 okPushButton->setText( tr( "&OK" ) );
115 okPushButton->setAccel( QKeySequence( tr( "Alt+O" ) ) );
116}
117
Note: See TracBrowser for help on using the repository browser.